// Form validation code
function SBW_Form1_Validator(theForm)
{

  var radioSelected = false;
  for (i = 0;  i < theForm.Request.length;  i++)
  {
    if (theForm.Request[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please select one of the \"Purpose of Request\" options.");
    return (false);
  }

  if (theForm.ApptDate.selectedIndex < 1)
  {
    alert("Please select one of the \"Appointment Date\" options.");
    theForm.ApptDate.focus();
    return (false);
  }

  if (theForm.ApptTime.value == "" || theForm.ApptTime.value == "Time")
  {
    alert("Please enter a value for the \"Appointment Time\" field.");
    theForm.ApptTime.focus();
    return (false);
  }

  if (theForm.Doctor.selectedIndex < 1)
  {
    alert("Please select one of the \"Doctor Name\" options.");
    theForm.Doctor.focus();
    return (false);
  }

  if (theForm.OfficeLocation.selectedIndex < 1)
  {
    alert("Please select one of the \"Office Location\" options.");
    theForm.OfficeLocation.focus();
    return (false);
  }

  if (theForm.PatientName.value == "")
  {
    alert("Please enter a value for the \"Patient Name\" field.");
    theForm.PatientName.focus();
    return (false);
  }

  if (theForm.PatientRelationship.selectedIndex < 1)
  {
    alert("Please select one of the \"Relationship to Patient\" options.");
    theForm.PatientRelationship.focus();
    return (false);
  }

  if (theForm.FirstName.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.LastName.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.Phone.value == "" && theForm.EMail.value == "")
  {
    alert("Please enter a value for either the \"Phone\" or \"E-Mail\" field.");
    theForm.Phone.focus();
    return (false);
  }

  return (true);
}

