function formValidator(){
	// Make quick references to our fields from 
	var firstname = document.getElementById('firstname');
	var lastname = document.getElementById('lastname');
	var email = document.getElementById('email');
	var address1 = document.getElementById('address1');
	var city= document.getElementById('city');
	var state = document.getElementById('state');
	var zipcode = document.getElementById('zipcode');
	var country = document.getElementById('country');
	
	// Check each input in the order that it appears in the form!
	if(isAlphabet(firstname, "Please enter your first name")){
	if(isAlphabet(lastname, "Please enter your last name")){
	if(emailValidator(email, "Please enter a valid email address")){
	if(isEmpty(address1, "Please enter your street address")){
	if(cityValidator(city, "Please enter your city")){
	if(madeSelection(state, "Please Select a State")){
	if(isEmpty(zipcode, "Please enter a valid zip code")){
	if(madeSelection(country, "Please Select a Country")){
	return true;
	}
	}
	}
	}
	}
	}
	}
	}
	
	
	return false;
	
}

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

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

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

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

function madeSelection(elem, helperMsg){
	if(elem.value == "Select One"){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

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 cityValidator(elem, helperMsg){
	var alphaExp = /^([a-zA-Z]+|[a-zA-Z]+\s[a-zA-Z]+)$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}