var strActiveMPID = "";
function SetMPHoverOn(strMPID){
	objMPElem = document.getElementById(strMPID+"_img");
	if(objMPElem && strMPID != strActiveMPID){
		objMPElem.style.visibility = "visible";
	}
}
function SetMPHoverOut(strMPID){
	objMPElem = document.getElementById(strMPID+"_img");
	if(objMPElem && strMPID != strActiveMPID){
		//objMPElem.style.visibility = "hidden";
	}
}

function CreateMenu(arMenu){
	var strMenu = "";
	var MenuContainerID = "idMenuContainer";
	
	//alert("T: ");
	
	strMenu += "<table cellpadding=0 cellspacing=0 class=\"menu\">";
	//strMenu += "";
	
	intFullWidth = 1000;
	intDivWidth = intFullWidth/arMenu.length;
	for(i=0;i<arMenu.length;i++){
		boolMenuActive = false;
		boolMenuActiveSub = false;
		strActiveColor = "#de0c15";
		strStandardColor = "#444444";
		strInactiveColor = "#CCCCCC";
		strActiveWeight = "bold";
		strStandardWeight = "bold";
		strStandardBgrnd = "#FFFFFF";
		strActiveBgrnd = "#01418a";
		strPaddingStyle = "padding:4px 3px 4px 0px;";
		strStandardBgrnd1 = "#BBBBBB";
		strActiveBgrnd1 = "#de0c15";
		
		if(arMenu[i][1] != ""){
			
			// aktiver Menuepunkt
			if(arMenu[i][2] == arMenuData[0]){
				boolMenuActive = true;
			}
			if(arMenu[i][5] && arMenu[i][5].length > 0){
				for(j=0;j<arMenu[i][5].length;j++){
					strSubMenuPageRequestString = arMenuData[1];
					if(arMenu[i][5][j][4] == arMenuData[0] && arMenu[i][5][j][5] == strSubMenuPageRequestString){
						boolMenuActiveSub = true;
					}
				}
			}
						
			/*
			// Active SubSubMenu
			if(arMenu[i][0] == "2"){
				for(m=1;m<=arSubSubMenu[0][1].length;m++){
					if(arSubSubMenu[0][1][m]){
						if(arSubSubMenu[0][1][m][2] && arSubSubMenu[0][1][m][2] == arMenuData[0]){
							boolMenuActiveSub = true;
						}
					}
				}
			}
			// Active SubSubPages
			if(arMenu[i][0] == "31"){
				for(n=1;n<arSubSubMenu[1][1].length;n++){
					if(arSubSubMenu[1][1][n]){
						if(arSubSubMenu[1][1][n][2] && arSubSubMenu[1][1][n][2] == arMenuData[0]){
							boolMenuActiveSub = true;
						}
					}
				}
			}
			*/	
			
			if(arMenu[i][2] == "" || arMenu[i][2] == 0){
				strStandardColor = strInactiveColor;
			}
			strLeftItemHTML = "<img id=\"MenuID_"+arMenu[i][0]+"_img\" src=\"img/menu_item_arrow_r_inactive.gif\">";
			if(boolMenuActive || boolMenuActiveSub){
				strStandardColor = strActiveColor;
				strStandardWeight = strActiveWeight;
				strStandardBgrnd = "";
				strStandardBgrnd1 = "";
				strLeftItemHTML = "<img id=\"MenuID_"+arMenu[i][0]+"_img\" src=\"img/menu_item_arrow_r_active.gif\">";
				strActiveMPID = "MenuID_"+arMenu[i][0];
			}

			if(i==0){
				strSpacerLineStyle = "height:2px;background-image:url(img/menu_item_border.gif);background-repeat:no-repeat;background-position:center top;";
			}
			else{
				strSpacerLineStyle = "height:2px;background-image:url(img/menu_item_border.gif);background-repeat:no-repeat;background-position:center center;";
			}
			strMenu += "<tr><td colspan=\"2\" style=\""+strSpacerLineStyle+"font-size:1px;\">&nbsp;</td></tr>";
			strMenu += "<tr>";
			strMenu += "<td style=\"width:28px;text-align:center;vertical-align:middle;\">"+strLeftItemHTML+"</td>";
			strMenu += "<td onmouseover=\"SetMPHoverOn(this.id)\" onmouseout=\"SetMPHoverOut(this.id)\" id=\"MenuID_"+arMenu[i][0]+"\"";
			strMenu += " class=\"menu_item\"";
			strMenu += " style=\"color:"+strStandardColor+";"+strPaddingStyle+"\"";
			
			if(arMenu[i][5] && arMenu[i][5].length > 0){
				strMenu += " onmouseover=\"ShowSubMenu("+arMenu[i][0]+");\" onmouseout=\"StartSubMenuTimer();\"";
			}
			else{
				strMenu += " onmouseover=\"ShowSubMenu(0);\"";
			}
			strMenu += ">";
			strMenu += "<div id=\"SubMenuID_"+arMenu[i][0]+"\" style=\"position:absolute;z-index:10000;margin-top:15px;margin-left:-15px;width:144px;overflow:visible;\"></div>";
			
			if(arMenu[i][3] != "" && arMenu[i][4] != ""){
				strMenuPageString = arMenu[i][3] +"&"+ arMenu[i][4];
			}
			else{
				strMenuPageString = arMenu[i][3];
			}
			if(strMenuPageString != ""){
				strMenu += "<a href=\""+strMenuPageString+"\" style=\"font-weight:"+strStandardWeight+";color:"+strStandardColor+";\">"+arMenu[i][1]+"</a>";
			}
			else{
				strMenu += arMenu[i][1];
			}
			strMenu += "</td>";
			
			if(i==arMenu.length-1){
				strSpacerLineStyle = "height:2px;background-image:url(img/menu_item_border.gif);background-repeat:no-repeat;background-position:center bottom;";
				strMenu += "<tr><td colspan=\"2\" style=\""+strSpacerLineStyle+"font-size:1px;\">&nbsp;</td></tr>";
			}
			
			strMenu += "</tr>";
		}
	}
	//strMenu += "";
	strMenu += "</table>";
	
	if(strMenu != ""){
		document.getElementById(MenuContainerID).innerHTML = strMenu;
		document.getElementById(MenuContainerID).style.visibility = "visible";
	}
	
	// MAC Erkennung und MP Positionierung
	strPlatformSearchString = navigator.appVersion;
	arPlatform = strPlatformSearchString.match(/mac/gi);
	
	/*
	for(MId=1;MId<8;MId++){
		if(arPlatform && arPlatform.length > 0){
			// MAC
			if(MId == 1){
				document.getElementById("MenuID_"+MId).style.padding = "0px 0px 0px 0px";
			}
			else if(MId == 7){
				document.getElementById("MenuID_"+MId).style.padding = "0px 0px 0px 0px";
			}
			else{
				document.getElementById("MenuID_"+MId).style.padding = "0px 0px 0px 0px";
			}
		}
		else{
			// SONSTIGES
			if(MId == 1){
				document.getElementById("MenuID_"+MId).style.padding = "0px 0px 0px 0px";
			}
			else if(MId == 7){
				document.getElementById("MenuID_"+MId).style.padding = "0px 0px 0px 0px";
			}
			else{
				document.getElementById("MenuID_"+MId).style.padding = "0px 0px 0px 0px";
			}
		}
	}
	*/
}


var ActiveSubMenu = "";
var SubMenuTimer = false;

function ShowSubMenu(strMenuID){
	//alert("terst "+strMenuID);
	StopSubMenuTimer();
	if(ActiveSubMenu != "" && ActiveSubMenu !=strMenuID){
		HideSubMenu();
	}
	if(strMenuID != "" && strMenuID > 0 && ActiveSubMenu == ""){
		CreateSubMenu(strMenuID);
		ActiveSubMenu = strMenuID;
	}
}
function StartSubMenuTimer(){
	if(!SubMenuTimer){
		SubMenuTimer = window.setInterval("HideSubMenu()",500);
	}
}
function StopSubMenuTimer(){
	if(SubMenuTimer){
		window.clearInterval(SubMenuTimer);
		SubMenuTimer = false;
	}
}

function HideSubMenu(){
	if(ActiveSubMenu != ""){
		strHideMenuID = "SubMenuID_"+ActiveSubMenu;
		document.getElementById(strHideMenuID).innerHTML = "";
		document.getElementById(strHideMenuID).style.visibility = "hidden";
		ActiveSubMenu = "";
		// SubSubMenu
		strActiveSubSubMenu = "";
	}
}

function CreateSubMenu(intMenuID){
	var	SubMenuList = "";
	var intActiveMenuID = 0;
	
	for(i=0;i<arMenu.length;i++){
		if(arMenu[i][0] == intMenuID){
			intActiveMenuID = i;
		}
	}
	
	if(intActiveMenuID > 0){
		SubMenuList += "<div class=\"menu_sub\">";
		SubMenuList += "<div class=\"menu_subitem_top\">&nbsp;</div>";
		
		if(arMenu[intActiveMenuID][5]){
			for(j=0;j<arMenu[intActiveMenuID][5].length;j++){
				boolSubMenuActive = false;
				strActiveColor = "#FFFFFF";
				strStandardColor = "#c2b6ac";
				strInactiveColor = "#615246";
				
				if(arMenu[intActiveMenuID][5][j][4] == arMenuData[0]){
					boolSubMenuActive = true;
				}
				if(boolSubMenuActive && arMenu[intActiveMenuID][5][j][5] != ""){
					strMenuPageRequestString = arMenuData[1];
					if(arMenu[intActiveMenuID][5][j][5] == strMenuPageRequestString){
						boolSubMenuActive = true;
					}
					else{
						boolSubMenuActive = false;
					}
				}
				
				/*
				// Active SubSubMenu
				if(arMenu[intActiveMenuID][5][j][0] == "8"){
					for(m=0;m<arSubSubMenu[0][1].length;m++){
						if(arSubSubMenu[0][1][m]){
							if(arSubSubMenu[0][1][m][2] == arMenuData[0]){
								boolSubMenuActive = true;
							}
						}
					}
				}
				*/
				
				if(arMenu[intActiveMenuID][5][j][5] != ""){
					strMenuPageString = arMenu[intActiveMenuID][5][j][2] +"&"+ arMenu[intActiveMenuID][5][j][5];
				}
				else{
					strMenuPageString = arMenu[intActiveMenuID][5][j][2];
				}
	
				SubMenuList += "<div";
				SubMenuList += " class=\"menu_subitem_default\"";
	
				if(arMenu[intActiveMenuID][5][j][4] == "" || arMenu[intActiveMenuID][5][j][4] == 0){
					strStandardColor = strInactiveColor;
				}
				if(boolSubMenuActive){
					strStandardColor = strActiveColor;
					SubMenuList += " style=\"color:"+strActiveColor+";\"";
				}
				if(arMenu[intActiveMenuID][5][j][2] != ""){
					SubMenuList += " onclick=\"document.location.href='" + strMenuPageString + "';\"";
				}
				SubMenuList += " onmouseover=\"ShowSubSubMenu("+arMenu[intActiveMenuID][5][j][0]+");this.style.textDecoration='underline';this.style.color='"+strActiveColor+"';\"";
				SubMenuList += " onmouseout=\"StartSubMenuTimer();this.style.textDecoration='none';this.style.color='"+strStandardColor+"';\"";
				
				SubMenuList += ">";
				SubMenuList += arMenu[intActiveMenuID][5][j][1];
				SubMenuList += "</div>";
				SubMenuList += "<div id=\"SubSubMenuID_"+arMenu[intActiveMenuID][5][j][0]+"\" style=\"position:absolute;z-index:10000;margin-top:-30px;margin-left:128px;width:144px;overflow:visible;\"></div>";
			}
		}
		SubMenuList += "<div class=\"menu_subitem_bottom\">&nbsp;</div>";
		SubMenuList += "</div>";
	}
	if(SubMenuList != ""){
		strParentMenuID = "SubMenuID_"+arMenu[intActiveMenuID][0];
		document.getElementById(strParentMenuID).innerHTML = SubMenuList;
		document.getElementById(strParentMenuID).style.visibility = "visible";
	}
}

var arSubSubMenu = new Array();
var strActiveSubSubMenu = "";

function ShowSubSubMenu(strMenuID){
	if(strActiveSubSubMenu != ""){
		document.getElementById(strActiveSubSubMenu).innerHTML = "";
		strActiveSubSubMenu = "";
	}
	if(strMenuID == 8 || strMenuID == 31){
		SubSubMenuList = "";
		SubSubMenuList += "<div class=\"menu_sub\">";
		SubSubMenuList += "<div class=\"menu_subsubitem_top\">&nbsp;</div>";
		
		intMenuArID = 0;
		for(h=0;h<arSubSubMenu.length;h++){
			if(arSubSubMenu[h][0][0] == strMenuID){
				intMenuArID = h;
			}
		}
		
		for(i=0;i<arSubSubMenu[intMenuArID][1].length;i++){
			
			boolSubMenuActive = false;
			strActiveColor = "#555555";
			strStandardColor = "#a29489";
			
			SubSubMenuList += "<div";
			SubSubMenuList += " class=\"menu_subitem_default\"";
			
			if(arSubSubMenu[intMenuArID][1][i][2] == arMenuData[0]){
				boolSubMenuActive = true;
			}
			if(boolSubMenuActive){
				strStandardColor = strActiveColor;
				SubSubMenuList += " style=\"color:"+strActiveColor+";\"";
			}
			SubSubMenuList += " onmouseover=\"this.style.textDecoration='underline';this.style.color='"+strActiveColor+"';\"";
			SubSubMenuList += " onmouseout=\"this.style.textDecoration='none';this.style.color='"+strStandardColor+"';\"";
			SubSubMenuList += " onclick=\"document.location.href='index.php?PageID="+arSubSubMenu[intMenuArID][1][i][2]+"'\"";
			SubSubMenuList += ">";
			SubSubMenuList += arSubSubMenu[intMenuArID][1][i][1];
			SubSubMenuList += "</div>";
		}
		
		SubSubMenuList += "<div class=\"menu_subitem_bottom\">&nbsp;</div>";
		SubSubMenuList += "</div>";
		strSubSubMenu = "SubSubMenuID_"+strMenuID;
		document.getElementById(strSubSubMenu).innerHTML = SubSubMenuList;
		strActiveSubSubMenu = strSubSubMenu;
	}
}

