/*
     $Revision$
     $Id$
*/
function updateDisc(purole, pautfunction)
{
  var lsrtdis_key = $("#srtdisc").val();
  $("#discmulti").load("../Shared/loadDisc.asp?urole=" + purole
                                           + "&autfunction=" + pautfunction
                                           + "&srtdisc_key=" + lsrtdis_key,
                       function ()
                       {
                         // Laad de stdmeldingen
                         updateStdm(purole, pautfunction);
                       });
}

function updateStdm(purole, pautfunction)
{
  var srtdisc_key = $("#srtdisc").val();
  var ldisc_key_arr = new Array();
  $('#discmulti :selected').each(function(i, selected)
                                   {
                                     ldisc_key_arr[i] = $(selected).val();
                                   });
  $("#sm").load("../Shared/loadStdmelding.asp?urole=" + purole
                                                 + "&autfunction=" + pautfunction
                                                 + (srtdisc_key > 0 ? "&srtdisc_key=" + srtdisc_key : "")
                                                 + (ldisc_key_arr.length != 0 ? "&disc_key_arr=" + ldisc_key_arr : ""));
}

function updateInsSrtGroup(pautfunction, psrtgroup, psrtdeel_arr)
{
  var ldis_key = $('#insdisc :selected').val();
  $("#inssrtgroup").load("../Shared/loadGroup.asp",
                         { autfunction:  pautfunction,
                           disc_key_arr: ldis_key,
                           module: "ins",
                           emptyOption: "",
                           psrtgroup: (psrtgroup? psrtgroup : []) },
                         function ()
                         {
                           // Laad de items
                           // Selecteer eventueel de initiële items die meegegeven kunnen worden
                           updateInsSrtDeel(pautfunction, psrtdeel_arr);
                         });
}

function updateInsSrtDeel(pautfunction, psrtdeel_arr)
{
  var lsrtgroup = $('#inssrtgroup :selected').val();
  $("#inssrtdeelmulti").load("../Shared/loadDeel.asp",
                             { autfunction :  pautfunction,
                               srtgroup_key_arr: lsrtgroup,
                               module: "ins",
                               psrtdeel_str: (psrtdeel_arr? psrtdeel_arr : []),
                               emptyOption: "",
                               multi: 1
                             });
}
