<!--

	var g_SubMenuId = null;	//the ID of the submenu being displayed
	var g_timer = null;		//timer object
	var g_DELAY	= 1;		//#1 that would elapse before the menu closes
	var g_clock = 0;
	
	document.onclick = CloseSubMenu;

	function ShowSubMenu(menuitem)
	{
		StopTimer();	//stop the timer
		
		if (menuitem == null) return;	//if this function is invoked by the submenu just stop the timer and return
		
		CloseSubMenu();
		
		var submenu;	//submenu 
		var mipos;		//menu item position
		
		g_SubMenuId = menuitem.getAttribute("submenu");
		
		submenu = document.getElementById(g_SubMenuId);
		
		if (submenu != null) 	//if submenu object exists display it
		{
			mipos = getElementPosition(menuitem);
			
			submenu.style.left = mipos.left + menuitem.offsetWidth;
			submenu.style.top = mipos.top;
			submenu.style.display = "block";
		}
	}




	function HideSubMenu()
	{
		IncreaseTimer();
	}





	function CloseSubMenu()
	{
		if (g_SubMenuId == null) return;
		
		var submenu = document.getElementById(g_SubMenuId);
		
		if (submenu != null) submenu.style.display = "none";
		
		g_SubMenuId = null;
	}





	function getElementPosition(elem) 
	{
		var offsetTrail = elem;
		var offsetLeft = 0;
		var offsetTop = 0;
		while (offsetTrail) 
		{
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") 
		{
			offsetLeft += document.body.leftMargin;
			offsetTop += document.body.topMargin;
		}
		return {left:offsetLeft, top:offsetTop};
	}



	function IncreaseTimer()
	{
		if (g_clock > g_DELAY)
		{
			StopTimer();
			CloseSubMenu();
		}
		else
		{
			g_clock++;
			g_timer = window.setTimeout("IncreaseTimer();", 1000);
		}
	}



	function StopTimer()
	{
		g_clock = 0;
		window.clearTimeout(g_timer);
	}


//-->
