var timesover=0;
var timerID = null;

var boolTimerOn = false;
var intTimecount = 400;
var intRunCount = 0;

var intNumTabs = 12;
var asTabs = new Array();
	asTabs[0] = "menua";
	asTabs[1] = "menub";
	asTabs[2] = "menuc";
	asTabs[3] = "menud";
	asTabs[4] = "menue";
	asTabs[5] = "menuf";
	asTabs[6] = "menug";
	asTabs[7] = "2menua";
	asTabs[8] = "2menub";
	asTabs[9] = "2menuc";
	asTabs[10] = "2menud";
	asTabs[11] = "2menue";
	function doInitializeMenu() {
	for (i=0; i<intNumTabs; i++)
	{
			if(document.getElementById("menuitem-" + asTabs[i]).className=="mainmenuitem active")
				intTabActive = i;
	}
}
function settimeover(){
timesover=1;
}
function doMenuOn(id) {
	/* initialize the menu to figure out which tab is set to active */
	if (intRunCount < 1)
	{
		doInitializeMenu();
		intRunCount++;
	}

		/*hide any menus that might be open*/
		if (document.getElementById("menuitem-" + id).className == "mainmenuitem active" && timesover==0)
		{
		//alert("active");
		timesover=1;
		}
		else
		{
		timesover=1;
		doHideAll();
		/* if statement to check if the submenu acutally exists, because the home menu doesn't have one */
		if(document.getElementById("submenu-" + id))
			document.getElementById("submenu-" + id).style.display = "block"; /*turn on the submenu*/
		/*change the style of the tab to the hover style*/	
		document.getElementById("menuitem-" + id).className = "mainmenuitem hover"; 
		/* stop the timer */
		doStopTime(); 
		}
	//}
}
function doMenuOff(id) {
for (i=0; i<intNumTabs; i++)
	{
			if(document.getElementById("menuitem-" + asTabs[i]).className=="mainmenuitem active")
				timesover=1;
	}
	/*start the timer */
	doStartTime(); 
}
function doSubMenuOn(){
	/* stop the timer */
	doStopTime(); 
}
function doSubMenuOff(){
	 /* start the timer */
	 doStartTime();
}
function doHideAll(){
	for (i=0; i<intNumTabs; i++)
	{
		/* if statement to check if the submenu exists before we try to hide it */
		if(document.getElementById("submenu-" + asTabs[i]))
			document.getElementById("submenu-" + asTabs[i]).style.display = "none"; /* hide the submenu */
		/*set all tabs to the inactive style */
		document.getElementById("menuitem-" + asTabs[i]).className="mainmenuitem inactive";
	}
	/*set the active tab to the active style*/
}
function doStopTime(){
	if (boolTimerOn){
		clearTimeout(timerID);
        timerID = null;
        boolTimerOn = false;
	}
}
function doStartTime(){
	if (boolTimerOn == false) {
		timerID=setTimeout( "doHideAll()" , intTimecount);
		boolTimerOn = true;
	}
}
