function Validate()
{ if (document.appform.schooldistrict.value == "")    // schooldistrict field
    {  alert("Please select the child's school district.");
       document.appform.schooldistrict.focus();
       return false;
    } else if (document.appform.school.value == "")   		  // school field
    {  alert("Please select the child's school.");
       document.appform.school.focus();
       return false;
    } else if (document.appform.BirthMonth.value == "")   // Child birth month field
    {  alert("Please select the child's birth month.");
       document.appform.BirthMonth.focus();
       return false;
    } else if (document.appform.BirthDay.value == "")  		  // Child birth day field
    {  alert("Please fill in the child's birth day.");
       document.appform.BirthDay.focus();
       return false;
    } else if (document.appform.BirthYear.value == "") // Child birth year field
    {   alert("Please select the child's birth year.");
        document.appform.BirthYear.focus();
         return false;
    }  else if (document.appform.grade.value == "")  // grade field
    {   alert("Please select the appropriate grade.");
        document.appform.grade.focus();
        return false;
    }  else if (document.appform.sport.value == "")     // sport field
    {   alert("Please select the sport in which the child will participate.");
        document.appform.sport.focus();
        return false;
    }  else
    { return true; }
}
function getSchools()
{   if (document.getElementById("schooldistrict").value=="7") // If Tulsa, go to image map
        ImageMapWindow = window.open("tulsamap.php","ImgMapWindow","width=710,height=534,dependent,scrollbars=no,resizable=no");
    dropdown=document.getElementById("school");  // Clear old options
    for (var q=dropdown.options.length; q>=1; q--) dropdown.options[q]=null;
    dropdown.options[0].text="Please wait...";
    if (window.XMLHttpRequest)      //  branch for native XMLHttpRequest object
    {   req = new XMLHttpRequest();
        req.onreadystatechange=showSchools;
        req.open("GET", "findschools.php?district=" + document.getElementById("schooldistrict").value, true);
        req.send(null);
    } else if (window.ActiveXObject) //  branch for IE/Windows ActiveX version
    {   req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req)
        {   req.onreadystatechange=showSchools;
            req.open("GET", "findschools.php?district=" + document.getElementById("schooldistrict").value, true);
            req.send();
        }
    }
    return false;
   }
function showSchools()
{  if (req.readyState == 4)// only if req shows "complete"
   {  if (req.status == 200)  // only if "OK"
      {  stringschools=req.responseText;   // Get the stuff into an array
         //if (document.getElementById("schooldistrict").value == 9) { stringschools = stringschools + "PRIVATE=Private|"; }
         arrschools=stringschools.split("|");
      } else  // Could not get list
         arrschools=all_schools_saved;        // Restore saved list of all schools
      dropdown=document.getElementById("school");  // Clear old options
      for (var q=dropdown.options.length; q>=1; q--) dropdown.options[q]=null;
      for (x=0; x<arrschools.length-1; x++)  // Add options from array
      {  arrschool=arrschools[x].split("=");
         myEle = document.createElement("option") ;
         var txt = document.createTextNode(arrschool[1]);
         myEle.appendChild(txt);
         myEle.value=arrschool[0];
         dropdown.appendChild(myEle);
      }
      dropdown.options[0].text="Please select";
      /*dropdown=document.getElementById("sport");  // Clear old sports
      for (var q=dropdown.options.length; q>=1; q--) dropdown.options[q]=null;
      dropdown.options[0].text="Please select grade";
      document.getElementById("grade").options[0].selected=true;*/
    }
   return false;
}
function getSports()
{   dropdown=document.getElementById("sport");  // Get list of sports for school
    for (var q=dropdown.options.length; q>=1; q--) dropdown.options[q]=null;  // Clear old options
    dropdown.options[0].text="Please wait...";
    if (window.XMLHttpRequest)      //  branch for native XMLHttpRequest object
    {   req = new XMLHttpRequest();
        req.onreadystatechange=showSports;
        req.open("GET", "findsports.php?district=" + document.getElementById("schooldistrict").value + "&grade=" + document.getElementById("grade").value, true);
        req.send(null);
    } else if (window.ActiveXObject)  //  branch for IE/Windows ActiveX version
    {   req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req)
        {   req.onreadystatechange=showSports;
            req.open("GET", "findsports.php?district=" + document.getElementById("schooldistrict").value + "&grade=" + document.getElementById("grade").value, true);
            req.send();
        }
      }
    return false;
}
function showSports()
{   if (req.readyState == 4)  // only if req shows "complete"
    { if (req.status == 200)  // only if "OK"
      {    arrsports=req.responseText.split("|");  // Get the stuff into an array
      }  else  // Could not get list
      {    arrsports=all_sports_saved; // Restore saved list of all schools
      }
			dropdown=document.getElementById("sport");  // Clear old options
      for (var q=dropdown.options.length; q>=1; q--) dropdown.options[q]=null;
      for (x=0; x<arrsports.length-1; x++)  // Add options from array
      { arrsport=arrsports[x].split("=");
        myEle = document.createElement("option") ;
        var txt = document.createTextNode(arrsport[1]);
        myEle.appendChild(txt);
        myEle.value=arrsport[0];
        dropdown.appendChild(myEle);
      }
      if (dropdown.options.length > 1)
        dropdown.options[0].text="Please select"; 
      else
        dropdown.options[0].text="No sports available for grade/school"; 
    }
   return false;
}
function schoolSelected()
{   if (document.getElementById("school").value == "PRIVATE")
    {   confirmboxtext="Students attending Bishop Kelly schools may elect to compete in sports programs at either the school they attend, or the school district in which they reside. Would you like to choose from the list of Bishop Kelly schools?\n\n(click OK to select a school in the Bishop Kelly district, or Cancel to reselect from schools in your district of residence.)";
        dropdown=document.getElementById("schooldistrict");
        if (confirm(confirmboxtext)) // "true" - Bishop Kelly selected
        {   for (var q=dropdown.options.length-1; q>=0; q--)
            {   if (dropdown.options[q].text == "Bishop Kelly")
                   dropdown.options[q].selected=true; 
                else
                   dropdown.options[q].selected=false; 
            }
        }
        return getSchools();
    }
    else return false;
}
function birthYearSelected()
{    return false;
}
<!-- Original:  Ben McFarlin (mcfarlin@netscape.net) -->
<!-- Web Site:  http://sites.netscape.net/mcfarlin -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function populate(objForm,selectIndex) //number of days in month
{ if (objForm.BirthYear.options[objForm.BirthYear.selectedIndex].value=="")
  { theYear="2000"; }
  else
  { theYear=objForm.BirthYear.options[objForm.BirthYear.selectedIndex].text; }
  // timeA = new Date(objForm.BirthYear.options[objForm.BirthYear.selectedIndex].text, objForm.BirthMonth.options[objForm.BirthMonth.selectedIndex].value,1);
  timeA = new Date(theYear, objForm.BirthMonth.options[objForm.BirthMonth.selectedIndex].value,1);
  timeDifference = timeA - 86400000;
  timeB = new Date(timeDifference);
  var daysInMonth = timeB.getDate();
  for (var i = 0; i < objForm.BirthDay.length; i++) 
    { objForm.BirthDay.options[0] = null; }
  for (var i = 0; i < daysInMonth; i++) 
    {
     objForm.BirthDay.options[i] = new Option(i+1);
     objForm.BirthDay.options[i].value = i+1;
    }
  document.appform.BirthDay.options[0].selected = true;
}
