sfHover = function() {
	var sfEls = document.getElementById("navbar").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//ARE WE USING EXPLORER?
var g_isIE = navigator.appName.indexOf("Microsoft")!=-1;
var userAgent = navigator.userAgent.toLowerCase();
var version = parseFloat((userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1]);
if(g_isIE && version <='7' ){
	var oldIE = true;
}
//ABSTRACTED CONNECT EVENT FUNCTION FOR ANY BROWSER
function connectEvent(element, event, handler) {
	if (g_isIE) {
		element.detachEvent("on" + event, handler);
		element.attachEvent("on" + event, handler);
	} else {
		element.addEventListener(event, handler, false);
	}
}
function activeSections() {
	var section = "home";
	var pathString=window.location.href.split("/");
	if(typeof pathString[3] != "undefined"){
		var section = pathString[3];
		var section = section.replace(".html", "");

	}
	if(typeof actSection != "undefined"){
		var section = activeSections;
	}
	if(typeof section != "undefined"){
		if(document.getElementById(section)){
			document.getElementById(section).setAttribute((oldIE ? 'className' : 'class'), "on");
		} 
		//Removed by JH - Makes the home button always active when new tabs are added.
		//else {
			//document.getElementById("home").setAttribute((oldIE ? 'className' : 'class'), "on");
		//}
	}
	var myfilename=window.location.href.replace("http://","");
	var myfilename=myfilename.replace(pathString[2],"");
	if(myfilename == ""){
		var myfilename = "index.html";
	}
	// Gets all <a> tags in html
	// var links = document.getElementsByTagName("A"); // removed due to incompatibility with productsmenu.js
	// Gets only <a> tags in id #navbar div
	var links = document.getElementById('navbar').getElementsByTagName("a");
	for ( i=0; i < links.length; i++ ) {
		if(links[i].getAttribute('href') == myfilename || links[i].getAttribute("href",2) == myfilename) {
			links[i].setAttribute(( oldIE ? 'className' : 'class'), "on");
		}
	}
}
connectEvent(window, "load", activeSections);
/**
 * Fixes the xhtml strict lack of target attribute on links.
 * 
 * Usage:
 * Add the class "blankTarget" to your link and this script will open the link in a new window.
 * <a href="someLocation.html" rel="window" title="Some Title">Popup</a>  
 * 
 */
function showPopup() {
  var popup = window.open(this.href, "popup", "status=1,toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1");
  return false;
}
function blankTargetLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href")) {
			var external = /window/;
			if (anchor.getAttribute("rel")) {
				var classValue = anchor.getAttribute("rel");
			}
			else{
				var classValue = anchor.getAttribute("rel");
			}
			if (external.test(classValue)) {
				anchor.onclick = showPopup;
			}
		}
	}
}
connectEvent(window, "load", blankTargetLinks);
