// JavaScript Document
//Frank Cedeno 03/24/2006
//use with menu.css or main.css
//code to show and hide menus.  The root menu (always visible) will be a group of buttons
//(unless the intent is to link to another page).  Using the onmouseover attribute
//of the button, the program will call on the show menu function
//SHOWMENU function will:
//	Hide any menus visible (hideall function)
//	Reset the timer (resettimer function)
//	Change to visible the chosen container and set the location 
//  load the array
//The bottom of each menu heirarchy will run resettimer function using the onmouseover function
//The onmouseout of every menu will call the starttimeout function
//STARTTIMEOUT function will:
//	runs the hideall function after a set time
//HIDEALL function will:
//	iterate through the array that contains open menu containers and sets visibility to false
//		on all of them
// examples:
//	root button:
//		<input type="button" class="moremenuup" value="My Reports" onmouseover="showMenu('reports', 100, 150); this.className='moremenuover'" onmouseout="startTimeout(1000); this.className='moremenuup';" id="btnMenu1" />
//div example
//<div id="reports" class="hideme"><table border="0" cellpadding="0" cellspacing="0">
//	<tr>
//		<td><input type="button" class="moremenuup" value="Human Resources" onmouseover="showMenu('reports', 'hrrep', 100, 300); this.className='moremenuover'" onmouseout="startTimeout(1000); this.className='moremenuup';" id="btnMenu21" /></td>
//	</tr>
//	<tr>
//		<td><input type="button" class="moremenuup" value="TR" onmouseover="showMenu('reports', 'trrep', 120, 300); this.className='moremenuover'" onmouseout="startTimeout(1000); this.className='moremenuup';" id="btnMenu22" /></td>
//	</tr>
//	<tr>
//		<td><input type="button" class="moremenuup" value="misc" onmouseover="showMenu('reports', 'msrep', 140, 300); this.className='moremenuover'" onmouseout="startTimeout(1000); this.className='moremenuup';" id="btnMenu23" /></td>
//	</tr>
//</table></div>
//<div id="hrrep" class="hideme"><img src="http://gabc.apps/jpg/brand.gif" />here1</div>
//<div id="trrep" class="hideme"><img src="http://gabc.apps/jpg/brand.gif" />here2</div>
//<div id="msrep" class="hideme"><img src="http://gabc.apps/jpg/brand.gif" />here3</div>

var arrMenus = null;
var timeid = null;

function hideAll(thisMenu){
	resetTimer();
	var thatObj;
	if (arrMenus){
		
		for(var i in arrMenus){
			thatObj = document.getElementById(arrMenus[i]);
			
			if(!thisMenu==""){
				if(thisMenu!=arrMenus[i]){
					thatObj.style.visibility = "hidden";
					
				}
			}else{
				thatObj.style.visibility = "hidden";
			}
		}
		if (thisMenu==""){
			arrMenus = null;
			
		}
	}
	
}

function resetTimer(){
	if (timeid){
		clearTimeout(timeid);
	}
	timeid = null;
}

function showMenu(thisMenu, thatMenu, y, x){
	hideAll(thisMenu);
	resetTimer();
	var obj;
	var tw = navigator;
	
	obj = document.getElementById(thatMenu);
	obj.style.visibility = "visible";
	if (navigator.appCodeName == "Mozilla"){
		obj.style.top = y + "px";
		obj.style.left = x + "px";
	}else{
		obj.style.top = y;
		obj.style.left = x;
	}
	if (!arrMenus){
		arrMenus = new Array;
	}
	if (!arrMenus[arrMenus.length]==""){
		arrMenus.length=arrMenus.length + 1;
	}
	arrMenus[arrMenus.length] = "" + thatMenu;
	
}

function startTimeout(timeDelay){
	var s;
	s = null;
	timeid = setTimeout("hideAll('')", timeDelay);
}
function navTo(urlTo){
		window.open(urlTo, '_self')
}
function navOut(urlTo){
		window.open(urlTo, '_blank')
}