// © 2004-2007, Applied Geographics, Inc.  All rights reserved.

var DropDownList_list = null;
var DropDownList_text = "";
var DropDownList_index = -1;
var DropDownList_handle = null;
var DropDownList_onchange = null;

function DropDownList_keyPress(list, event) {
  var keyCode = document.all ? event.keyCode : event.which;
  
  if (keyCode == 13 && list.onchange != null) {
    list.onchange();
    return true;
  }
  
  DropDownList_list = list;
  
  if (keyCode >= 32) {
    if (list.onchange != null) {
      DropDownList_onchange = list.onchange;
      list.onchange = null;
    }
    
    if (97 <= keyCode && keyCode <= 122) {
      keyCode -= 32;
    }
    DropDownList_text += String.fromCharCode(keyCode);
    
    textLen = DropDownList_text.length;

    for (var i = 0; i < list.options.length; ++i) {
      var optText = list.options[i].text.toUpperCase().substr(0, textLen);
      if (optText == DropDownList_text) {
        DropDownList_index = i;
        list.selectedIndex = 0;
        break;
      }
    }
  }

  setTimeout("DropDownList_setIndex()", 1);
  return false;
}

function DropDownList_reset() {
  DropDownList_text = "";
  DropDownList_index = -1;
}

function DropDownList_setIndex() {
  if (DropDownList_index > -1) {
    DropDownList_list.selectedIndex = DropDownList_index;
  }
  if (DropDownList_onchange != null) {
    DropDownList_list.onchange = DropDownList_onchange;
    DropDownList_onchange = null;
  }
  DropDownList_list = null;

  if (DropDownList_handle != null) {
    clearTimeout(DropDownList_handle);
    DropDownList_handle = null;
  }

  if (DropDownList_index > -1) {
    DropDownList_handle = setTimeout("DropDownList_reset()", 2000);
  }
}

