	//Preloads submenu indicators
	var itemOn = new Image();
	var itemOff = new Image();
	
	//Selected menu item image
	itemOn.src = "/images/menu_on.gif";
	
	//Unselected menu item image
	itemOff.src = "/images/menu_off.gif";
	
	//The active submenu object
	var visibleSubmenu = null;
	
	//The timer used to hide the active submenu
	var timeOut = null;
	
	//This is called whenever the mouse moves over a menu which has a submenu
	function MenuOver(menuId, submenuId)
	{
		//Clears the timer if it is activeted
		if(timeOut != null)
	    clearTimeout(timeOut);
	    
	  //Gets the menu object
		var menu = document.getElementById(menuId);
		
		//Gets the submenu object
		var submenu = document.getElementById(submenuId);
		
		//If the current activ submenu is diffetent then the new submenu
		if(submenu != visibleSubmenu)
		{
			//Hides active submenu
			HideSubmenu();
			
			//Shows new submenu
			ShowSubmenu(menu, submenu);
		}
	}
	
	//This function is called when the mouse moves away from a menu item
	function MenuOut()
	{
		//Calls HideSubmenu after 500 miliseconds
		timeOut = setTimeout("HideSubmenu()", 500);
	}
	
	//This function is called when the mouse moves over a submenu
	function SubmenuOver()
	{
		//Clears the timer if exists
		if(timeOut != null)
	    clearTimeout(timeOut);
	}

	//Shows a submenu
	function ShowSubmenu(menu, submenu)
	{
		//Sets the left position of the submenu
		submenu.style.left = getElementLeft(menu);
		
		//Makes the submenu visible
		submenu.style.display = 'block';
		
		//Saves the active submenu
		visibleSubmenu = submenu;
	}
	
	//Hides the active submenu
	function HideSubmenu()
	{
		if(visibleSubmenu != null)
		{
			//Makes the submenu invisible
		  visibleSubmenu.style.display = 'none';
		  
		  //There is no active submenu
		  visibleSubmenu = null;
		}
	}

	//Gets the left possition of an object
	function getElementLeft(elem) 
	{
		var xPos = elem.offsetLeft;
		var tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;
	}
	
	//Changes the image of a submenu item when selected
	function SubmenuItemOver(img)
	{
		document.getElementById(img).src = itemOn.src;
	}
	
	//Changes the image of a submenu item when unselected
	function SubmenuItemOut(img)
	{
		document.getElementById(img).src = itemOff.src;
	}