function checkreset(f)
 { 
 if(confirm('This will lose your changes, do you want to continue?')) { f.reset(); } else { return false; }
 }

function echeck(str)
 {
 var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
 if (pattern.test(str) == false) { return false; }
 return true;
 }

function validate(f)
 {
	var y=f.name.value;
 if (!(y.charAt(0)>="a" && y.charAt(0)<="z"||y.charAt(0)>="A" && y.charAt(0)<="Z"))
  {
  alert("Please enter your Name");
  f.name.focus();
  return false;
  }
 
 var emailErr = false;
 var HphoneErr = false;
 var WphoneErr = false;
 var CellphoneErr = false;

// EMAIL TEST
 if (!echeck(f.email.value)) { var emailErr = true; }

// PHONE TESTS (REPLACE NON-NUMERICAL DATA)
 var phonePattern = /([^0-9])/g;
 var phoneReplace = '';
 var Hphone = f.phone.value.replace (phonePattern, phoneReplace);
 if (Hphone.length < 7) { var HphoneErr = true; }
 if (f.wphone)
  {
  var Wphone = f.wphone.value.replace (phonePattern, phoneReplace);
  if (Wphone.length < 7) { var WphoneErr = true; }
  }
 if (f.cellphone)
  {
  var Cellphone = f.cellphone.value.replace (phonePattern, phoneReplace);
  if (Cellphone.length < 7) { var CellphoneErr = true; }
  }

// CHECK FOR MINIMAL CONTACT (EMAIL OR PHONE)
 if (emailErr && HphoneErr && WphoneErr && CellphoneErr)
  {
  alert ('Please enter a valid phone number or email address where we may contact you.');
  f.Email_xr.focus();
  return false;
  }

 if(f.verificationcode.value=="")
  {
  alert("Please enter the correct verification code");
  f.verificationcode.focus();
  return false ;
  }

 return true;
 }
