var shownSubMenu = null;

function showSubMenu(subMenuId, parentMenu) {
	//if we are currently showing one, then hide it
	if (shownSubMenu != null) {
		shownSubMenu.style.display="none";
		shownSubMenu = null;
	}
	
	//alert("Got here " + parentMenu.offsetTop + "   " + parentMenu.offsetLeft);
	var menu = document.getElementById(subMenuId);
	var browser=navigator.appName;
	//alert(browser);
	if (browser.indexOf('Explorer') > -1) {
		//alert("IE");
		menu.style.top = (getAbsTop(parentMenu) - 1) + "px";
		menu.style.left = (getAbsLeft(parentMenu)) + "px";
		menu.style.width = (getElementWidth(parentMenu)) + "px";
	}
	else {
		//alert("Other");
		menu.style.top = (getAbsTop(parentMenu)) + "px";
		menu.style.left = (getAbsLeft(parentMenu) + 2) + "px";
		menu.style.width = (getElementWidth(parentMenu) - 1) + "px";
	}
	
	menu.style.display = "block";
	
	shownSubMenu = menu;
}

function hideSubMenu(subMenuId) {
	//alert("Got here HIDE ");
	//var menu = document.getElementById(subMenuId);
	InitializeTimer();
}



function mouseOverSubMenu(subMenu) {
	//alert("Got here mouse over ");
	StopTheClock();
}



function getAbsLeft(el){
	var l=el.offsetLeft;
  	while((el=el.parentNode) && el!=document)
    	l+=el.offsetLeft;
  	return l;
}

function getAbsTop(el){
	var t=el.offsetTop;
  	while((el=el.parentNode) && el!=document)
    	t+=el.offsetTop;
  	return t;
}

function getElementHeight(elem) {
	xPos = elem.offsetHeight;
	return xPos;

}

function getElementWidth(elem) {
	xPos = elem.offsetWidth;
	return xPos;

}



var secs
var timerID = null
var timerRunning = false
var delay = 100

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 1
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        if (shownSubMenu != null) {
        	shownSubMenu.style.display="none";
        }
        //alert("You have just wasted 10 seconds of your life.")
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
//-->
