// CURRENT PAGE: Paste this anywhere. Include the ID of your menu <UL>, and call
// it once onload for each menu object you create.
// Note: You will probably have to edit this to make it work. The key line is
// the one that tests location.pathname (which is like '/folder/file.html'
// without any '?querystring' or '#bookmark'). I am trying to find the longest
// matching item and highlight that and all its parent links.
// Note 2: Add a rule like this:
//   .current-page { font-weight: bold }
// or similar to your stylesheet of course :).

function activePageHighlight(elm)
{
 if (typeof elm == 'string') elm = document.getElementById(elm);
 if (!elm) return;
 var links = elm.getElementsByTagName('a'), chosen = null;

 for (var i = 0; i < links.length; i++)
 {
  if (links.item(i).href.indexOf(location.pathname) > -1)
   if (!chosen || links[i].href.length > chosen.href.length) chosen = links[i];
 }

 while (chosen && chosen.className != 'menulist')
 {
  if (chosen.nodeName.toLowerCase() == 'li')
  {
   chosen.getElementsByTagName('a').item(0).className = 'current-page';
  }
  chosen = chosen.parentNode;
 }
};

