var d = document;

function subNav(l){
		var mLi = l.parentNode.getElementsByTagName("LI");
		var tD = null;
		if (document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand)   
        document.execCommand('BackgroundImageCache', false, true);	
		for(var p = 0; p < mLi.length; p++){
			if(l.parentNode.parentNode.getAttribute("subLevelIn") == "subLevelIn"){
				return false;
			}
			if(mLi[p].className == "actSubNav" && mLi[p].parentNode == l.parentNode){
				var tD = mLi[p];
			}
		};
		


		if(l.className == "subLevel"){			

			l.setAttribute("subLevelIn", "subLevelIn");

			if(tD != null){				
				var LIold = tD.getElementsByTagName("UL");
				for(var n = 0; n < LIold.length; n++){
					if(LIold[n].className == "subList" && LIold[n].parentNode.parentNode == tD.parentNode){
						var ULold = LIold[n];					
					};
				};
				var LInew = l.getElementsByTagName("UL");
				for(var e = 0; e < LInew.length; e++){
					if(LInew[e].className == "subList" && LInew[e].parentNode.parentNode == tD.parentNode){
						var ULnew = LInew[e];					
					}
				}
				tD.className = "subPenLevel";
				l.className = "actSubNav";				
				var hh = ULnew.offsetHeight;
				ULnew.style.height = 0; 
				if(hh >= ULold.offsetHeight){
					var HT = ULold.offsetHeight;
				}else{
					var HT = hh;
				}
				window.tMoveOp = setTimeout(function(){moveOpenNew(ULnew,1,hh,ULold,ULold.offsetHeight,HT)},25);
			}else{
				var ULLs = l.getElementsByTagName("UL");
				for(var e = 0; e < ULLs.length; e++){
					if(ULLs[e].className == "subList" && ULLs[e].parentNode.parentNode == l.parentNode){
						var Ullka = ULLs[e];						
					};
				};				
				l.className = "actSubNav";		
				var hh = Ullka.offsetHeight;			
				Ullka.style.height = 0;
				window.tMoveOp = setTimeout(function(){moveOpen(Ullka,1,hh)},25);
			}
		}
}


function moveClose(oldL,oldLH){	
	if(oldLH > 10){
		var nH = oldLH - 10;
		oldL.style.height = nH + "px";
		setTimeout(function(){moveClose(oldL,nH)},25)
	}else if(oldLH >= 1){		
		var nH = oldLH - 1;
		oldL.style.height = nH + "px";
		setTimeout(function(){moveClose(oldL,nH)},25)		
	}else{
		clearTimeout(window.hMenu);
		window.anchorCl = false;
		oldL.parentNode.className = "subLevel";
		oldL.style.height = "auto";	
		var sLIs = oldL.getElementsByTagName("LI");
		for(var e = 0; e < sLIs.length; e++){
			if(sLIs[e].className == "actSubNav"){
				sLIs[e].className = "subLevel"						
			};
		};		
	}
}


function moveOpen(oldL,oldLH,hh){
	if(oldLH < hh - 10){
		var nH = oldLH + 10;
		oldL.style.height = nH + "px";
		setTimeout(function(){moveOpen(oldL,nH,hh)},25)
	}else if(oldLH <= hh){
		var nH = oldLH + 1;
		oldL.style.height = nH + "px";
		setTimeout(function(){moveOpen(oldL,nH,hh)},25)		
	}else{		
		oldL.style.height = "auto";	
		oldL.parentNode.setAttribute("subLevelIn", "false");
	}
}

function moveOpenNew(oldL,oldLH,hh,s,sH,HT){
	if(hh > HT){
		if(sH > 9){
			var nH = oldLH + 10;
			var nM = sH - 10;
			oldL.style.height = nH + "px";
			s.style.height = nM + "px";
			setTimeout(function(){moveOpenNew(oldL,nH,hh,s,nM,HT)},25)
		}else{
			s.parentNode.className = "subLevel";
			s.style.height = "auto";			
			setTimeout(function(){moveOpen(oldL,oldLH,hh)},25)	
		}
	}else{
		if(oldLH < hh && sH - 10 > 0){
			var nH = oldLH + 10;
			var nM = sH - 10;
			oldL.style.height = nH + "px";
			s.style.height = nM + "px";			
			setTimeout(function(){moveOpenNew(oldL,nH,hh,s,nM,HT)},25);						
		}else{			
			oldL.style.height = "auto";
			oldL.parentNode.setAttribute("subLevelIn", "false");
			setTimeout(function(){moveClose(s,sH)},25);
		};
	}
	
}

function hideNav(mmU,event){
		//if(window.hMenu){alert(1)};
	var mU = d.getElementById(mmU);
	var LInew = mU.getElementsByTagName("UL");
	var mD = d.getElementById('precenter');
	var mmD = d.getElementById('floating');
	var mT = mmD.offsetTop + mD.offsetTop;
	var mL = mD.offsetLeft;
	var mW = mU.offsetWidth;
	var mH = mU.offsetHeight;
	x = event.clientX;
	y = event.clientY;
	if(x > mL && x < (mL + mW + 5) && y > mT && y < (mT + mH + 5)){		
		return false;
	}else{
		for(var e = 0; e < LInew.length; e++){
			window.anchorCl;
			if(LInew[e].parentNode.parentNode == mU && LInew[e].parentNode.className == "actSubNav" && window.anchorCl != true){
					window.anchorCl = true;
					var LaL = LInew[e];
					window.hMenu = setTimeout(function(){moveClose(LaL,LaL.offsetHeight)},1000);					
			}
		};
	}
}

/*function clsNav(l){
	var mULb = l.parentNode;
	var aULs = 	mULb.getElementsByTagName("UL");
	for(var e = 0; e < aULs.length; e++){
		if(aULs[e].parentNode.parentNode == mULb && aULs[e].parentNode.className == "actSubNav"){
				var ULcl = aULs[e];
				setTimeout(function(){moveClose(ULcl,ULcl.offsetHeight)},1000);					
		}
	};
}*/