 //Highlights the users location on the menu, also redirects the user when a content page is being used as a placeholder for a control (like calendar,atoz)
 
 function menuH(){   //highlights the current location on the menu bar (based on the breadcrumbs links)
//a potential bug is if there are multiple categories with the same name or a name of a category that encapsulates another name, its entry on the menu will be wrongly highlighted
	var menu = document.getElementById("ucLeftNavigation_RadLeftMenu");
	

	if(window.location.href.indexOf("default.aspx?CATID=5623")!= -1)  //if user has selected to view the directory of services
	{
	 location.replace("http://"+window.location.hostname+"/default.aspx?page=AtoZ&LET=A");
	}

	if(window.location.href.indexOf("default.aspx?CATID=5625")!= -1)  //if user has selected to view the diary
	{
	 location.replace("http://"+window.location.hostname+"/default.aspx?page=Calendar");
	}


	var special = "";

	if(window.location.href.indexOf("default.aspx?page=")!= -1)  //user is not viewing a content page, but they were probably linked from a place holder in the menu, will now attempt to identify which placeholder to highlight
	{
		if(window.location.href.indexOf("default.aspx?page=Calendar")!= -1) //viewing the "diary"
		{
			special = "Diary";
		}

		if(window.location.href.indexOf("default.aspx?page=AtoZ")!= -1) //viewing the "directory of services"
		{
			special = "Directory Of Services";
		}
	}


	var linkList = getElementsByClass("item",menu,"*");

	for(var i=0;i<linkList.length;i++)
	{
				
		var text = getElementsByClass("text",linkList[i],"span")[0].innerHTML;
		
		var str = document.getElementById("heartBreadCrumbsDiv").innerHTML;
		
		  if( ((str.indexOf(text) != -1 ) && !(text=="Home" && special!=""))|| text==special) //if the current menu link text is in the breadcrumbs links (but the text is not "Home" when we are not in a content page) , or this is the placeholder for the page we are viwewing
		  {
			getElementsByClass("text",linkList[i],"span")[0].parentNode.style.backgroundColor = "#004080";
			getElementsByClass("text",linkList[i],"span")[0].style.backgroundColor = "#004080";
			getElementsByClass("text",linkList[i],"span")[0].style.color = "#ffffff";
		  }
		
	}
 }

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}