
function getLeaf(url) {
  return url.substring(url.lastIndexOf("/")+1);
}

function setNav() {
  var currentLocation = getLeaf(document.location.href);
  if (currentLocation=="") currentLocation="index.html";


         if (document.getElementById("navigation")) {
    var menu = document.getElementById("navigation");
    links = menu.getElementsByTagName("a");
    li    = menu.getElementsByTagName("li");

    for (i=0; i<links.length; i++) {
      var currentHref = links[i].getAttribute("href");
      var currentLeafName = getLeaf(currentHref);
      if (currentLeafName==currentLocation) {
        li[i].setAttribute("class", "selected");
        li[i].setAttribute("className", "selected");
      }
    }
  }
}