  var keys = "";

  function selectbox(name,width,height,class_name,extra,selected_value,selected_caption){
    this.name = name;
    this.extra = extra;
    this.selected_value = selected_value;
    this.selected_caption = selected_caption;
    this.width = width;
    this.height = height;
    this.boxes = new Array();
    this.hidden = true;
    this.class_name = class_name;
  }
  
  selectbox.prototype.add_box = function(value,caption){    // Define Method{    this.x += y;}
    this.boxes.push([value,caption]);
  }
  
  selectbox.prototype.show_select = function (){
    temp = this.name;
    document.write("<input type=\"hidden\" id=\""+this.name+"\" name=\""+this.name+"\" value=\""+this.boxes[0][0]+"\" />");
    document.write("<a href=\"#\" style=\""+this.extra+" width: "+(this.width+5)+"px;\" id=\""+this.name+"_caption\" onclick=\"toggle('"+this.name+"');\" onkeydown=\"find_character(event,'"+this.name+"');\">"+this.boxes[0][1]+"</a>");
    document.write("<div id=\""+this.name+"_box\" style=\"overflow: auto; height:"+this.height+"px; width:"+this.width+"px; clear: both; position: absolute; z-index: 1; display: none; border: 1px solid #ccc; background: #fff; margin-top: 0px; padding: 4px;\">");
    for(var x in this.boxes){
      document.write("<a href=\"#\" onclick=\"update('"+this.name+"','"+this.boxes[x][0]+"','"+this.boxes[x][1]+"');\">"+this.boxes[x][1]+"</a><br />"); 
    }    
    document.write("</div>");
    document.getElementById(this.name+"_caption").className = this.class_name;
    update(this.name,this.selected_value,this.selected_caption);
  }
 
  function clear_cache(){
    keys = "";
  }
  
  function find_character(e,what){
    keys += String.fromCharCode(e.keyCode).toString();
    this.setTimeout('clear_cache()', 1000)
    for(var i in eval("x = "+what+".boxes")){
      if(x[i][1].substr(0,keys.length).toLowerCase() ==  keys.toLowerCase() ){
        update(what,x[i][0],x[i][1]);
      }
    }
  }
  
  function update (name,value,caption) {
    document.getElementById(name).value = value;
    document.getElementById(name+"_caption").innerHTML = caption;
    document.getElementById(name+"_box").style.display = 'none';
  }
  function toggle(what){ 
    if(document.getElementById(what+"_box").style.display == 'none')
      document.getElementById(what+"_box").style.display = 'block';
    else
      document.getElementById(what+"_box").style.display = 'none';
  }
  

