window.onload = rolloverInit;

function rolloverInit() {
	for(var i=0; i<document.images.length; i++) {
		setupRollover(document.images[i]);
	}
}

function setupRollover(thisImage) {
	if(thisImage.id != "") {
		thisImage.outImage = new Image();
		thisImage.outImage.src = "images/button_" + thisImage.id + ".jpg";
		thisImage.onmouseout = rollOut;
		
		thisImage.overImage = new Image();
		thisImage.overImage.src = "images/button_" + thisImage.id + "2.jpg";
		thisImage.onmouseover = rollOver;
		
		thisImage.parentNode.childImage = thisImage;
		thisImage.parentNode.onblur = rollOutChild;
		thisImage.parentNode.onfocus = rollOverChild;
	}
}

function rollOut() {
	this.src = this.outImage.src;
}

function rollOver() {
	this.src = this.overImage.src;
}

function rollOutChild() {
	this.childImage.src = this.childImage.outImage.src;
}

function rollOverChild() {
	this.childImage.src = this.childImage.overImage.src;
}

function exitStrategy() {
	var truth = confirm("By accessing the noted link you will be leaving Mountain America Credit Union's Web site and entering a Web site hosted by another party. Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of Mountain America Credit Union's Web site. MACU is not responsible for the content of the third party site and we do not represent the third party or the member if the two enter into a transaction. We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different from those of Mountain America Credit Union's.");
	if(truth) {
		return true;
	} else {
		return false;
	}
}
function checkMe(value, id) {
	var value;
	var id;
	if(value == "") {
		document.getElementById(id).style.background = "#FF9999";
		document.getElementById(id).style.border = "solid 1px #7F9DB9";
		document.getElementById(id).style.padding = "2px 1px";
	} else {
		if(id == "zip") {
			if(isNaN(value)) {
				alert("The zip code field can only contain numbers.");
				document.getElementById(id).style.background = "#FF9999";
				document.getElementById(id).style.border = "solid 1px #7F9DB9";
				document.getElementById(id).style.padding = "2px 1px";
				exit;
			}
		}
		if(id == "bPhone") {
			rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);
			if (!rePhoneNumber.test(value)) {
				alert("Phone Number Must Be Entered As: (555) 555-1234");
				document.getElementById(id).style.background = "#FF9999";
				document.getElementById(id).style.border = "solid 1px #7F9DB9";
				document.getElementById(id).style.padding = "2px 1px";
				exit;
			}
		}
		if(id == "email") {
			var AtPos;
			AtPos = value.indexOf("@");
			StopPos = value.lastIndexOf(".");
			if(AtPos == -1 || StopPos == -1) {
				alert("Please enter a valid email address.");
				document.getElementById(id).style.background = "#FF9999";
				document.getElementById(id).style.border = "solid 1px #7F9DB9";
				document.getElementById(id).style.padding = "2px 1px";
				exit;
			} else if(StopPos < AtPos) {
				alert("Please enter a valid email address.");
				document.getElementById(id).style.background = "#FF9999";
				document.getElementById(id).style.border = "solid 1px #7F9DB9";
				document.getElementById(id).style.padding = "2px 1px";
				exit;
			} else if(StopPos - AtPos == 1) {
				alert("Please enter a valid email address.");
				document.getElementById(id).style.background = "#FF9999";
				document.getElementById(id).style.border = "solid 1px #7F9DB9";
				document.getElementById(id).style.padding = "2px 1px";
				exit;
			}
		}
		document.getElementById(id).style.background = "#FFFFFF";
		document.getElementById(id).style.border = "solid 1px #7F9DB9";
		document.getElementById(id).style.padding = "2px 1px";
	}
}