window.addEvent('domready', function() {
function menuHighlight(menu,level){
	if (!document.getElementsByTagName) return;
		
	var mainMenu = document.getElementById(menu);
	if(document.getElementById(menu)){
		var menuItems = mainMenu.getElementsByTagName("li");
		var pathName = window.location.pathname.toString().split("/");
		var hostName = window.location.hostname.toString();
		
		//remove any filename that may end up at the end of the pathName
	
		var pathNameLength = pathName.length;
		if((pathName[pathNameLength -1].indexOf("."))!= -1) {
			pathName[pathNameLength -1] = "";	
		}
		
		// loop through all the menu items to find the corresponding one
		for (var i=0; i<menuItems.length; i++) {
			var menuItem = menuItems[i];
			var anchors = menuItem.getElementsByTagName("a");
			var anchoref = anchors[0].href.toString().split("/");
			if (anchoref[2] == hostName) {
				var success = true;
				anchors[0].removeAttribute('class');
				anchors[0].className = "notcurrent";
				for (var j = 0; j<(level +1); j++) {
					if (anchoref[j + 3] == pathName[j +1]){}
					else {success = false;}
				}
				if(success == true) {
					anchors[0].removeAttribute('class');
					anchors[0].className = "current";
				}
			}
		}
	}
}
menuHighlight('nav',0);
menuHighlight('subnav',1);
menuHighlight('sectionnav',2);
});