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;borderStyle=""
	
	divObj = document.createElement("DIV")
			document.body.appendChild(divObj)
	retStr = "<table border='0' style='width:850' cellspacing='5' cellpadding='0' id='menuTbl_TOP'><tr>"
	for(i=0;i<menuArr.length;i++){ // all level 1 menues
	w=100
		if(this.includeFrontPage || (!this.includeFrontPage && !menuArr[i].isFront)){


					retStr += "<td class='" + this.className + "'  style='padding:0px 20px 0px 20px; cursor:hand;' onmouseOut='mainOut(" + menuArr[i].id + ",this,\"topmenu\")' onmouseOver='mainOver(" + menuArr[i].id + ",1,this,\"topmenu\",true)' id='menuCell_"+menuArr[i].id+"' onclick=\"document.location='" + menuArr[i].url + "&mid="+menuArr[i].id+"'\"><nobr>"+menuArr[i].title+"</nobr><br><img src='/gfx/icons/bullet.gif' style='visibility:hidden' id='bullet_"+menuArr[i].id+"'></td>"
			
				/*
					create submenu for topmenu
					
				*/
				this.createSubMenu(menuArr[i],0,"topmenu",menuArr[i].id)
		}
	}
		retStr += "<td>&nbsp;</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 = "menuContainer_topmenu_1";	
	isFirst?isFirst=false:null;	
}

function __createSubMenu(pObj,lvl,parentMenuName,grandparentID){
	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="+grandparentID+"&scid="+pObj.childs[i].id+"\"' onmouseOut='mainOut(" + pObj.childs[i].id + ",this,\"" + parentMenuName + "\")' onmouseOver='mainOver(" + pObj.childs[i].id + "," + pObj.id + ",this,\"" + parentMenuName + "\")' 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,\"" + parentMenuName + "\")' onmouseOver='mainOver(" + pObj.childs[i].id + "," + pObj.id + ",this,\"" + parentMenuName + "\")' id='childMenuCell_"+pObj.childs[i].id+"'>" + pObj.childs[i].title + "</td></tr>"				
				}
				this.createSubMenu(pObj.childs[i],tmpLvl+1,parentMenuName,grandparentID)
			}
			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_" + parentMenuName + "_" + pObj.id;	
			
	}
}






function __createMenu2(){
	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)){
			retStr += "<table border='0' cellspacing='0' width=115 cellpadding='0' id='menuTblMain'>";
			if(menuArr[i].childs.length<1){
				retStr += "<tr><td class='" + this.className + "' style='font-weight:bold;border-bottom-width:0px; height:15px;' onmouseOut='mainOut2(" + menuArr[i].id + ",this)' onmouseOver='mainOver2(" + menuArr[i].id + ","+this.uId+",this)' id='menuCell_"+menuArr[i].id+"' onclick=\"document.location='" + menuArr[i].url + "&mid="+document.mid+"&scid="+menuArr[i].id+"'\"><img src='/gfx/spacer.gif' height=9 width=9 id='leftmenuBullet_"+menuArr[i].id+"'><nobr>"+menuArr[i].title+"</nobr></td></tr>";
			}else{
				retStr += "<tr><td class='" + this.className + "' style='font-weight:bold;cursor:default; border-bottom-width:0px; height:15px;' height=15 onmouseOut='mainOut2(" + menuArr[i].id + ",this)' onmouseOver='mainOver2(" + menuArr[i].id + ","+this.uId+",this)' id='menuCell_"+menuArr[i].id+"' aonclick=\"document.location='" + menuArr[i].url + "&mid="+document.mid+"'\"><img src='/gfx/spacer.gif' height=9 width=9 id='leftmenuBullet_"+menuArr[i].id+"'>"+menuArr[i].title+"</td></tr>";
			}
			retStr += this.createSubMenu2(menuArr[i],0,retStr) + "</table>";
		}
	}

	divObj = document.createElement("DIV")			
	divObj.innerHTML = retStr;
	divObj.style.position="absolute";
	divObj.style.top=this.top;
	divObj.style.width=300; 
	divObj.style.display="block"
	divObj.id = "menuContainer_leftmenu_" + this.uId;
	document.body.appendChild(divObj)		
}


function __createSubMenu2(pObj,lvl,retStrt){
	var retStr="";
			var i, className="childmenu";
	if(pObj.childs.length>0){
			for(i=0;i<pObj.childs.length;i++){
				if(pObj.childs[i].childs.length<1){
					retStr += "<tr><td bgcolor='#FFFFFF' height=15 class='" + className + "' style='padding:0 0 0 15;' onclick='document.location=\"" + pObj.childs[i].url + "&mid="+document.mid+"&scid="+pObj.childs[i].id+"\"' onmouseOut='mainOut2(" + pObj.childs[i].id + ",this)' onmouseOver='mainOver2(" + pObj.childs[i].id + "," + pObj.id + ",this)' id='childMenuCell_"+pObj.childs[i].id+"'><img src='/gfx/spacer.gif' height=9 width=9 id='leftmenuBullet_"+pObj.childs[i].id+"'>" + pObj.childs[i].title + "</td></tr>"				
				}else{
					retStr += "<tr><td bgcolor='#FFFFFF' height=15 class='" + className + "' style='padding:0 0 0 15; cursor:default;' aonclick='document.location=\"" + pObj.childs[i].url + "\"' onmouseOut='mainOut2(" + pObj.childs[i].id + ",this)' onmouseOver='mainOver2(" + pObj.childs[i].id + "," + pObj.id + ",this)' id='childMenuCell_"+pObj.childs[i].id+"'><img src='/gfx/spacer.gif' height=9 width=9 id='leftmenuBullet_"+pObj.childs[i].id+"'>" + pObj.childs[i].title + "</td></tr>"				
				}
				retStr += this.createSubMenu2(pObj.childs[i],lvl+1,retStr)
			}
	}
	return retStr;
}


/*************************Functions for the display things ***************************************/
var menuTimer;

function mainOver(childId, ownId, obj,parentMenuName,fromTop){
	menuTimer?window.clearTimeout(menuTimer):null;
	bul = document.getElementById("bullet_" + childId);
	if(bul)
		bul.style.visibility="visible";
	
	
	childDivObj = document.getElementById("menuContainer_" + parentMenuName + "_" + childId);
	ownDivObj = document.getElementById("menuContainer_" + parentMenuName + "_" + ownId);
	ownTdObj = obj;
	
	if(ownDivObj){
		if(ownDivObj.showingDiv){
			if(ownDivObj.showingDiv!=childDivObj)
				hideShowingDivs(ownDivObj.showingDiv)
		}
	}

	ownTdObj.className += "Hover"
	
	if(fromTop){
		leftOffset = parseInt(ownDivObj.style.left) + parseInt(ownTdObj.offsetLeft)
		topOffset = parseInt(ownTdObj.offsetTop) + parseInt(ownDivObj.style.top)+30
	}else{
		leftOffset = parseInt(ownDivObj.style.left) + parseInt(ownTdObj.offsetWidth)+3
		topOffset = parseInt(ownTdObj.offsetTop) + parseInt(ownDivObj.style.top)	
	}
	
	if(childDivObj){		
		childDivObj.style.top=topOffset;
		childDivObj.style.left=leftOffset;
		childDivObj.style.visibility="visible";
		childDivObj.style.display = "block";
		ownDivObj.showingDiv=childDivObj;
	}
}

function mainOut(id, obj,parentMenuName){	
	var childDivObj = document.getElementById("menuContainer_" + parentMenuName + "_" + id);	
	obj.className=obj.className.toString().replace(/hover/gi,"")
	menuTimer = window.setTimeout('hideAllDivs()',500)
	
	bul = document.getElementById("bullet_" + id);
	if(bul && id != document.bulletId){
		bul.style.visibility="hidden";
	}
	
}


function mainOver2(childId, ownId, obj){
	var imgObj = document.getElementById("leftmenuBullet_" + childId)
	if(imgObj){
		imgObj.src="/gfx/icons/bullet2.gif"
	}
	obj.className += "Hover"
}
	

function mainOut2(id, obj){	
	var imgObj = document.getElementById("leftmenuBullet_" + id)
	
	if(imgObj && document.leftmenuBulletId!=id){
		imgObj.src="/gfx/spacer.gif"
	}
	obj.className=obj.className.toString().replace(/hover/gi,"")	;
	
}

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_leftmenu_2" && oDivs[i].id!="menuContainer_topmenu_1"){
				oDivs[i].style.visibility="hidden";
				oDivs[i].style.display="none";
			}
		}
	}
}

/*************************Functions for the display things ***************************************/

document.menuTimer=null;
document.showingEl=null;
document.activeMainMenu=null;
document.useFilter=4
document.effectTime=0.2
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,percent=11,Duration="+document.effectTime+")"
document.filt[5] = "progid:DXImageTransform.Microsoft.Checkerboard(Direction=right,SquaresX=50,SquaresY=50)"
document.filt[6] = "progid:DXImageTransform.Microsoft.Iris(irisstyle=circle,motion=in)"
document.filt[7] = "progid:DXImageTransform.Microsoft.Stretch(stretchstyle=SPIN)"
document.filt[8] = "progid:DXImageTransform.Microsoft.Opacity(opacity=10,style=0)"




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)
	}
}	
