//JS WEB MENU
//BUILT BY QUINN HANAM
//This file contains the main body of the menu.  All functions handling events are based
//in this file.  To edit the paramaters of this file, refer to "MENU_VARS.js"

//VARS
var over = false;
var timeoutID = "";

self.document.writeln("<style type=\'text/css\'>");
self.document.writeln(".submenu a:link {color:#000000; text-decoration:none;font-size:10; font-weight:normal; font-family: verdana;}");
self.document.writeln(".submenu a:active {color:#FFFFFF; text-decoration:none;font-size:10; font-weight:normal;font-family: verdana;}");
self.document.writeln(".submenu a:visited {color:#000000; text-decoration:none;font-size:10; font-weight:normal;font-family: verdana;}");
self.document.writeln(".submenu a:hover {color:#FFFFFF; text-decoration:none;font-size:10; font-weight:normal;font-family: verdana;}");
self.document.writeln("</style>")

self.document.writeln("<div id=\"banana\" style=\"position:absolute\">");
self.document.writeln("<\/div>");

for(var i=0; i<menuItems.length; i++)
{
	var theID="Submenu"+i;
		
	self.document.write("<div ID="+theID+" class=\"submenu\" width=\"100%\" height=\"100%\" target=\""+tgt+"\"");
	self.document.write("style=\"position: absolute;left: 0px;top: 0px;width:"+menuWidth+"; background-color:"+menuBodyColor+";border-style:"+menuBorderStyle+";border-color:"+menuBorderColor+";border-width:"+menuBorderWidth+";visibility: hidden;\"");
	self.document.writeln("onMouseOver=\"javascript:cancelTimer()\" onMouseOut=\"javascript:setTimer()\">"); 
	self.document.writeln("<table>");
		
	for(var j=0; j < menuItems[i].length; j++)
	{
		self.document.writeln("<tr><td>");
		self.document.writeln("<a href=\""+menuLinks[i][j]+"\" target=\""+tgt+"\"> ");
		self.document.writeln(menuItems[i][j]);
		self.document.writeln("<\/a>");
		self.document.writeln("<\/td><\/tr>");
	}		
	self.document.writeln("<\/table><\/div>");
}


function activateMenu(menuNum)
{
	over=true;
	cancelTimer();
	closeAll();

	var theMenu=eval("Submenu"+menuNum);
	
	theMenu.style.visibility="visible";
	
	if(document.body.clientWidth<750)
	{
		theMenu.style.left = menuCoords[menuNum].x;
		theMenu.style.top = menuCoords[menuNum].y;
	}
	else
	{
		var xCoord =  (document.body.clientWidth - 750)/2 + fromLeft;
		theMenu.style.left= xCoord;
		theMenu.style.top = menuCoords[menuNum].y;
	}
}

function setTimer()
{
	timeoutID = window.setTimeout("closeAll()", tmr);
}

function cancelTimer()
{
	window.clearTimeout(timeoutID);
}

function closeAll()
{
	for(var i=0; i<menuItems.length; i++)
	{
		var theMenu=eval("Submenu"+i);
		theMenu.style.visibility="hidden";
		theMenu.style.left="0px";
		theMenu.style.top="0px";
	}
}