/*----------------------------------------------------
// js_functions.js
//
// written by Kevin Eyer (keyer@frymulti.com)
// Fry Multimedia
//--------------------------------------------------*/

// define menu attributes here
menuColor="#FFFFFF"
menuColorN="Navy"
menuColorOn="#000066"
menuColorOnN="#EFEFEF"
fontColorOn="#FFFFFF"
fontColorOff="#6699CC"
lineColor = "#FFFFFF"

separator="<img src=pix/trans.gif height=1 width=1>"

//*---------------------------------------------------
// shows the drop down menu 
// expected arg is active div
//--------------------------------------------------*/
function showDDNav(){
	args = showDDNav.arguments;
	if(br=="N"){
		 if (document.layers) {
			var args, theObj;
			args = showDDNav.arguments;
			theObj = eval(args[1]);
	  		if (theObj) if(theObj.visibility=='hide'){theObj.visibility = 'show';}
		}
		else {
			//alert ("N3");
		}
	}
	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 if(NS6){
		theObj=eval(args[2]);
		theObj.style.visibility = 'visible';
		
	}
	else{return}
}

//*---------------------------------------------------
// hides the drop down menu 
// expected arg is active div 
//--------------------------------------------------*/
function hideDDNav(){
	args = hideDDNav.arguments;
	var theObjev;
	if(br=="N"){
		if (document.layers) {
			var args, theObj;
			args = hideDDNav.arguments;
			theObj = eval(args[1]);
			if (theObj) if(theObj.visibility=='show'){theObj.visibility = 'hide';}
		}
		else {
			//alert ("n3 too");
		}
	}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if (theObj) if(theObj.style.visibility=='visible'){showElement('SELECT');theObj.style.visibility = 'hidden'}
		}
	else if(NS6){
		theObj=eval(args[2]);
		theObjev=eval(args[3]);
		if (theObjev.clientY < 79 ){
			//alert (theObjev.clientY );
			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(e){
	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 (IS_MAC){
			if(window.event.clientY > bottomDiv || 
			window.event.clientY < (topDiv+20) || 
			window.event.clientX < (leftDiv+30) || 
			window.event.clientX > rightDiv)
			{
			theObj.style.visibility = 'hidden';
			 // activate showElement to show <select> menu's
			 //showElement('SELECT');
			}	
		}	
		else {
			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 if(NS6){ 
		theObj=eval(args[1]);
		//alert (theObj.offsetWidth);	
		// calculate active size of menu
		leftDiv=theObj.offsetLeft +2
		rightDiv=theObj.offsetLeft + theObj.offsetWidth -2
		topDiv=theObj.offsetTop +2
		bottomDiv=theObj.offsetTop + theObj.offsetHeight -2		
		theObj2=eval(args[2]);
		//theObj.style.visibility = 'hidden';
		if(theObj2.clientY > bottomDiv || 
			theObj2.clientY < topDiv || 
			theObj2.clientX < leftDiv || 
			theObj2.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;
		theObj.style.color=fontColorOn;
		//theObj.style.text-decoration=underline;
	}
	else if(NS6){ 
		theObj=eval(args[1]);
		theObj.style.backgroundColor=menuColorOn;
		theObj.style.color=fontColorOn;
	}
	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;
		theObj.style.color=fontColorOff;
	}
	else if(NS6){ 
	theObj=eval(args[1]);
		theObj.style.backgroundColor=menuColor;
		theObj.style.color=fontColorOff;
	}
	else{return}
}


//*---------------------------------------------------
// highlight off menuitem
// expected arg is active menuitem
//--------------------------------------------------*/
function divOutTitle(){
	args = divOutTitle.arguments;
	if(br=="N"){}
	else if(br=="IE"){
	theObj=eval(args[0]);
		theObj.style.backgroundColor="#FF9900";
		theObj.style.color="#FFFFFF";
	}
	else if(NS6){ 
	theObj=eval(args[1]);
		theObj.style.backgroundColor="#FF9900";
		theObj.style.color="#FFFFFF";
	}
	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=menuColorOnN; 
}

//*---------------------------------------------------
// 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;
	theMenu.FontColor=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)
{
	if(br=="IE"){
		for (i = 0; i < document.all.tags(HTMLtag).length; i++)
		{
			obj = document.all.tags(HTMLtag)[i];
			obj.style.visibility = "hidden";
		}
	}
	else {
		for (i = 0; i < document.getElementsByTagName(HTMLtag).length; i++)
		{
			obj = document.getElementsByTagName(HTMLtag)[i];
			obj.style.visibility = "hidden";
		}
	}
}

//*---------------------------------------------------
// shows specified tag
//--------------------------------------------------*/
function showElement(HTMLtag)
{
	if(br=="IE"){
		for (i = 1; i < document.all.tags(HTMLtag).length; i++)
		{
			obj = document.all.tags(HTMLtag)[i];
			obj.style.visibility = "visible";
		}
	}
	else {
		for (i = 2; i < document.getElementsByTagName(HTMLtag).length; i++)
		{
			obj = document.getElementsByTagName(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];
	//var imgtop =  args[4];
	var menuName =  args[4];
	var thewidth = 140;
	var thepaddingleft = 21;
	var thepaddingright = 3;
	if (IS_MAC && is_ie4) { thewidth = 140; thepaddingleft=0; thepaddingright=0; }
	//rollover(\\'" + menuName + "_on\\', \\'" +menuName + "\\');
	
	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; width:" + thewidth + "px; z-index:2; top:"+ divTop +"px; left: " + divLeft + "; background-color: #003399; border:0; visibility: hidden;\" onMouseover=\"rollover('" + menuName + "_on', '" + menuName + "_" + x + "');showDDNav('document.all[\\'"+ divID +"\\']');\"  onMouseout=\"rollover('" + menuName + "', '" + menuName + "_" + x + "');hideDiv('document.all[\\'" + divID + "\\']','document.getElementById(\\'" + divID + "\\')',event)\">"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:1px; width:" + (thewidth-3) + "px; z-index:3; left: 1px; top:0px;font-size:1px;\"></div>"
	
	var iestyle, iestyletitle;
	if (IS_MAC) {
		if (is_ie4) {
		iestyle = "dhtmlNavMacIE4";
		iestyletitle = "dhtmlNavMacIE4Title";
		}
		else {
		iestyle = "dhtmlNavMac";
		iestyletitle = "dhtmlNavMacTitle";
		}
	}
	else {
		iestyle = "dhtmlNav";
		iestyletitle = "dhtmlNavTitle";
	}
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		if (y == 0) {
			objDiv = objDiv + "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ "#ff9900" +"; text-indent:-9px; padding-left:" + thepaddingleft + "px; padding-right:" + thepaddingright + "px; width:" + (thewidth-2) + "px; z-index:3; left: 1px;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" onMouseout=\"divOutTitle('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" class=\"" + iestyletitle + "\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">"
			if (IS_MAC && is_ie4) { 
				objDiv = objDiv + "<img src=\"pix/pix_trans.gif\" border=\"0\" width=\"4\" height=\"4\"><br>&nbsp;&nbsp;"+ menuData[x][y][0] +"&nbsp;</div>"
			}
			else {
				objDiv = objDiv + menuData[x][y][0] +"&nbsp;</div>"
			}
		}
		else {
			//objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:138px; z-index:3; left: 1px; background-color:" + lineColor + ";\">" + separator + "</div>";
			objDiv = objDiv + "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ menuColor +"; text-indent:-9px; padding-left:" + thepaddingleft + "px; padding-right:" + thepaddingright + "px; width:" + (thewidth-2) + "px; z-index:3; left: 1px;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" class=\"" + iestyle + "\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><B>-</B>&nbsp;"+ menuData[x][y][0] +"&nbsp;</div>"
		}
		tdID = tdID +1
		}
	}
	//objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:138px; z-index:3; left: 1px; background-color:" + lineColor + ";\">" + separator + "</div>"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:1px; width:" + (thewidth-2) + "px; z-index:3; left: 1px; font-size:1px;\"></div></div>"
	//alert (objDiv);
	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];
	//var imgtop =  args[4];
	
	if(navigator.platform.indexOf("Win") < 0){layerInc=16;layerStyle="netMenuMac";layerStyleTitle="netMenuMacTitle";}
	else{layerInc=15;layerStyle="netMenu";layerStyleTitle="netMenuTitle";}	
		
	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=1 BGCOLOR=\""+ menuColorN +"\" WIDTH=140 LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('','document.layers[\\'"+ layerID +"\\']','document.getElementById[\\'x"+ layerID +"\\']')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']')\">"
	
	//objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=138 HEIGHT=1 Z-INDEX=8 LEFT=\"1px\" TOP="+ 1 +"px></layer>"
	var myheight
	var nestTop=1
		for (y = 0; y < 15; y++){
		    if(menuData[x][y][0]!=null){
				if ((menuData[x][y][0].length)>30) {
					myheight = 38;
					//alert (menuData[x][y][0]);
				}
				else {
					myheight = 19;
				}
				//objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=138 HEIGHT=1 Z-INDEX=8 LEFT=\"1px\" TOP="+ nestTop +">"+ separator +"</layer>";
				if (y == 0) {
					objDiv = objDiv + "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyleTitle +"\" Z-INDEX=7 BGCOLOR=\""+ "#ff9900" +"\" HEIGHT=" + myheight + " WIDTH=138 LEFT=\"1px\" TOP="+ nestTop +" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><a id=navstyle  href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font color=" + "#FFFFFF" + ">"+ menuData[x][y][0];
					objDiv = objDiv + "</font></a></layer>";		
				}
				else {
					objDiv = objDiv + "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=7 BGCOLOR=\""+ menuColor +"\" HEIGHT=" + myheight + " WIDTH=138 LEFT=\"1px\" 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]+"')><B>-</B><font color=" + fontColorOff + ">"+ menuData[x][y][0];
					objDiv = objDiv + "</font></a></layer>";		
				}
				nestLayerID=nestLayerID+1
				if ((menuData[x][y][0].length)>30) {
					nestTop=nestTop+layerInc+4;
				}
				nestTop=nestTop+layerInc+1
			}
		}
		//objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=138 LEFT=\"1px\" HEIGHT=1 Z-INDEX=8 TOP="+ nestTop +">"+ separator +"</layer>"
		objDiv +="<layer id=\"lineEnd\" BGCOLOR=\""+ menuColorN +"\" WIDTH=140 HEIGHT=\"1px\" Z-INDEX=7 TOP="+ (nestTop +2) +"></layer></layer>"
	//alert (objDiv);
	document.write(objDiv)
}

//*---------------------------------------------------
// build the divs for IE
// expected args are 'div name','x in menudata aray',
// 'menu left coord','top in pixels' 
//--------------------------------------------------*/
function doNS6Div(){
	args = doNS6Div.arguments;
	var divID = args[0];
	var x = args[1];
	var divLeft = args[2];
	var divTop = args[3];
	//var imgtop =  args[4];
	var menuName =  args[4];
		
	
	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; width:168px; z-index:2; top:"+ divTop +"px; left: " + divLeft + "; background-color: #003399; border:0; visibility: hidden;\" onMouseover=\"rollover('" + menuName + "_on', '" + menuName + "_" + x + "');showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"rollover('" + menuName + "', '" + menuName + "_" + x + "');hideDiv('document.all[\\'" + divID + "\\']','document.getElementById(\\'" + divID + "\\')',event)\">"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:0px; width:137px; z-index:3; left: 1px; top:0px;font-size:1px;\"></div>"
	objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:166px; z-index:3; left: 1px; background-color:#003399;\">" + separator + "</div>";
		
	var iestyle;
	if (IS_MAC) {
		iestyle = "dhtmlNS6NavMac";
		iestyleTitle = "dhtmlNS6NavMacTitle";
	}
	else {
		iestyle = "dhtmlNS6Nav"
		iestyleTitle = "dhtmlNS6NavTitle"
	}
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		//objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:138px; z-index:3; left: 1px; background-color:" + lineColor + ";\">" + separator + "</div>";
		if (y == 0) {
			objDiv = objDiv + "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ "ff9900" +"; text-indent:-9px; padding-left:25px; padding-right:3px; width:138px; z-index:3; left: 1px;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" onMouseout=\"divOutTitle('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" class=\"" + iestyleTitle + "\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">"+ menuData[x][y][0] +"&nbsp;</div>"
		}
		else {
			objDiv = objDiv + "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ menuColor +"; text-indent:-9px; padding-left:25px; padding-right:3px; width:138px; z-index:3; left: 1px;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']','document.getElementById(\\'x" + tdID + "\\')')\" class=\"" + iestyle + "\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\"><B>-</B>&nbsp;"+ menuData[x][y][0] +"&nbsp;</div>"
		}
		tdID = tdID +1
		}
	}
	//objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:138px; z-index:3; left: 1px; background-color:" + lineColor + ";\">" + separator + "</div>"
	objDiv += "<div id=\"spacer\" style=\"position:relative; height:1px; width:136px; z-index:3; left: 1px; font-size:1px;\"></div></div>"
	//alert (objDiv);
	document.write(objDiv);
}

