// JavaScript Document

function showMenu(menuid, submenuId, subsubmenu, mainMenuId)
{
	var Elem = document.getElementById(menuid);
	
	topPos = Elem.offsetTop;
	leftPos = Elem.offsetLeft;
	
	var subElem = document.getElementById(submenuId);
	
	topPosSub = subElem.offsetTop;
	leftPosSub = subElem.offsetLeft;
	
	if(subsubmenu == 'yes')
	{
		//if(leftPosSub !== leftPos + 386)
		//{
			if(leftPosSub < leftPos + 386)
			{
				leftPosSub = leftPosSub + 386;
				var mainElem = document.getElementById(menuid);
				var mainElem2 = document.getElementById(mainMenuId);				
				
				topPosMain = mainElem.offsetTop;
				topPosMain2 = mainElem2.offsetTop;
				finalTop = topPosMain + topPosMain2;
				
				subElem.style.top = finalTop + 'px';
			}
		//}
	}
	
	if(leftPosSub !== leftPos + 193)
	{
		if(leftPosSub < leftPos + 193)
		{
			leftPosSub = leftPosSub + 193;
			subElem.style.top = topPos + 'px';
		}
	}
	
	//alert('leftPos ==' + leftPos + ' topPos ==' + topPos);
	subElem.style.zIndex = "2";
	subElem.style.left = leftPosSub + 'px';
	subElem.style.position = 'absolute';
	subElem.style.visibility = 'visible';
}

function showMenuSimple(menuName)
{
	var Elem = document.getElementById(menuName);
	Elem.style.visibility = 'visible';
}

function hideMenu(menuName)
{
	var Elem = document.getElementById(menuName);
	
	Elem.style.visibility = 'hidden';
}

function hideMenu2(menuName)
{
	var Elem = document.getElementById(menuName);
	
	Elem.style.visibility = 'hidden';
}

//Highlight On Function
function highlightOn(id)
{
	document.getElementById(id).style.background="#7C96AD"
}

//Highlight Off Function
function highlightOff(id)
{
	document.getElementById(id).style.background="#ffffff"
}

//Creates onmouseover link instead of <a> anchor
function linkFunction(url)
{
	window.location = url;
}

function setMenuPadding()
{
	var screenHeight = window.innerHeight;
	var bodyHeight = document.getElementById('wrap').offsetHeight;
	var menuHeight = document.getElementById('onlyMain').offsetHeight;
	var menuSpace = bodyHeight - menuHeight;
	var emptySpace = screenHeight - bodyHeight;
	
	if(emptySpace < 0)
		var padding = screenHeight - menuHeight;
	else if(menuSpace < 0)
		var padding = emptySpace;
	else
		var padding = emptySpace + menuSpace;

	document.getElementById('menu').style.paddingBottom = padding + 'px';
	//var padding = (docHeight - bodyHeight) + ((bodyHeight - menuHeight) < 0) ? 0 : (bodyHeight - menuHeight));
}

/*
function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}*/