// shows the drop down menu 
// expected arg is active div
function showDDNav(){
	args = showDDNav.arguments;
	if(br=="N"){
		var args, theObj;
		args = showDDNav.arguments;
		theObj = eval(args[1]);
  		if (theObj) if(theObj.visibility=='hide'){theObj.visibility = 'show';}
	}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if (theObj) if(theObj.style.visibility=='hidden'){hideElement('SELECT');theObj.style.visibility = 'visible'}
		}
	else{return}
}

// hides the drop down menu 
// expected arg is active div 
function hideDDNav(){
	args = hideDDNav.arguments;
	if(br=="N"){
		var args, theObj;
		args = hideDDNav.arguments;
		theObj = eval(args[1]);
		if (theObj) if(theObj.visibility=='show'){theObj.visibility = 'hide';}
	}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if (theObj) if(theObj.style.visibility=='visible'){showElement('SELECT');theObj.style.visibility = 'hidden'}
		}
	else{return}
}

// hides drop down menu when menu is active
// expected arg is active menu
function hideDiv(){
	args = hideDiv.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
		// calculate active size of menu
		leftDiv=theObj.offsetLeft +0
		rightDiv=theObj.offsetLeft + theObj.clientWidth -0
		topDiv=theObj.offsetTop +0
		bottomDiv=theObj.offsetTop + theObj.clientHeight -0
		if(window.event.clientY > bottomDiv || 
			window.event.clientY < topDiv || 
			window.event.clientX < leftDiv || 
			window.event.clientX > rightDiv)
			{theObj.style.visibility = 'hidden';showElement('SELECT');}				
		}
	else{return}
}

// highlight menuitem
// expected arg is active menuitem
function divOver(){
	args = divOver.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if(theObj.style.backgroundColor=="#999999"){
			theObj.style.backgroundColor="#003366";
		}
	}
	else{return}
}

// highlight off menuitem
// expected arg is active menuitem
function divOut(){
	args = divOut.arguments;
	if(br=="N"){}
	else if(br=="IE"){
	theObj=eval(args[0]);
		if(theObj.style.backgroundColor="#003366"){
			theObj.style.backgroundColor="#999999"; //background for each menu item
		}
	}
	else{return}
}

// highlight on menuitem in netscape
// expected arg is active menuitem
function menuOver(){
	var args, theMenu;
	args = menuOver.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor="#003366" //background for rollover effect
}

// highlight off menuitem in netscape
// expected arg is active menuitem
function menuOut(){
	var args, theMenu;
	args = menuOut.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor="#999999" //resets background to original color
}

// goes to specified url
// expected arg is url 
function gotoUrl(){
	args = gotoUrl.arguments;
	//added this if..else to look for external links and display them in a new window
	if(args[0].substring(0,4)=="http") {
	window.open(args[0],"NewWindow");
	} else {
	//this is end of addition to script
	location.href=args[0]
	}//This was also added to conclude the if statement
}

// hides specified tag
function hideElement(HTMLtag)
{
	for (i = 1; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
		obj.style.visibility = "hidden";
	}
}

// shows specified tag
function showElement(HTMLtag)
{
	for (i = 1; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
		obj.style.visibility = "visible";
	}
}

// build the divs for IE
// expected args are 'div name','x in menudata aray',
// 'menu left coord','arrow alignment','top in pixels' 
var tdID = 0
function doDiv(){
	args = doDiv.arguments;
	var divID = args[0]; //name of layer
	var x = args[1]; //set data to pull from data.js file
	var divLeft = args[2];  //left of layer
	var arrowPos = args[3]; //arrow position
	var divTop = args[4]; //top of layer
	var divWidth = args[5]; //width of layer
																																			                                             //color of front pad					size of front pad						
	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; left:"+ divLeft +"px; top:"+ divTop +"px; width:" + divWidth + "px; z-index:1; background-color:#999999; visibility:hidden; padding-left:0;\" onMouseover=\"showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"hideDiv('document.all[\\'" + divID + "\\']')\">"
	
	
	for (y = 0; y < 17; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"line\" style=\"position:relative; background-color:#999999; width:" + divWidth + "px;\"><img src=images/bar.gif width=" + divWidth + " height=2></div>"; //this bar.gif is for IE only and it is all but the last one
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:#999999; z-index:6; width:" + divWidth + "px;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\"><span class=\"nav\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">&nbsp;"+ menuData[x][y][0] +"&nbsp;</span></div>"
		tdID = tdID +1
		}
	}
	
	objDiv +="<div id=\"line\" style=\"position:relative; background-color:#999999; width:" + divWidth + "px; height:0px;\"><img src=images/bar.gif width=" + divWidth + " height=2></div></div>" //this bar.gif is only for IE and it is the last bar
	
	document.write(objDiv);
}

//*---------------------------------------------------
// build the layers for netscape
// expected args are 'div name','x in menudata aray',
// 'menu left coord','arrow alignment','top in pixels' 
//--------------------------------------------------*/
function doLayer(){
	args = doLayer.arguments;
	var nestLayerID=0
	var layerID = args[0]; //name of layer
	var x = args[1]; //set data to pull from data.js file
	var layerLeft = args[2]; //left of layer
	var arrowPos = args[3]; //arrow position
	var layerTop = args[4]; //top of layer
	var layerWidth = args[5]; //width of layer
	
	if(navigator.platform.indexOf("Win") < 0){layerInc=16;layerStyle="netMenuMac";}//netMenuMac is found in the <style of the main page
	else{layerInc=19;layerStyle="netMenu";}	//netMenu is found in the <style of the main page
		
	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=1 BGCOLOR=\"#999999\" WIDTH=" + layerWidth + " LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('','document.layers[\\'"+ layerID +"\\']')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']')\">"
	objDiv +="<layer id=\"line\" BGCOLOR=\"#999999\" WIDTH=" + layerWidth + " HEIGHT=2 Z-INDEX=1 TOP=0><center><img src=images/bar.gif width=" + layerWidth + " height=2></center></layer>" //this bar.gif only affects the first one in Netscape
	
	
	var nestTop=0 //This affects the space at top of the menu in Netscape
		for (y = 0; y < 17; y++){
		    if(menuData[x][y][0]!=null){
			
	objDiv += "<layer id=\"x"+nestLayerID+"\" CLIP=\"1,0," + layerWidth + ",20\" class=\""+ layerStyle +"\" Z-INDEX=1 BGCOLOR=\"#999999\" HEIGHT=15 WIDTH=" + layerWidth + " TOP="+ nestTop +" onmouseover=\"menuOver('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\" onmouseout=\"menuOut('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\"><a id=navstyle  href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font color=#FFFFFF>&nbsp;"+ menuData[x][y][0]
	objDiv +="</font></a></layer>"		

	nestLayerID=nestLayerID+1
	nestTop=nestTop+layerInc
	objDiv +="<layer id=\"line2\" BGCOLOR=\"#999999\" WIDTH=" + layerWidth + " HEIGHT=2 Z-INDEX=1 TOP="+ nestTop +"><center><img src=images/bar.gif width=" + layerWidth + " height=2></center></layer>" //this bar.gif affects last one
	nestTop=nestTop+2
			}
		}
	objDiv +="<layer id=\"lineEnd\" BGCOLOR=\"#999999\" WIDTH=" + layerWidth + " HEIGHT=0 Z-INDEX=1 TOP="+ nestTop +"></layer></layer>"

	document.write(objDiv)
}