/**************************************************************************
 *                                                                        *
 *  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                                      *
 
 
 ////// modified by RM 8-29-06. Uses bg in the css, gets all portfolio section 
 pages to show as portfolio in nav /////
 **************************************************************************/

function extractPageName(hrefString)
{
 var arr = hrefString.split('.');
 var str = hrefString; //ME
 var port = ""; //ME
 if (str.match("portfolio")) //ME
		{ 
			port = "portfolio_idty_ed"
			return port;
    }			
 else if(arr.length >= 2) {
  arr = arr[arr.length-2].split('/');
  return arr[arr.length-1].toLowerCase();
	} else {
  return "x";
	}
}


/* original function - version above eliminates error messages etc taken from: 
http://bendalziel.blogspot.com/2006/07/auto-highlighting-navigation.html

function extractPageName(hrefString)
{
	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	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";
		}
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("nav")!=null) 
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
	
	if (document.getElementById("nav_bottom")!=null) 
		setActiveMenu(document.getElementById("nav_bottom").getElementsByTagName("a"), extractPageName(hrefString));
		
/* if (document.getElementById("nav_port")!=null  &&  extractPageName(hrefString)!="portfolio_idty_ed")
		setActiveMenu(document.getElementById("nav_port").getElementsByTagName("a"), extractPageName(hrefString));
*/
}
