function validateBlank(form1, fieldname) {
  var fieldvalue = eval("form1." +fieldname +".value");
  if ( fieldvalue == "" || fieldvalue == null || !isNaN(fieldvalue) || fieldvalue.charAt(0) == ' ') {
	   alert("Please enter a valid " +fieldname +".");
	   eval("form1." +fieldname +".focus()");
	   return 1;
  }
  return 0;
}

function validateAntispam(form1) {
  if ( form1.antispam.value== "") {
	   alert("For security and anti-spam purposes, please enter the text in the image below.");
	   form1.antispam.focus();
	   return 1;
  }
  return 0;
}

function validateForm(form1, dofirstname, dosurname, doemail, doantispam, docomments) {
  var errors =0;
  if (dofirstname) { errors += validateBlank(form1, "firstname"); }
  if (dosurname) { errors += validateBlank(form1, "surname"); }
  if (docomments) { errors += validateBlank(form1, "comments"); }
  if (doemail) { errors += validateBlank(form1, "email"); }
  if (doantispam) { errors += validateAntispam(form1); }
  if (errors) {	return false; }
  else { return true; }
}
