if(ver4) var oldDocOnMouseOver,mouseX, mouseY, oldX, oldY,timeID = null, scNum;

if(NS4){
	window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove = recordMousePos;
}

function recordMousePos(e){
	mouseX = e.pageX;
	mouseY = e.pageY;
}

if(ver4) {
	var menuHTML="";
	if (NS4) {
		sDiv = "LAYER";
		sWidth = "WIDTH='";
		sNSOnly = " onMouseOut='hideAllMenu();' "
	}
	if (IE4) {
		sDiv = "DIV";
		sWidth = " STYLE='width:";
		sNSOnly = "";
	}
	for (var j=1; j<=howManyMenus;j++) {
		eval ("menuArray = menu" + j + ";");
		menuHTML += "<" + sDiv + " id='menuList" + j + "' class='menuList' top=110 bgcolor=#CCCCFF visibility='hide' " + sNSOnly + sWidth + menuArray[0] + "'><table border=0 cellspacing=2 cellpadding=2>";
		var k=1;
		while (menuArray[k]){
			if (IE4) menuHTML += "<tr><td><a class='menuListItem' href='" + menuArray[k+1] + "'>" + menuArray[k] + "</a></td></tr>";
			if (NS4) menuHTML += "<tr><td><layer top=" + (10*k-5) +" left = 5 id='bold" + j + k + "' visibility='hide'><a class='menuListItemBold' href='" + menuArray[k+1] + "' onMouseOut='clearAllBold(" + j +");'>" + menuArray[k] + "</a></layer><layer top=" + (10*k-5) +" left = 5 id='unbold" + j + k + "' visibility='inherit'><a class='menuListItem' href='#' onMouseOver='bold(" + j +","+ k +");'>" + menuArray[k] + "</a></layer></td></tr>";
			k += 2;
		}
		menuHTML += "</table></" + sDiv + ">";
	}
}

function init(){
	if(IE4){
		OnResize();
		var scroll = document.all.scroll;
		currentMsg = 2;
		with(scroll){
			innerText = msg[0];
			href = msg[1];
			style.pixelLeft = container.style.pixelWidth;
			style.pixelTop = container.style.pixelHeight - scroll.scrollHeight;
		}
	}
	if(NS4){
		if (document.cookie.indexOf("scNum") != -1) {
			var aCookie = document.cookie.split(";");
			for (var i=0; i < aCookie.length; i++){
		    var aCrumb = aCookie[i].split("=");
		    if (aCrumb[0].indexOf("scNum") != -1) scNum = aCrumb[1] * 1;
		  }
		} else scNum = 0;
		document.cookie = "scNum=; expires=Thu, 01-Jan-70 00:00:01 GMT";
		eval ("document.container.document.scroll" + scNum + ".visibility='show';");
		eval ("document.container.document.scroll" + scNum + ".left = document.width - 320");
		//eval ("document.container.document.scroll" + scNum + ".left = screen.availWidth - 320");

	}
	timeID = setInterval("scrollIt()",100);
}

function OnResize(){
	if(IE4){
		if (document.body.clientWidth < 778) tableWidth = 758;
		else tableWidth = document.body.clientWidth - 20;
		theTable.style.pixelWidth = tableWidth;
		var orgLeft = 0;
		for (var j=1; j<=howManyMenus;j++) {
			tdWidth = document.all['menuBtn'+j].offsetWidth;
			document.all['menuList'+j].style.pixelLeft = orgLeft + tdWidth/2 - 10;
			orgLeft += tdWidth;
		}
	} 
	if(NS4){
		document.cookie="scNum=" + scNum + ";";
		window.location.reload();
	}
}

function checkMenu() {
	CN = event.srcElement;
	while (CN.className.indexOf("menuList") == -1) {
		CN = CN.parentElement;
		if (CN == null) {
			hideAllMenu();
			document.onmouseover = oldDocOnMouseOver;
			return;
		}
	}
}	

function show(name){
	hideAllMenu();
	if(IE4) {
		document.all['menuList' + name].style.visibility = "visible";
		oldDocOnMouseOver = document.onmouseover;
		document.onmouseover = checkMenu;
	}
	if(NS4) {
		clearAllBold(name);
		oldX = mouseX; oldY = mouseY;
		eval ("document.menuList" + name + ".left = mouseX -30;");
		eval ("document.menuList" + name + ".visibility = 'SHOW';");
	}
}

function hideAllMenu(){
	for (var j=1; j<=howManyMenus; j++){
		if(IE4) document.all['menuList'+j].style.visibility = 'hidden';
		if(NS4) eval("document.menuList" + j + ".visibility = 'hide';");
	}
}

function clearAllBold(j){
	var k=1;
	eval("crap = document.menuList" + j + ".document.bold" + j + k);
	while (crap){
		eval("document.menuList" + j + ".document.bold" + j + k +".visibility ='hide';");
		eval("document.menuList" + j + ".document.unbold" + j + k +".visibility ='inherit';");
		k+=2;
		eval("crap = document.menuList" + j + ".document.bold" + j + k);
	}
}

function hideOrNot(){
	if (mouseY<106) hideAllMenu();
}

function bold(j,k){
	clearAllBold(j);
	eval("document.menuList" + j + ".document.bold" + j + k +".visibility ='inherit';");
	eval("document.menuList" + j + ".document.unbold" + j + k +".visibility ='hide';");
}

function scrollIt(){
	if(IE4){
		var scroll = document.all.scroll;
		scroll.style.pixelLeft -= 5;
		if ((scroll.style.pixelLeft + scroll.scrollWidth) < 5) {
			if(!msg[currentMsg]) currentMsg = 0;
			with(scroll){
				innerText = msg[currentMsg];
				href = msg[currentMsg + 1];
				style.pixelLeft = container.style.pixelWidth;
			}
			currentMsg +=2;
		} else if (scroll.style.pixelLeft <= 15 && scroll.style.pixelLeft > 10) {
			scroll.style.pixelLeft = 10;
			clearInterval(timeID);
			timeID = null;
			pause();
		}
	}
	if(NS4){
		eval ("scroll = document.container.document.scroll" + scNum);
		scroll.left -= 5;
		if((scroll.left + 300) < 5) {
			scroll.visibility = 'hide';
			scNum +=2;
			eval ("if (!document.container.document.scroll" + scNum +") scNum=0;");
			eval ("document.container.document.scroll" + scNum + ".visibility='show';");
			eval ("document.container.document.scroll" + scNum + ".left = document.container.clip.width;");
		} else if (scroll.left <= 15 && scroll.left > 10) {
			scroll.left = 10;
			clearInterval(timeID);
			timeID = null;
			pause();
		}
	}
}
function pause(){
	setTimeout("timeID = setInterval('scrollIt()',100)",1000);
}
