// showMenu() is called on mouseover of the main nav item.
// Each menu item also calls showMenu() to ensure that the menu
// stays visible as long as the mouse is within the menu area.
// The DIV that surrounds the menu items has a mouseout that
// calls hideMenu() to hide the menu when you roll off.
// On most browsers, the showMenu() call overrides the
// hideMenu() (at least, the hide/show delay is unnoticeable),
// but Netscape has trouble with this, resulting in flicker
// of the menu. To get around this, we have the mouseout instead
// trigger a timeOut script (setHideMenu()) that calls hideMenu().
// if showMenu() is called, it invalidates the timeOut (as long
// as it's called for the same menu), so the menu stays visible.

var lastMenu;
function showMenu(id) {
	if (lastMenu == id) clearTimeout(timeOutID);
	setMenuPos(id);
	var obj = document.getElementById(('menu'+id));
	obj.style.display = "block";
	
	var navobj = document.getElementById(('navitem'+id));
	navobj.className += " over";
	
	lastMenu = id;
};

var timeOutID;
function hideMenu(id) {
	var obj = document.getElementById(('menu'+id));
	obj.style.display = "none";
	
	var navobj = document.getElementById(('navitem'+id));
	navobj.className = navobj.className.substring(0,navobj.className.indexOf(" over"));
};

function setHideMenu(id) {
	timeOutID = setTimeout("hideMenu("+id+")",50);
}

function setMenuPos(id) {
	var obj = document.getElementById(('menu'+id));
	var navobj = document.getElementById(('navitem'+id));
	var containerobj = document.getElementById(('nav'));
	
	var navItemOffset = navobj.offsetParent.offsetLeft;
	var navParentOffset = containerobj.offsetLeft;
	var totalOffset = navItemOffset + navParentOffset;
	
	//alert(obj.style.left);
	//obj.setAttribute("left",totalOffset);
	obj.style.left = totalOffset  + "px";
};
