function swapImages() {
	setZ("image1",2);
	setZ("image2",1);
	setInterval('swapIt("image1","image2")',5000);
} 
function swapIt(id1, id2) {
var object1=document.getElementById(id1);
var object2=document.getElementById(id2);

var z1=object1.style.zIndex;
var z2=object2.style.zIndex;

object1.style.zIndex=z2;
object2.style.zIndex=z1;


} 

function setZ(id, z) {
	var object=document.getElementById(id);
	object.style.zIndex=z;
} 
function checkEmail(id)
{
	var emailPattern=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	return emailPattern.test(id);
}
 
function checkInfoNum()
{
	strng = document.getInfo;
	if( isNaN(strng.phone1.value)){
		strng.phone1.value="";
		showError("tryAgain");
		document.getElementById("tryAgain").innerHTML = "Please only enter numbers in the phone fields";
	}
	if( isNaN(strng.phone2.value)){
		strng.phone2.value="";
		showError("tryAgain");
		document.getElementById("tryAgain").innerHTML = "Please only enter numbers in the phone fields";
	}
	if( isNaN(strng.phone3.value)){
		strng.phone1.value="";
		showError("tryAgain");
		document.getElementById("tryAgain").innerHTML = "Please only enter numbers in the phone fields";
	}
} 
function showError(id) {
            object=document.getElementById(id);
            object.style.visibility="visible";
        }

function checkInfoForm() {
	
	if (document.getInfo.phone1.value.length < 3){
      	 	showError("tryAgain");
      	 	return false;
      	 }
      	else if (document.getInfo.phone2.value.length < 3){
      	 	showError("tryAgain");
      	 	return false;
      	 }
      	else if (document.getInfo.phone3.value.length < 4){
      	 	showError("tryAgain");
      	 	return false;
      	 }
	else if (document.getInfo.email.value.length != 0){
		var strng = document.getInfo.email.value;
		if (checkEmail(strng)==false){
			showError("tryAgain");
			document.getElementById('tryAgain').innerHTML = 'Please enter a valid email address';
      	 		return false;
      	 	}
	}

	else if (document.getInfo.firstname.value.length == 0){
      	 		showError("tryAgain");
      	 		return false;
      	 }
      	 else if (document.getInfo.lastname.value.length == 0){
      	 		showError("tryAgain");
      	 		return false;
      	 }

}
