var sstrStay = '';
var sstrOn = '';
var sintTimer = 0;
// sarrItem is now set at /assets/menu.asp

//Should really be called: menu off if not highlighted...
//only do MenuOff if the current page is different from the strID page (i.e. user's not currently viewing it)

function setClassName(strClassID, strClassName) {

	var objN = document.getElementById(strClassID);
	if (objN != null) {
		objN.className = strClassName;
	}	
}


function getTrueOffSet(obj, strPos)
{
	var offsetStr="offset" + (strPos.toLowerCase()=="top" ? "Top" : strPos.toLowerCase()=="top" ? "Top" : "Left");
	var offsetVal=eval("obj." + offsetStr);
	while (obj.offsetParent != null)
	{
		offsetVal += eval("obj.offsetParent." + offsetStr);
		obj=obj.offsetParent;
	}
	return(offsetVal);
}

function MenuOn(strID, blnRight) {
	sstrStay = strID;
	if (strID != sstrOn) {
		sstrOn = strID;
		var objN = document.getElementById('nav_' + strID);
		var objM = document.getElementById('menu_' + strID);

		if (objN != null && objM != null) {
			if (blnRight) {
				objM.style.left = (getTrueOffSet(objN, "left") - (objM.offsetWidth - objN.offsetWidth)) + 'px';
			}
			else {
				objM.style.left = (getTrueOffSet(objN, "left") - 1) + 'px';
			}
			objM.style.top = (getTrueOffSet(objN, "top")+33) + 'px';
			objM.style.visibility = 'visible';
		}
		MenuAllHide(strID);
	}
}

function MenuStay(strID, strClass) {
	sstrStay = strID;

		var objN = document.getElementById('nav_' + strID);	
		if (objN != null) {
			setClassName('cell_' + strID, strClass);
		}
}

function MenuOff(strID, strClass) {
	sstrStay = '';
	clearTimeout(sintTimer);
	sintTimer = setTimeout('MenuHide(\'' + strID + '\')', 500);

		var objN = document.getElementById('nav_' + strID);	
		if (objN != null) {
			setClassName('cell_' + strID, strClass);
		}
	
}

function MenuOffIf(strID, gstrScript, keyword) {

	sstrStay = '';
	clearTimeout(sintTimer);
	sintTimer = setTimeout('MenuHide(\'' + strID + '\')', 500);
	
	//If the menu should not be highlighted, turn it off
	if (gstrScript.indexOf(keyword) < 0) {
		var objN = document.getElementById('nav_' + strID);	
		if (objN != null) {
			setClassName('cell_' + strID, strID);
		}
	}
}

function MenuAllOff() {
	sstrStay = '';
	sstrOn = '';
	clearTimeout(sintTimer);
	MenuAllHide();
}

function MenuHide(strID) {
	if (strID != sstrStay) {
		if (strID == sstrOn) sstrOn = '';
		var objM = document.getElementById('menu_' + strID);
		if (objM != null)
		{
			objM.style.visibility = 'hidden';
		}	
	}
}

function MenuAllHide(strID) {
	var intCount, strItem;
	for (intCount = 0; intCount < sarrItems.length; intCount++) {
		strItem = sarrItems[intCount];
		if (strID != strItem) MenuHide(strItem);
	}
}

