/*
 * menuDropdown.js - implements an dropdown menu based on a HTML list
 * Author: Dave Lindquist (dave@gazingus.org)
 * Adapted to display menus onmouseover, not onclick, and to add a delay before hiding
 */

var currentMenu = null;
var currentAct = null;
var timer = null;

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (actuator == null) return;
    
   

    actuator.onmouseover = function() {
        if (currentMenu == null) {
            this.showMenu();
        }
        else {
            currentMenu.style.visibility = "hidden";
            currentAct.className = "actuator";
            this.showMenu();
        }
    }

    actuator.onmouseout = function() {
        if (currentMenu) {
            timer = setTimeout('currentMenu.style.visibility = "hidden";currentAct.className = "actuator"', 600);
        }
    }
    
    menu.onmouseover = function() {
        window.clearTimeout(timer);
    }

    menu.onmouseout = function() {
        timer = setTimeout('currentMenu.style.visibility = "hidden";currentAct.className = "actuator"', 600);
    }
  
    actuator.onclick = function() {
        return false;
    }

    actuator.showMenu = function() {
        window.clearTimeout(timer);
        menu.style.visibility = "visible";
        actuator.className = "actuator currmenu";
        currentMenu = menu;
        currentAct = actuator;
    }
}
