/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Revised by: DeWayne Whitaker :: http://www.aecdfw.com
Original by: Andrew Berry */

function selectChange(control, controlToPopulate, ItemArray, GroupArray) {
  var myEle ;
  var x ;
  // Empty the second drop down box of any choices
  for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

  // ADD Default Choice - in case there are no values
  myEle=document.createElement("option");
  theText=document.createTextNode("-Any-");
  myEle.appendChild(theText);
  myEle.setAttribute("value","");
  controlToPopulate.appendChild(myEle);
  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;
      txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)
      myEle.setAttribute("value", ItemArray[x]);
      controlToPopulate.appendChild(myEle)
    }
  }
}
