var menu = {};

menu.expanded = null;
menu.colapse_obj = null;
menu.expand_obj = null;
menu.colapse_obj_height = null;
menu.expand_obj_height = null;

menu.timer_interval = 10;
menu.max_step = 10;
menu.timer = null;
menu.processing = false;

menu.expand = function(menu_id, step_num){
	if(typeof(step_num) == "undefined" && !menu.processing){
		var process = false;
		if(menu.expanded != null && menu.expanded.id != menu_id){
			menu.colapse_obj = menu.expanded;
			menu.expand_obj = document.getElementById(menu_id);
			
			menu.expand_obj.style.display = "";
			menu.colapse_obj_height = menu.colapse_obj.offsetHeight;
			menu.expand_obj_height = menu.expand_obj.offsetHeight;
			menu.expand_obj.style.display = "none";
			process = true;
		}else if(menu.expanded == null){
			menu.colapse_obj = null;
			menu.expand_obj = document.getElementById(menu_id);
			
			menu.expand_obj.style.display = "";
			menu.expand_obj_height = menu.expand_obj.offsetHeight;			
			menu.expand_obj.style.display = "none";
			process = true;
		}
		if(process){
			menu.expanded = menu.expand_obj;
			menu.processing = true;
			menu.timer = window.setTimeout("menu.expand(null, 0)", menu.timer_interval);
		}
		
		document.getElementById("header" + menu.expand_obj.id).className = "left_module_over";
		document.getElementById("header" + menu.colapse_obj.id).className = "left_module";
	}else{
		
		if(menu.max_step > (step_num + 1)){
			menu.expand_obj.style.display = "";
			if(menu.colapse_obj != null){
				menu.colapse_obj.style.height = (menu.colapse_obj_height - (menu.colapse_obj_height / menu.max_step * step_num)) + "px";
			}
			if(menu.expand_obj != null){
				menu.expand_obj.style.height = (menu.expand_obj_height / menu.max_step * step_num) + "px";
			}
			step_num++;
			menu.timer = window.setTimeout("menu.expand(null, " + step_num + ")", menu.timer_interval);
		}else{
			if(menu.colapse_obj != null){
				menu.colapse_obj.style.display = "none";
				menu.colapse_obj.style.height = "";
			}
			if(menu.expand_obj != null){
				menu.expand_obj.style.height = "";
			}
			
			menu.colapse_obj_height = null;
			menu.expand_obj_height = null;
			
			menu.processing = false;
		}
	}
}
