//This function validates all fields except for the special request field for contact_us.php
//Created by Ryan Aker 11/27/2008
	
	function check_form() {
		//gets the value of the input fields of the form
		firstname = document.referral.fname.value;
		lastname = document.referral.lname.value;
		email = document.referral.cemail.value;
		phone = document.referral.phone.value;
		message = document.referral.message.value;
		
		//checks to see if it is actually an e-mail format (somthing@somthing.com)		
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		
		var rePhone=/^\(\d\d\d\) \d\d\d-\d\d\d\d$/;
		//strips out characters that are not numbers
		var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
		
		//checks to make sure that the the fields are not blank
		if (firstname ==""){
			alert("Please type your first name");
			return false;
		}
		if (lastname ==""){
			alert("Please type your last name");
			return false;
		}
		if (email ==""){
			alert("Please type in an e-mail address");
			return false;
		}
		if (reg.test(email) == false) {
      		alert("Invalid Email Address");
      		return false;
		}
		if (phone == "") {
        	error = "You didn't enter a phone number.\n";
			alert(error);
			return false;
    	} 
		else if (!(stripped.length == 10)) {
        	error = "Please type the area code and phone number";
			alert(error);
			return false;
    	}
		else if (rePhone.test(phone)==false) {
			alert("Please input a valid phone number in format of (604) 123-1234");
			return false
		}
		if (message ==""){
			alert("Please type in a message");
			return false
		}
		
		else{
			return true;
		}
		
	}