/**************************************************************************
 *                                                                        *
 *  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 arr = hrefString.split('.');
//	document.write("1. dot'" + arr + "' , ");
	arr = arr[arr.length-2].split('/');
//	document.write("2. /'" + arr + "' , ");
	arr1 = arr[0].split('=');
	if (arr1[1] !=null) {
//		document.write("3. ='" + arr1[1] + "' , ");
		return arr1[1].toLowerCase();	
	}
//	arr = arr[0].split('=');
//	document.write("The result is: '" + arr[arr.length-1] + "'<BR />");
	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 setPageVert()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("tameVert")!=null) 	
		setActiveMenu(document.getElementById("tameVert").getElementsByTagName("a"), extractPageName(hrefString));	
		
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("tameHoriz")!=null) 
	
	if (hrefString.indexOf("/p-18") != -1) // if the page is p-18 go here
		
		setActiveMenu(document.getElementById("tameHoriz").getElementsByTagName("a"), "p-18-gift-card");
	
		else { 
			// Check against any of the tameHoriz menu items
			setActiveMenu(document.getElementById("tameHoriz").getElementsByTagName("a"), extractPageName(hrefString));		
			if ((hrefString.indexOf("/p-") != -1))	// if the page has a /p- in its string, it is a product page then turn the SHOP ON
					setActiveMenu(document.getElementById("tameHoriz").getElementsByTagName("a"), "c-3-vitalizex");
					
					else if (hrefString.indexOf("=account") != -1 || hrefString.indexOf("signin") != -1) // Turn  Members ON
							setActiveMenu(document.getElementById("tameHoriz").getElementsByTagName("a"), "account");				 
		}
		
		
}

function setPage2()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("tameHoriz2")!=null) 
		setActiveMenu(document.getElementById("tameHoriz2").getElementsByTagName("a"), extractPageName(hrefString));
}