function menuObject(){
	this.dataObject = new menuDataObject();
	this.offsetId = 0;
	this.includeFrontPage = false;
	this.dataObject.offsetId = this.offsetId;
	this.dataObject.includeFrontPage = this.includeFrontPage;
	this.uId=0
	
	this.top=0;
	this.className=""
	this.mainMenuObjects = new Array();
	this.allMenuObjects = new Array();
	
	//EXTERNAL FUNCTIONS
	this.createMenu=__createMenu;
	this.createMenu2=__createMenu2;
	
	
	//INTERNAL FUNCTIONS	
	
	this.createSubMenu2 = __createSubMenu2;
	return this;
}

function menuViewObject(){
	this.viewDivObj = null;
	this.viewTableObj = null;
	this.viewTdObj = null;
	
	this.childViewObj = null;
	this.parentViewObj = null;
	
	return this;
}

function __createMenu(){
	var menuArr = this.dataObject.topMenues
	var retStr, divObj, i, vObj, tmp, isFirst=true;
	
	
	
			divObj = document.createElement("DIV")
			document.body.appendChild(divObj)

			retStr = "<table border='0' cellspacing='0' cellpadding='0' id='menuTbl_top'><tr>"
			
			for(i=0;i<menuArr.length;i++){ // all toplevel menues
				if(this.includeFrontPage || (!this.includeFrontPage && !menuArr[i].isFront)){			
						retStr += "<td><img src='/gfx/icons/menudevider.gif'></td><td class='" + this.className + "' style='padding:0 5 0 5' height=15 onmouseOut='' onmouseOver='' id='menuCell_"+menuArr[i].id+"' onclick=\"document.location='" + menuArr[i].url + "&mid="+menuArr[i].id+"'\">"+menuArr[i].title+"</td>"
				}
			}
			retStr += "</tr></table>"
				divObj.innerHTML = retStr;
				divObj.style.visibility = "hidden";
				divObj.style.position="absolute";
				divObj.style.top=this.top
				divObj.style.left="0"

			divObj.id = "mContainer_top"
			
			viewObj = this.mainMenuObjects[this.mainMenuObjects.length] = new menuViewObject()
			
			viewObj.viewDivObj = divObj;
			viewObj.viewTableObj = document.getElementById("menuTbl_top")
			viewObj.viewTdObj = document.getElementById("menuCell_top")
			this.allMenuObjects[this.allMenuObjects.length]=viewObj;
			
			

}

























function __createMenu2(){
	var menuArr = this.dataObject.topMenues
	var retStr, divObj, i, vObj, tmp, isFirst=true;

	retStr = "<table border='0' cellspacing='0' width='123 cellpadding='0' id='menuTblMain'>";
	for(i=0;i<menuArr.length;i++){ // all level 1 menues
		if(this.includeFrontPage || (!this.includeFrontPage && !menuArr[i].isFront)){
				if(menuArr[i].childs.length<1){
					retStr += "<tr><td class='" + this.className + "' height=15 onmouseOut='mainOut(" + menuArr[i].id + ",this)' onmouseOver='mainOver(" + menuArr[i].id + ","+this.uId+",this)' id='menuCell_"+menuArr[i].id+"' onclick=\"document.location='" + menuArr[i].url + "&mid="+document.mid+"&scid="+menuArr[i].id+"'\"><nobr>"+menuArr[i].title+"</nobr></td></tr>";
				}else{
					retStr += "<tr><td class='" + this.className + "' style='cursor:default;' height=15 onmouseOut='mainOut(" + menuArr[i].id + ",this)' onmouseOver='mainOver(" + menuArr[i].id + ","+this.uId+",this)' id='menuCell_"+menuArr[i].id+"' aonclick=\"document.location='" + menuArr[i].url + "&mid="+document.mid+"'\"><nobr>"+menuArr[i].title+"</nobr></td></tr>";
				}
				this.createSubMenu2(menuArr[i],0)
			//Submenu
		}
	}
	retStr += "</table>";

	divObj = document.createElement("DIV")
			
	divObj.innerHTML = retStr;
	divObj.style.position="absolute";
	divObj.style.top=this.top;
	divObj.style.height=10;
	divObj.style.left="0";
	divObj.id = "menuContainer_" + this.uId;
	document.body.appendChild(divObj)
		
	//this.allMenuObjects[this.allMenuObjects.length]=viewObj;
 	

		
}

function __createSubMenu2(pObj,lvl){
	if(pObj.childs.length>0){
			var retStr="";
			var divObj, i, tmpLvl=lvl,className;
			divObj = document.createElement("DIV")
			document.body.appendChild(divObj)
			
			//tmpLvl % 2 ? className="subMenu2":className="submenu";
			tmpLvl % 2 ? className="childMenu":className="childmenu";
			
			retStr = "<table border='0' class='" + className + "' width=100% cellspacing='0' cellpadding='0' id='childMenuTbl_" + pObj.id + "'>"
			for(i=0;i<pObj.childs.length;i++){
				if(pObj.childs[i].childs.length<1){
					retStr += "<tr><td bgcolor='#FFFFFF' height=15 class='" + className + "' onclick='document.location=\"" + pObj.childs[i].url + "&mid="+document.mid+"&scid="+pObj.childs[i].id+"\"' onmouseOut='mainOut(" + pObj.childs[i].id + ",this)' onmouseOver='mainOver(" + pObj.childs[i].id + "," + pObj.id + ",this)' id='childMenuCell_"+pObj.childs[i].id+"'>" + pObj.childs[i].title + "</td></tr>"				
				}else{
					retStr += "<tr><td bgcolor='#FFFFFF' height=15 class='" + className + "' style='cursor:default;' aonclick='document.location=\"" + pObj.childs[i].url + "\"' onmouseOut='mainOut(" + pObj.childs[i].id + ",this)' onmouseOver='mainOver(" + pObj.childs[i].id + "," + pObj.id + ",this)' id='childMenuCell_"+pObj.childs[i].id+"'>" + pObj.childs[i].title + "</td></tr>"				
				}
				this.createSubMenu2(pObj.childs[i],tmpLvl+1)
			}
			retStr += "</table>"
			
			divObj.innerHTML = retStr;
			divObj.style.visibility = "hidden";
			divObj.style.display = "none";
			divObj.style.position="absolute";
			divObj.style.top="0"
			divObj.style.left="0"
			divObj.style.width="123"
			divObj.id = "menuContainer_" + pObj.id;	
	}
}
/*************************Functions for the display things ***************************************/
var menuTimer;

function mainOver(childId, ownId, obj){
	menuTimer?window.clearTimeout(menuTimer):null;
	childDivObj = document.getElementById("menuContainer_" + childId);
	ownDivObj = document.getElementById("menuContainer_" + ownId);
	ownTdObj = obj;
	
	if(ownDivObj){
		if(ownDivObj.showingDiv){
			if(ownDivObj.showingDiv!=childDivObj)
				hideShowingDivs(ownDivObj.showingDiv)
		}
	}

	ownTdObj.className += "Hover"
	
	leftOffset = parseInt(ownDivObj.style.left) + parseInt(ownTdObj.offsetWidth)+3
	topOffset = parseInt(ownTdObj.offsetTop) + parseInt(ownDivObj.style.top)-0
		
	if(childDivObj){		
		childDivObj.style.top=topOffset+5;
		childDivObj.style.left=leftOffset-10;
		childDivObj.style.zIndex=100;
		childDivObj.style.visibility="visible";
		childDivObj.style.display = "block";
		ownDivObj.showingDiv=childDivObj;
	}
}
	

function mainOut(id, obj){	
	var childDivObj = document.getElementById("menuContainer_" + id);	
	obj.className=obj.className.toString().replace(/hover/gi,"")
	menuTimer = window.setTimeout('hideAllDivs()',500)
}


function hideShowingDivs(divObj){
	divObj.style.visibility="hidden";
	divObj.style.display="none";
	if(divObj.showingDiv)
		hideShowingDivs(divObj.showingDiv);
}

function hideAllDivs(id){
	oDivs = document.body.getElementsByTagName("DIV");
	for(i=0;i<oDivs.length;i++){
		if(oDivs[i].id.toString().indexOf("menuContainer_")>-1){
			oDivs[i].showingDiv=null;
			if(oDivs[i].id!="menuContainer_2"){
				oDivs[i].style.visibility="hidden";
				oDivs[i].style.display="none";
			}
		}
	}
}