var currentMenu = null;		// stores object of type myMenu for current selected menu

var menuArray = new Array;	// array of myMenu objects


if (!document.getElementById)
	document.getElementById = function() { return null; }

function myMenu(menuObject){ 
	this.Status = "Closed";
	this.menuObject = menuObject;
}

function initializeMenu(menuId, actuatorId, menuNumber) {
	var menu = document.getElementById(menuId);
	var actuator = document.getElementById(actuatorId);
	
	//if (menu == null || actuator == null) return;
	if (menu == null)
	{
		if (actuator != null)
		{
			actuator.onmouseover = function ()
			{
				if (currentMenu != null)
				{
					currentMenu.menuObject.style.display = "none";
					currentMenu.Status = "Closed";
					currentMenu = null; 
				}
			}
		}
		return;
	}	

	menuArray[menuNumber] = new myMenu(menu);
	//alert(menuArray[0].Status);
	
	actuator.onmouseover = function() {
		
		
		menuArray[menuNumber].Status = "Open";
		
		if ((currentMenu != null) && (currentMenu.menuObject != menu) && (currentMenu.Status != "Closed")) {
			//alert("close");
			currentMenu.Status = "Closed";
			//currentMenu.menuObject.style.zIndex = 2;
			currentMenu.menuObject.menuClose();
		}
		currentMenu = menuArray[menuNumber];
		//currentMenu.menuObject.style.zIndex = 3;

		if (menuId != "menu1") {
			//alert ("menuId = " + menuId);
			menu.style.display = "block";
			currentMenu.menuObject.menuOpen();
		}
	}
	
		
	menu.menuOpen = function() {
		//alert("open menu");
		this.style.display = 'block';
		//this.style.height = 'auto';
	}
		
	menu.menuClose = function() {
		this.style.display = 'none';
		//this.style.height = '0';
	}
}
		
function initializeCloser(closerID) {
	if (document.getElementById(closerID))
	{
		var closer = document.getElementById(closerID);
		
		closer.onmouseover = function() {
			if (currentMenu != null) {
				//alert(currentMenu.menuObject.menuClose);
				currentMenu.Status = "Closed";
				currentMenu.menuObject.menuClose();
			}
		}
	}
}


function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}

}
