
////////////////////////////////////////////////////////////////////////

var g_image_height = 90;
var g_image_width = 20;
var g_image_padding = 10;
var g_scrollbar_width = 15;
var g_page_ypos = -1;
var g_check_interval = 10; // miliseconds
var g_scroll_amount = 120; // pixels

////////////////////////////////////////////////////////////////////////

function eventInit() {
	if(NS) {
		document.captureEvents(Event.MOUSEMOVE);
		window.onresize = handleResizeEvent;
	} else if(DOM && !MS && !OP) {
		getTag("body", 0).addEventListener("resize", handleResizeEvent, true);
	} else if (DOM && OP) {
		document.onresize = handleResizeEvent;
	}	else if (MS) {
		getTag("body", 0).onresize = handleResizeEvent;
	}
}

////////////////////////////////////////////////////////////////////////

function handleResizeEvent()
{
	showScrollPanel();
}	

////////////////////////////////////////////////////////////////////////

function showScrollPanel() 
{
	g_page_ypos = getPageYPos();
	var y = g_image_height;
	var x = 20000;
	if (NS) {
		//alert("NS");
		y = window.innerHeight;
		x = window.innerWidth;
	} else if (DOM) {
		//alert("DOM");
		y = document.body.offsetHeight;
		x = document.body.offsetWidth;
	} else {
		y = window.height;
		x = window.width;
	}
	y -= g_image_height;
	// subtract horizontal scrollbar height if window is smaller than footer image width
	if ((x - g_scrollbar_width) < g_image_width) {y -= g_scrollbar_width;}
	x = getPageWidth();
	if (x == 0) {
		x = g_image_width + g_image_padding * 2;
	} else {
		if (NS || DOM) x += 20;
		if (MS) x -= 30;
	}
	moveElement("scrollPanel", x - (g_image_width + g_image_padding + 10), y);
	
	
	var tmp = getElement('scrollPanel');
	if (tmp) {
		var y2 = tmp.offsetTop;
		var y1 = 0;
		if (NS) {
			//alert("NS");
			y1 = window.innerHeight;
		} else if (DOM) {
			//alert("DOM");
			y1 = document.body.offsetHeight;
		} else {
			//alert("other");
			y1 = window.height;
		}
		if (y1 < y2 + g_image_height) {
			showElement('scrollPanel', true);
		} else {
			showElement('scrollPanel', false);
		}
	}
}

////////////////////////////////////////////////////////////////////////

function checkLocation() 
{
	if (getPageYPos() != g_page_ypos) {
		g_page_ypos = getPageYPos();
		showScrollPanel();
	}
	setTimeout("checkLocation()", g_check_interval);
}

////////////////////////////////////////////////////////////////////////

function init()
{
	showElement("scrollPanel", true);
	eventInit();
	checkLocation();
}

////////////////////////////////////////////////////////////////////////

