// JavaScript Document


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;
  if (control.name == "firstChoice") {

    for (var q=form.thirdChoice.options.length;q>=0;q--) form.thirdChoice.options[q] = null;
 }

  myEle = document.createElement("option") ;
  myEle.value = 0 ;
  myEle.text = "[Seleccionar]" ;

  controlToPopulate.appendChild(myEle)

  for ( x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;

      myEle.setAttribute('value',x);

      var txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)

      controlToPopulate.appendChild(myEle)
    }
  }
}

function selectChange(control, controlToPopulate, ItemArray, GroupArray) {
  var myEle ;
  var x ;

  for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
  if (control.name == "firstChoice") {

    for (var q=form.thirdChoice.options.length;q>=0;q--) form.thirdChoice.options[q] = null;
  }

  myEle=document.createElement("option");
  theText=document.createTextNode("[Seleccionar]");
  myEle.appendChild(theText);
  myEle.setAttribute("value","[Seleccionar]");
  controlToPopulate.appendChild(myEle);

  for ( x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;

      myEle.setAttribute("value",ItemArray[x]);

      var txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)

      controlToPopulate.appendChild(myEle)
    }
  }
}

