// JavaScript Document

// CHECKS ALL LINKS ON PAGE: IF PARENTNODE ID = LEFTNAV AND HREF = LOC THEN CLASSNAME is ONTHISPAGE
function showURL(){
	var loc = document.location.href;
	if(document.location.hash != '' || document.location.search != '') { // if theres a hash (#top) or search (?q=21) in the URL
		var a = document.location.href; //get url with hash and search e.g. http://www.apfc.org/home/Content/home/search.cfm?q=21
		var b = document.location.pathname; //get pathname to this page from web root e.g. /home/Content/home/search.cfm
		var lastPos = a.lastIndexOf(b);
		var theLength = (lastPos + b.length);
		loc = a.substring(0,theLength);
	}
	
	
	var links = document.links;
	var i = 0;
	for(i=0;i<links.length;i++) {
		if(links[i].parentNode.id == 'navLeft' && links[i].href == loc) {
				links[i].className = 'onThisPage';
			}
	} //end for loop
}
var win = window;
win.onfocus = showURL;