// JavaScript Document

function showSide(id) {
	var obj = document.getElementById(id);
	
	
	
	if (obj.style.display == "block") {
		fadeDropOutSide(id);
		
		var header = document.getElementById(id+"_header");
		header.className = "side_nav";
	}
	else {
		obj.style.filter = "alpha(opacity=0)";	
		obj.style.opacity = "0.0";
		obj.style.overflow = "hidden";
		obj.style.height = "0px";		
		obj.style.display = "block";
		
		var header = document.getElementById(id+"_header");
		header.className = "side_nav_over";
		
		var height = 0;
		
		if (obj.childNodes && obj.childNodes.length > 0) {
        	for (var x = 0; x < obj.childNodes.length; x++) {
            	if (obj.childNodes[x].offsetHeight > 1 && obj.childNodes[x].offsetHeight != null) {
					if(height == 0) {
					   height = obj.childNodes[x].offsetHeight;
					}
					else {
						if (obj.childNodes[x].style.cssFloat != "left") {
							height += obj.childNodes[x].offsetHeight;
						}
					}
				}
            }
		}
		else {
			// nothing exists in the drop	
		}
		
		slideDropOutSide(id, height);
	}
}


function slideDropOutSide(id, height) {
	var obj = document.getElementById(id);
	var current = parseInt(obj.style.height.replace("px", ""));
	if (current < height) {
		var step = 20;
		
		if (current + step > height) {
			current = height;	
		}
		else {
			current += step;
		}
		obj.style.height = current+"px";
		
		setTimeout("slideDropOutSide('"+id+"', "+height+")", 20);
	}
	else {
		fadeDropInSide(id);	
	}
}

function fadeDropInSide(id) {
	var obj = document.getElementById(id);
	var current = (obj.style.opacity*100);
	
	if (current < 100) {
		var step = 10;
		
		if (current+step > 100) {
			current = 100;	
		}
		else {
			current += step;	
		}
		
		obj.style.opacity = current/100;
		obj.style.filter = "alpha(opacity="+current+")";
		
		setTimeout("fadeDropInSide('"+id+"')", 20);
		
	}
	else {
		//done	
	}
	
}

function fadeDropOutSide(id) {
	var obj = document.getElementById(id);
	var current = (obj.style.opacity*100);
	
	if (current > 0) {
		var step = 10;
		
		if (current-step < 0) {
			current = 0;	
		}
		else {
			current -= step;	
		}
		
		obj.style.opacity = current/100;
		obj.style.filter = "alpha(opacity="+current+")";
		
		setTimeout("fadeDropOutSide('"+id+"')", 20);
		
	}
	else {
		slideDropInSide(id);	
	}
	
}

function slideDropInSide(id) {
	var obj = document.getElementById(id);
	var current = parseInt(obj.style.height.replace("px", ""));
	if (current > 0) {
		var step = 20;
		
		if (current - step < 0) {
			current = 0;	
		}
		else {
			current -= step;
		}
		obj.style.height = current+"px";
		
		setTimeout("slideDropInSide('"+id+"')", 20);
	}
	else {
		document.getElementById(id).style.display = "none";
	}
}
