var _HiderContainer = null;

function BrowserDetect() {
	var ua = navigator.userAgent.toLowerCase();
	// browser name
	this.isIE = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) );
	// browser version
	this.versionMinor = parseFloat(navigator.appVersion);
	if (this.isIE && this.versionMinor >= 4) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
	}
	this.versionMajor = parseInt(this.versionMinor);
	// specific browser shortcuts
	this.isIE5x = (this.isIE && this.versionMajor == 5);
	this.isIE55 = (this.isIE && this.versionMinor == 5.5);
	this.isMac   = (ua.indexOf('mac') != -1);
}

//Link menu rollovers
startList = function() 
{
	navRoot = document.getElementById("links");
	if (navRoot) 
	{
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") 
			{
				node.onmouseover=function() 
				{
					this.className=this.className.replace("idle", "over");
				}
				node.onmouseout=function() 
				{
					this.className=this.className.replace("over", "idle");
				}
		
				for (j=0; j<node.childNodes.length; j++)
				{
					node2 = node.childNodes[j];
					if (node2.nodeName=="UL")
					{
						for (k=0; k<node2.childNodes.length; k++)
						{
							node3 = node2.childNodes[k];
							if (node3.nodeName=="LI")
							{
								for (l=0; l<node3.childNodes.length; l++)
								{
									node4 = node3.childNodes[l];
									if (node4.nodeName=="UL")
									{
										node3.onmouseover=function() 
										{
											this.className=this.className.replace("idle", "over");
										}
										node3.onmouseout=function() 
										{
											this.className=this.className.replace("over", "idle");
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}


// Assign Rollovers to the main navigation
function Main(strNavAbbrev) {
	BrowserDetect();
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById(strNavAbbrev);
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				if(this.versionMinor >=5.5)
				{
					var aUL = new Array();
					for (var z=0;z<node.childNodes.length;z++) {
						if (node.childNodes[z].nodeName == "UL") {
							aUL[aUL.length] = node.childNodes[z];
						}
					}
					oUL = aUL[0];
					node.nIndex = 0;
					node.parentMenu = navRoot;
					node.submenu = oUL;
				}
				node.onmouseover=function() {
					this.className+=" over";
					if (typeof(iFrameCtrl) != "undefined" && typeof(this.submenu) != "undefined")
					{ 
						iFrameCtrl(this.submenu, this);
						xShow(this.submenu);
						this.parentMenu.shownMenu = this.submenu;
					}
				}
				node.onmouseout=function() {
					this.className = "";
					if (typeof(this.submenu) != "undefined")
					{
						xHide(this.submenu);
						HideMenu(navRoot);
					}
				}
			}
		}
	}
}

function HideMenu(oMenu) {
	var curmenu = oMenu.shownMenu;
	var prevMenu;
	while ( curmenu ) {
		if (typeof(HideiFrame) != "undefined") HideiFrame(curmenu);
		prevMenu = curmenu;
		curmenu = curmenu.shownMenu;
		prevMenu.shownMenu = null;
	}
}

function iFrame(oLayer, oNewHiderContainer) {
	sFilter = "filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);";

	var zIndex = oLayer.style.zIndex;
	if (zIndex == "")
		zIndex = xGetAnyCS(oLayer, "z-index");
	zIndex = parseInt(zIndex);
	if ( isNaN(zIndex) ) {
		zIndex = 2;
	}
	
	var oHiderContainer;
	if ( (oNewHiderContainer = xGetElementById(oNewHiderContainer)) ) {
		oHiderContainer = oNewHiderContainer;
	} else {
		oHiderContainer = _HiderContainer;
	}

	oIframe = document.getElementById("hider" + oLayer.id);
	if (!oIframe) {
		zIndex--;
		oHiderContainer.insertAdjacentHTML("afterBegin", '<iframe id="hider' + oLayer.id + '" scroll="no" frameborder="0" src="about:blank" style="position:absolute;visibility:hidden;border:0px;' + sFilter + 'top:0px;left;0px;width:0px;height:0px;background-color:#999;z-index:' + zIndex + ';"></iframe>');
		oIframe = document.getElementById("hider" + oLayer.id);
	}
	return oIframe;
}

function iFrameCtrl(oLayer, oNewHiderContainer) {
	oIframe = iFrame(oLayer, oNewHiderContainer);
	if (oIframe) {
		xMoveTo( oIframe, xLeft(oLayer), xTop(oLayer) );
		xResizeTo( oIframe, xWidth(oLayer), xHeight(oLayer) );
		xShow( oIframe );
	}
}

function HideiFrame(oLayer, oNewHiderContainer) {
	oIframe = iFrame(oLayer, oNewHiderContainer);
	if (oIframe) 
		xHide( oIframe );
}

