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() {
	debugger;
	var section = "home";
	var pathString=window.location.href.split("/");

	if(typeof pathString[3] != "undefined"){
		var section = pathString[3];
		var section = section.replace(".html", "");
		
		//EXCEPTIOM MAPPING
		if(section == "avl-solution"){var section = "solutions";}
		if(section == "national-emergency-center"){var section = "solutions";}
		if(section == "benefits-avl-solution"){var section = "solutions";}
		if(section == "benefits-gfc-solution"){var section = "solutions";}
		if(section == "benefits-mls-solution"){var section = "solutions";}
		if(section == "benefits-nec-solution"){var section = "solutions";}
		if(section == "benefits-sms-solution"){var section = "solutions";}
		if(section == "geo-fare-solution"){var section = "solutions";}
		if(section == "major-avl-features"){var section = "solutions";}
		if(section == "major-gfc-features"){var section = "solutions";}
		if(section == "major-nec-features"){var section = "solutions";}
		if(section == "major-sms-features"){var section = "solutions";}
		if(section == "mls"){var section = "solutions";}
		if(section == "national-emergency-center"){var section = "solutions";}
		if(section == "scheduling-monitering-system"){var section = "solutions";}
		if(section == "geo-fare-solution"){var section = "solutions";}
		if(section == "geo-fare-solution-cnt"){var section = "solutions";}
		if(section == "mytraining"){var section = "training";}
		if(section == "telcordia-training"){var section = "training";}
		if(section == "archibus-training"){var section = "training";}
		if(section == "project-services"){var section = "services";}
		if(section == "support-programs"){var section = "services";}
		if(section == "esri-products"){var section = "products";}
		if(section == "esri-news"){var section = "news";}
		if(section == "openware-news"){var section = "news";}
		if(section == "about-openware"){var section = "company";}
		if(section == "careers"){var section = "company";}
		if(section == "partners"){var section = "company";}
		if(section == "contact-us"){var section = "company";}
	}
	
	if(typeof actSection != "undefined"){
		var section = actSection;
	}

	if(typeof section != "undefined"){
		if(document.getElementById(section)){
			document.getElementById(section).setAttribute((oldIE ? 'className' : 'class'), "on");
		} 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");
		}
	}
	if(document.getElementById("homeTopper")) {

		var images = [];
		var links = [];
		
		images[0]	= 'v24_business2.jpg';
		links[0]	= '#';
		
		images[1]	= 'v24_cartography2.jpg';
		links[1]	= '#';

		images[2]	= 'v24_cartography3.jpg';
		links[2]	= '#';

		images[3]	= 'v24_cartography4.jpg';
		links[3]	= '#';

		images[4]	= 'v24_cartography5.jpg';
		links[4]	= '#';
		
		images[5]	= 'v24_cartography6.jpg';
		links[5]	= '#';
		
		images[6]	= 'v24_cartography7.jpg';
		links[6]	= '#';
		
		images[7]	= 'v24_cartography8.jpg';
		links[7]	= '#';
		
		images[8]	= 'v24_cartography32.jpg';
		links[8]	= '#';

		images[9]	= 'v24_cartography22.jpg';
		links[9]	= '#';

		images[10]	= 'v24_business22.jpg';
		links[10]	= '#';

	var min = 1;
		var max = images.length;

		var i = Math.floor(Math.random() * (max - min + 1)) + min;
		ht = document.getElementById("homeTopper");
		ht.style.backgroundImage="url(graphics/splash/"+images[0]+")";
		connectEvent(ht, "click", goTo);
		imgLink = links[0];

		if (typeof images[i] != "undefined") {
			document.getElementById("homeTopper").style.backgroundImage="url(graphics/splash/"+images[i]+")";
			imgLink = links[i];
		}
	}

}

function goTo() {
	document.location.href=imgLink; 
}

var imgLink = "";

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);