		
	var containerFrame = "Main";
	var menuFrame = "menu";
	
	var menuStack = [];
	var menuOwners = [];
	
	var hideTimeout = null;	
	var showTimeout = null;
	
	var xOffset = 0;
	
	function menuNavigate(src, sUrl)
	{
		var target = "Main";
		parent.frames[target].location.href = sUrl;
		src.className = src.className == "rootitemhover" ? "rootitem" : "subitem";
		hideStack(0);
	}
	
	function getElement(id, secondFrame)
	{
		var element = secondFrame ? null : document.getElementById(id);
		if( !element )
			element = parent.frames[containerFrame].document.getElementById(id);
		return element;
	}
	
	function requestShow(src, subMenuId, level, nopause)
	{
		var x, y, w;
		if( subMenuId != "kill" )
		{
			if( level > 0 )
			{
				x = (findPosX(src) + src.offsetWidth) + 2;		
				y = findPosY(src);
				w = 0;
			}		
			else		
			{
				x = 0; //findPosX(src) - 1;
				y = (findPosY(src) ) - 1;
				w = src.offsetWidth + 3;				
			}
			menuOwners[subMenuId] = src;
		}
		
		cancelShow();

		showTimeout = setTimeout("show('" + subMenuId + "'," + x + "," + y + "," + w + "," + level + ");", nopause || menuStack.length > 0 && level == 0 ? 0 : 0);
	}
	
	function hilite(src, level)
	{
		src.className = (level > 0 ? "sub" : "root" ) + "itemhover";
	}
	
	function lolite(src, subMenuId, level)
	{
		if( subMenuId == "kill" || menuStack[level] != getElement(subMenuId) )
			src.className = (level > 0 ? "sub" : "root" ) + "item";
	}
	
	function show(subMenuId, x, y, w, level)
	{			
		if( subMenuId != "kill" )
		{
			var o;
			if( containerFrame && level >= 0 )
			{
				if( level == 0 )
				{
//					y = 0;
					x -= xOffset;
				}
				o = getElement(subMenuId, true);
			}
			else 
				o = getElement(subMenuId);
			
			if( o )
			{
				with( o.style )
				{
					display = "";
/*					if( o.offsetWidth < o.childNodes[0].offsetWidth )
						o.style.width = o.childNodes[0].offsetWidth + "px";*/
					if( w > o.offsetWidth )
						width = w + "px";
					left = x + "px";
					if( document.all && level == 0 )
					{
						y += parent.frames[containerFrame].document.body.scrollTop + 1;
					}
					top = y + "px";
				}
				if( menuStack[level] != o )
				{
					hideStack(level);
					menuStack.push(o);
				}		
			}
			else
				hideStack(level);
		}
		else
		{
			hideStack(level);
		}
	}
			
	function cancelShow()
	{
		if( showTimeout != null )
			clearTimeout(showTimeout);
	}
		
	function initTimeout()
	{
		killTimeout();
		hideTimeout = setTimeout("hideStack(0);", 400);
	}
	
	function killTimeout()
	{
		if( hideTimeout != null )
			clearTimeout(hideTimeout);
	}
	
	function hideStack(level)
	{
		while( menuStack.length > level )
		{
			currentMenu = menuStack.pop();
						
			currentMenu.style.display = "none";
			owner = menuOwners[currentMenu.id];
			if( owner != null )
				owner.className = (menuStack.length > 0 ? "sub" : "root" ) + "item";
		}
	}	
	
	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
	
	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}
