// Looks through subnav items and if URIs match turns the highlight "on"
function CheckSubNavigation()
{
	// find the effective section of doc.location
	var regURL = /[\\\/]{1}([A-Za-z0-9]+)[_\.]+/
	regURL.exec(location.pathname.toString());
	var sURI = RegExp.$1;
	
	if(sURI.length == 0) { return }

	// Get the subnavigation nodes
	var alNavNodes = GetSubNavNodes();
	
	// If a nodes first child has a href that matches sURI then turn it "on"
	for(var i = 0; i < alNavNodes.length; i++)
	{
		if(LinkMatches(alNavNodes[i], sURI))
		{
			alNavNodes[i].childNodes[0].style.backgroundImage = "url(images/red_bullet.gif)";
			break;
		}
	}
}

// Matches the list item link with the effective location
function LinkMatches(listItem, sURI)
{
	var listLink = listItem.childNodes[0];
	if(listLink != null) 
	{
		if((listLink.href != null) && (listLink.href.indexOf(sURI) != -1))
		{
			return true;
		}
	}
	return false;
}

// Finds all the LI nodes that comprise the subnavigation
function GetSubNavNodes()
{
	var navHolder = document.getElementById("subnav");
	if(navHolder == null){ return new Array() }
	
	var subNav = null;
	for(var i = 0; i < navHolder.childNodes.length; i++)
	{
		if((navHolder.childNodes[i].tagName != null) && (navHolder.childNodes[i].tagName.toUpperCase() == "UL"))
		{
			subNav = navHolder.childNodes[i];
			break;
		}
	}
	
	return (subNav != null) ? subNav.childNodes : new Array();
}

window.onload = CheckSubNavigation;

var oldWindow = null;
function FramePop(linkItem)
{
	if(linkItem.href != null)
	{
		linkItem = linkItem.href;
	}

	if(oldWindow != null)
	{
		oldWindow.close();
	}
	
	var height = 570;
	var width = 780;
	
	var left = (screen.availWidth/2) - (width/2);
	var top = (screen.availHeight/2) - (height/2);
	
	if(left <1) { left =1 };
	if(top<1) {top=1};
	

	var rider = "width=" + width + ",height=" + height + ",top=" + top +",left=" + left + ",directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	
	oldWindow = window.open("framepop.html?outside=" + linkItem, "FramedContent", rider);
	
	return false;	
}

function FlashPop(linkString)
{
	FramePop(linkString);
}

