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