﻿// JScript File

/**************************************************************************
 *                                                                        *
 *  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)
{
    if(hrefString.indexOf(".aspx") > -1)
    {
	    var arr = hrefString.split('.');
	    arr = arr[arr.length-2].split('/');
	    return arr[arr.length-1].toLowerCase();		
	}
	else 
	{
	    var arr = "Default.aspx".split('.');
	    return arr[0].toLowerCase();
	}
}

function setActiveMenu(arr, crtPage)
{
try
{
	for(var i=0; i <= arr.length; i++)
        
		if(extractPageName(arr[i].href).substring(0,arr[i].href.length-4) == crtPage.substring(0,crtPage.length))
		{	
		    if (arr[i].parentNode.tagName != "DIV" && arr[i].parentNode.tagName != "UL")
	        {
	         if(arr[i].parentNode.id ==crtPage.substring(0,crtPage.length))
             //   alert( arr[i].parentNode.id);
		     //  arr[i].className = "";
		      arr[i].parentNode.className = "select";
		       
		  	//alert(arr[i].parentNode);
              
			    //arr[i].childNodes.className = "acrive";
			}
		}
		if(crtPage == "")
	    {
	       setActiveMenu(document.getElementById("nav").getElementsByTagName("a"),"Default.aspx");
        }
        }
catch(err){}
}

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));
}

window.onload=function(){
setPage();
}

