sfHover = function() {
	var sfEls = document.getElementById("glocalnav").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"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function currentNav() {
	currPage = getCurrentPath();
	navdiv = document.getElementById("glocalnav")
	navli = navdiv.getElementsByTagName("li")
	if ((typeof(currPage[0])=="undefined")||currPage[0].length<2){
		for (var j = 0; j < navli.length; j++) {
			//console.log(cleanLastSlash(currPage).substr(0,4));
			//console.log(cleanLastSlash(getPath(navli[j].firstChild.href)).substr(0,4));
			if (cleanLastSlash(currPage).substr(0,4) == cleanLastSlash(getPath(navli[j].firstChild.href)).substr(0,4)) {
					navli[j].className = 'nav_current';
			}
		}

	}
	else {
		for (var i = 0; i < currPage.length; i++) {
			currPage[i];
			for (var j = 0; j < navli.length; j++) {
				if (currPage[i] == cleanLastSlash(getPath(navli[j].firstChild.href))) {
					navli[j].className = 'nav_current';
				}
			}
		}
	}
}

function getPath(someurl){
 d = document;
 csite = d.domain;
 sp = someurl.indexOf(csite) + csite.length;
 cpath = someurl.substring(sp);
 if (cpath.search(/index/)!=-1){
  re = "(.*?)\/index.shtml";
  myRe = new RegExp(re);
  cpath = cpath.match(myRe);
 }
return cpath;
}

function cleanLastSlash(someurl){
 lastchar = someurl.length-1;
 if (someurl.charAt(lastchar)=="/"){someurl = someurl.substring(0,(someurl.length-1))}
 return someurl;
}

