// JScript File

function selectBooking(control, controlToPopulate, ItemArray, GroupArray, IdxArray) {
  var myEle ;
  // 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 == "Location") {
    // Empty the third drop down box of any choices
    var objThird=getObject('Tidspunkt');
    for (var q=objThird.options.length;q>=0;q--) objThird.options[q] = null;
	objThird.size=1;
  }

  // ADD Default Choice - in case there are no values
  myEle=document.createElement("option");
  theText=document.createTextNode("[Vælg]");
  myEle.appendChild(theText);
  myEle.setAttribute("value","0");
  controlToPopulate.appendChild(myEle);


  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  var itm = 1;
  for (var x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;
      myEle.setAttribute("value", IdxArray[x]);
      var txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)
      controlToPopulate.appendChild(myEle)
      itm+=1;
    }
  }
  if(itm==1){itm=2}
  //controlToPopulate.size=itm;
}

function selectInfomode(control, controlToPopulate, ItemArray, GroupArray, IdxArray) {
  var myEle ;
  // 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("[Vælg]");
  myEle.appendChild(theText);
  myEle.setAttribute("value","0");
  controlToPopulate.appendChild(myEle);

  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  var itm = 1;
  for (var x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;
      myEle.setAttribute("value", IdxArray[x]);
      var txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)
      controlToPopulate.appendChild(myEle)
      itm+=1;
    }
  }
  if(itm==1){itm=2}
  //controlToPopulate.size=itm;
}



function selectUdskrift(control, controlToPopulate, ItemArray, GroupArray, IdxArray) {
  var myEle ;
  // 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("[Vælg]");
  myEle.appendChild(theText);
  myEle.setAttribute("value","0");
  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 (var x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;
      myEle.setAttribute("value", IdxArray[x]);
      var txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)
      controlToPopulate.appendChild(myEle)
    }
  }
}


