//global variables for timeout and for current menu
var t=false;
var current=false;
function SetupMenu(){
	if (!document.getElementsByTagName) return;
	var menuItems=document.getElementsByTagName("ul");
	// loop thru all the documents ul codes looking for the rMenu ones
	for(var iAll=0; iAll<menuItems.length; iAll++) 
		{
		if(menuItems[iAll].className !="rMenu") continue;	// not what we want bye 
		//set up event handlers for menu item
		var iNumTopLevel = menuItems[iAll].childNodes.length;
		for(var iTop=0;iTop<iNumTopLevel;iTop++)
			{
			 // get top level menu, show those and start timer
			var topLevelMenu = menuItems[iAll].childNodes[iTop]
			topLevelMenu.onmouseover=ShowMenu;
			topLevelMenu.onmouseout=StartTimer;
			//hide all the sub menus
			setMenuDisplay(topLevelMenu,"none");
			}
	}
}

function setMenuDisplay(topLevelMenu,strType)
{
	var numNodes = topLevelMenu.childNodes.length;
	for (var j=0; j<numNodes; j++) 
		{
		var subMenu = topLevelMenu.childNodes[j];
		if (subMenu.tagName == "UL")
			{
			subMenu.onmouseover=ResetTimer;
			subMenu.onmouseout=StartTimer;
			subMenu.style.display = strType;
			}
		}
} // end of setMenuDisplay()

function ShowMenu(e) {
//	if (!e)  e=window.event;
	// which link was the mouse over?
//	var topMenu = (e.target) ? e.target: e.srcElement;
	var topMenu = e.currentTarget;
	ResetTimer();
	// hide the previous menu, if any
	if (current) HideMenu(current);
	current = e.currentTarget;
	//show all the sub menus
	setMenuDisplay(topMenu,"block");
}
function HideMenu (theLink) {
	//show all the sub menus
	setMenuDisplay(theLink,"none");
}
function ResetTimer() {
	if (t) window.clearTimeout(t);
}
function StartTimer() {
	t=window.setTimeout("HideMenu(current)",1000);
}
// set up the menu when the page loads
window.onload=SetupMenu;