function updatesubmenu()
{
	var fullURL =  window.location.href;
	var list  = document.getElementById("sub-menu");
	if(list)
	{
		var listItems = list.getElementsByTagName("a");
		for(var j=0;j<=listItems.length-1; j++) 
		{
			if((listItems[j].href) == (fullURL))
			{
			 listItems[j].parentNode.className = "selected"; // select the li and write a class of selected on it
			}
		}
	}
};


function toggleNext(el) {
 var next=el.nextSibling;
 while(next.nodeType != 1) next=next.nextSibling;
 next.style.display=((next.style.display=="none") ? "block" : "none");
};

function toggleNextById(el) {
 var ccn="clicker";
 var clicker=document.getElementById(el);
 clicker.className+=" "+ccn;
 clicker.onclick=function() {toggleNext(this)}
 toggleNext(clicker);
};

function toggleNextByTagName(tname) {
 var ccn="clicker";
 var clickers=document.getElementsByTagName(tname);
 for (i=0; i<clickers.length; i++) {
 clickers[i].className+=" "+ccn;
 if(isIE())
 {
// for stupid ie6
 clickers[i].onmouseover = function(){this.style.color='#E67D00';}
 clickers[i].onmouseout = function () {this.style.color='';}	
 }
 clickers[i].onclick=function() {toggleNext(this)}
 toggleNext(clickers[i]);
 }
};

function doublelevelnav()
{
	var fullURL =  window.location.href;
	var list  = document.getElementById("sub-team");
	if(list)
	{
		var levelOne = fullURL.match(/our\-team\/(\S*)?\//);
		var levelTwo = fullURL.match(/([a-z\-]*)?\.html/);
		levelOne = levelOne[1]; // this holds the first part of the url. Which sub directory we are in.
		levelTwo= levelTwo[1];
		var listItems = list.getElementsByTagName("h4");
		
		for(var j=0;j<=listItems.length-1; j++) 
		{
			listItem = trimAll((listItems[j].innerHTML).toLowerCase());
			listItem = listItem.replace(/ /g,'-');
			if(listItem == levelOne)
			{
				/*ie doesn't quite see the DOM path the same way so we must diverge here.*/
				if(!isIE())
				{
				listItems[j].nextSibling.nextSibling.className += " selected"; // select the h4 and write a class of selected on it this is now expanded using css
				}
				else 
				{
				listItems[j].nextSibling.className += " selected"; // select the h4 and write a class of selected on it this is now expanded using css
	
				}
			}
		}
		var subListItems = list.getElementsByTagName("a");
		for(var i=0;i<=subListItems.length-1; i++) 
		{
			
			subListItem = (subListItems[i].innerHTML);
			subListItem =  trimAll(subListItem.toLowerCase());
			subListItem = subListItem.replace(/ /g,'-');
			if(subListItem == levelTwo)
			{
			 subListItems[i].parentNode.className = " selected"; // select the li and write a class of selected on it
			}
		}
	}
};
function isIE()
{
  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}
function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
return sString;
}
