// JavaScript Document

current = "";
current_id = "";


obj_in_slide = "";

function expand(id, obj) {
	
	if (current_id == id) {			
		closeNav(0);
	}
	else {
	
		if (current_id != "") {
			
			closeNav(0);
		}
		document.getElementById(id).style.display = "block";
		
		var height_needed = document.getElementById(id).offsetHeight;
		
		document.getElementById(id).style.height = "0px";
		
		if (current != "") {
			current.className = "nav_header";
		}
		obj.className = "nav_header_blue";		
		
		
		
		slide(height_needed, id, obj);	
	}
}


function slide(height, id, obj) {
	if (obj_in_slide == "") {
		obj_in_slide = obj;
	}
	cur_height = parseInt(document.getElementById(id).style.height.replace("px", ""));
	step = 20;
	
	if (height > cur_height) {
		if ((cur_height + step) > height) {
			cur_height = height;	
		}
		else {
			cur_height = cur_height + step;	
		}
		document.getElementById(id).style.height = cur_height+"px";
		setTimeout ("slide('"+height+"', '"+id+"')", 20);
	}
	else {
		obj_in_slide.className = "nav_header_blue";
		current = obj_in_slide;
		current_id = id;
		obj_in_slide = "";
	}
	
}


function closeNav(height) {
	cur_height = parseInt(document.getElementById(current_id).style.height.replace("px", ""));
	if (height == 0) {
		height = cur_height;	
	}
	step = 20;
	
	if (0 < cur_height) {
		if ((cur_height - step) < 0) {
			cur_height = 0;	
		}
		else {
			cur_height = cur_height - step;	
		}
		document.getElementById(current_id).style.height = cur_height+"px";
		setTimeout ("closeNav('"+height+"')", 20);
	}
	else {
		
		document.getElementById(current_id).style.display = "none";
		document.getElementById(current_id).style.height = height+"px";
		current.className = "nav_header";
		
		current_id = "";
		current = "";
	}
}
