/*----------------------------------------------------
// js_functions.js
//
// written by Kevin Eyer (keyer@frymulti.com)
// Fry Multimedia
//--------------------------------------------------*/

// define menu attributes here

MenuWidth=150

/*Original*/
/*menuColor="#CCCCCC"*/
/*menuColorOn="#A0A0A0"*/
/*fontColorOn="#414141"*/
/*fontColorOff="#414141"*/
/*lineColor = "#000000"*/


//*Tan background
//menuColor="#ADB584"
//menuColorOn="#A0A0A0"
//fontColorOn="#414141"
//fontColorOff="#414141"
//lineColor="#78814E" *//

/*Dark background white letters, light blue hightlight*/
/*menuColor="#2F2F63"*/
/*menuColorOn="#666698"*/
/*fontColorOn="#D4D2C3"*/
/*fontColorOff="#D4D2C3"*/
/*lineColor="#D4D2C3"*/

/*Dark Gray background white letters, light blue hightlight*/
/* blue */
menuColor="#666698"
/* dark blue */
menuColor="#2F2F63"
/* darker gray */
menuColor="#5C5B52"
/* lighter gray */
menuColor="#858374"

/* tan */
menuColorOn="#ADB584"
/* darker gray */
menuColorOn="#5C5B52"
/* lighter gray */
menuColorOn="#858374"
/* yellow */
menuColorOn="#FFCC35"
/* blue */
menuColorOn="#666698"

fontColorOn="#FFC637"
fontColorOff="#D4D2C3"
lineColor="#D4D2C3"


separator="<img src=/assets/images/spacer.gif>"
separator_top="<img src=/assets/images/spacer_top.gif>"
separator_bottom="<img src=/assets/images/spacer_bottom.gif>"

//*---------------------------------------------------
// 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'){
				// activate hideElement to hide <select> boxes
				//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 +2
		rightDiv=theObj.offsetLeft + theObj.clientWidth -2
		topDiv=theObj.offsetTop +2
		bottomDiv=theObj.offsetTop + theObj.clientHeight -2		
		if(window.event.clientY > bottomDiv || 
			window.event.clientY < topDiv || 
			window.event.clientX < leftDiv || 
			window.event.clientX > rightDiv)
			{
			theObj.style.visibility = 'hidden';
			 // activate showElement to show <select> menu's
			 //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]);
		theObj.style.backgroundColor=menuColorOn;
	}
	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]);
		theObj.style.backgroundColor=menuColor;
	}
	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=menuColorOn 
}

//*---------------------------------------------------
// highlight off menuitem in netscape
// expected arg is active menuitem
//--------------------------------------------------*/
function menuOut(){
	var args, theMenu;
	args = menuOut.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor=menuColor 
}

//*---------------------------------------------------
// goes to specified url
// expected arg is url 
//--------------------------------------------------*/
function gotoUrl(){
	args = gotoUrl.arguments;
	var CM_RefferingURL, CM_Location, CM_Exists;
	CM_ReferringURL = window.location.href;
	CM_ReferringURL = CM_ReferringURL.split("&referringurl=");
	CM_ReferringURL = CM_ReferringURL[0].split("?referringurl=");
	CM_Exists = args[0].indexOf('?');
	
	if (CM_Exists == -1) {
		/*CM_Location = args[0] + '?referringurl=' + escape(CM_ReferringURL[0])*/
		CM_Location = args[0] 
	}
	else {
		/*CM_Location = args[0] + '&referringurl=' + escape(CM_ReferringURL[0])*/
		CM_Location = args[0]
	}
	location.href = (CM_Location)
}

//*---------------------------------------------------
// hides specified tag
//--------------------------------------------------*/
function hideElement(HTMLtag)
{
	for (i = 0; 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','top in pixels' 
//--------------------------------------------------*/
var tdID = 0
function doDiv(){
	args = doDiv.arguments;
	var divID = args[0];
	var x = args[1];
	var divLeft = args[2];
	var divTop = args[3];

	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; width:" + MenuWidth + "px; z-index:5; top:" + divTop + "px; left: " + divLeft + "; background-color:" + menuColor + "; border:0 solid #A0A0A0; visibility: hidden;\" onMouseover=\"showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"hideDiv('document.all[\\'" + divID + "\\']')\">"
	
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:" + MenuWidth + "px; z-index:5; left: 0; background-color:" + lineColor + ";\">" + separator_top + "</div>"
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ menuColor +"; width:" + MenuWidth + "px; z-index:5; left: 0;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\" class=\"dhtmlNav\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">&nbsp;"+ menuData[x][y][0] +"&nbsp;</div>"
		objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:" + MenuWidth + "px; z-index:5; left: 0; background-color:" + lineColor + ";\">" + separator_bottom + "</div>"
		tdID = tdID +1
		}
	}
	objDiv += "</div>"
	document.write(objDiv);
}


//*---------------------------------------------------
// build the layers for netscape
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels' 
//--------------------------------------------------*/
function doLayer(){
	args = doLayer.arguments;
	var nestLayerID=0
	var layerID = args[0];
	var x = args[1];
	var layerLeft = args[2];
	var layerTop = args[3];

	if(navigator.platform.indexOf("Win") < 0){layerInc=16;layerStyle="netMenuMac";}
	else{layerInc=19;layerStyle="netMenu";}	
		
	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=0 BGCOLOR=\""+ menuColor +"\" WIDTH=" + MenuWidth + " HEIGHT=0 LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('','document.layers[\\'"+ layerID +"\\']')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']')\">"
	
	var nestTop=0
		for (y = 0; y < 15; y++){
		    if(menuData[x][y][0]!=null){
			objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=" + MenuWidth + " HEIGHT=1 Z-INDEX=8 LEFT=0 TOP="+ nestTop +">"+ separator_top +"</layer>"
			objDiv += "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=0 BGCOLOR=\""+ menuColor +"\" HEIGHT=21 WIDTH=" + MenuWidth + " LEFT=0 TOP="+ nestTop +" onmouseover=\"menuOver('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\" onmouseout=\"menuOut('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><a id=navstyle  href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font color=" + fontColorOff + ">"+ menuData[x][y][0]
			objDiv +="</font></a></layer>"			
			layerIncBottom=nestTop+layerInc	
			objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=" + MenuWidth + " HEIGHT=1 Z-INDEX=0 LEFT=0 TOP="+ layerIncBottom +">"+ separator_bottom +"</layer>"
					
			nestLayerID=nestLayerID+1
			
			nestTop=nestTop+layerInc+2
			
			}
		}
		/*objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=" + MenuWidth + " LEFT=0 HEIGHT=1 Z-INDEX=0 TOP="+ nestTop +">"+ separator +"</layer>"*/
		/*objDiv +="<layer id=\"lineEnd\" BGCOLOR=\""+ menuColor +"\" WIDTH=" + MenuWidth + " HEIGHT=0 Z-INDEX=0 TOP="+ nestTop +"></layer></layer>"*/
		objDiv +="</layer>"

	document.write(objDiv)
}


//*---------------------------------------------------
// build the divs for IE - Home Page Mouseover
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels' 
//--------------------------------------------------*/
function doDivHome(){
	args = doDivHome.arguments;
	var divID = args[0];
	var x = args[1];
	var divLeft = args[2];
	var divTop = args[3];
	var navType = args[4];
	var divWidth = args[5];
	var divHeight = args[6];

	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; width:" + divWidth + "px; height:" + divHeight + "px; z-index:0; top:" + divTop + "px; left: " + divLeft + "; border:0 solid #A0A0A0; visibility: hidden;\" class=\"" + navType + "\">" + menuData[x][0][0] +"&nbsp;</div>"
	document.write(objDiv);
}

//*---------------------------------------------------
// build the layers for netscape - Home Page Mouseover
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels' 
//--------------------------------------------------*/
function doLayerHome(){
	args = doLayerHome.arguments;
	var layerID = args[0];
	var x = args[1];
	var layerLeft = args[2];
	var layerTop = args[3];
	var layerStyle = args[4];
	var layerWidth = args[5];
	var layerHeight = args[6];

	/*if(navigator.platform.indexOf("Win") < 0){layerInc=16;layerStyle="netMenuMac";}*/
	/*else{layerInc=19;layerStyle="netHoverHome";}*/

	/*objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=0 BGCOLOR=\""+ menuColor +"\" WIDTH=" + MenuWidth + " HEIGHT=0 LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('','document.layers[\\'"+ layerID +"\\']')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']')\">"+ menuData[x][0][0]*/
	/*objDiv = "<layer id=\""+ layerID +"\" class=\""+ layerStyle +"\" Z-INDEX=1 HEIGHT=286 WIDTH=137 LEFT=" + layerLeft + " TOP="+ LayerTop + " ><font color=" + fontColorOff + ">"+ menuData[x][0][0]*/
	objDiv = "<layer id=\""+ layerID +"\" class=\""+ layerStyle +"\" Z-INDEX=0 BORDER=0 HEIGHT=" + layerHeight + " WIDTH=" + layerWidth + " LEFT=" + layerLeft + " TOP=" + layerTop + " VISIBILITY=HIDE onmouseover=\"showDDNav('','document.layers[\\'"+ layerID +"\\']')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']')\">"+ menuData[x][0][0]
	objDiv +="</font></layer>"			

	document.write(objDiv)
}
