// Set focus to current menu item
var focusMenuPath;  // manual override
focusCurrentMenuItem = function () {
 var domain = window.location.protocol + "//" + window.location.host;
 var path = window.location.pathname;
 if (focusMenuPath) { path = focusMenuPath; }
 var els = document.getElementById("nav").getElementsByTagName("A");
 for (var i=0; i<els.length; i++) {
  var h = els[i].getAttribute("href").replace(domain,''); // fix IE absolute href bug
  if (h == path) {
   els[i].className="focus";
   // has subemu?
   var siblingUl = els[i].parentNode.getElementsByTagName("UL");
   if (siblingUl.length > 0) {
    siblingUl[0].className="focus";
   }
   // is submenu?
   var parentUL = els[i].parentNode.parentNode;
   var parentLI = parentUL.parentNode;
   var parentA = parentLI.firstChild;
   if (parentLI.nodeName=="LI" && parentUL.nodeName=="UL" && parentA.nodeName=="A") {
    parentUL.className="focus";
	parentA.className="focus";
   }
   break;
   }
  }
}
// Navigation, for older browsers that does not support li:hover  pseudo class
sfHover = function() {
 var sfEls = document.getElementById("nav").getElementsByTagName("LI");
 for (var i=0; i<sfEls.length; i++) {
  sfEls[i].onmouseover=function() {
  this.className+=" sfhover";
  }
  sfEls[i].onmouseout=function() {
   this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
   }
  }
 }
// change class on parent li - all browsers
subMenuHover = function() {
 var smhEls = document.getElementById("nav").getElementsByTagName("UL");
 for (var i=0; i<smhEls.length; i++) {
  if (smhEls[i].parentNode.firstChild.nodeName=="A") {
   smhEls[i].onmouseover=function() {
    this.parentNode.firstChild.className+=" focus";
    }
   smhEls[i].onmouseout=function() {
    this.parentNode.firstChild.className=this.parentNode.firstChild.className.replace(new RegExp(" focus\\b"), "");
    }
   }
  }
 }
if (window.addEventListener) { // gecko, safari, konqueror and standard
window.addEventListener('load', focusCurrentMenuItem, false);
window.addEventListener('load', subMenuHover, false);
}
else if (document.addEventListener) { // opera 7
document.addEventListener('load', focusCurrentMenuItem, false);
document.addEventListener('load', subMenuHover, false);
}
else if (window.attachEvent) {  // win/ie
window.attachEvent("onload", focusCurrentMenuItem);
window.attachEvent("onload", sfHover);
window.attachEvent("onload", subMenuHover);
}
