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

var currentMenu = null;

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 == null) {
		this.className = "selected";
		this.showMenu();
		}
		else if(currentMenu) {
		this.className = "selected";
		currentMenu.style.visibility = "hidden";
		this.showMenu();
		}
		a=0;
		return false;
	}
  
	actuator.onmouseout = function() {
		actuator.className = "actuator";
		a=1;setTimeout('if(a==1){currentMenu.style.visibility = "hidden"};',150);
	}
	
	menu.onmouseover = function(){
		a=0;
		actuator.className = "selected";
	}
	
	menu.onmouseout = function() {
		a=1;
		actuator.className = "actuator";
		setTimeout('if(a==1){currentMenu.style.visibility = "hidden"};',150);
	}

    actuator.showMenu = function() {
        menu.style.left = this.offsetLeft + "px";
        menu.style.top = this.offsetTop + this.offsetHeight + "px";
        menu.style.visibility = "visible";
		
		currentMenu = menu;
    }
}

window.onload = function() {
	initializeMenu("gMenu", "gActuator");
	initializeMenu("hMenu", "hActuator");
	initializeMenu("iMenu", "iActuator");
	initializeMenu("jMenu", "jActuator");
	initializeMenu("kMenu", "kActuator");
}
