/*
 * 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 handleDropdownArea(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (actuator == null) return;

    actuator.onmouseover = function() {
        if (currentMenu) {
            currentMenu.style.visibility = "hidden";
            if (menu) this.showMenu();
        }
    }

	if (menu)
	{
	    actuator.onclick = function()
	    	{
			if (currentMenu == null)
			{
				this.showMenu();
			}
			else
			{
				currentMenu.style.visibility = "hidden";
				currentMenu = null;
			}

			return false;
		}
	}

    actuator.showMenu = function() {
        menu.style.left = this.offsetLeft + 20 + "px";
        menu.style.top = this.offsetTop + this.offsetHeight - 10 + "px";
        menu.style.visibility = "visible";
        currentMenu = menu;
    }
}

