var GrowTimer;

function OpenMenuJs(LiElement){
	var ObjParent = LiElement.parentNode;
	var ParentFound = false;

	while(ObjParent && !ParentFound){
		if(ObjParent.nodeName.toUpperCase() == 'DIV'){ParentFound = true;}
		else{ObjParent = ObjParent.parentNode;}
	}
	
	var LIS = ObjParent.getElementsByTagName("LI");
	for(var i=0;i<LIS.length;i++){
		if(LIS[i] != LiElement){LIS[i].className = "LiHidden";LIS[i].AutoOpened = false;}
	}

	LiElement.className = "LiVisible";
	
	var ULChild = LiElement.childNodes;
	
	for(var i=0; i<ULChild.length; i++){
		if(ULChild[i].nodeName.toUpperCase() == 'UL' && LiElement.AutoOpened != true){
			var UL_OroginalHeight = ULChild[i].offsetHeight;
			ULChild[i].style.height = "1px";
			ULChild[i].style.overflow = "hidden";
			GrowTimer = setInterval(function(){GrowUL(ULChild[i],UL_OroginalHeight);},40);
			break;
		}
	}
	LiElement.AutoOpened = true;
}

function GrowUL(ULObj, MaxHeight){
	var ActHeight = ULObj.offsetHeight;
	if(ActHeight < (MaxHeight - 5)){ULObj.style.height = (ActHeight + ((MaxHeight - ActHeight)/8)) + "px";}
	else{ULObj.style.height = MaxHeight + "px"; clearInterval(GrowTimer);}
}

function OpenAllSelectedParents(MenuID){
	
	var MenuUL = document.getElementById(MenuID);
	if(MenuUL){
		var A_Array = MenuUL.getElementsByTagName("A");
		var ASelectedObj = null;
		for(var i=0; i<A_Array.length; i++){if(A_Array[i].className == 'selected'){ASelectedObj = A_Array[i];break;}}

		if(ASelectedObj){
			var ParentFound = false;
			var ObjParent = ASelectedObj.parentNode;

			while(ObjParent && ObjParent.id != MenuID){
				if(ObjParent.nodeName.toUpperCase() == 'LI'){
					ObjParent.className = 'LiVisible';
					ObjParent.AutoOpened = true;
				}
				ObjParent = ObjParent.parentNode;
			}
		}
	}
}
