// JavaScript Document

function formValidator(){
	
	

	// Make quick references to our fields
	var name = document.getElementById('name');
//	var lastname = document.getElementById('lastname');
	var email = document.getElementById('email');
//	var email2 = document.getElementById('email2');
	var countyzip = document.getElementById('countyzip');

	// Check each input in the order that it appears in the form!
	//if(isAlphabet(name, "Please enter a valid First Name (letters only)")){
		//			if(empty(countyzip, "Please enter a valid zip code")){
						if (emailValidator(email, "Please enter a valid Email Address")){
							
								return true;
						}
	//				}
//	}	

	return false;
	
} // end form validator


function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function empty(elem, helperMsg){
	if(elem.value.length >  0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}



function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}



function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function emailEqual(elem, elem2, helperMsg){
	if(elem.value != elem2.value){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

