/*
 * caMenu.js
 * implements a JavaScript-driven dropdown menu, using a
 * CSS-styled list
 */

var currentMenu = null;

if (!document.getElementById)
    document.getElementById = function() {
	return null;
}

window.onload = function() {
/* JavaScript user-defined function initializeMenu(dl.menuID, dd.actuatorID) */
initializeMenu("aboutMenu", "aboutActuator");
initializeMenu("volunteerMenu", "volunteerActuator");
initializeMenu("donateMenu", "donateActuator");
initializeMenu("newsMenu", "newsActuator");
initializeMenu("eventsMenu", "eventsActuator");
initializeMenu("contactMenu", "contactActuator");
}

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    //if (window.opera) return; // opera has only a small following

    actuator.onmouseover = function() {
        menu.style.left = this.offsetLeft + "px";
        menu.style.top = this.offsetTop + this.offsetHeight + "px";
        menu.style.visibility = "visible";
        currentMenu = menu;
    }
  
    actuator.onmouseout = function() {
        if (currentMenu == null) {
            this.showMenu();
        }
        else {
            currentMenu.style.visibility = "hidden";
            currentMenu = null;
       }
        return false;
    }

    actuator.showMenu = function() {
        menu.style.left = this.offsetLeft + "px";
        menu.style.top = this.offsetTop + this.offsetHeight + "px";
        menu.style.visibility = "visible";
        currentMenu = menu;
    }
}
