 /* This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
 
 
function List(node)
{
   this.values = new Array();
   this.meanings = new Array();
   
   if (node== null)
     return;

   ids = node.getElementsByTagName("codeValue");

   for (var i = 0; i < ids.length; i++) {
      id =  ids.item(i)
      var attr = id.attributes
      for (var ii = 0; ii < attr.length; ii++) {
       if (attr[ii].name == 'code')
         this.values[i]=attr[ii].value
       if    (attr[ii].name == 'value')
        this.meanings[i]=attr[ii].value
        }
   }
}


new List(null);
List.prototype.display = list_display;
List.prototype.size = list_size;
List.prototype.get = list_get;

function list_display(val, node)
{
  var i;

  var opt = document.createElement("option");
  node.appendChild(opt)
  
  opt.setAttribute("value", "");
  
  if (val > "")
    opt.selected = 'false';
  else
    opt.selected = 'true';
  
  opt.appendChild(document.createTextNode("Not Selected"));

  for (i=0; i<this.values.length; i++)
    {
      opt = document.createElement("option");
      node.appendChild(opt)
      opt.setAttribute('value', this.values[i]);
      if (val == this.values[i]) 
               opt.selected = 'true';
      //else slct = " "         
       
      opt.appendChild(document.createTextNode(this.meanings[i]));
      
    }

   return

}


function list_size() {    return this.values.length;  }


function list_get(lpos)
{

  e = document.forms[0].elements[lpos]
  
  var options = e.options
  var got = ""
  
  for (var i = 0; i < options.length; i++)
  {
     if (options[i].selected) 
     {
       if (got == "")
          got = options[i].value
       else 
         got += ";"+options[i].value;
     }    
  
  }
  
  return trim(got)
}

