	/*
		Copyright Rotator.Aps 2003
		
		(DK)
		Alle rettigheder forbeholdes.
		Må ikke kopieres uden forfatterens udtrykkelige samtykke.
		
		(Int)
		All rights reserved.
		Do not copy without the author's written consent.		
	*/
	
	var menuStack = [];
	var menuOwners = [];
	
	var hideTimeout = null;	
	var showTimeout = null;
	
	function menuNavigate(src, target)
	{
		document.location.href = src;
/*		target = "hovedmain";
		if( !target )
			navigate(src);
		else
			parent.frames[target].location.href = "main.asp" + src;*/
		src.className = src.className == "rootitemhover" ? "rootitem" : "subitem";
		hideStack(0);
	}
	
	function requestShow(src, subMenuId, level, nopause)
	{		
		var x = 0, y = 0, w = 0;
				
		if( subMenuId != "kill" )
		{
			if( level > 0 )
			{
				x = (findPosX(src) + src.offsetWidth) + 2;		
				y = findPosY(src) - 2;
				w = 0;
			}		
			else		
			{
				x = findPosX(src);
				y = (findPosY(src) + src.offsetHeight);
				w = src.offsetWidth;				
			}
			menuOwners[subMenuId] = src;
		}
		
		if( window._menu_offsetX ) x += window._menu_offsetX;
		if( window._menu_offsetY ) y += window._menu_offsetY;
		
		cancelShow();
		showTimeout = setTimeout("show('" + subMenuId + "'," + x + "," + y + "," + w + "," + level + ");", nopause || menuStack.length > 0 && level == 0 ? 0 : 100);
	}
	
	function hilite(src, level)
	{
		src.className = (level > 0 ? "sub" : "root" ) + "itemhover";
	}
	
	function lolite(src, subMenuId, level)
	{
		if( subMenuId == "kill" || menuStack[level] != document.getElementById(subMenuId) )
			src.className = (level > 0 ? "sub" : "root" ) + "item";
	}
	
	function show(subMenuId, x, y, w, level)
	{	
		if( subMenuId != "kill" )
		{
			var o = document.getElementById(subMenuId);
			with( o.style )
			{
				if( w > o.offsetWidth )
					width = w + "px";
				display = "";
				left = x + "px";
				top = y + "px";
			}
			if( menuStack[level] != o )
			{
				hideStack(level);
				menuStack[menuStack.length] = o;
			}		
		}
		else
		{
			hideStack(level);
		}
	}
			
	function cancelShow()
	{
		if( showTimeout != null )
			clearTimeout(showTimeout);
	}
		
	function initTimeout()
	{
		killTimeout();
		hideTimeout = setTimeout("hideStack(0);", 500);
	}
	
	function killTimeout()
	{
		if( hideTimeout != null )
			clearTimeout(hideTimeout);
	}
	
	
	function _pop(a)
	{
		var tmp = [];
		for( var i = 0; i < a.length - 1; i++ )
			tmp[i] = a[i];
		return [a[a.length - 1], tmp];
	}
	
	function hideStack(level)
	{
		while( menuStack.length > level )
		{
			var poppedStack = _pop(menuStack);
			currentMenu = poppedStack[0];
			menuStack = poppedStack[1];
			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
				if( obj.tagName.toLowerCase() == "td" && obj.currentStyle && obj.currentStyle.borderLeftStyle != "none" )
				{
					var iBorderLeftWidth = parseInt(obj.currentStyle.borderLeftWidth);
					if( !isNaN(iBorderLeftWidth) )
						curleft += parseInt(obj.currentStyle.borderLeftWidth);				
				}
			
				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;
				if( obj.tagName.toLowerCase() == "td" && obj.currentStyle && obj.currentStyle.borderTopStyle != "none" )
				{
					curtop += parseInt(obj.currentStyle.borderTopWidth);				
				}
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

/*	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;
	}*/
