function Menu(){
	this.current = "";
	this.submenu = new Array();
	this.submenu[0] = "";
	this.submenu[1] = "";
	this.showSubSection = MenuShowSubSection;
	this.showLayer = MenuShowLayer;
	this.hideLayer = MenuHideLayer;
	this.getLayer = MenuGetLayer;
	this.swapLayerClass = MenuSwapLayerClass;
	this.subLevelClosing = MenuSubLevelClosing;
	this.wipeOutSubmenuArray = MenuWipeOutSubmenuArray;
	this.init=init;

}

function MenuShowSubSection(menuId,rollover){
	if(!menuId || menuId == ""){
		return;
	}

	this.current = menuId;
	//if( this.current != ""){
	if( this.current != "" && this.submenu[1] != this.current && this.submenu[0] != this.current){
		menuId = this.subLevelClosing(menuId);
		this.showLayer(menuId);
		//this.hideLayer('submenu3');
	}
	else
	{	
		this.hideLayer(menuId);
		this.wipeOutSubmenuArray(menuId);
	}
	
}

function MenuShowLayer(id){
	if(!id || id == ""){
		return;
	}
	var layer = this.getLayer(id);
	layer.style.display = "block";
}

function MenuHideLayer(id){
	if(!id || id == ""){
		return;
	}
	var layer = this.getLayer(id);
	layer.style.display = "none";
}

function MenuGetLayer(layerId){
	var layer = null;
	layer = document.getElementById(layerId);
	return layer;
}

function MenuSwapLayerClass(layerId, css){
	layer = this.getLayer(layerId);
	if(!layer || layer == ""){
		return;
	}
	layer.className = css;
}

function init(menuid)
{
	var layer = null;
	layer = document.getElementById(menuid);
	layer.style.display = "block";
	this.current =menuid;
	this.submenu[0] = this.current;
	//document.write(""+menuid+"");

}

function MenuWipeOutSubmenuArray(Id){
	switch(Id.substring(3,6)){
		case "men":
					this.submenu[0] = "";
					break;
		case "sub":
					this.submenu[1] = "";
					break;
	
		default:
					break;
		}
}



function MenuSubLevelClosing( menuId ){
	var strCloseOneMenu = false;
	var strCloseTwoMenu = false;
	switch(menuId.substring(3,6)){
		case "men":
					if( this.submenu[0] == "" ){
						this.submenu[0] = this.current;
					}
					else if( this.submenu[0] != this.current){
						strCloseTwoMenu = true;
					}
					break;
		
		case "sub":
					if( this.submenu[1] == ""){
						this.submenu[1] = this.current;
					}
					else if( this.submenu[1] != this.current ){
						strCloseOneMenu = true;
					}
					break;
		
		default:
					break;
	}
	if(strCloseTwoMenu){
		this.hideLayer(this.submenu[0]);
		this.submenu[0] = this.current;
		this.hideLayer(this.submenu[1])
		this.submenu[1] = "";
		strCloseTwoMenu = false;
	}
	if(strCloseOneMenu){
		this.hideLayer(this.submenu[1]);
		this.submenu[1] = this.current;	
		strCloseOneMenu = false;
	}
	return menuId;
}
