// slideDiv.js

function slideTimeout(ID) {
	//setTimeout("slideAutoClose('"+ID+"')",500);
}
function slideAutoClose(ID) {
	
	if (ID != activeSubMenu) {	
		slideDiv(ID,true);
	}
}

function slideDiv(toSlide,closeAll) {
	
	if (activeSubMenu != null) {
		
		if (document.getElementById(activeSubMenu).style.width) {
			varWd = parseInt(document.getElementById(activeSubMenu).style.width);
		} else {
			content = document.getElementById(activeSubMenu).innerHTML;
			content = '<html><head><link rel="stylesheet" href="../../layout.css" /></head><body>'+content+'</body></html>';
			WriteByID('wTester',null,content);
			varWd = parseInt(document.getElementById('wTester').offsetWidth);
		}
		slider(activeSubMenu,0,varWd,1);
		var timeOut = varWd + 250;
		setTimeout("slideDiv('"+toSlide+"','"+closeAll+"')",timeOut);
		activeSubMenu = null;
		
	} else {
	
		toSlideArr = toSlide.split("|");
		for (i=0; i<toSlideArr.length; i++) {
			if (toSlideArr[i] != activeSubMenu) {
				varWd = 0;
				content = document.getElementById(toSlideArr[i]).innerHTML;
				
				content = '<html><head><link rel="stylesheet" href="../../layout.css" /></head><body>'+content+'</body></html>';
				WriteByID('wTester',null,content);
				Wd = parseInt(document.getElementById('wTester').offsetWidth);
				if (parseInt(document.getElementById(toSlideArr[i]).style.width) > 0 || (closeAll == true && closeAll != null)) {
					/*y = 1;
					Wd = 0;
					varWd = parseInt(document.getElementById(toSlideArr[i]).style.width);*/
				} else {
					y = 0;
					document.getElementById(toSlideArr[i]).style.visibility = "visible";
					activeSubMenu = toSlideArr[i];
					slider(toSlideArr[i],Wd,varWd,y);
				}
			}
		}
	}
}



function slider(Hide,Wd,varWd,y) {
	
	var x = 10;
	var z = 10;
	if (y != 1) {
		document.getElementById(Hide).style.width = varWd+'px';
		if (((parseInt(Wd)-parseInt(varWd)) < z) && (parseInt(varWd) !== parseInt(Wd))) {
			varWd = Wd;
		} else {
			varWd = parseInt(varWd)+parseInt(z);
		}
		if (varWd <= Wd) {
			setTimeout("slider('"+Hide+"','"+Wd+"','"+varWd+"','"+y+"')",z);
		}
		if (varWd > Wd) {
			varWd = Wd;
		}
	} else {
		document.getElementById(Hide).style.width = varWd+'px';
		if (parseInt(varWd) >= parseInt(z)) {
			varWd = parseInt(varWd)-parseInt(z);
			setTimeout("slider('"+Hide+"','"+Wd+"','"+varWd+"','"+y+"')",z);
		} else {
			document.getElementById(Hide).style.width = '0px';
			document.getElementById(Hide).style.visibility = "hidden";
		}
	}
}

