/*
 * jsMenu.js:    Implements a dropdown menu based on an HTML list
 * Created:      Jeff McLennan (jeffwa@jeffwa.com) - 1/19/2002
 * Modified:      
 *
 *                    Based on menuDropdown.js by Dave Lindquist (dave@gazingus.org) 
 *                    Original code found: http://www.gazingus.org/dhtml/?id=109
 */

var currentMenu = null;
var varTimeOut  = null;

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    if (window.opera) return; // I'm too tired

    actuator.onmouseover = function() {
        if (currentMenu) {
		    clearTimeout(varTimeOut);
            currentMenu.style.visibility = "hidden";
        }
		this.showMenu();
    }
	actuator.onclick = function() { return false; }

    actuator.onmouseout = function() { 
	  varTimeOut = setTimeout("hideMenu()", 2000);
	}

    actuator.showMenu = function() {
	    var posLeft = Math.floor(this.offsetLeft / 150) * 150;
        menu.style.left = posLeft -1 + "px";
        menu.style.top = this.offsetTop + this.offsetHeight + "px";
        menu.style.visibility = "visible";
        currentMenu = menu;
    }
}

function hideMenu() {
	if (currentMenu) currentMenu.style.visibility = "hidden";
}

function closeDelay() {
    varTimeOut = setTimeout("hideMenu()", 2000);    
}

function closeCancel() {
    if (varTimeOut) clearTimeout(varTimeOut);
}
