var ns = (document.layers ? true : false);
var ie = (document.all ? true : false);
var moz= (document.getElementById ? true:false);
if (ie==false && moz && true) moz=2;
// menu globals
if ((ie)|| (moz==2)) {
	var x = 10;
	var y = 93;
	//var x = 231;
	//var y = 97;
} else {
	// ns 
	var x = 232;
	var y = 97;
}	
var spacing = 111;	
//var spacing = 100;	
var numMenus = 5;

// html globals
if ((ie) || (moz==2)) {
	startTag = "<span id=\"";
	endTag = "</span>";
}
if (ns) {
	startTag = "<ilayer name=\"";
	endTag = "</ilayer>";
}

// here are the colors; BY DEFAULT THE HOVER TEXT COLOR IN IE IS THE BG COLOR IN NETSCAPE
var itemColor = "#555555";
var itemColorSel = "#999999";
var bgcolor="#E7E7E7";
//var itemColor = "#0C339C";	Navy blue
//var itemColorSel = "#FE9901";	Orange
//var bgColor = "#E1E1E1";		Light Gray


// internal globals
var menuTimer = null;
var currentMenu = null;
var menuPause = 500;

//code
function hilight(theMenu, theId, isOn) {
	if (isOn) {
		if (ie) {
			document.all["item" + theMenu + theId].style.color = itemColorSel;
		} else if (ns) {
			document.layers["menu" + theMenu].document.layers["item" + theMenu + theId].bgColor = "#FFFFFF";
		} else if (moz==2) {
			document.getElementById("item" + theMenu + theId).style.color = itemColorSel;
		}
		stopTimer(theMenu);
	} else {
		if (ie) {
			document.all["item" + theMenu + theId].style.color = itemColor;
		} else if (ns) {
			document.layers["menu" + theMenu].document.layers["item" + theMenu + theId].bgColor = bgColor;
		} else if (moz==2) {
			document.getElementById("item" + theMenu + theId).style.color = itemColor;
		}
		pauseHide(theMenu);
	}
} // function hilight

function showMenu(theId, isOn) {
	if (isOn) {
		if (ie) {
			document.all["menu" + theId].style.visibility = "visible";
		} else if (ns) {
			document.layers["menu" + theId].visibility = "show";
		} else if (moz==2) {
			document.getElementById("menu" + theId).style.visibility = "visible";
		}
		stopTimer(theId);
	} else {
		if (ie) {
			document.all["menu" + theId].style.visibility = "hidden";
		} else if (ns) {
			document.layers["menu" + theId].visibility = "hide";
		} else if (moz==2) {
			document.getElementById("menu" + theId).style.visibility = "hidden";
		}
	}
} // function showMenu

function pauseHide(theId) {
	if (menuTimer) {
		clearTimeout(menuTimer);
	}
	currentMenu = theId;
	menuTimer = setTimeout("showMenu(" + theId + ", false)", menuPause);
} // function pauseHide

function stopTimer(theId) {
	if (menuTimer) {
		clearTimeout(menuTimer);
		menuTimer = null;
	}
	if (currentMenu != null) {
		if (theId != currentMenu) {
			showMenu(currentMenu, false);
		}
		currentMenu = null;
	}
} // function stopTimer

function initMenu(relPath) {
	for (i = 0; i < numMenus; i++) {
				
		if ((ie)|| (moz==2)) {

			document.writeln('<div id="menu' + i + '" style="position: absolute; left: ' + (x + (spacing * i)) + 'px; top: ' + y + 'px; visibility: hidden;">');
		} else if (ns) {
			document.writeln('<layer name="menu' + i + '" left=' + (x + (spacing * i)) + ' top=' + y + ' visibility="hide">');
		}
		document.writeln('<table border=0 cellpadding=0 cellspacing=0>');
		document.writeln('<tr>');
		document.writeln('<td bgcolor="E7E7E7" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=90)"><table border=0 cellpadding=0 cellspacing=1>');
		theArray = eval("menu" + i);
		theLink = eval("link" + i);
		for (j = 0; j < theArray.length; j++) {
			document.writeln("<tr>");
			if (theArray[j] != "") {
				var theItem = theArray[j];
				if (theItem.charAt(0) == "-") {
					theItem = '<img src="' + relPath + 'images/nav-norm.gif" width=9 height=9 border=0> ' + theItem.substring(1);
				}
				if (theLink[j] != "") {
					if (moz==2) {
						document.writeln('<td bgcolor="#E7E7E7">' + startTag + 'item' + i + j + '">&nbsp;<a href="' + relPath + theLink[j] + '" class="menuitem" onMouseOver="hilight(' + i + ', ' + j + ', true)" onMouseOut="hilight(' + i + ', ' + j + ')"><font color="#555555">' + theItem + '</font></a>' + endTag + '&nbsp;</td>');
					} else {
						document.writeln('<td bgcolor="#E7E7E7">' + startTag + 'item' + i + j + '">&nbsp;<a href="' + relPath + theLink[j] + '" class="menuitem" onMouseOver="hilight(' + i + ', ' + j + ', true)" onMouseOut="hilight(' + i + ', ' + j + ')">' + theItem + '</a>' + endTag + '&nbsp;</td>');
					}	
				} else {
					document.writeln('<td bgcolor="#E7E7E7">' + startTag + 'item' + i + j + '">&nbsp;<a href="#" class="menuitem" onMouseOver="hilight(' + i + ', ' + j + ', true)" onMouseOut="hilight(' + i + ', ' + j + ')">' + theItem + '</a>' + endTag + '&nbsp;</td>');
				}
			} else {
				document.writeln('<td bgcolor="#FFFFFF"><img src="' + relPath + 'images/dot-clear.gif" width=1 height=1 border=0></td>');
			}
			document.writeln("</tr>");
		}
		document.writeln('</table></td>');
		document.writeln('</tr>');
		document.writeln('</table>');
		if ((ie)|| (moz==2)){
			document.writeln("</div>");
		}
		if (ns) {
			document.writeln("</layer>");
		}
	}
} // function initMenu
