/**************************************************************************
 *                                                                        *
 *  JAVASCRIPT MENU HIGHLIGHTER v.1.0 (051123)                            *
 * --------------------------------------------                           *
 * ©2005 Media Division (www.MediaDivision.com)                           *
 *                                                                        *
 * Written by Marius Smarandoiu & Armand Niculescu                        *
 *                                                                        *
 * You are free to use, modify and distribute this file, but please keep  *
 * this header and credits                                                *
 *                                                                        *
 * Usage:                                                                 *
 * - the script will apply the .current class to the <a> and its parent   *
 *   <li> that is contained in the element with id="primarynav" and points*
 *   to the current URL                                                   *
 * - works in IE6, Firefox and Opera                                      *
 **************************************************************************/
 
/* 
Last modified: 20091120
 
This script modified to:
- Allow for query strings, etc (based on comments on http://www.richnetapps.com/automatically_highlight_current_page_in/)
- Add different styles based on nav level (series of nested <div>s) 	
*/

function extractPageName(hrefString)
{
var arr = hrefString.split('.');
// Check to see if the url has a query string by searching for the question mark
var hasquestion=hrefString.indexOf('?');
if (hasquestion == '-1')
{
arr = arr[arr.length-2].split('/alumni/');
return arr[arr.length-1].toLowerCase();
}
else
{
return arr[arr.length-1].toLowerCase();
}
}

function setActiveMenu(arr, crtPage)
{
	for(var i=0; i < arr.length; i++)
		if(extractPageName(arr[i].href) == crtPage)
		{
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
			arr[i].parentNode.parentNode.className = "currentfour";
			arr[i].parentNode.parentNode.parentNode.className = "currentfive";
			arr[i].parentNode.parentNode.parentNode.parentNode.className = "currentsix";
		}
}

function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;

	if (document.getElementById("nav")!=null)
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
}
