function formValidation(thisform) {
	var why = "";	
	
	why += checkEmpty(thisform.agreed,"Terms and Conditions");
	why += checkEmpty(thisform.first_name,"First name");
	why += checkEmpty(thisform.last_name,"Last name");
	why += checkEmail(thisform.email,"Email address");
	why += checkEmpty(thisform.add_state,"State");
	why += checkEmpty(thisform.phone_number,"Phone number");
		
		
	if(why != "") {
		alert(why);
		return false;
	} else {
		return true;
	}
}
	
function checkEmpty(thisfield,thisname) {
	var error = "";
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	
	if (thisfield.type == "checkbox") {
		if(thisfield.checked == false) {
			error = "Required field empty. "+thisname+"\n";
		}
	} else if (thisfield.type == "text") {
		if (thisfield.value == "") {
			error = "Required field empty. "+thisname+"\n";
		}
	}
	
	return error;
}

function checkEmail(thisfield,thisname) {
	var error = "";
	var emailFilter=/^[^@]+@[^@.]+\.[^@]*\w\w$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	
	if (!(emailFilter.test(thisfield.value))) { 
		error = "Please enter a valid email address. "+thisname+"\n";
	} else if (thisfield.value.match(illegalChars)) {
		error = "Email address contains illegal characters. "+thisname+"\n";
	}
	
	return error;
}

