// FUNCTIONS USED WITH A SELECT BOX.
// WRITTEN BY RUSS HAWKINS.
// ClearSelectBox(TheSelect) - Clears a select box
// GetListIndex(TheSelect) - Returns the index of the selected item.
// GetSelected(TheSelect,lIndex) - Returns true or false if this item is selected.
// SetSelected(TheSelect,lIndex,bIsSelected) - Sets whether or not this item is selected.
// GetListIndex(TheSelect) - Returns the index of the selected item.
// GetListCount(TheSelect) - Returns the number of items.
// GetValue(TheSelect) - Returns the value of the selected item.
// GetText(TheSelect) - Returns the text of the selected item.
// GetListValue(TheSelect,lRow) - Returns the value of an item.
// GetListText(TheSelect,lRow) - Returns the text of an item.
// ChangeRow(TheSelect,lRow,sText,sValue) - Changes a row of a select box.

function ClearSelectBox(TheSelect)
{
  // CLEARS A SELECT BOX.
  var i;
  // null out in reverse order (bug workarnd)
  for(i=TheSelect.options.length-1;i>0;i--)
  {
   TheSelect.options[i] = null; 
  }
}

function GetSelected(TheSelect,lIndex)
{
  return(TheSelect.options[lIndex].selected);
}

function SetSelected(TheSelect,lIndex,bIsSelected)
{
  TheSelect.options[lIndex].selected=bIsSelected;
}

function GetListIndex(TheSelect)
{
  return(TheSelect.selectedIndex);
}

function GetListCount(TheSelect)
{
  return(TheSelect.length);
}

function GetValue(TheSelect)
{
  // RETURNS THE VALUE OF A SELECT BOX.
  var lIndex;
  lIndex = TheSelect.selectedIndex;
  if (lIndex<0)
  {
    return("");
  } else
  {
    return(TheSelect.options[lIndex].value);
  }
}
function GetText(TheSelect)
{
  // RETURNS THE TEXT OF A SELECT BOX.
  var lIndex;
  lIndex = TheSelect.selectedIndex;
  if (lIndex<0)
  {
    return("");
  } else
  {
    return(TheSelect.options[lIndex].text);
  }
}
function GetListValue(TheSelect,lRow)
{
  var TheOption;
  TheOption = TheSelect.options[lRow];
  if (TheOption == null)
  {
    return("");
  } else
  {
    return(TheOption.value);
  }
}
function GetListText(TheSelect,lRow)
{
  var TheOption;
  TheOption = TheSelect.options[lRow];
  if (TheOption == null)
  {
    return("");
  } else
  {
    return(TheOption.text);
  }
}
function ChangeRow(TheSelect,lRow,sText,sValue)
{
  // CHANGES THE TEXT AND THE VALUE OF A ROW IN A SELECT BOX.
  var TheOption;
  TheOption = new Option(sText,sValue);
  TheSelect.options[lRow] = TheOption;
  return;
}
