
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-22476190-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

  // extract the file name from a URL 
//("if input is /files/index.html", output is "index")
function extractPageName(hrefString)
{
  var arr = hrefString.split('.');
  arr = arr[arr.length-2].split('/');
  return arr[arr.length-1].toLowerCase();    
}

// search through all the links in array, if one points to
// the same file, apply the class .current to it and to its parent
function setActiveMenu(arr, crtPage)
{
  
  for(var i=0; i < arr.length; i++)
    //if(extractPageName(arr[i].href) == crtPage)
  if (!(crtPage.indexOf(extractPageName(arr[i].href)) ))  
  {
    
    arr[i].className = "current";
    arr[i].parentNode.className = "current";
  }
}

// call this method from your page
function setPage()
{
  if(document.location.href) 
    hrefString = document.location.href;
  else
    hrefString = document.location;

  if (document.getElementById("navlist")!=null)

    setActiveMenu(document.getElementById("navlist").getElementsByTagName("a"), extractPageName(hrefString));

  if (document.getElementById("underlinemenu")!=null)

    setActiveMenu(document.getElementById("underlinemenu").getElementsByTagName("a"), extractPageName(hrefString));
  
  }

