// JavaScript Document

	var anim_timeout = null;	// Global var, holds the timer
	var period = 1;			// msec, timer period

	function showMenu(id) {
	
		/* If a timer is running, clear it */
		if (anim_timeout) { clearInterval(anim_timeout); }
	
		var menu = $('menu_'+id);
		//$('debug_id').innerHTML = "Menu id: "+id;
	
		/* If the ID is of a menu that is currently showing, simply hide that menu */
		if (menu.style.display == "") {
			
			menu.style.display = "none";
			$(id+'up').style.display = "none";
		
		} else {
		
			/* First we need to hide all menus */
			for(var i=1;i<=5;i++) {
				$('menu_'+i).style.display = "none";
				$(i+'up').style.display = "none";
			}
			
			/* Then, we need to show and animate the currently clicked menu */
			menu.style.height = "0px";
			menu.style.display = "";
			$(id+'up').style.display = "";
			menu.style.zIndex = "250";
			// Now call a timer function that fires off every (period) and increments the height of the menu
			anim_timeout = setInterval("reveal("+id+");",period);
		}
		
		return false;	
	
	}
	
	function closeMenu(id) {
	
		$('menu_'+id).style.display = "none";
		return false;
	
	}
	
	function reveal(id) {
		
		var menu = $('menu_'+id);
		var maxHeight = 200;
		
		if (id == 1 ){
			maxHeight = 750;
		}
		else if (id == 2) {
			maxHeight = 750;
		}
		else if (id == 3){
			maxHeight = 750;
		}
		else if ( id == 4){
			maxHeight = 750;
		}
		else if ( id == 5){
			maxHeight = 750;
		}
		
		
		// First of all, get the current height of the DIV layer
		var height = menu.style.height;
		height = height.substring(0,(height.length-2));
		height = height * 1;
		
		// Increment the height by 10 px
		height = height + 10;
		
		// Check to see if height has not surpassed the max (200)
		if (height > maxHeight) { height = maxHeight; }
		
		// Set the height of the div
		menu.style.height = height+"px";
		//$('debug_height').innerHTML = height;
		
		if (height >= maxHeight) {
		
			// Stop the timer
			clearInterval(anim_timeout);
		
		} 
	
	}
	
	function $(id) {
		return document.getElementById(id);	
	}
