var isIE = (navigator.appName == "Microsoft Internet Explorer") ? 1 : 0;
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
var isNS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
var isOpera = (navigator.appName == "Opera") ? 1 : 0;
if (isIE)
	document.onmouseout = offPage;
if (isNS && !isNS4)
	document.addEventListener("mouseout", offPage, true);
if (isOpera)
	document.addEventListener("mouseout", offPage, true);
function offPage(event){
	var offScreen;
	if (isIE) offScreen = (window.event.clientY < 5) ? 1 : 0;
	if (isNS) offScreen = (event.pageY < 5) ? 1 : 0;
	if (isOpera) offScreen = (event.pageY < 5) ? 1 : 0;
	if (offScreen) HideMenus();
}

function FindSubMenu(subMenu)
{
	var menu=eval(subMenu)
	var Items = menu.children
	for(var j=0; j<Items.length; j++)
	{
		menu.style.visibility = "hidden"
		var menuItem = eval(Items[j].id)

		//If Text is Used instead of image the following lines of code are used for displaying arrow symbol for submenus
		//if(menuItem.menu!= null)
		//{
		//	menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
		//	FindSubMenu(menuItem.menu)
		//}

		if(menuItem.cmd != null) 
		{
			menuItem.onclick = new Function("Do("+menuItem.id+")") 
		} 
		menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
	}  
} 

 
function ShowSubMenu(obj)
{
	if(obj == "mnuPortfolio")
	{
		document.getElementById('mnuPortfolio').style.visibility = "visible"
		document.getElementById('mnuPortfolio').style.pixelTop =  document.getElementById('aPortfolio').getBoundingClientRect().top + Bdy.scrollTop
		document.getElementById('mnuPortfolio').style.pixelLeft =  document.getElementById('aPortfolio').getBoundingClientRect().right + Bdy.scrollLeft

		if(document.getElementById('mnuPortfolio').getBoundingClientRect().right > window.screen.availWidth )
			document.getElementById('mnuPortfolio').style.pixelLeft = document.getElementById('aPortfolio').getBoundingClientRect().left - document.getElementById('mnuPortfolio').offsetWidth
	}
	
	else if(obj == "mnuPricing")
	{
		document.getElementById('mnuPricing').style.visibility = "visible"
		document.getElementById('mnuPricing').style.pixelTop =  document.getElementById('aPricing').getBoundingClientRect().top + Bdy.scrollTop
		document.getElementById('mnuPricing').style.pixelLeft =  document.getElementById('aPricing').getBoundingClientRect().right + Bdy.scrollLeft

		if(document.getElementById('mnuPricing').getBoundingClientRect().right > window.screen.availWidth )
			document.getElementById('mnuPricing').style.pixelLeft = document.getElementById('aPricing').getBoundingClientRect().left - document.getElementById('mnuPricing').offsetWidth
	}
} 

function highlight(obj)
{
	var PElement = eval(obj.parentElement.id)
	if(PElement.hasChildNodes() == true)
	{  
		var Elements = PElement.children
		for(var i=0;i<Elements.length;i++)
		{
			TE = eval(Elements[i].id)
			TE.className = "menuItem"
		}
	} 
	obj.className="ItemMouseOver"
	window.defaultStatus = obj.title
	ShowSubMenu(obj)
}
   
function Do(obj)
{
	var cmd = eval(obj).cmd	
	window.navigate(cmd)
}

function HideMenus()
{
	document.getElementById('mnuPortfolio').style.visibility='hidden';
	document.getElementById('mnuPricing').style.visibility='hidden';
}
