//Validates the contact form
//

function validate_mod1() {

//validates that the entry is formatted as a valid email
function isEMailAddr(elem) {
	var str =elem.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re)) {
		return false;
	} else {
		return true;
	}
}



if (document.mod1.name.value.length<2) {
    alert("Please enter your name.");
    document.mod1.name.focus();
    return false;
  }
if ((document.mod1.call_me.checked) && (document.mod1.phone.value.length<6)) {
    alert("Please enter a valid phone number so we can call you back.");
    document.mod1.phone.focus();
    return false;
  }

if (!isEMailAddr(document.mod1.email_1)){
    alert("Please enter a valid email address.");
    document.mod1.email_1.focus();
    return false;
  }

//check that first and second email address are the same
if (document.mod1.email_1.value != document.mod1.email_2.value){
    alert("Email addresses not the same.");
    document.mod1.email_2.focus();
    return false;
  }

if (document.mod1.enquiry.value.length<1){
    alert("What's the question.");
    document.mod1.enquiry.focus();
    return false;
  }
return true;
}

