/*
CALLBACK FUNCTION FOR IMAGE SWAPPING
- SWAPS IMAGE & CANCELS DEFAULT LINK ACTION FOR FLIP PHOTO LINK
*/
function imageRoll(e) {
	// swap image
	if(this.firstChild){
			
			if(this.firstChild.src.indexOf("-over.jpg") != -1){
				// strip out last portion and replace string
				this.firstChild.src = this.firstChild.src.substr(0, this.firstChild.src.indexOf("-over.jpg")) + ".jpg";
			}
			else {
				this.firstChild.src = this.firstChild.src.substr(0, this.firstChild.src.indexOf(".jpg")) + "-over.jpg";
			}
		}
		
		// prevent default link action ONLY FOR FLIPLINK
		if(this.id == 'flipAnchor') {
			YAHOO.util.Event.preventDefault(e);
		}

}

/*
CALLBACK FUNCTION FOR OPEN WINDOW FUNCTIONS
- CANCELS DEFAULT LINK ACTION FOR ENLARGE IMAGE LINKS 7 OPENS NEW WINDOW
*/
function popup(e) {
	// get file location
	if(this.href) {
		// open popup window
		window.open(this.href, "enlarge", "width=500, height=500, scrollbars=1");
	}
	
	// prevent default action
	YAHOO.util.Event.preventDefault(e);
}


/*
// ----------------------
// ATTACH LISTENERS TO PAGE ELEMENTS (flip photo & enlarge image links)
//
// ----------------------
*/
function addListeners() {
	
	if(!document.getElementById || !document.getElementsByTagName) {
		return;
	}
	
	// 'Flip Photo' if it exists
	if(document.getElementById("flipAnchor")) {
		
		fliplink = document.getElementById("flipAnchor"); 
		YAHOO.util.Event.addListener(fliplink, "click", imageRoll);
	}
	
	// 'enlarge image' links
	if(document.getElementsByTagName("a")) {
		links = document.getElementsByTagName("a");
		
		// loop through links and look for "enlarge" class
		for(var i=0; i < links.length; i++) {
			
			if(links[i].className ==  "enlarge") {
				// add handlers
				YAHOO.util.Event.addListener(links[i], "mouseover", imageRoll);
				YAHOO.util.Event.addListener(links[i], "mouseout", imageRoll);
				YAHOO.util.Event.addListener(links[i], "click", popup);
				
				// preload the rollover images
				if(links[i].firstChild){
					// get rollover source
					preloadedImage = links[i].firstChild.src.substr(0, links[i].firstChild.src.indexOf(".jpg")) + "-over.jpg";
					// pass to MM function
					MM_preloadImages(preloadedImage);
				}
			}
		}
	}
}




window.onload = function(){
	P7_TMclass();
	P7_TMopenUrl(1,'/move/index.html'); MM_preloadImages('/images/functionbuttons/findbuttonrollover.gif', '/images/functionbuttons/pagetoproll.gif', '/images/functionbuttons/printablepage.gif', '/images/functionbuttons/emailpage.gif', '/images/functionbuttons/returntolistrollover.gif', '/move/images/photoflip-over.jpg');
	addListeners();
// focus firstname if accessible
if(document.getElementById('firstName')) {
  document.getElementById('firstName').focus();
}
}


