// Fry Multimedia

// sniff for mac
isMac = (navigator.appVersion.indexOf("Mac") != -1) ? 1 : 0;

// define menu attributes here
menuColor="#bd9071"
menuColorOn="#000000"
fontColorOff="#FFFFFF"

// shows the drop down menu 
// expected arg is active div
function showDDNav(){
	args = showDDNav.arguments;
	// dropdowns
	if(br=="N"){
		var args, theObj;
		args = showDDNav.arguments;
		// rollover
		if (args[2] != "on"){
			changeImages(args[2], eval('\''+args[2]+'on'+'\''));
		}
		theObj = eval(args[1]);
  		if (theObj) if(theObj.visibility=='hide'){theObj.visibility = 'show';}
	}
	else if(br=="IE"){
		// rollover
		if (args[2] != "on"){
			changeImages(args[2], eval('\''+args[2]+'on'+'\''));
		}
		theObj=eval(args[0]);
		if (theObj){ 			
			if(theObj.style.visibility=='hidden'){
				theObj.style.visibility = 'visible'
			}
		}
	}
	else{return}
}

// hides the drop down menu 
// expected arg is active div 
function hideDDNav(){
	var args, theObj;
	args = hideDDNav.arguments;
	// rollover
	if (args[2] != "on"){
		changeImages(args[2], eval('\''+args[2]+'off'+'\''));
	}
	if(br=="N"){
		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 IE only
// 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';
				// rollover
				if (args[1] != "on"){
					changeImages(args[1], eval('\''+args[1]+'off'+'\''));
				}
			}				
		}
	else{return}
}

// highlight menuitem in IE
// expected arg is active menuitem
function divOver(){
	args = divOver.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		menuColorOn=args[1];
		theObj=eval(args[0]);
		theObj.style.backgroundColor=menuColorOn;
	}
	else{return}
}

// highlight off menuitem in IE
// expected arg is active menuitem
function divOut(){
	args = divOut.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		// if the total number of items in the array changes, you will need to change the number below
		menuColor=args[1];
		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;
	menuColorOn=args[1];
	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;
	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]
}

// hides specified tag. Note from Sheri: I don't think this works and it should be taken out.
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 MENU IN IE
// 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;
	
	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('document.all[\\'"+ divID +"\\']','null','" + whichImg + "')\"  onMouseout=\"hideDiv('document.all[\\'" + divID + "\\']','" + whichImg + "')\">"
// the loop below writes out each line of the menu.	
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ menuColor +"; width:" + innerWidth + "px; z-index:23;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']', '" + menuColorOn + "' )\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']', '" + menuColor + "')\" 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
// 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

	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('','document.layers[\\'"+ layerID +"\\']','" + whichImg + "')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']','" + whichImg + "')\">"
	var nestTop=0
// this loop writes out the menu items.
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=7 BGCOLOR=\""+ menuColor +"\" HEIGHT=19 WIDTH=" + innerWidth + " TOP="+ nestTop +" onmouseover=\"menuOver('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']', '" + menuColorOn + "')\" onmouseout=\"menuOut('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']', '" + menuColor + "')\" 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>"		
		nestLayerID=nestLayerID+1
		nestTop=nestTop+layerInc+1
		tdID = tdID +1
		}
	}
	objDiv += "</layer>"

	document.write(objDiv)
}
