function validEmail(email){
  invalidChars = " /:,;";

  if (email ==" "){
    return false;
  }

  for (i=0; i<invalidChars.length; i++){
    badChar = invalidChars.charAt(i);
    if(email.indexOf(badChar,0) > -1){
      return false;
    }
  }

  atPos =email.indexOf("@",1);
  if(atPos ==  -1) {
    return false;
  }

  periodPos = email.indexOf(".", atPos);
  if (periodPos == -1){
    return false;
  }

  if(periodPos+3 > email.length) {
   return false;
  }
  return true;
}

function isANum(str){

  for(i=0;i<str.length;i++){
    ch = str.substring(i,i+1);
    if (ch < "0" || ch > "9"){
      return false;
    }
  }
  return true;
}

function chkForm(formName){
 
 if (formName.q1_HorseName.value ==""){
    alert("Please enter the field of \"Name of Horse\"");
    formName.q1_HorseName.focus();
    formName.q1_HorseName.select();
    return false;
  }

 if (formName.q2_CountryFoaled.value ==""){
    alert("Please enter the field of \"Country Foaled\"");
    formName.q2_CountryFoaled.focus();
    formName.q2_CountryFoaled.select();
    return false;
  }

 if (formName.q3_HorseAge.value ==""){
    alert("Please enter the field of \"Age\"");
    formName.q3_HorseAge.focus();
    formName.q3_HorseAge.select();
    return false;
  }

 if (formName.q4_HorseSex.value ==""){
    alert("Please enter the field of \"Sex\"");
    formName.q4_HorseSex.focus();
    formName.q4_HorseSex.select();
    return false;
  }

 if (formName.q5_OwnerName1.value ==""){
    alert("Please enter the field of \"Name of Owner\"");
    formName.q5_OwnerName1.focus();
    formName.q5_OwnerName1.select();
    return false;
  }

 if (formName.q9_TrainerName.value ==""){
    alert("Please enter the field of \"Name of Trainer\"");
    formName.q9_TrainerName.focus();
    formName.q9_TrainerName.select();
    return false;
  }

 if (formName.q11_TrainerPhoneCode.value ==""){
    alert("Please enter the field of \"Country Code\"");
    formName.q11_TrainerPhoneCode.focus();
    formName.q11_TrainerPhoneCode.select();
    return false;
  }

 if (formName.q12_TrainerPhone.value ==""){
    alert("Please enter the field of \"Phone\"");
    formName.q12_TrainerPhone.focus();
    formName.q12_TrainerPhone.select();
    return false;
  }

	  if (formName.q13_TrainerFaxCode.value ==""){
		alert("Please enter either the field of \"Fax\" or \"Email\"");
		formName.q13_TrainerFaxCode.focus();
		formName.q13_TrainerFaxCode.select();
		return false;
	  }

	  if (formName.q14_TrainerFax.value ==""){
		alert("Please enter the field of \"Fax\"");
		formName.q14_TrainerFax.focus();
		formName.q14_TrainerFax.select();
		return false;
	  }

	 if (!validEmail(formName.q15_Email.value)){
	   alert("Please input a valid email address..");
	   formName.q15_Email.focus();
	   formName.q15_Email.select();
	   return false;
	 }
 
  return true;
 
}


