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

/*************************************
+
+	configure vars
+
**************************************/
// how long does the menu stay open
var waitToClose = 500;
// allow link in actuator
var allowActuatorLink=true;



/*************************************
+
+	please leave unchange from here
+
**************************************/
var currentMenu = null;
var closeMenu = true;


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

function closeIt(){
	if (currentMenu && closeMenu) {
		currentMenu.style.visibility = "hidden";
	}
}

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();
  }
	menu.onmouseover = function(){
		closeMenu = false;
	}
	menu.onmouseout = function(){
		closeMenu = true;
       window.setTimeout("closeIt()",waitToClose);	
	}
     actuator.onmouseout = function() {
		closeMenu = true;

       window.setTimeout("closeIt()",waitToClose);	
 }
 
    actuator.onclick = function() {
        if (currentMenu == null) {
            this.showMenu();
        }
        else {
            currentMenu.style.visibility = "hidden";
            currentMenu = null;
        }

        if(!allowActuatorLink){
	        return false;   
        }
    }

    actuator.showMenu = function() {
    	closeIt();
        menu.style.left = this.offsetLeft + "px";
        menu.style.top = 19 + "px";
        menu.style.visibility = "visible";
 		closeMenu = false;
       currentMenu = menu;
    }
}

window.onload = function() {
            initializeMenu("vaargebiedMenu", "vaargebiedActuator");
            initializeMenu("schepenMenu", "schepenActuator");
            initializeMenu("extraMenu", "extraActuator");
            initializeMenu("schipperMenu", "schipperActuator");
        }
