

function validateForm()
{

   var theForm = document.forms["form1"];

   var theButton = theForm.elements["Submit"];
   theButton.disabled = true;

   var radio = theForm.elements["required_Preferred_Gender"];
   var ok = false;
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please select a preferred gender.");
      radio[0].focus();
      return;
   }


   var text = theForm.elements["required_Desired_Dog_Age"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the desired age of the dog.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_Oldest_Dog"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the oldest age you would consider.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_Preferences"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your preferences for the dog you would like to adopt.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_Work_with_dog"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please describe how your family is willing to work with the dog.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_Characteristics"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please describe the behaviours that would be unacceptable to you or your family.");
      text.focus();
      return;
   }
   

   text = theForm.elements["required_Applicant_Name"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your name.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_App_Street_Address"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your street address.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_App_City"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your city.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_App_State"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your state.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_App_Zip"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your zip code.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_DL_Number"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your drivers license number.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_License_State"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the state that issued your drivers license.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_Home_Phone"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your home phone number.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_App_Email_Address"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your email address.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_App_DOB"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your date of birth.");
      text.focus();
      return;
   }
   
   var select = theForm.elements["required_People_in_Household"];
   ok = false;
   for (var i = 0; i < select.length; i++)
   {
      if (select[i].selected)
      {
         ok = true;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please select the number of people in your household.");
      select.focus();
      return;
   }

   text = theForm.elements["required_Kids_age"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your children's ages.");
      text.focus();
      return;
   }
   
   radio = theForm.elements["required_Allergic"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if anyone in your household is allergic to pets.");
      radio[0].focus();
      return;
   }

   radio = theForm.elements["required_Employed"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please select your employment status.");
      radio[0].focus();
      return;
   }
   if (val == "Employed")
   {
      text = theForm.elements["App_Employer"];
      if (text.value == "")
      {
         theButton.disabled = false;
         alert ("Please enter the name of your employer.");
         text.focus();
         return;
      }
   }   
   
   text = theForm.elements["required_CoApp_Name"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the name of your co-applicant.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_CoApp_Relationship"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please describe your relationship to the co-applicant.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_CoApp_Home_Phone"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the co-applicant's home phone number.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_CoApp_Email_Address"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the co-applicant's email address.");
      text.focus();
      return;
   }
   
   text = theForm.elements["required_CoApp_DOB"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the co-applicant's date of birth.");
      text.focus();
      return;
   }
   
   radio = theForm.elements["required_CoApp_Employed"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please select the co-applicant's employment status.");
      radio[0].focus();
      return;
   }
   if (val == "Employed")
   {
      text = theForm.elements["CoApp_Employer"];
      if (text.value == "")
      {
         theButton.disabled = false;
         alert ("Please enter the name of the co-applicant's employer.");
         text.focus();
         return;
      }
   }   
   
   
   radio = theForm.elements["required_Residence"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate your type of residence.");
      radio[0].focus();
      return;
   }

   radio = theForm.elements["required_Fenced_Yard"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate whether you have a fenced yard.");
      radio[0].focus();
      return;
   }
   if (val == "Yes")
   {
      text = theForm.elements["Fence_Describe"];
      if (text.value == "")
      {
         theButton.disabled = false;
         alert ("Please describe your fence.");
         text.focus();
         return;
      }
   }
   
   text = theForm.elements["required_Bathroom_Duties"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please describe how you will handle bathroom duties.");
      text.focus();
      return;
   }

   select = theForm.elements["required_Hours_Alone"];
   ok = false;
   for (var i = 0; i < select.length; i++)
   {
      if (select[i].selected)
      {
         ok = true;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please select how many hours the dog will spend alone.");
      select.focus();
      return;
   }

   text = theForm.elements["required_Absence"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please describe who will take care of the dog in the absence of the primary caregiver.");
      text.focus();
      return;
   }

   radio = theForm.elements["required_Return"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         if (radio[i].value == "Other") val = radio[i].value;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please select the reasons you would need to return the dog to NCSR.");
      radio[0].focus();
      return;
   }
   if (val == "Other")
   {
      text = theForm.elements["Return_Other_Explain"];
      if (text.value == "")
      {
         theButton.disabled = false;
         alert ("Please describe 'other'.");
         text.focus();
         return;
      }
   }

   radio = theForm.elements["Experience"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate whether you have researched miniature schnauzers or have had any experience with them.");
      radio[0].focus();
      return;
   }
   if (val == "Yes")
   {
      text = theForm.elements["Yes_Experience"];
      if (text.value == "")
      {
         theButton.disabled = false;
         alert ("Please describe your experience or research of miniature schnauzers.");
         text.focus();
         return;
      }
   }

   text = theForm.elements["required_Schnauzer_Characteristics"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please describe the good and bad characteristics of miniature schnauzers as you know them.");
      text.focus();
      return;
   }

   radio = theForm.elements["Responsibility"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if you are willing to take responsibility if the pet becomes ill.");
      radio[0].focus();
      return;
   }
   radio = theForm.elements["Finance"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if you are willing and financially able to pay veterinary costs.");
      radio[0].focus();
      return;
   }
   radio = theForm.elements["Behavioral"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if you are willing to work on behavioural issues");
      radio[0].focus();
      return;
   }
   radio = theForm.elements["Training"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if you would consider obedience training.");
      radio[0].focus();
      return;
   }

   text = theForm.elements["required_Adjust"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please describe how much time you are willing to allow for the dog to adjust to its new home.");
      text.focus();
      return;
   }

   radio = theForm.elements["required_Pets_5_Years"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if you have had pets in the last 5 years.");
      radio[0].focus();
      return;
   }

   text = theForm.elements["required_Current_Former_Pets"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please list your current or former pets.");
      text.focus();
      return;
   }

   text = theForm.elements["required_vet"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please list your current or former veterinarians.");
      text.focus();
      return;
   }

   radio = theForm.elements["Family_Dog"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate whether you consider a dog part of the family.");
      radio[0].focus();
      return;
   }

   radio = theForm.elements["Heartworm_Prevent"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate whether you will use monthly heartworm prevention.");
      radio[0].focus();
      return;
   }


   text = theForm.elements["required_OneRefName"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the reference's name.");
      text.focus();
      return;
   }
   text = theForm.elements["required_OneRefPhone"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the reference's phone number.");
      text.focus();
      return;
   }

   text = theForm.elements["required_TwoRefName"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the reference's name.");
      text.focus();
      return;
   }
   text = theForm.elements["required_TwoRefPhone"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the reference's phone number.");
      text.focus();
      return;
   }

   text = theForm.elements["required_ThreeRefName"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the reference's name.");
      text.focus();
      return;
   }
   text = theForm.elements["required_ThreeRefPhone"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter the reference's phone number.");
      text.focus();
      return;
   }

   radio = theForm.elements["required_Committed"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate whether you are committed to care for the dog over its lifetime.");
      radio[0].focus();
      return;
   }

   radio = theForm.elements["required_Leash"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate whether you will keep the dog on a leash.");
      radio[0].focus();
      return;
   }

   radio = theForm.elements["required_Wait"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if you are willing to wait for the right dog.");
      radio[0].focus();
      return;
   }

   radio = theForm.elements["required_Travel"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate whether you are willing to travel to pick up the odg.");
      radio[0].focus();
      return;
   }

   radio = theForm.elements["required_Donation"];
   ok = false;
   var val = "";
   for (var i = 0; i < radio.length; i++)
   {
      if (radio[i].checked)
      {
         ok = true;
         val = radio[i].value;
         break;
      }
   }
   if (!ok)
   {
      theButton.disabled = false;
      alert ("Please indicate if you are willing to make the required donation.");
      radio[0].focus();
      return;
   }

   text = theForm.elements["required_SignApp"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter your name.");
      text.focus();
      return;
   }
   text = theForm.elements["required_SignAppDate"];
   if (text.value == "")
   {
      theButton.disabled = false;
      alert ("Please enter today's date.");
      text.focus();
      return;
   }

   theForm.submit();
   
}
