/*
 * 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 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;
    
    
    if (menuId == "brandMenu" || menuId == "aboutMenu" || menuId == "pressMenu") {

    actuator.onmouseover = function() {
        if (currentMenu == null) {
            this.showMenu();
        }
        else {
            currentMenu.style.visibility = "hidden";
            this.showMenu();
        }
    }

    actuator.onmouseout = function() {
        if (currentMenu) {
            timer = setTimeout('currentMenu.style.visibility = "hidden"', 600);
        }
    }
    
    menu.onmouseover = function() {
        window.clearTimeout(timer);
    }

    menu.onmouseout = function() {
        timer = setTimeout('currentMenu.style.visibility = "hidden"', 600);
    }
  
    actuator.onclick = function() {
        return false;
    }

    actuator.showMenu = function() {
        window.clearTimeout(timer);
        menu.style.visibility = "visible";
        currentMenu = menu;
    }
    
    } else {
    
      actuator.onmouseover = function() {
        if (currentMenu) {
          currentMenu.style.visibility = "hidden";
        }
      }
    
    }
}
