function menuObject(){
	this.dataObject = new menuDataObject();
	this.offsetId = 0;
	this.includeFrontPage = false;
	this.dataObject.offsetId = this.offsetId;
	this.dataObject.includeFrontPage = this.includeFrontPage;
	
	this.top=0;
	this.className=""
	this.mainMenuObjects = new Array();
	this.allMenuObjects = new Array();
	
	//EXTERNAL FUNCTIONS
	this.createMenu=__createMenu;
	this.createMenu2=__createMenu2;
	
	//INTERNAL FUNCTIONS	
	this.createSubMenu = __createSubMenu;
	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;
	
	
	for(i=0;i<menuArr.length;i++){ // all level 1 menues
		if(this.includeFrontPage || (!this.includeFrontPage && !menuArr[i].isFront)){
			divObj = document.createElement("DIV")
			document.body.appendChild(divObj)
			if(isFirst){
				retStr = "<table border='0' cellspacing='0' cellpadding='0' id='menuTbl_" + menuArr[i].id + "'><tr>"
				retStr += "<td valign=top width='11'><img src='/gfx/icons/topMenuStart.gif' width=11></td>"
				retStr += "<td valign=top class='" + this.className + "' height=15 onmouseOut='mainOut(" + menuArr[i].id + ",this)' onmouseOver='mainOver(" + menuArr[i].id + ",this)' id='menuCell_"+menuArr[i].id+"' onclick=\"document.location='" + menuArr[i].url + "'\">"+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"
				isFirst = false
			}else{
				retStr = "<table border='0' cellspacing='0' cellpadding='0' id='menuTbl_" + menuArr[i].id + "'><tr>"
				retStr += "<td valign=top class='" + this.className + "' height=15 onmouseOut='mainOut(" + menuArr[i].id + ",this)' onmouseOver='mainOver(" + menuArr[i].id + ",this)' id='menuCell_"+menuArr[i].id+"' onclick=\"document.location='" + menuArr[i].url + "'\">"+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_" + menuArr[i].id;	
			
			viewObj = this.mainMenuObjects[this.mainMenuObjects.length] = new menuViewObject()
			
			viewObj.viewDivObj = divObj;
			viewObj.viewTableObj = document.getElementById("menuTbl_" + menuArr[i].id)
			viewObj.viewTdObj = document.getElementById("menuCell_" + menuArr[i].id)
			this.allMenuObjects[this.allMenuObjects.length]=viewObj;
			//divObj;
			
			//Submenu
			this.createSubMenu(menuArr[i],viewObj)
		}
	}
}

function __createSubMenu(pObj,vObj){
	if(pObj.childs.length>0){
			var retStr="";
			var divObj, i, tmpMVO;
			divObj = document.createElement("DIV")
			document.body.appendChild(divObj)
			retStr = "<table border='0' class='subMenu' cellspacing='0' cellpadding='0' id='childMenuTbl_" + pObj.id + "'>"
			for(i=0;i<pObj.childs.length;i++){
				retStr += "<tr><td bgcolor='#FFFFFF' height=15 class='subMenu' onclick='document.location=\"" + pObj.childs[i].url + "\"' onmouseOut='subOut(" + pObj.childs[i].id + ",this)' onmouseOver='subOver(" + pObj.childs[i].id + ",this)' id='childMenuCell_"+pObj.childs[i].id+"'>" + pObj.childs[i].title + "</td></tr>"
				//this.createSubMenu(pObj.childs[i]) //recurse
			}
			retStr += "<tr><td align=center height=5><img src='/gfx/spacer.gif' height=5px;></td></tr>"
			retStr += "</table>"
			
			divObj.innerHTML = retStr;
			divObj.style.visibility = "hidden";
			divObj.style.position="absolute";
			divObj.style.top="0"
			divObj.style.left="0"
			divObj.id = "childMenuContainer_" + pObj.id;	
			divObj.innerHTML = retStr;
			tmpMVO = new menuViewObject();
			tmpMVO.viewDivObj = divObj
			tmpMVO.viewTableObj = document.getElementById("childMenuTbl_" + pObj.id)
			
			vObj.childViewObj = tmpMVO;	
			this.allMenuObjects[this.allMenuObjects.length]=tmpMVO
		}
}


function __createMenu2(){
	var menuArr = this.dataObject.topMenues
	var retStr="", divObj, i, vObj, tmp;
	
	
	for(i=0;i<menuArr.length;i++){ // all level 1 menues
		if(this.includeFrontPage || (!this.includeFrontPage && !menuArr[i].isFront)){
			
			retStr += "<table width='180' border='0' cellspacing='0' cellpadding='0' id='menuTbl_" + menuArr[i].id + "'><tr><td width=21 align=right valign='top'><img src='/gfx/icons/bullet.gif' width='7' height='10'></td><td width=8><img src='/gfx/spacer.gif' width='8'></td>"
			retStr += "<td class='" + this.className + "' height=15 onmouseOut='mainOut(" + menuArr[i].id + ",this)' onmouseOver='mainOver(" + menuArr[i].id + ",this)' id='menuCell_"+menuArr[i].id+"' onclick=\"document.location='" + menuArr[i].url + "'\">"+menuArr[i].title+"</td>"
			retStr += "</tr></table>"
			
			
			viewObj = this.mainMenuObjects[this.mainMenuObjects.length] = new menuViewObject()
			viewObj.viewTableObj = "menuTbl_" + menuArr[i].id
			viewObj.viewTdObj = "menuCell_" + menuArr[i].id 
			this.allMenuObjects[this.allMenuObjects.length]=viewObj;
			//divObj;
			
			if(document.location.toString().indexOf(menuArr[i].url.toString())>-1){
				for(ii=0;ii<menuArr[i].childs.length;ii++){
					retStr += "<table width='180' border='0' cellspacing='0' cellpadding='0' id='menuTbl_" + menuArr[i].id + "'><tr><td width=16><img src='/gfx/spacer.gif' width='8'></td><td width=21 align=right valign='top'><img src='/gfx/icons/bullet.gif' width='7' height='10'></td><td width=8><img src='/gfx/spacer.gif' width='8'></td>"
					retStr += "<td class='" + this.className + "' height=15 onmouseOut='mainOut(" + menuArr[i].childs[ii].id + ",this)' onmouseOver='mainOver(" + menuArr[i].childs[ii].id + ",this)' id='menuCell_"+menuArr[i].childs[ii].id+"' onclick=\"document.location='" + menuArr[i].childs[ii].url + "'\">"+menuArr[i].childs[ii].title+"</td>"
					retStr += "</tr></table>"
				}
					retStr += "<table width='180' border='0' cellspacing='0' cellpadding='0' id='menuTbl_" + menuArr[i].id + "'><tr><td width=16><img src='/gfx/spacer.gif' width='8' height='10'></td>"
					retStr += "</tr></table>"
			}else{			
				//Submenu
				this.createSubMenu2(menuArr[i],viewObj)
			}
		}
	}
	return retStr;
}

function __createSubMenu2(pObj,vObj){
	if(pObj.childs.length>0){
			var retStr="";
			var divObj, i, tmpMVO;
			divObj = document.createElement("DIV")
			document.body.appendChild(divObj)
			retStr = "<table border='0' class='subMenu' cellspacing='0' cellpadding='0' id='childMenuTbl_" + pObj.id + "'>"
			for(i=0;i<pObj.childs.length;i++){
				retStr += "<tr><td bgcolor='#FFFFFF' height=15 class='subMenu' onclick='document.location=\"" + pObj.childs[i].url + "\"' onmouseOut='subOut(" + pObj.childs[i].id + ",this)' onmouseOver='subOver(" + pObj.childs[i].id + ",this)' id='childMenuCell_"+pObj.childs[i].id+"'>" + pObj.childs[i].title + "</td></tr>"
				//this.createSubMenu(pObj.childs[i]) //recurse
			}
			retStr += "<tr><td align=center height=5><img src='/gfx/spacer.gif' height=5px;></td></tr>"
			retStr += "</table>"
			
			divObj.innerHTML = retStr;
			divObj.style.visibility = "hidden";
			divObj.style.position="absolute";
			divObj.style.top="0"
			divObj.style.left="0"
			divObj.id = "childMenuContainer_" + pObj.id;	
			divObj.innerHTML = retStr;
			tmpMVO = new menuViewObject();
			tmpMVO.viewDivObj = divObj
			tmpMVO.viewTableObj = document.getElementById("childMenuTbl_" + pObj.id)
			
			vObj.childViewObj = tmpMVO;	
			this.allMenuObjects[this.allMenuObjects.length]=tmpMVO
		}
}

/*************************Functions for the display things ***************************************/

document.menuTimer=null;
document.showingEl=null;
document.activeMainMenu=null;
document.useFilter=4
document.effectTime=0.4
document.filt = new Array()
document.filt[1] = "progid:DXImageTransform.Microsoft.Pixelate(maxSquare=50,duration=0.2)"
document.filt[2] = "progid:DXImageTransform.Microsoft.RandomDissolve(duration=0.5)"
document.filt[3] = "progid:DXImageTransform.Microsoft.Slide(slidestyle=PUSH,Bands=2)"
document.filt[4] = "progid:DXImageTransform.Microsoft.Fade(Overlap=0.5,Duration="+document.effectTime+")"
document.filt[5] = "progid:DXImageTransform.Microsoft.Checkerboard(Direction=right,SquaresX=50,SquaresY=50)"
document.filt[6] = "progid:DXImageTransform.Microsoft.Iris(irisstyle=circkle,motion=in)"
document.filt[7] = "progid:DXImageTransform.Microsoft.Stretch(stretchstyle=SPIN)"
document.filt[8] = "progid:DXImageTransform.Microsoft.Opasity(opsity=10,style=0)"


function mainOver(id, obj){
	var subDiv
	if(document.menuTimer){window.clearTimeout(document.menuTimer);document.menuTimer=null}
	subDiv=document.getElementById("childMenuContainer_"+id);
	
	if(document.showingEl && document.showingEl!=subDiv){
		document.showingEl.style.visibility="hidden";
		tmpId = document.showingEl.id.toString().replace(/childMenuContainer_/gi,"")
		__mainOut(tmpId, "menuCell_"+tmpId)
	}
	
	obj.className.toString().indexOf("Hover")==-1?obj.className+="Hover":null;
	document.activeMainMenu = obj
	if(subDiv && document.showingEl!=subDiv){
		if(document.all){
			subDiv.style.filter=document.filt[document.useFilter];
			subDiv.filters[0].apply();
			subDiv.style.visibility="visible";
			subDiv.filters[0].play();
		}else{
			subDiv.style.visibility="visible";
			subDiv.style.opacity=0.0;
			setOpIn(99,10,subDiv.id)
		}
		
		
	}
	subDiv?document.showingEl=subDiv:null;
}



function setOpIn(end,jmp,objId){
	obj=document.getElementById(objId)
	if(end<=obj.style.opacity*100+jmp){
		obj.style.opacity=end/100;
	}else{
		obj.style.opacity=parseFloat(obj.style.opacity)+(parseFloat((jmp/100)));
		window.setTimeout("setOpIn("+end+","+jmp+",'"+objId+"')",30)
	}
}

function setOpOut(end,jmp,objId){
	obj=document.getElementById(objId)
	if(obj.style.opacity*100-jmp<=end){
		obj.style.opacity=end/100;
		obj.style.visibility="hidden";
	}else{
		obj.style.opacity=parseFloat(obj.style.opacity)-(parseFloat((jmp/100)));
		window.setTimeout("setOpOut("+end+","+jmp+",'"+objId+"')",30)
	}
}

function mainOut(id, obj){	
	document.menuTimer=window.setTimeout("__mainOut('"+id+"','"+obj.id+"')",500)	
	if(!document.getElementById("childMenuContainer_"+id)){
		obj.className=obj.className.toString().replace(/Hover/gi,"")
	}
}

function __mainOut(id,obj){
	
	
	document.getElementById(obj).className=document.getElementById(obj).className.toString().replace(/Hover/gi,"")
	
	subDiv=document.getElementById("childMenuContainer_"+id);
	if(subDiv){
		if(document.all){
			subDiv.filters[0].apply();
			subDiv.style.visibility="hidden"
			subDiv.filters[0].play();
		}else{
			setOpOut(0,10,subDiv.id)
		}
	}
	document.showingEl=null
}

function subOver(id, obj){
	if(document.menuTimer){window.clearTimeout(document.menuTimer);document.menuTimer=null}
	obj.className="subMenuHover"
}

function subOut(id, obj){
	obj.className="subMenu"
	document.menuTimer=window.setTimeout("__subOut('"+id+"','"+obj.id+"')",500)	
}

function __subOut(id, obj){
	subDiv=document.showingEl //document.getElementById("childMenuContainer_"+id);
		if(subDiv){
		if(document.all){
			subDiv.filters[0].apply();
			subDiv.style.visibility="hidden"
			subDiv.filters[0].play();
		}else{
			setOpOut(0,10,subDiv.id)
		}
	}
	document.showingEl=null
	document.activeMainMenu.className=document.activeMainMenu.className.toString().replace(/Hover/gi,"")
}