$(document).ready(function()
{
	$("A.blank").click(function()
	{
		window.open(this.href);
		return false;
	});
});
$(document).ready(function()
{
	$("IMG[src$=icon_txtSml.gif]").click(function()
	{
		if(window.location.href.indexOf("?") == -1)
		{
			window.location.href = window.location.href + "?fontSize=s";
		}
		else
		{
			if(window.location.href.indexOf("fontSize=l") > -1)
			{
				window.location.href = window.location.href.replace(/fontSize\=l/gi, "fontSize=s");
				return false;
			}
			window.location.href = window.location.href + "&fontSize=s";
		}
		return false;
	});
	$("IMG[src$=icon_txtLarge.gif]").click(function()
	{
		if(window.location.href.indexOf("?") == -1)
		{
			window.location.href = window.location.href + "?fontSize=l";
		}
		else
		{
			if(window.location.href.indexOf("fontSize=s") > -1)
			{
				window.location.href = window.location.href.replace(/fontSize\=s/gi, "fontSize=l");
				return false;
			}
			window.location.href = window.location.href + "&fontSize=l";
		}
		return false;
	});
});
$(document).ready(function()
{
	if(
	   (window.location.href.indexOf("/data/") == -1)
	   &&
	   (window.location.href.toLowerCase().indexOf("/environmenthub/") == -1)
	   ){ return; }
	// Should any be expanded?
	var filename = window.location.pathname.substring(window.location.pathname.lastIndexOf('\/')+1);
	var currentPageSelector = "SPAN#navigationLevel3 A[href$=" + filename + "]";
	$(currentPageSelector).each(function(index, domElement)
	{
		$(this).addClass("initiallySelected");
		var iSanity = 0;
		var $parent = $(this).parent().get(0);
		var $parents = new Array();
		while((++iSanity <= 10) && ($parent.tagName != "SPAN"))
		{
			$parent = $($parent).parent().get(0);
			$parents.push($parent);
		}
		if(iSanity >= 10){ return; }
		var $toExpand = $($parents[$parents.length-3]);
		$toExpand.addClass("expanded");
	});
	// Okay, collapse the others.
	var cssLevel3NavigationSelector = "SPAN#navigationLevel3 > UL > LI > A";
	$(cssLevel3NavigationSelector).each(function(index, domElement)
	{
		var $this = $(this).parent(0);
		$this.addClass("collapsable");
		if($this.hasClass("expanded")){ return; }
		$this.children("UL").slideUp(600);
	});
	$(cssLevel3NavigationSelector).click(function()
	{
		var $this = $(this).parent(0);
		if($this.children("UL").length == 0){ return true; }
		$this.toggleClass("expanded");
		if($this.hasClass("expanded"))
		{
			$this.children("UL").slideDown(600);
		}
		else
		{
			$this.children("UL").slideUp(600);
		}
		return false;
	});
	
});