var MenuHTML = new Array();
var PopularPagesIndex;



function ShowNavMenu(Btn, Trip) {
	var Mn = document.getElementById(Btn.id.replace('Btn', 'Mn'));
	var MnC = document.getElementById(Btn.id.replace('Btn', 'MnC'));

	if (Mn==null || MnC==null) return;

	HideNavMenus();

	if (Trip!=true) {
		eval("setTimeout(\"ShowNavMenu(document.getElementById('"+Btn.id+"'), true)\", 50);");
		return;
	}

	if (Mn.className=='MnAct') return;
	else if (Mn.className=='MnInA') {
		with (Mn.style) {
			if (BIsIE) Btn.className.indexOf("Level1")!=-1?top=22:top=53;
			else Btn.className.indexOf("Level1")!=-1?top=16:top=47;
			left = BIsIE?Btn.parentElement.offsetLeft:Btn.parentNode.offsetLeft;
			height = MnC.offsetHeight+8;
			width = MnC.offsetWidth+4;
			paddingTop = 6;
		}

		if (BIsIE && BVer>=6 && !BIsMaccak) {
			for (i=4; i>0 && Mn.children.length<=4; i--) {
				var SdDv = document.createElement('div');
				var SdO = ("50,37,20,7").split(',');

				with (SdDv.style) {
					position = 'absolute';
					left = i;
					top = i+6;
					width = MnC.offsetWidth;
					height = MnC.offsetHeight;
					zIndex = MnC.style.zIndex-i;
					backgroundColor = '#666666';
					filter = 'alpha(opacity='+SdO[i-1]+')';
				}

				Mn.insertAdjacentElement('afterBegin', SdDv);
			}

			Mn.style.filter = 'blendTrans(duration=0.3)';
			MnC.style.filter = 'blendTrans(duration=0.3)';	
			Mn.filters[0].Apply();
			MnC.filters[0].Apply();
		}

		Mn.style.visibility = '';
		MnC.style.visibility = '';

		if (BIsIE && BVer>=6 && !BIsMaccak) {
			Mn.filters[0].Play();
			MnC.filters[0].Play();
		}

		Mn.className = 'MnAct';
	}
}



function HideNavMenus() {
	for (i=0; i<NavItems.length; i++) {
		if (NavItems[i][1]==-1 && document.getElementById("Menu"+NavItems[i][0]+"Mn")!=null) {
			var Btn = document.getElementById("Menu"+NavItems[i][0]+"Btn");

			with (document.getElementById("Menu"+NavItems[i][0]+"Mn")) {
				style.visibility = 'hidden';
				className = 'MnInA';
			}
		}
	}
}



function DrawNavbar() {
	var NavBarHTML = "";
	var BaseID = -9;
	var SharedID = -9;

	for (i=0; i<NavItems.length; i++) {
		if (NavItems[i][2].toUpperCase()==BaseNavItemSelectorText.toUpperCase()) BaseID=NavItems[i][0];
		if (NavItems[i][2].toUpperCase()==SharedNavItemSelectorText.toUpperCase()) SharedID=NavItems[i][0];
	}

	for (i=0; i<NavItems.length; i++) {
		var NI = NavItems[i];

		if (NI[1]==BaseID || NI[1]==SharedID) {
			NavBarHTML+="<td><a id=Menu"+NI[0]+"Btn href='"+NI[4]+"' onmouseover=this.parentElement.style.backgroundColor='#D0DEF0';ShowNavMenu(this);event.cancelBubble=true onmouseout=this.parentElement.style.backgroundColor='' class=NavMenu>&nbsp;&nbsp;&nbsp;&nbsp;"+NI[2]+"&nbsp;&nbsp;&nbsp;&nbsp;</a></td><td width=1 bgcolor=#999999><img src=\""+ClientTemplatePath+"\"trans.gif height=1 width=1 border=0></td>";

			for (a=0; a<NavItems.length; a++) {
				NA = NavItems[a];

				if (NA[1]==NI[0]) {
					if (MenuHTML[NI[0]]==null) MenuHTML[NI[0]]="";

					if (NA[5] == '_blank') {
						var click = "window.open('"+NA[4]+"','wname','')";
					} else {
						var click = "location.href='"+NA[4]+"'";
					}

					MenuHTML[NI[0]]+="<div style='"+(BIsIE?"width:100%":"width:132")+";padding:3 8 3 5;cursor:pointer' onclick="+click+" onmouseover=this.style.backgroundColor='#363B90' onmouseout=this.style.backgroundColor='' class=NavMenu>"+NA[2]+"</div>";
				}
			}
		}
	}

	NavBarHTML = "<table height=26 cellspacing=0 cellpadding=0 border=0>"+NavBarHTML+"</table>";

	for (i=0; i<NavItems.length; i++) {
		if (NavItems[i][1]==-1 && MenuHTML[NavItems[i][0]]!=null) {
			NavBarHTML+="<div id=Menu"+NavItems[i][0]+"Mn style='position:absolute;z-index:9;visibility:hidden' onmouseover=event.cancelBubble=true class=MnInA>";
				NavBarHTML+="<div id=Menu"+NavItems[i][0]+"MnC style='width:150;padding:4 4 4 3;background-color:#2B3086"+(BVer<6?";border:solid 2px #363B90":"")+"'>"+MenuHTML[NavItems[i][0]]+"</div>";
			NavBarHTML+="</div>";
		}
	}

	document.write("<div style=position:absolute;top:71;z-index:9>"+NavBarHTML+"</div>");
	document.onmouseover = HideNavMenus;
}



DrawNavbar();
