var oActiveLevel;
var timerID;
var iDivHeight;
var iBodyHeight;
var oDiv;
var iScrollHeight;
var iScrollHeightForWheel;

isIE = (document.all) ? true : false;
isNS = (!document.all && document.getElementById) ? true : false;
isMac = (navigator.userAgent.indexOf("Mac") != -1); 

iScrollHeight = isIE?2:4;
iScrollHeightForWheel = isIE?48:32;

function Over(oItem)
{
	oItem.className = oItem.className.substring(0,6) + "Over";
}

function Out(oItem)
{
	oItem.className = oItem.className.substring(0,6) + "Out";
}

function levelExpandCollapse(oItem)
{
	oActiveLevel = (isIE && !isMac)?oItem.nextSibling:oItem.nextSibling.nextSibling;
	oActiveLevel.className = (oActiveLevel.className == 'hiddenDiv')?'shownDiv':'hiddenDiv';
}

function scrollUp()
{
	oDiv = isIE?divMenu:document.getElementById("divMenu");
	iDivHeight = (isIE?divMenu.scrollHeight:document.getElementById("divMenu").offsetHeight);
	iBodyHeight = (isIE?document.body.clientHeight:document.height);
	iDivTop = new Number(oDiv.style.top.replace(new RegExp("px"), ""));
	
	oDiv.style.top = Math.min(iScrollHeight+iDivTop, 15);
	timerID = setTimeout("scrollUp()", 10);
}

function scrollDown()
{

	oDiv = isIE?divMenu:document.getElementById("divMenu");
	iDivHeight = (isIE?divMenu.scrollHeight:document.getElementById("divMenu").offsetHeight);
	iBodyHeight = (isIE?document.body.clientHeight:document.height);
	iDivTop = oDiv.style.top.replace(new RegExp("px"), "");

	if (iBodyHeight-30 < iDivHeight )
	{
		oDiv.style.top = Math.max(iDivTop-iScrollHeight, iBodyHeight - iDivHeight - 20);
		timerID = setTimeout("scrollDown()", 10);
	}
}

function scrollStop()
{
	clearTimeout(timerID);
}

function doMouseWheel()
{
	if (event.wheelDelta >= 120)
	{
		//Scroll Up
		oDiv = isIE?divMenu:document.getElementById("divMenu");
		iDivHeight = (isIE?divMenu.scrollHeight:document.getElementById("divMenu").offsetHeight);
		iBodyHeight = (isIE?document.body.clientHeight:document.height);
		iDivTop = new Number(oDiv.style.top.replace(new RegExp("px"), ""));
		
		oDiv.style.top = Math.min(iScrollHeightForWheel+iDivTop, 15);
	}
	else if (event.wheelDelta <= -120)
	{
		//ScrollDown
		oDiv = isIE?divMenu:document.getElementById("divMenu");
		iDivHeight = (isIE?divMenu.scrollHeight:document.getElementById("divMenu").offsetHeight);
		iBodyHeight = (isIE?document.body.clientHeight:document.height);
		iDivTop = oDiv.style.top.replace(new RegExp("px"), "");

		if (iBodyHeight-30 < iDivHeight )
			oDiv.style.top = Math.max(iDivTop-iScrollHeightForWheel, iBodyHeight - iDivHeight - 20);
	}
}

function doLink (sUrl)
{
	//alert(parent.frames["principal"]);
	//parent.frm_txt.document.location.replace(sUrl);
	parent.frames["principal"].document.location.replace(sUrl);
}

function linkToTop(sUrl)
{
	top.document.location.replace(sUrl);
}

function openPopup(sUrl)
{
	sitepop = window.open (sUrl,'','');
}