/* requires YAHOO main, Dom and Event scripts */

function rollover () {
	// is the image in the rollover state?
	if(this.src.indexOf("rollover.gif") != -1){
				// strip out last portion and replace string
				this.src = this.src.substr(0, this.src.indexOf("rollover.gif")) + ".gif";
			}
			else {
				this.src = this.src.substr(0, this.src.indexOf(".gif")) + "rollover.gif";
			}
}

window.onload = function() {
	// nav and image rollovers
	if(typeof window.P7_TMclass == 'function') {
             P7_TMclass();
        }
	// open the nav at the correct url
	if(typeof navURLtoOpen != 'undefined' && typeof window.P7_TMopenUrl == 'function') {
		P7_TMopenUrl(1, navURLtoOpen);
		}
	// preload any images if required
	if(typeof preloadImages != 'undefined' && typeof window.MM_preloadImages == 'function') {
		for(i = 0; i < preloadImages.length; i++) {
			MM_preloadImages(preloadImages[i]);
		}
	}
	
	// focus a specific field on page load
	if(typeof fieldToFocus != 'undefined' && document.getElementById(fieldToFocus)) {
		document.getElementById(fieldToFocus).focus();
	}	
	
	/* 
	add events for form checks (currently only meetings, bylaws and plans / policies search will use this)
	*/
	if(typeof searchCheck != 'undefined' && document.getElementById('searchform') && typeof YAHOO != 'undefined') {
		// get element
		YAHOO.util.Event.addListener(document.getElementById('searchform'), 'submit', checkSearchString);
	}
	
	/*
	handlers for printable page and return buttons
	*/
	// printable page
	if(typeof YAHOO != 'undefined' && typeof YAHOO.util != 'undefined' && typeof YAHOO.util.Dom != 'undefined') {
	
		var ppagebuttons = YAHOO.util.Dom.getElementsByClassName('printablepage', 'img');
		if(ppagebuttons) {
			// set handler for mouseover, mouseout
			YAHOO.util.Event.addListener(ppagebuttons, 'mouseover', rollover);
			YAHOO.util.Event.addListener(ppagebuttons, 'mouseout', rollover);
		}
		
		// print page
		var printbuttons = YAHOO.util.Dom.getElementsByClassName('printpage', 'img');
		if(printbuttons) {
			// set handler for mouseover, mouseout
			YAHOO.util.Event.addListener(printbuttons, 'mouseover', rollover);
			YAHOO.util.Event.addListener(printbuttons, 'mouseout', rollover);
		}
	}
}

