document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
};

var eventListenerClass = {
addLoadListener:function(fn) {
	if (typeof window.addEventListener != 'undefined'){
		window.addEventListener('load', fn, false);
	} else if (typeof document.addEventListener != 'undefined')	{
		document.addEventListener('load', fn, false);
	} else if (typeof window.attachEvent != 'undefined'){
		window.attachEvent('onload', fn);
	} else {
		return false;
	}
	return true;
},
attachEventListener:function(target, eventType, functionRef, capture) {
    if (typeof target.addEventListener != "undefined") {
        target.addEventListener(eventType, functionRef, capture);
    } else if (typeof target.attachEvent != "undefined") {
        target.attachEvent("on" + eventType, functionRef);
    } else {
        return false;
    }
    return true;
}//end function
}; //end eventlistenerclass

eventListenerClass.attachEventListener(window, "load", initWindow, true);
//eventListenerClass.attachEventListener(window, "click", initWindow, true);
function initWindow(e) {
if(!document.getElementById || !document.createTextNode){return;}
	switch(e.type) {
		case 'load':
			//alert("load");	
			//nihinit.initToggleCategories();
			//nihinit.swapPic();
			nihinit.addPopUpLink();
			nihinit.closePopup();
			urhere_init.addYouAreHere();
			urhere_init.addYouAreHereTabs();
		break;
		case 'click':
			//alert("anotherfunction");
			//audio_videoToggle();
			//what to do;
		break;
		}//endswitch
		}//end initWindow switch
		

var nihinit = {
initToggleCategories:function() {
	// Hide the container with all toggleable elements 
	if(!document.getElementById('captiontextwrapper')){ return; }
	document.getElementById('captiontextwrapper').style.display = 'none';
	if(!document.getElementById('toggle')){ return; }
	var as = document.getElementById('toggle');
	var bs = document.getElementById('captiontextanchor');
	//alert("as " + as);
		as.onclick = function() {
		if(document.getElementById('captiontextwrapper').style.display == 'none'){
			document.getElementById('captiontextwrapper').style.display = 'block';
			as.firstChild.nodeValue = 'Close Information Box';
			bs.focus();
			return true;
		} else {
			document.getElementById('captiontextwrapper').style.display = 'none';
			as.firstChild.nodeValue = 'Please Read On';
			return false;
		}//end else
	}//end onclick function
},//end initToggle
swapPic:function() {
//alert("In swap");
if(!document.getElementById('middleobject')){ return; } 
var mo=document.getElementById('middleobject');
var pic = mo.getElementsByTagName('img');
	for (var i=0; i < pic.length; i++) {
	//alert(pic[i].src);
	var swapImg = (pic[i].src.search(/_off/i));
				if(swapImg != -1) {
				pic[i].onmouseover=function() {
					var imageSrc = this.src;
					var imageSrcLength = imageSrc.length;
					var indexLastSlash = imageSrc.toString().lastIndexOf('/', (imageSrcLength -1));
					var indexLastDash = imageSrc.toString().lastIndexOf('_', (imageSrcLength -1));
					//var indexLastDot = imageSrc.toString().lastIndexOf('.', (imageSrcLength -1));
					var imageName = imageSrc.substring(indexLastSlash +1,indexLastDash);
					this.src = (imageName + '_on.gif');
			}//end onclick
				pic[i].onmouseout=function() {
					var imageSrc = this.src;
					var imageSrcLength = imageSrc.length;
					var indexLastSlash = imageSrc.toString().lastIndexOf('/', (imageSrcLength -1));
					var indexLastDash = imageSrc.toString().lastIndexOf('_', (imageSrcLength -1));
					//var indexLastDot = imageSrc.toString().lastIndexOf('.', (imageSrcLength -1));
					var imageName = imageSrc.substring(indexLastSlash +1,indexLastDash);
					this.src = (imageName + '_off.gif');
			}//end onmouseout
			}//end if _off
	}// end for
},// end function
addPopUpLink:function() {
var popupClass='smallpopup';
var popupMessage=' (Opens in new window)';
var _POPUP_FEATURES = 'location=0,scrollbars=1,statusbar=0,menubar=0,width=500,height=500';
var pop, t;
var as=document.getElementsByTagName('a');
	for(var i=0; i<as.length; i++) {
		t=as[i].className;
		if(t && t.toString().indexOf(popupClass)!=-1) {
		//huntja createnode here
			if(as[i].firstChild.nodeName != 'IMG') {
				as[i].appendChild(document.createTextNode(popupMessage));
			} //end if
			as[i].onclick=function() {
				pop=window.open(this.href,'popup',_POPUP_FEATURES);
				pop.focus();
				return false;
			}//end onclick
		}//end if
	}//end for
},//end function
closePopup:function() {
if(!document.getElementsByClassName('jsclose')){ return; }
var js=document.getElementsByClassName('jsclose');
for(var i=0; i<js.length; i++) {
	js[i].innerHTML = ("<a href='#' onclick='self.close()'>Close Window</a>");
	}//end for
}//end closepopup
}//end class

var urhere_init = {
addYouAreHere:function() {
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 to add class="current" to the appropriate LI
	var listElement = document.getElementById("navcontainer");
	var objAnchors = listElement.getElementsByTagName('a');
    // Iterate through all anchors in the form
        	for (var iCounter=0; iCounter<objAnchors.length; iCounter++) {
			//alert("first for: " + objAnchors[iCounter].href);
      	  	// Locate the associated li container,
          	// and style it
         	var strID = urhere_init.getIDFromHref(objAnchors[iCounter].href);
			if(strID == strMatch) {
				//alert(strID);
				//alert("Match: String ID: " + strID + " LI: " + objAnchors[iCounter].href);
				objAnchors[iCounter].parentNode.className = 'current';
				//alert(objAnchors[iCounter].parentNode.className);
				}//end if match
		  	 }//end for
		},//end addyouarehere
		
addYouAreHereTabs:function() {
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 to add class="current" to the appropriate LI
	var listElement = document.getElementById("horizontalnav");
	var objAnchors = listElement.getElementsByTagName('a');
    // Iterate through all anchors in the form
        	for (var iCounter=0; iCounter<objAnchors.length; iCounter++) {
			//alert("first for: " + objAnchors[iCounter].href);
      	  	// Locate the associated li container,
          	// and style it
         	var strID = urhere_init.getIDFromHref(objAnchors[iCounter].href);
			if(strID == strMatch) {
				//alert(strID);
				//alert("Match: String ID: " + strID + " LI: " + objAnchors[iCounter].href);
				objAnchors[iCounter].parentNode.className = 'horcurrent';
				//alert(objAnchors[iCounter].parentNode.className);
				}//end if match
		  	 }//end for
		},//end addyouarehereTabs
			
getIDFromHref:function(strHref) {
  	var iOffsetLI = strHref.indexOf('/') + 4;
  	var iEndLI = strHref.length; 
  	//alert("IDfromHREF " + strHref.substring(iOffsetLI, iEndLI));
  	return strHref.substring(iOffsetLI, iEndLI);
  } // end getIDFromHref
}//end class