// Generic JavaScript to support Dependent List Box Refresh ----------------------
// Don't change this code, just include in <head>...</head>
//
// Usage:
//   updateSubList
//      ParentID - parent ID, used in SQL selection to fill child-list
//      SubList  - child-list control name
//
function addOption(formname, name, title, id, selected) {
  var form = document.forms[formname];
  var select = form[name];

  select.options[select.options.length] = new Option(title, id);
  select.selectedIndex = (select.options.length == 1 ? 0 : select.selectedIndex);
  if(selected) {
    select.options[select.options.length - 1].selected = true;
    select.selectedIndex = select.options.length - 1;
  }
}

function updateSubList(ParentID, SubList, FrameName) {
  // Read Current Selection
  var ParentIDValue;
  if (ParentID.type == 'select-one') {ParentIDValue = ParentID.options[ParentID.selectedIndex].value;};
  if (ParentID.type == 'hidden') {ParentIDValue = ParentID.value;};

  // Store SubList ActiveID to pass it to popupDataRead
  if (FrameName == undefined) FrameName = 'puller';

  var SubListActiveID = (SubList.options.length > 0 ? SubList.options[SubList.selectedIndex].value : null);

  for(var i = SubList.options.length; i >= 0; i--) { SubList.options[i] = null; }           // Clear SubList Options
  SubList.selectedIndex = 0;

  window[FrameName].location = 'popupDataRead.asp?formname=' + SubList.form.name + '&SubListname=' + SubList.name + '&SubListActiveID=' + SubListActiveID + '&ParentID=' + ParentIDValue;
}
// Generic JavaScript to support Dependent List Box Refresh ------------------end-
  
