/*
 * menuDropdown.js - implements an dropdown menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 */

var currentMenu = null;
var inMenu=false;

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) {currentMenu.style.visibility = "hidden";}
        this.showMenu();


        return false;
    }

    actuator.onclick = function() {
      return false;
    }
    actuator.onmouseout=function() {
      inMenu=false;
      setTimeout('checkHide()',1000);
    }



    actuator.showMenu = function() {
        menu.style.left = (this.offsetLeft + 15) + "px";
        menu.style.top = (this.offsetTop + this.offsetHeight) + 11 + "px";
        menu.style.visibility = "visible";
        currentMenu = menu;
        inMenu=true;
        menu.onmouseover=function() {inMenu=true;}
        menu.onmouseout=function() {
          inMenu=false;
          setTimeout('checkHide()',1000);
        }
    }
}

function checkHide() {
  if(inMenu==false) {
    currentMenu.style.visibility = "hidden";
  }
}
