/**************************************************************************
 *                                                                        *
 *  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(href)
{
	if(href.substring(href.length - 1, href.length) == "/") href = href.substring(0, href.length - 1);
	
	var parts = href.split("/");
	var pageName = parts[parts.length -1];
	
	var dot = pageName.lastIndexOf(".");
	if(dot > 0) pageName = pageName.substring(0, dot);
	
	// check for main index page without /index.html
	var urls = ["www.mooreassociateshampshire", "mooreassociateshampshire"];
	for(var i = 0; i < urls.length; i++)
	{
		var url = urls[i].toLowerCase();
		if(pageName.substring(0, url.length).toLowerCase() == url)
		{
			pageName = "index";
			break;
		}
	}
		
	// check for news page - special case
	if((pageName == "index") && (href.substring(href.length - 15, href.length) == "news/index.html"))
	{
		pageName = "news";
	}
	
	return pageName;
}



function setPage()
{
	var href;
	
	if(document.location.href) href = document.location.href;
	else href = document.location;

	var e = document.getElementById("nav");
	if(! e) return;
	
	var currentPage = extractPageName(href);
	var links = e.getElementsByTagName("a");
	for(var i = 0; i < links.length; i++)
	{
		var link = links[i];
		if(extractPageName(link.href) == currentPage)
		{
			link.className = "current";
			link.parentNode.className = "current";
		}
	}
}