// *** define menu color attributes here**
//****************************************

//Default menu color:
menuColor="#96B2C5";
//Menu background on mouseover:
menuColorOn="#ffffff";
//Font colors (Internet Explorer & NS 6 ONLY!):
//Starting font color:
fontColorStart="#ffffff";
//Font color on MouseOut (usually the same as fontColorStart):
fontColorOff="#ffffff";
//Font color on MouseOver:
fontColorOn="#000000";
//NS6 does not have a layer color property for font,
//so we must use one single color for use in Netscape
NSfontColor="#000000";

//**END of user-customizable parameters**
//***************************************

fontColor=fontColorStart;

// sniff for mac
isMac = (navigator.appVersion.indexOf("Mac") != -1) ? 1 : 0;

// shows the drop down menu 
// expected arg is active div
function showDDNav(){
	args = showDDNav.arguments;
	var divName = args[0];
	var divRef;
	
	if(br=="N"){
	divRef=eval("document." + divName);
		if(divRef.visibility=='hide'){
			divRef.visibility = 'show';
		}
	} else {
		if (br=="NS6") {
			divRef=eval("document.getElementById('" + divName + "')");
		} else {
			divRef=eval("document.all." + divName);
		}
		if(divRef.style.visibility=='hidden'){
			divRef.style.visibility = 'visible';
		}
	}
	// rollover
	if (args[1] != "on"){
		changeImages(args[1], eval('\''+args[1]+'on'+'\''));
	}
}

// hides the drop down menu 
// expected arg is active div 
function hideDDNav(){
	args = hideDDNav.arguments;
	// rollover
	if (args[1] != "on"){
		changeImages(args[1], eval('\''+args[1]+'off'+'\''));
	}
	var divName = args[0];
	var divRef;
	
	if(br=="N"){
		divRef=eval("document." + divName);
		if(divRef.visibility=='show'){
			divRef.visibility = 'hide';
		}
	} else {
		if (br=="NS6") {
			divRef=eval("document.getElementById('" + divName + "')");
		} else {
			divRef=eval("document.all." + divName);
	}
		if(divRef.style.visibility=='visible'){
			divRef.style.visibility = 'hidden';
	}
		}
}

// hides drop down menu when menu is active IE & NS6
// expected arg is active menu
function hideDiv(){
	args = hideDiv.arguments;
	var divName = args[0];
	var divRef;
	// fix menu flicker problem in IE
	if(br=="IE"){
		divRef=eval("document.all." + divName);
		// calculate active size of menu
		leftDiv=divRef.offsetLeft +2
		rightDiv=divRef.offsetLeft + divRef.clientWidth -2
		topDiv=divRef.offsetTop +2
		bottomDiv=divRef.offsetTop + divRef.clientHeight -2		
		if(window.event.clientY > bottomDiv || 
			window.event.clientY < topDiv || 
			window.event.clientX < leftDiv || 
			window.event.clientX > rightDiv){
				divRef.style.visibility = 'hidden';
				// rollover
				if (args[1] != "on"){
					changeImages(args[1], eval('\''+args[1]+'off'+'\''));
				}
			}				
	// NS6
	} else {
		divRef=eval("document.getElementById('" + divName + "')");
		divRef.style.visibility = 'hidden';
		// rollover
		if (args[1] != "on"){
			changeImages(args[1], eval('\''+args[1]+'off'+'\''));
		}
	}
}

// highlight menuitem in IE & NS6
// expected arg is active menuitem
function divOver(){
	args = divOver.arguments;
	var divName = args[0];
	var menuColorOn = args[1];
	var fontColor = args[2];
	var divRef;
	//var fontColor;
	
	if (br=="NS6") {
		divRef=eval("document.getElementById('" + divName + "')");
		divRef.style.cursor = "pointer";
	} else {
		divRef=eval("document.all." + divName);
	}
	divRef.style.color=fontColor;
	divRef.style.backgroundColor=menuColorOn;
	//alert("color=" + fontColor);
}

// highlight off menuitem in IE & NS6
// expected arg is active menuitem
function divOut(){
	args = divOut.arguments;
	var divName = args[0];
	var menuColor = args[1];
	var fontColor = args[2];
	var divRef;
	//var fontColor;
	
	if (br=="NS6") {
		divRef=eval("document.getElementById('" + divName + "')");
	} else {
		divRef=eval("document.all." + divName);
	}
	divRef.style.color=fontColor;
	divRef.style.backgroundColor=menuColor;
}

// highlight on menuitem in NETSCAPE 4.x
// expected arg is active menuitem
function menuOver(){
	var args, theMenu;
	args = menuOver.arguments;
	menuColorOn=args[1];
	theMenu = eval(args[0]);
	theMenu.bgColor=menuColorOn 
}

// highlight off menuitem in NETSCAPE 4.x
// expected arg is active menuitem
function menuOut(){
	var args, theMenu;
	args = menuOut.arguments;
	menuColor=args[1];
	theMenu = eval(args[0]);
	theMenu.bgColor=menuColor 
}

// goes to specified url
// expected arg is url 
function gotoUrl(){
	args = gotoUrl.arguments;
	location.href=args[0]
}

// BUILD THE MENU IN IE & NETSCAPE 6
// expected args are 'div name','x in menudata array',
// 'menu left coord','top in pixels (aka y-coord)','color scheme',menu width
var tdID = 0
function doDiv(){
	args = doDiv.arguments;
	var divID = args[0];
	var x = args[1];
	var divLeft = args[2];
	var divTop = args[3];
	var menuWidth = args[4];
	var innerWidth=menuWidth;
//	var fontColor;
//	var fontColorOn;
//	var fontColorOff;
	
	/* if (isMac) {
		outerWidth=menuWidth;
	 } */
	var whichImg = args[5];
	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; width:" + menuWidth + "px; z-index:20; top:"+ divTop +"px; left: " + divLeft + "; background-color: " + menuColor + "; visibility: hidden;\" onMouseover=\"showDDNav('"+ divID +"', '" + whichImg + "')\"  onMouseout=\"hideDiv('" + divID + "', '" + whichImg + "')\">"
// the loop below writes out each line of the menu.	
//alert("fontColor=" + fontColor);

	for (y = 0; y < 20; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; color:"+ fontColor +"; background-color:"+ menuColor +"; width:" + innerWidth + "px; z-index:23;\" onMouseover=\"divOver('x" + tdID + "', '" + menuColorOn + "', '" + fontColorOn + "')\" onMouseout=\"divOut('x" + tdID + "', '" + menuColor + "', '" + fontColorOff + "')\" class=\"dhtmlNav\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">&nbsp;"+ menuData[x][y][0] +"&nbsp;</div>"
		tdID = tdID +1
		}
	} 
	objDiv += "</div>"
	document.write(objDiv);
} 


// BUILD THE MENU IN NETSCAPE 4.x
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels',color scheme, menu width
function doLayer(){
	args = doLayer.arguments;
	var nestLayerID=0
	var layerID = args[0];
	var x = args[1];
	var layerLeft = args[2];
	var layerTop = args[3];
	var menuWidth = args[4];
	var whichImg = args[5];
	var innerWidth = menuWidth
	//var fontColor;
	//var fontColorOn;
	//var fontColorOff;

	if(navigator.platform.indexOf("Win") < 0){layerInc=16;layerStyle="netMenuMac";}
	else{layerInc=15;layerStyle="netMenu";}	
		
	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=1 BGCOLOR=\""+ menuColor +"\" WIDTH=" + menuWidth + " LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('"+ layerID +"','" + whichImg + "')\" onmouseout=\"hideDDNav('"+ layerID +"','" + whichImg + "')\">"
	var nestTop=0
// this loop writes out the menu items.
//alert("NS: Each menu item: fontColorOn=" + fontColorOn + ", fontColor=" + fontColor + ", fontColorOff=" + fontColorOff);
	for (y = 0; y < 20; y++){
	  if(menuData[x][y][0]!=null){
		objDiv += "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=7 COLOR=\""+ fontColor +"\" BGCOLOR=\""+ menuColor +"\" HEIGHT=19 WIDTH=" + innerWidth + " TOP="+ nestTop +" onmouseover=\"menuOver('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']', '" + menuColorOn + "', '" + fontColorOn + "')\" onmouseout=\"menuOut('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']', '" + menuColor + "', '" + fontColorOff + "')\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><a id=navstyle target=\"top\"  href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font color=" + NSfontColor + ">" + menuData[x][y][0];
		objDiv +="</font></a></layer>";

		nestLayerID=nestLayerID+1;
		nestTop=nestTop+layerInc+1;
		tdID = tdID +1;
		}
	}
	objDiv += "</layer>"

	document.write(objDiv)
}
