// Based on http://surguy.net/menu/highlight.html

function getLeaf(url) {
  return url.substring(url.lastIndexOf("/")+1);
}

function setNav() {
	 found=0;
  if(document.getElementById("header")){
    var currentLocation = getLeaf(document.location.href);
    var menu = document.getElementById("header");
    var Links = menu.getElementsByTagName("a");
    if (currentLocation == '') { currentLocation="index.html"; }
    if (currentLocation == 'online_media2.html') { currentLocation="online_media.html"; }

    for (var i=0; i<Links.length; i++) {
      var currentHref = Links[i].getAttribute("href");
				
   			Links[i].getAttribute("class")
      var currentLeafName = getLeaf(currentHref);
      if (currentLeafName==currentLocation) {
        // Setting class is needed for Mozilla compatibility - className appears to be correct 
        // according to the DOM spec
        Links[i].parentNode.setAttribute("class", "currentpage");
        Links[i].parentNode.setAttribute("className", "currentpage");
								found=1;
      }
    }
		}
  if(!document.getElementById("footer"))
    return;

  var currentLocation = getLeaf(document.location.href);
  var menu = document.getElementById("footer");
  var Links = menu.getElementsByTagName("a");
    if (currentLocation == 'online_media2.html') { currentLocation="online_media.html"; }

  if (currentLocation == '') { currentLocation="index.html"; }
   for (var i=0; i<Links.length; i++) {		
    var currentHref = Links[i].getAttribute("href");		
				Links[i].getAttribute("class")
    var currentLeafName = getLeaf(currentHref);
    if (currentLeafName==currentLocation) {
      // Setting class is needed for Mozilla compatibility - className appears to be correct 
      // according to the DOM spec
      Links[i].parentNode.setAttribute("class", "currentpage");
      Links[i].parentNode.setAttribute("className", "currentpage");
						found=1;
    }
  }		
}
