
var menuSpeed = 20;			// milliseconds between animation steps
var menuAnimation = 20;		// distance in pixels of each animation step
var currentMenu = null;		// stores object of type myMenu for current selected menu
var maxTop = 85;			// the top of the menu when open
var menuTop = -180;			// the top of the menu when closed

var menuArray = new Array;	// array of myMenu objects
var openAni;				
var closeAni;

var maxHeight = 300;


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);
	
	//menu.style.top = menuTop + "px";
	
	if (menu == null || actuator == 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;
		menu.style.display = "block";
		currentMenu.menuObject.menuOpen();
	}
	
		
	menu.menuOpen = function() {
		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 menuLoad() {
	initializeMenu("styleMenu", "styleTrigger", 0);
	initializeMenu("spaceMenu", "spaceTrigger", 1);
	initializeMenu("productsMenu", "productsTrigger", 2);
	initializeMenu("buyMenu", "buyTrigger", 3);
	initializeMenu("supportMenu", "supportTrigger", 4);
	initializeMenu("companyMenu", "companyTrigger", 5);
	initializeCloser("contentrow");
	initializeCloser("tabcontent");
}


function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}

}

//window.onload = menuLoad;
addLoadEvent(menuLoad);