
/* http://localhost/pre-emergency/ */
var strLocation = window.location.href;
var iOffset = strLocation.indexOf('/') + 4;
var iEnd = strLocation.length; 
var strMatch = (strLocation.substring(iOffset, iEnd));
//alert("URL STRING: " + strMatch);
	
function getIDFromHref(strHref) {
  	var iOffsetLI = strHref.indexOf('/') + 4;
  	var iEndLI = strHref.length; 
  	//alert("IDfromHREF " + strHref.substring(iOffsetLI, iEndLI));
  	return strHref.substring(iOffsetLI, iEndLI);
  } // end getIDFromHref
		
// Function to add class="current" to the appropriate LI
function addYouAreHere() {
	var listElement = document.getElementById("navigation");
	var sideElement = document.getElementById("sidenavigation");
	var subElement = document.getElementById("sublinks");
	var objAnchors = listElement.getElementsByTagName('a');
	var objSideAnchors = sideElement.getElementsByTagName('a');
	if(subElement != null) {
		var objSubAnchors = subElement.getElementsByTagName('a');
	}
    // Iterate through all anchors in the top navigation
        	for (var iCounter=0; iCounter<objAnchors.length; iCounter++) {
			//alert("first for: " + objAnchors[iCounter].href);
      	  	// Locate the associated li container,
          	// and style it
         	var strID = getIDFromHref(objAnchors[iCounter].href);
			if(strID == strMatch) {
				//alert("Match " + objAnchors[iCounter].parentNode.nodeName);
				objAnchors[iCounter].parentNode.className = 'current';
				}//end if match
		  	 }//end for
			 
			// Iterate throught all anchors in the footer 
			for (var iCounter=0; iCounter<objSideAnchors.length; iCounter++) {
			//alert("second for: " + objSideAnchors[iCounter].href);
      	  	// Locate the associated li container,
          	// and style it
         	var strID = getIDFromHref(objSideAnchors[iCounter].href);
			if(strID == strMatch) {
				//alert("Match " + objSideAnchors[iCounter].parentNode.nodeName);
				objSideAnchors[iCounter].parentNode.className = 'current';
				}//end if match
		  	 }//end for
			 
			 // Iterate throught all sublinks if there are any
			 if(subElement != null) {
			 for (var iCounter=0; iCounter<objSubAnchors.length; iCounter++) {
      	  	// Locate the associated li container,
          	// and style it
         	var strID = getIDFromHref(objSubAnchors[iCounter].href);
			if(strID == strMatch) {
				//alert("Match " + objSubAnchors[iCounter].parentNode.nodeName);
				objSubAnchors[iCounter].parentNode.className = 'current';
				}//end if match
		  	 }//end for
			 }// end if for subElement
		}//end ur here
		window.onload = addYouAreHere;
	
