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);
	var timer;
	
    if (menu == null || actuator == null) return;

      actuator.onmouseover = function() {
      window.clearTimeout(timer);
        if (currentMenu) {
            currentMenu.style.visibility = "hidden";
            this.showMenu();
        }
        
	actuator.onmouseout = function() {
		window.clearTimeout(timer);
   	 if (currentMenu == null) {
   	             this.showMenu();
   	     }
   	   }
   	     
    }

menu.onmouseout = function() {
        if (currentMenu != null) {
			timer = window.setTimeout('currentMenu.style.visibility = "hidden"',2000)
		}
		else {
			window.clearTimeout(timer);
		}
    }
	
	menu.onmouseover = function() {
   		window.clearTimeout(timer);
    }

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










/*
*bottom menu bit below
*/
function initializeMenu2(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);
	var timer;
	
    if (menu == null || actuator == null) return;

      actuator.onmouseover = function() {
      window.clearTimeout(timer);
        if (currentMenu) {
            currentMenu.style.visibility = "hidden";
            this.showMenu();
        }
        
	actuator.onmouseout = function() {
		window.clearTimeout(timer);
   	 if (currentMenu == null) {
   	             this.showMenu();
   	     }
   	   }
   	     
    }

menu.onmouseout = function() {
        if (currentMenu != null) {
			timer = window.setTimeout('currentMenu.style.visibility = "hidden"',2000)
		}
		else {
			window.clearTimeout(timer);
		}
    }
	
	menu.onmouseover = function() {
   		window.clearTimeout(timer);
    }

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





