﻿
// ***********************************
// jQuery code for PHOENIX2030.MASTER
// ***********************************

$(document).ready(function() {
	
	// If the site is launched without DEFAULT.ASPX specified, redirect to DEFAULT.ASPX
	// This ensures that the primary navigation toolbar will highlight the "active" home page
	if (window.location.toString().lastIndexOf("/") == (window.location.toString().length - 1))
	{
		window.location.replace("default.aspx");
	}
	
	// Find out which primary navigation link should be highlighted and set the CSS class accordingly
	$("#navLinks").find("a").each(
		function(idx, el)
		{
			var targetLocation = el.href;
			targetLocation = targetLocation.substring(targetLocation.lastIndexOf("/") + 1, targetLocation.length);

			var windowLocation = window.location.toString();
			windowLocation = windowLocation.substring(windowLocation.lastIndexOf("/") + 1, windowLocation.indexOf(".aspx") + 5);
			
			var baseWindowLocation = windowLocation;
			if (baseWindowLocation.lastIndexOf("_") >= 0)
				baseWindowLocation = baseWindowLocation.substring(0, baseWindowLocation.lastIndexOf("_")) + ".aspx";
				
			if ((targetLocation == windowLocation) || (targetLocation == baseWindowLocation))
				$(el).addClass("current");
			
			var className = windowLocation.substring(0, windowLocation.lastIndexOf("."));
			$(el).closest("#picture").addClass(className);
		}
	);
});
