
//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 myfilename=window.location.href.substring(window.location.href.lastIndexOf("/")+1,window.location.href.length);

	var section = window.location.href.replace('/'+myfilename, "");
	var section = section.substring(section.lastIndexOf("/")+1,section.length);
	
	
	
	var links = document.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(section == ""){
		section = "webmaps";
	}
	if(typeof section != "undefined"){
		document.getElementById(section).setAttribute((oldIE ? 'className' : 'class'), "on");
	}


 if(document.getElementsByTagName){  
   var rows = document.getElementsByTagName("tr");  
   for(i = 0; i < rows.length; i++){           
     if(i % 2 == 0){ 
       rows[i].className = "color_one";
     }else{ 
       rows[i].className = "color_two";
     }      
   }
}

}

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");
  popup.focus();
  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 = /blankTarget/;
			if (anchor.getAttribute("class")) {
				var classValue = anchor.getAttribute("class");
			}
			else{
				var classValue = anchor.getAttribute("className");
			}
			if (external.test(classValue)) {
				anchor.onclick = showPopup;
			}
		}
	}
	
}
window.onload = blankTargetLinks;