////////////////////////////////////////////
// GENERIC OPTION LIST JAVASCRIPT FUNCTIONS

function select_generic( sel, avail )
{
   var idx = avail.selectedIndex;
   var selected = avail.options[idx].value;

   if (selected)
   {
      var new_opt = new Option(avail.options[idx].text, avail.options[idx].value);
      var count = sel.length;

      sel.options[count] = new_opt;
      avail.options[idx] = null;
   }
}

function unselect_generic( sel, avail )
{
   var idx = sel.selectedIndex;
   var selected = sel.options[idx].value;

   if (selected)
   {
      var new_opt = new Option(sel.options[idx].text, sel.options[idx].value);
      var count = avail.length;

      avail.options[count] = new_opt;
      sel.options[idx] = null;
   }
}

function storeGeneric( select, hidden )
{
   var values = "";
   var i;
   var el = select.options;

   for (i = 0; i < el.length; i++)
      values += el[i].value + ",";

   if (values.length > 0) 
      values = values.slice(0, values.length - 1);

   hidden.value = values;
}
