function menuHighlight(menu,level){
	if (!document.getElementsByTagName) return;	
	var mainMenu = document.getElementById(menu);
	var contentArea = document.getElementById("content");
	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((pathName[j+1] == "giving") & (level == 0)) {
						pathName[j+1] = "about";	
					}
					if (anchoref[j + 3] == pathName[j +1]){
						if(level == 0) {
							var page = "page-" + anchoref[j+3];
							contentArea.className = contentArea.className + " " + page;
						}
					}
					else {success = false;}
				}
				if(success == true) {
					anchors[0].removeAttribute('class');
					anchors[0].className = "current";
					
				}
			}
		}
	}
}
window.addEvent('domready', function() {
	menuHighlight('nav',0);
	menuHighlight('subnav',1);
});