/**************************************************************************
 *                                                                        *
 *  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                                      *
 **************************************************************************/
function extractPageName(hrefString)
{
var hrefString = hrefString.split('#');
var hrefString = hrefString[0].split('?');

var arr = hrefString[0].split('/');

return (arr.length<2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();
}

function setActiveMenu(arr, crtPage)
{
	//alert("arr.length = " + arr.length + "\ncrtPage = " + crtPage);
	for(var i=0; i < arr.length; i++)
	{
		//alert("arr[" + i + "] = " + arr[i] + "\n crtPage = " + crtPage);
		if(extractPageName(arr[i].href) == crtPage)
		{
			//alert("in page match");
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}
	}
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;
    if (document.getElementById("nav")!=null) 
		{
		var x = document.getElementById("nav");
		//alert("x = " + x);
		var y = x.getElementsByTagName("a");
		//alert("y = " + y);
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
		}
}