// JScript source code

function checkForm(Form){

	
	if (Form.zip.value == ""){
			alert("You must provide your zip code.")
			return false
	}
	
	
	if (Form.email.value == ""){
		alert("You must provide an Email address.")
		return false
	}

	if (Form.name.value == ""){
			alert("You must provide your name.")
			return false
	}
	
	if(!ValidPhone(Form.phone.value))
		{
		return false
		}
	

	if (!validateEmail(Form.email.value)){
		alert("You must provide a valid Email address.")
		return false
	}
	
	return true
	
}

function validateEmail(emailAddress){
	atPos = emailAddress.indexOf("@",1)
	periodPos = emailAddress.indexOf(".",atPos)
	
	if (atPos == -1){
		return false
	}
	
	if (periodPos == -1){
		return false
	}
	
	if ((periodPos - atPos) < 3 ){
		return false
	}
	
	if ((emailAddress.length - periodPos) < 3){
		return false
	}
	
	return true

}

function ValidPhone(phone)
{
	var valid = "0123456789-";

		if(phone=="")
		{
		alert("You must provide a phone number.")
		return false
		}
		
		if(phone.length != 12)
		{
		alert("Invalid phone number! Format must be xxx-xxx-xxxx.")
		return false
		}
		
		
		for (var i=0; i < phone.length; i++)
		{
		temp = "" + phone.substring(i, i+1);
		
		
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your phone.  Format must be xxx-xxx-xxxx.")
			return false;
			}
		}
		
	
		return true
}




