function OpenMenu(elem,startHeight,endHeight,steps,intervals,nestedElem) {
	document.getElementById(elem).style.display = 'block';
	if (widthChangeMemInt) clearInterval(widthChangeMemInt);
	if (NwidthChangeMemInt) clearInterval(NwidthChangeMemInt);
	var actStep = 0;
	var NactStep = 0;
	
	if (nestedElem != 0) {
		var NestedHeight = parseInt(document.getElementById(nestedElem).style.height.substring(0, document.getElementById(nestedElem).style.height.indexOf('px')));
	}
	if (parseInt(document.getElementById(elem).style.height.substring(0, document.getElementById(elem).style.height.indexOf('px'))) > 1) {
		startHeight = parseInt(document.getElementById(elem).style.height.substring(0, document.getElementById(elem).style.height.indexOf('px')));
		endHeight = 0;
	}
	
	if (elem.substring(0, 7) == 'SubMenu') { 
		var myScan = 0;
		var divs = document.getElementsByTagName('div');
		for (var x=0; x<divs.length; x++) {
			var myMenuLoc = divs[x];
			if (parseInt(myMenuLoc.style.height.substring(0, myMenuLoc.style.height.indexOf('px'))) > 1) {
				if (myMenuLoc.className == 'SubHiddenDiv') {
					if (myMenuLoc != document.getElementById(elem)) {
						var myScan = myMenuLoc;
						var CloseStartHeight = parseInt(myMenuLoc.style.height.substring(0, myMenuLoc.style.height.indexOf('px')));
						var CloseEndHeight = 0;
					}
				}
			}
		}
		
		if (myScan != 0) {
			var NwidthChangeMemInt = setInterval(
				function() {
					var delta = CloseEndHeight - CloseStartHeight;
					var stepp = Math.ceil(CloseStartHeight+((delta/steps)*actStep));
					myScan.style.height = stepp+"px";
					if (nestedElem != 0) {
						var Nstepp = Math.ceil(NestedHeight+((delta/steps)*actStep));
						document.getElementById(nestedElem).style.height = Nstepp+"px";
					}
					actStep++;
					if (actStep > steps) { 
						clearInterval(NwidthChangeMemInt);
						if(navigator.product=='Gecko') {
		 					redrawContent(-1);
							redrawContent(1);							
						}
						OpenMenu(elem,startHeight,endHeight,steps,intervals,nestedElem);
					}
				}
			,intervals)
		} else {
			var NwidthChangeMemInt = setInterval(
				function() {
					var delta = endHeight - startHeight;
					var stepp = Math.ceil(startHeight+((delta/steps)*actStep));
					document.getElementById(elem).style.height = stepp+"px";
					if (nestedElem != 0) {
						var Nstepp = Math.ceil(NestedHeight+((delta/steps)*actStep));
						document.getElementById(nestedElem).style.height = Nstepp+"px";
					}
					actStep++;
					if (actStep > steps) { 
						clearInterval(NwidthChangeMemInt);
						if(navigator.product=='Gecko') {
		 					redrawContent(-1);
							redrawContent(1);
						}
					}
				}
			,intervals)	
		}
	
	} else {
	
		var widthChangeMemInt = setInterval(
			function() {
				var delta = endHeight - startHeight;
				var stepp = Math.ceil(startHeight+((delta/steps)*actStep));
				document.getElementById(elem).style.height = stepp+"px";
				if (nestedElem != 0) {
					var Nstepp = Math.ceil(NestedHeight+((delta/steps)*actStep));
					document.getElementById(nestedElem).style.height = Nstepp+"px";
				}
				actStep++;
				if (actStep > steps) { 
					clearInterval(widthChangeMemInt);
					if (nestedElem != 0) {
						var myClickHeight = parseInt(document.getElementById(nestedElem).style.height.substring(0, document.getElementById(nestedElem).style.height.indexOf('px')));
						document.getElementById(nestedElem+'_open').onclick = function() { OpenMenu(nestedElem,0,myClickHeight,steps,intervals,0); }
					}
					if(navigator.product=='Gecko') {
	 					redrawContent(-1);
						redrawContent(1);
					}
				}
			}
		,intervals)
	}
}

function redrawContent(height) {
	var contentHeight=document.getElementById('SubMenu2').offsetHeight;
    document.getElementById('SubMenu2').style.height = contentHeight-height+'px';
    return;
}
