// Fry Multimedia

// sniff for mac
isMac = (navigator.appVersion.indexOf("Mac") != -1) ? 1 : 0;

// define menu attributes here
menuColor="#f7fae5"
menuColorOn="#d9e1a9"
fontColorOff="#373C42"
borderColor="#70a612"
lineColor="#ffffff"
separator="<img src=/assets/images/spacer.gif width=1 height=1>"

// 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){
			if(divRef.style.visibility=='hidden'){
				divRef.style.visibility = 'visible';
			}
		}
	}
}

// hides the drop down menu 
// expected arg is active div 
function hideDDNav(){
	args = hideDDNav.arguments;
	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){
			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';
		}
	// NS6
	} else {
		divRef=eval("document.getElementById('" + divName + "')");
		divRef.style.visibility = 'hidden';
	}	
}

// highlight menuitem in IE & NS6
// expected arg is active menuitem
function divOver(){
	args = divOver.arguments;
	var divName = args[0];
	var menuColorOn = args[1];
	var divRef;
	
	if (br=="NS6") {
		divRef=eval("document.getElementById('" + divName + "')");
		divRef.style.cursor = "pointer";
	} else {
		divRef=eval("document.all." + divName);
	}
	divRef.style.backgroundColor=menuColorOn;
}

// 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 divRef;
	
	if (br=="NS6") {
		divRef=eval("document.getElementById('" + divName + "')");
	} else {
		divRef=eval("document.all." + divName);
	}
	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)',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];
// menuWidth below is a variable because each menu is a different width. 
// If the menu items should have padding around them, set the innerWidth and Outerwidth to plus and minus the padding.
// eg, if you want 7 pts padding: innerWidth = menuWidth-7; outerWidth = menuWidth+7
// Sample menus have no padding this is not used here.
	var menuWidth = args[4];
	var innerWidth=menuWidth-7;
	var outerWidth=menuWidth;
	
	if (isMac) {
		outerWidth=menuWidth;
	} 
		
// the line below is the opening tag of the menu.
	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; width:" + menuWidth + "px; z-index:20; top:"+ divTop +"px; left: " + divLeft + "; background-color: " + menuColor + "; border-style: solid; border-width: 1px; border-color: " + borderColor + "; visibility: hidden;\" onMouseover=\"showDDNav('"+ divID +"')\"  onMouseout=\"hideDiv('" + divID + "')\">"
// the line below sets padding at the TOP of the menu. Change the height value to change the top padding. 
//objDiv += "<div id=\"spacer\" style=\"position:relative; height:2px; width:" + innerWidth + "px; z-index:3; left: 7; font-size:1;\"></div>"

// the loop below writes out each line of the menu.	
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
		
// the line below puts a spacer bar between each menu item. 
objDiv += "<div id=\"bar\" style=\"position:relative; height:2; width:" + menuWidth + "px; z-index:3; left: 0; background-color:" + lineColor + ";\">" + separator + "</div>"

// the line below is the actual menu item. Notice that it uses the "dhtmlNav" stylesheet (in the default.css stylesheet file). I added &nbsp;s to put spacing *inside* each menu item (whereas the innerWidth/outerWidth padding stuff would have added space *around* the menu items and highlights.)	
		objDiv += "<table border=0 cellpadding=0 cellspacing=0><tr><td>&nbsp;</td><td><div id=\"x" + tdID + "\" style=\"position:relative; background-color:"+ menuColor +"; width:" + innerWidth + "px; z-index:23;\" onMouseover=\"divOver('x" + tdID + "', '" + menuColorOn + "' )\" onMouseout=\"divOut('x" + tdID + "', '" + menuColor + "')\" class=\"gIEMenuItemStyle\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">"+ menuData[x][y][0] +"</div></td><td>&nbsp;</td></tr></table>"
		tdID = tdID +1
		}
	}
// the line below closes out the div tag for the entire menu. Commented out here because we are adding padding to the bottom of each menu, and closing out the div there. Uncomment this and comment line 193 if no padding at the bottom of each menu.

objDiv += "</div>"

// the line below adds a spacer bar after the last item on the menu.
// objDiv += "<div id=\"bar\" style=\"position:relative; height:1; width:" + innerWidth + "px; z-index:3; left: 7; background-color:" + lineColor + ";\">" + separator + "</div>"

// the line below adds padding to the bottom of the menu. Change the height property for more or less padding. Commented here because Echo does not use extra padding at the top and bottom of the menus.
//	objDiv += "<div id=\"spacer\" style=\"position:relative; height:2px; width:" + outerWidth + "px; z-index:3; left: 7; font-size:1;\"></div></div>"
	
	document.write(objDiv);
}


// BUILD THE MENU IN NETSCAPE 4.x
// expected args are 'div name','x in menudata array',
// '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];
// if you want padding around the menu items, set innerWidth = menuWidth-14, for 7pts padding on each side. Unlike IE there is no outerWidth setting.
	var innerWidth = menuWidth

// use a different stylesheet for Mac, since the font sizes are not quite the same.
	if(navigator.platform.indexOf("Win") < 0){layerInc=16;layerStyle="gNetMenuItemStyleMac";}
	else{layerInc=15;layerStyle="gNetMenuItemStyle";}	
		
// the line below is the opening tag of the menu.
	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=1 BGCOLOR=\""+ menuColor +"\" WIDTH=" + menuWidth + " LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('"+ layerID +"')\" onmouseout=\"hideDDNav('"+ layerID +"')\">"
// the line below adds a graphic at the top of each menu. Put the graphic between the opening and closing tags of the div.
	// objDiv +="<layer id=\"arrow\" BGCOLOR=\""+ menuColor +"\" class=\""+ layerStyle + "\" WIDTH=" + innerWidth + " LEFT=7></layer>"

// set nestTop below to how many pixels of padding you want at the top of the menu.	If no padding, set it to 0.
	var nestTop=5
// this loop writes out the menu items.
	for (y = 0; y < 15; y++){
	    if(menuData[x][y][0]!=null){
// the line below writes a spacer bar between each menu item.
objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=" + innerWidth + " HEIGHT=1 Z-INDEX=8 LEFT=7 TOP="+ nestTop +">"+ separator +"</layer>"
// the line below writes out the menu item itself. The stylesheets used are netMenu for PC, and netMenuMac for Mac, in the netscape.css stylesheet file.
		objDiv += "<layer id=\"x"+nestLayerID+"\" class=\""+ layerStyle +"\" Z-INDEX=7 BGCOLOR=\""+ menuColor +"\" HEIGHT=10 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 class='navstyle' href=javascript:gotoUrl('"+menuData[x][y][1]+"')>"+ menuData[x][y][0]
		objDiv +="</a></layer>"		
		nestLayerID=nestLayerID+1
		nestTop=nestTop+layerInc+1
		tdID = tdID +1
		}
	}
// the line below closes the layer tag for the entire menu. 
//	objDiv += "</layer>"
// the line below writes a spacer bar after the last menu item and closes out the layer.
// objDiv += "<layer id=\"line2\" BGCOLOR=\""+ lineColor +"\" WIDTH=" + innerWidth + " LEFT=7 HEIGHT=1 Z-INDEX=8 TOP="+ nestTop +">"+ separator +"</layer>"
// the line below adds padding after the last menu item and closes out the layer.
	objDiv +="<layer id=\"lineEnd\" BGCOLOR=\""+ menuColor +"\" WIDTH=" + menuWidth + " HEIGHT=5 Z-INDEX=7 TOP="+ nestTop +"></layer></layer>"
	

	document.write(objDiv)
}
