// Browser Detection Code
var sBrowserName = navigator.appName;
var iVersion = parseInt(navigator.appVersion);
var NS4 = (sBrowserName == "Netscape" && iVersion >= 4);
var DOM = (document.getElementById) ? true : false;
var IE4 = (sBrowserName == "Microsoft Internet Explorer" && iVersion >= 4);

if (DOM) //If it's DOM compliant and Netscape (6) returning DOM then it can't be Netscape 4
	NS4 = false;

var menuActive = 0
var menuOn = 0
var onLayer
var timerHandle = null


//setup event notification
if (document.layers)
  document.captureEvents(Event.KEYPRESS);

function MenuKeyStroke(menuName, element, orientation)
{

	if (window.event.keyCode == 32)
	{	
		if (onLayer != null) hideMenu(onLayer);
		showMenu (menuName, element, orientation);
		onLayer = menuName;
		timerHandle = setTimeout("hideMenu(onLayer)", 15000);
	}

}
  
function showMenu(menuName, element, orientation)
{
	if (timerHandle != null) 
	{
		clearTimeout(timerHandle);
		hideMenu(onLayer); 
	}
	
	if (DOM)
	{
		if (orientation == 'h')
			var x = element.offsetTop + element.offsetHeight;
		else
			var x = element.offsetTop;
			
		var y = element.offsetLeft;
		var positionElement = element.offsetParent;
		while (positionElement)
		{
			x += positionElement.offsetTop;
			y += positionElement.offsetLeft;
			positionElement = positionElement.offsetParent;
		}

		if (orientation == 'v')
			y += element.parentNode.offsetWidth;
//			y += element.parentElement.offsetWidth;

		var docElement = document.getElementById(menuName);

		if (IE4) //Some differences between IE and DOM (Netscape 6)
		{
			if (document.body.clientWidth < (y + docElement.offsetWidth + 10)) 
				if (document.body.scrollWidth == document.body.clientWidth)
					y = document.body.clientWidth - (docElement.offsetWidth + 10);
				else
				{
					if ((y + docElement.offsetWidth + 10) > document.body.scrollWidth) 
						y = document.body.scrollWidth - (docElement.offsetWidth + 10);
				}	
		}
		else
		{
			if (document.body.offsetWidth < (y + docElement.offsetWidth + 10)) 
				y = document.body.offsetWidth - (docElement.offsetWidth);
		}
		docElement.style.top = x;
		docElement.style.left = y;
		docElement.style.visibility = "visible";
	}
	if (NS4)
	{
		document.layers[menuName].visibility = "visible";		
		anchorname = menuName + "Anchor";
		x = document.anchors[anchorname].x;
		y = document.anchors[anchorname].y + 20;

		var layerwidth = 0;
		layerwidth = document.layers[menuName].clip.width;

		if (orientation == "v")
		{
			var positionAnchorName = menuName + "PositionAnchor";
			x = document.anchors[positionAnchorName].x;
			y = document.anchors[positionAnchorName].y;
		}
		
		if ((x + layerwidth) > window.outerWidth )
			x = window.outerWidth - (layerwidth + 40);

		document.layers[menuName].top = y;
		document.layers[menuName].left = x;
	} 
	onLayer = menuName;
}

function hideMenu(menuName)
{
	if (menuActive == 0) 
	{
		if (DOM)
		{
				var docElement = document.getElementById(menuName);
				docElement.style.visibility = "hidden";
		}
		if (NS4)
		{
			document.layers[menuName].visibility = "hidden";		
		}
	}
}

function btnTimer() 
{
	timerHandle = setTimeout("btnOut()",1000);
}

function btnOut(menuName) 
{
	if (menuActive == 0) 
	{
		hideMenu(onLayer);
	}
}

function menuOver(itemName) 
{
	clearTimeout(timerHandle);
	menuActive = 1;
}

function menuOut(itemName)  
{
	menuActive = 0;
	timerHandle = setTimeout("hideMenu(onLayer)", 400);
}

function NoOp()
{
	return;
}

function openWindow(URL)
{
	var details;
	details="toolbar=no,titlebar=no,width=760,height=560";
	window.open(URL,'',details);

}