// Based on http://surguy.net/menu/highlight.html

function getLeaf(url) {
  return url.substring(url.lastIndexOf("/")+1);
}

function setNav() {
  if(!document.getElementById("navCell"))
      return;

  var currentLocation = getLeaf(document.location.href);
  var menu = document.getElementById("navCell");
  links = menu.getElementsByTagName("a");

  for (i=0; i<links.length; i++) {
    var currentHref = links[i].getAttribute("href");
    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].setAttribute("class", "currentPage");
      links[i].setAttribute("className", "currentPage");
    }
  }
}

