var countrySite = "us";
var filterCountryCode = null;
var ct = new Array;
var idx = 0;
var hideShowSelects=true;
for (var i = 0; i <= 24; i++) {
  ct[i] = new Object();
}
resultCache=new Object(); // This is a cache of results from server... (was Ua)
var w="";
var pa=false;
var Va=(new Date()).getTime();
var hasXMLHTTP=false; // Gets set to true if XMLHTTP Supported (was Q)
var xmlHttp=null; // This is the XMLHttp Object... (was k)

for (var i = 0; i < 24; i++) {
ct[i].oldInputFieldValue=""; // inputField value (set during call to server...)...(was ta)
var da=false;
ct[i].currentInputFieldValue=""; // also inputField value (was g)
var G="";
ct[i].eventKeycode=""; // event keycode... (was m)
ct[i].highlightedSuggestionIndex=-1; // currently hightlighted suggestion index (was j)
ct[i].highlightedSuggestionDiv=null; // currently highlisted suggestion div... (was h)
ct[i].lyrRows=-1; // lyr rows at time of keypress... (was Z)
ct[i].lyrDivList=null; // lyr div list at time of keypress (was za)
ct[i].lyrRows2=5; // was Ca... initially 5? not sure difference between this and ct[idx].lyrRows...
var q="";
ct[i].divTag="div"; // Was Lb
ct[i].spanTag="span"; // Was Bb
//ct[i].documentForm=null; // Form on html page... (was la...)
ct[i].inputField=null; // Input field on form... (was a)
ct[i].lyr=null; // document.lyr (was b)
//ct[i].submitButton=null; // submit button (was Xa)
var mb=null;
var X=null;
ct[i].enString=null; // This becomes the string "en" (was ha)
ct[i].cursorUpDownPressed=false;  // Was ra...
var kc=null;
var hc=null;
var ca=1;
var Aa=1;
var Y=false;
ct[i].lastKeyCode=-1; // Gets set on keyDown... Was na...
ct[i].completeSearchString=null; // Gets set to "/complete/search" ... (was E)
var B=null;
var aa=null;
var Ba=false;
var Ka=false;
var p=60;
ct[i].searchString=null; // Gets set to "search" in installAC (was ia)
var ya=null;
ct[i].timeoutAdjustment=0; // timeout adjustment... (was W)... gets adjusted over time...
}

//initialize=function(from, to, next, h, country){
initialize=function(from, country){
  var countryIndex = 3;
  filterCountryCode = initialize.arguments[countryIndex];
  countrySite = country;
//  idx= 0;
//  InstallAC(from, to);
//  alert(idx + " --> " + ct[idx].inputField);
//  if (!ct[idx].inputField  || (typeof ct[idx].inputField == "undefined")) {
    InstallAC(from);
//  }
//  idx= 1;
//  InstallAC(to, next);
//  idx= 0;
//  hideShowSelects=h;  
}
InstallAC=function(fld){
  ct[idx].inputField=fld;
//  ct[idx].nextField=next;
    X=true;
    Y=false;
    Ba=false
    hd=false;
  ya=hd;

  installACPartTwo()
}
;

// blurs focus, then sets focus again...
// This isse getting aclled when we press cursor up / cursor down...
// Was Yb...
function blurThenGetFocus(){
  ct[idx].cursorUpDownPressed=true;
  ct[idx].inputField.blur();
  setTimeout("setInputFieldFocus();",10);
  return
}

// setup a keydown event...
// Was Fb...
function setupKeydown1(){
  if(document.createEventObject) {
    var y=document.createEventObject();
    y.ctrlKey=true;
    y.keyCode=70;
    document.fireEvent("onkeydown",y)
  }
}

// setup a keydown event...
// I can't figure out what calls this...
// was nc...
function setupKeydown2(vb){
  var y=document.createEventObject();
  y.ctrlKey=true;
  y.keyCode=vb;
  document.fireEvent("onkeydown",y)
}

function gc(event){}
function ic(event){}

// Was Pb
function keyDownHandler(event){
  if(!event&&window.event) {
    event=window.event;
  }
  if(event) {
    ct[idx].lastKeyCode=event.keyCode;
  }

  // We are backspacing here...
  if(event&&event.keyCode==8){
    if(X&&(ct[idx].inputField.createTextRange&&(event.srcElement==aa&&(bb(ct[idx].inputField)==0&&lb(ct[idx].inputField)==0)))){
      cc(ct[idx].inputField);
      event.cancelBubble=true;
      event.returnValue=false;
      return false
    }
  }
}

function mc(){}

// Was Db..
function resizeHandler(){
  if(w=="url"){
    setInputFieldSize()
  }
  setLyrSize()
}

// was ba...
function setLyrSize(){
  if(ct[idx].lyr){
    ct[idx].lyr.style.left=calculateOffsetLeft(ct[idx].inputField)+"px";
    ct[idx].lyr.style.top=calculateOffsetTop(ct[idx].inputField)+ct[idx].inputField.offsetHeight-1+"px";
    ct[idx].lyr.style.width=calculateWidth()+"px"
  }
}

// calculate width of inputField... Note browser specific adjustments...
// Was Ja()
function calculateWidth(){
  if(navigator&&navigator.userAgent.toLowerCase().indexOf("msie")==-1){
    return ct[idx].inputField.offsetWidth-ca*2
  }else{
    return ct[idx].inputField.offsetWidth
  }
}


// Called from InstallAC...
// was ac()
function installACPartTwo(){
  if(getXMLHTTP()){
    hasXMLHTTP=true
  }else{
    hasXMLHTTP=false
  }

  ct[idx].completeSearchString="cities.cgi";


  if(!hasXMLHTTP){
    setCookie("qu","",0,ct[idx].completeSearchString,null,null)
  }

  ct[idx].inputField.autocomplete="off";
  ct[idx].inputField.onblur=onBlurHandler;
  ct[idx].inputField.onkeypress=onKeyPressHandler;
  if(ct[idx].inputField.createTextRange) {
    ct[idx].inputField.onkeyup=new Function("return okuh(event);");
  } else {
    ct[idx].inputField.onkeyup=okuh;
  }
  ct[idx].currentInputFieldValue=ct[idx].inputField.value;
  ct[idx].oldInputFieldValue=ct[idx].currentInputFieldValue;
  if (document.getElementById("lyr" + idx)) {
    document.body.removeChild(ct[idx].lyr);
  }
  ct[idx].lyr=document.createElement("DIV");
  ct[idx].lyr.id="lyr" + idx;
  ca=1;
  Aa=1;
  ct[idx].lyr.style.borderRight="black "+ca+"px solid";
  ct[idx].lyr.style.borderLeft="black "+ca+"px solid";
  ct[idx].lyr.style.borderTop="black "+Aa+"px solid";
  ct[idx].lyr.style.borderBottom="black "+Aa+"px solid";
  ct[idx].lyr.style.zIndex="1";
  ct[idx].lyr.style.paddingRight="0";
  ct[idx].lyr.style.paddingLeft="0";
  ct[idx].lyr.style.paddingTop="0";
  ct[idx].lyr.style.paddingBottom="0";
  setLyrSize();
  ct[idx].lyr.style.visibility="hidden";
  ct[idx].lyr.style.position="absolute";
  ct[idx].lyr.style.backgroundColor="white";
  ct[idx].lyr.style.textAlign="left";
  document.body.appendChild(ct[idx].lyr);
  
  cacheResults("",new Array(),new Array());
  Gb(ct[idx].lyr);
/*
  var s=document.createElement("DIV");
  s.style.visibility="hidden";
  s.style.position="absolute";
  s.style.left="-10000";
  s.style.top="-10000";
  s.style.width="0";
  s.style.height="0";
  var M=document.createElement("IFRAME");
  M.lyr=ct[idx].lyr;
  M.name="completionFrame";
  M.id="completionFrame";
  s.appendChild(M);
  document.body.appendChild(s);
*/
  if(frames&&(frames["completionFrame"]&&frames["completionFrame"].frameElement)) {
    B=frames["completionFrame"].frameElement;
  } else {
    B=document.getElementById("completionFrame");
  }
  if(w=="url"){
    setInputFieldSize();
    setLyrSize()
  }
  window.onresize=resizeHandler;
  document.onkeydown=keyDownHandler;
  setupKeydown1()

}

function onKeyPressHandler(event){
  if(!event&&window.event) {
    event=window.event;
  }
  if (event.keyCode == 13) {
//    ct[idx].nextField.focus();
    return false;
  }
  return true;
}

// Was Ob
function onBlurHandler(event){
  if(!event&&window.event) {
    event=window.event;
  }
  if(!ct[idx].cursorUpDownPressed){
    hideLyr();
    // check if tab pressed...
    if(ct[idx].lastKeyCode==9){
//      setSubmitButtonFocus();
      ct[idx].lastKeyCode=-1
    }
  }

  ct[idx].cursorUpDownPressed=false
}

okuh=function(e){
  ct[idx].eventKeycode=e.keyCode;
  aa=ct[idx].inputField.value;
  Oa()
}
;
// Was Xb...
function setSubmitButtonFocus(){
 // ct[idx].submitButton.focus()
}

// Was sfi..
setInputFieldFocus=function(){
  ct[idx].inputField.focus()
}
;

// strip CR from string...
// was Wb
function stripCRFromString(va){
  for(var f=0,oa="",zb="\n\r"; f<va.length; f++) {
    if (zb.indexOf(va.charAt(f))==-1) {
      oa+=va.charAt(f);
    } else {
      oa+=" ";
    }
  }
return oa
}

// Find span value with className = dc...
// Was Qa
function findSpanValueForClass(i,dc){
  var ga=i.getElementsByTagName(ct[idx].spanTag);
  if(ga){
    for(var f=0; f<ga.length; ++f){
      if(ga[f].className==dc){
        var value=ga[f].innerHTML;
        if(value=="&nbsp;") {
          return"";
        }
        else{
          var z=stripCRFromString(value);
          return z
        }
      }
    }
  }else{
    return""
  }
}

// Return null if i undefined...
// otherwise return value of span cAutoComplete...
// was U
function valueOfCAutoComplete(i){
  if(!i) {
    return null;
  }
  return findSpanValueForClass(i,"cAutoComplete")
}

// Return null if i undefined...
// otherwise return value of span dAutoComplete...
// was wa
function valueOfDAutoComplete(i){
  if(!i) {
    return null;
  }
  return findSpanValueForClass(i,"dAutoComplete")
}

// Was F
function hideLyr(){
  document.getElementById("lyr" + idx).style.visibility="hidden"
//  if(hideShowSelects) {
//    if (idx == 0) {
//      document.getElementById("d0").style.visibility="visible";
//     document.getElementById("m0").style.visibility="visible";
//      document.getElementById("d1").style.visibility="visible";
//      document.getElementById("m1").style.visibility="visible";
//    }
//    else {
//     document.getElementById("t00").style.visibility="visible";
//      document.getElementById("t1").style.visibility="visible";
//    }
//  }
}
// Was cb
function showLyr(){
  document.getElementById("lyr" + idx).style.visibility="visible";
//  if(hideShowSelects) {
//    if (idx == 0) {
//      document.getElementById("d0").style.visibility="hidden";
//      document.getElementById("m0").style.visibility="hidden";
//      document.getElementById("d1").style.visibility="hidden";
//      document.getElementById("m1").style.visibility="hidden";
//    }
//    else {
//      document.getElementById("t00").style.visibility="hidden";
//      document.getElementById("t1").style.visibility="hidden";
//    }
//  }
//  setLyrSize()
}

// This is a result caching mechanism...
// was Ma
function cacheResults(is,cs){
//  alert("Caching " + is + " --> " + cs);
  resultCache[is]=cs;
}

// We get the following javascript code dynamically returned from server:
handle=function(is,cs, pr){
  if(ct[idx].timeoutAdjustment>0) {
    ct[idx].timeoutAdjustment--;
  }
  var lc=(new Date()).getTime();
  cacheResults(is,cs);
  var b=ct[idx].lyr;
  b.completeStrings=cs;
  b.prefixStrings=pr;
  displaySuggestedList(b,b.completeStrings);b
  Pa(b,valueOfCAutoComplete);
  if(ct[idx].lyrRows2>0) {
    b.height=16*ct[idx].lyrRows2+4;
  } else {
    hideLyr();
  }
}

function Oa(){
  // 38 is up cursor key, 40 is down cursor key...
  if(ct[idx].eventKeycode==40||ct[idx].eventKeycode==38) {
    blurThenGetFocus();
  }
  var N=lb(ct[idx].inputField);
  var v=bb(ct[idx].inputField);
  var V=ct[idx].inputField.value;
  if(X&&ct[idx].eventKeycode!=0){
    if(N>0&&v!=-1) {
      V=V.substring(0,v);
    }
    if(ct[idx].eventKeycode==13||ct[idx].eventKeycode==3){
      var d=ct[idx].inputField;
      if(d.createTextRange){
        var t=d.createTextRange();
        t.moveStart("character",d.value.length);
        t.select()
      } else if (d.setSelectionRange){
        d.setSelectionRange(d.value.length,d.value.length)
      }
    } else {
      if(ct[idx].inputField.value!=V) {
        selectEntry(V)
      }
    }
  }
  ct[idx].currentInputFieldValue=V;
  if(handleCursorUpDownEnter(ct[idx].eventKeycode)&&ct[idx].eventKeycode!=0) {
    Pa(ct[idx].lyr,valueOfCAutoComplete)
  }
}

function Fa(){
  return xb(w)
}

function xb(eb) {
  da=true;
  if(!hasXMLHTTP){
    setCookie("qu","",0,ct[idx].completeSearchString,null,null)
  }
  hideLyr();
  if(eb=="url"){
    var R="";
    if(ct[idx].highlightedSuggestionIndex!=-1&&h) {
      R=valueOfCAutoComplete(ct[idx].highlightedSuggestionDiv);
    }
    if(R=="") {
      R=ct[idx].inputField.value;
    }
    if(q=="") {
      document.title=R;
    } else {
      document.title=q;
    }
    var Tb="window.frames['"+mb+"'].location = \""+R+'";';
    setTimeout(Tb,10);
    return false
  } else if(eb=="query"){
//    ct[idx].documentForm.submit();
    return true
  }
}

newwin=function(){
  window.open(ct[idx].inputField.value);
  hideLyr();
  return false
}
;

idkc=function(e){
  if(Ba){
    var Ta=ct[idx].inputField.value;
    if(Ta!=aa){
      ct[idx].eventKeycode=0;
      Oa()
    }
    aa=Ta;
    setTimeout("idkc()",10)
  }
}
;
setTimeout("idkc()",10);

// Go read about encodeURIComponent here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsmthencodeuricomponent.asp
// Basically converts a string to a valid uri... (spaces become %20, etc, etc..)
// this function was nb...
function escapeURI(La){
  if(encodeURIComponent) {
    return encodeURIComponent(La);
  }
  if(escape) {
    return escape(La)
  }
}

// Was yb
// If Mb is 0, will return 150...
// If Mb is 3, will return 250...
// If Mb is 4, will return 450...
// If Mb is X, will return 850...
function recalculateTimeout(Mb){
  var H=30;
//  for(var o=1; o<=(Mb-2)/2; o++){
//    H=H*2
//  }
//  H=H+50;
  return H
}

// This function sets itself up and gets called over and over (timeout driven)
mainLoop=function(){
  if(ct[idx].oldInputFieldValue!=ct[idx].currentInputFieldValue){
    if(!da){
      var prefix= ct[idx].currentInputFieldValue.toLowerCase();
      var Za=escapeURI(prefix);
      var ma=resultCache[Za];
      if(!ma) {
        if(Za.length > 2) {
          var subPrefix=Za.substring(0,2);
          var t=resultCache[subPrefix];
          if (t) {
            ma=new Array();
            var x=0;
            for (var i=0; i < t.length; i++) {
              if (t[i].toLowerCase().indexOf(prefix) == 0) {
                ma[x++]= t[i];
                if (x > 9) break;
              }
            }
          }
        }
      }
      if(ma){
        // Found in our cache...
        Va=-1;
//        handle(ct[idx].currentInputFieldValue,ma)
        handle(ct[idx].currentInputFieldValue,ma,new Array(""));
      }else{
        ct[idx].timeoutAdjustment++;
        Va=(new Date()).getTime();
        if(hasXMLHTTP){
          callServer(Za);
        }else{
          setCookie("qu",Za,null,ct[idx].completeSearchString,null,null);
          frames["completionFrame"].document.location.reload(true)
        }
      }
      ct[idx].inputField.focus()
    }
    da=false
  }
  ct[idx].oldInputFieldValue=ct[idx].currentInputFieldValue;
  setTimeout("mainLoop()",recalculateTimeout(ct[idx].timeoutAdjustment));
  return true
}
;
// Call mainLoop() after 10 milliseconds...
setTimeout("mainLoop()",10);

// This is onMouseDown function...
var Cb=function(){
  selectEntry(valueOfCAutoComplete(this));
  q=valueOfDAutoComplete(this);
  da=true;
  Fa()
}
;

// on mouseover...
var pb=function(){
  if(ct[idx].highlightedSuggestionDiv) {
    setStyleForElement(ct[idx].highlightedSuggestionDiv,"aAutoComplete");
  }
  setStyleForElement(this,"bAutoComplete")
}
;

// On Mouse out...
var ec=function(){
  setStyleForElement(this,"aAutoComplete")
}
;

// Called when cursor up/down pressed... selects new entry in lyr...
// was Na
function highlightNewValue(C){
  ct[idx].currentInputFieldValue=G;
  selectEntry(G);
  q=G;
  if(!ct[idx].lyrDivList||ct[idx].lyrRows<=0) {
    return;
  }
  showLyr();
  if(C>=ct[idx].lyrRows){
    C=ct[idx].lyrRows-1
  }
  if(ct[idx].highlightedSuggestionIndex!=-1&&C!=ct[idx].highlightedSuggestionIndex){
    setStyleForElement(ct[idx].highlightedSuggestionDiv,"aAutoComplete");
    ct[idx].highlightedSuggestionIndex=-1
  }
  if(C<0){
    ct[idx].highlightedSuggestionIndex=-1;
    ct[idx].inputField.focus();
    return
  }
  ct[idx].highlightedSuggestionIndex=C;
  ct[idx].highlightedSuggestionDiv=ct[idx].lyrDivList.item(C);
  setStyleForElement(ct[idx].highlightedSuggestionDiv,"bAutoComplete");
  ct[idx].currentInputFieldValue=G;
  q=valueOfDAutoComplete(ct[idx].highlightedSuggestionDiv);
  selectEntry(valueOfCAutoComplete(ct[idx].highlightedSuggestionDiv))
}

// Was Eb
// returns false if cursor up / cursor down or enter pressed...
function handleCursorUpDownEnter(eventCode){
  if(eventCode==40){
    highlightNewValue(ct[idx].highlightedSuggestionIndex+1);
    return false
  }else if(eventCode==38){
    highlightNewValue(ct[idx].highlightedSuggestionIndex-1);
    return false
  }else if(eventCode==13||eventCode==3){
    return false
  }
  return true
}

// Pa(lyr,H)
// This function gets called for every keypress I make...
function Pa(localLyr,ib){
  var localInputField=ct[idx].inputField;
  var T=false;
  ct[idx].highlightedSuggestionIndex=-1;
  // This becomes the rows in our suggestion list...
  var J=localLyr.getElementsByTagName(ct[idx].divTag);
  // # of rows in list...
  //alert(J.length);
  var O=J.length;
  ct[idx].lyrRows=O;
  ct[idx].lyrDivList=J;
  ct[idx].lyrRows2=O;
  G=ct[idx].currentInputFieldValue;
  if(ct[idx].currentInputFieldValue==""||O==0){
    hideLyr()
  }else{
    showLyr()
  }
  var Ab="";
  if(ct[idx].currentInputFieldValue.length>0){
    var f;
    var o;
    // My prefixStrings was always an empty array...
    // So local variable T never would be set to true...
    // And the local variable Ab would remain empty...
    for(var f=0; f<O; f++){
      if (localLyr.prefixStrings) {
        for(o=0; o<localLyr.prefixStrings.length; o++){
          var Ib=localLyr.prefixStrings[o]+ct[idx].currentInputFieldValue;
          if(Y||ib(J.item(f)).toUpperCase().indexOf(Ib.toUpperCase())==0) {
            Ab=localLyr.prefixStrings[o];
            T=true;
            break
          }
        }
      }
      if(T){
        break
      }
    }
  }
  if(T) {
    ct[idx].highlightedSuggestionIndex=f;
  }
  for(var f=0; f<O; f++) {
    setStyleForElement(J.item(f),"aAutoComplete");
  }
  if(T){
    ct[idx].highlightedSuggestionDiv=J.item(ct[idx].highlightedSuggestionIndex);
    q=valueOfDAutoComplete(ct[idx].highlightedSuggestionDiv)
  }else{
    q=ct[idx].currentInputFieldValue;
    ct[idx].highlightedSuggestionIndex=-1;
    ct[idx].highlightedSuggestionDiv=null
  }
  var ab=false;
  switch(ct[idx].eventKeycode){
    // cursor left, cursor right, others??
    case 8:
    case 33:
    case 34:
    case 35:
    case 35:
    case 36:
    case 37:
    case 39:
    case 45:
    case 46:
      ab=true;
      break;
    default:
      // regular keypress ...
      break
  }
 // alert("ab: " + ab);
  if(!ab&&ct[idx].highlightedSuggestionDiv){
    var Da=ct[idx].currentInputFieldValue;
    setStyleForElement(ct[idx].highlightedSuggestionDiv,"bAutoComplete");
    var z;
    if(T) {
      z=ib(ct[idx].highlightedSuggestionDiv).substr(localLyr.prefixStrings[o].length);
    } else {
      z=Da;
    }
    if(z!=localInputField.value){
      if(localInputField.value!=ct[idx].currentInputFieldValue) {
        return;
      }
      if(X){
        if(localInputField.createTextRange||localInputField.setSelectionRange) {
          selectEntry(z);
        }
        if(localInputField.createTextRange){
          var t=localInputField.createTextRange();
          t.moveStart("character",Da.length);
          t.select()
        }else if(localInputField.setSelectionRange){
          localInputField.setSelectionRange(Da.length,localInputField.value.length)
        }
      }
    }
  }else{
    ct[idx].highlightedSuggestionIndex=-1;
    q=ct[idx].currentInputFieldValue
  }
}

// Called as:
// calculateOffsetLeft(ct[idx].inputField)
// was ob
function calculateOffsetLeft(r){
  return Ya(r,"offsetLeft")
}

// Called as:
// calculateOffsetTop(ct[idx].inputField)
// Was Qb...
function calculateOffsetTop(r){
  return Ya(r,"offsetTop")
}

function Ya(r,attr){
  var kb=0;
  while(r){
    kb+=r[attr];
    r=r.offsetParent
  }
  return kb
}

// Sets cookie...
// (was called qa...)
function setCookie(name,value,Ra,hb,fb,Sb){
  var Nb=name+"="+value+(Ra?";expires="+Ra.toGMTString():"")+(hb?";path="+hb:"")+(fb?";domain="+fb:"")+(Sb?";secure":"");
  document.cookie=Nb
}

// Was Ha
function setInputFieldSize(){
  var xa=document.body.scrollWidth-220;
  xa=0.73*xa;
  ct[idx].inputField.size=Math.floor(xa/6.18)
}
function lb(n){
  var N=-1;
  if(n.createTextRange){
    var fa=document.selection.createRange().duplicate();
    N=fa.text.length
  }else if(n.setSelectionRange){
    N=n.selectionEnd-n.selectionStart
  }
  return N
}

function bb(n){
  var v=0;
  if(n.createTextRange){
    var fa=document.selection.createRange().duplicate();
    fa.moveEnd("textedit",1);
    v=n.value.length-fa.text.length
  }else if(n.setSelectionRange){
    v=n.selectionStart
  }else{
    v=-1
  }
  return v
}
function cc(d){
  if(d.createTextRange){
    var t=d.createTextRange();
    t.moveStart("character",d.value.length);
    t.select()
  } else if(d.setSelectionRange) {
    d.setSelectionRange(d.value.length,d.value.length)
  }
  //alert("cc");
}

function jc(Zb,Ea){
  if(!Ea)Ea=1;
  if(pa&&pa<=Ea){
    var Ia=document.createElement("DIV");
    Ia.innerHTML=Zb;
    document.getElementById("console").appendChild(Ia)
  }
}

// Ex: setStyleForElement(document.createElement("DIV"), "aAutoComplete");
// was l
function setStyleForElement(c,name){
  db();
  c.className=name;
  if(Ka){
    return
  }
  switch(name.charAt(0)){
    case "m":
      c.style.fontSize="13px";
      c.style.fontFamily="arial,sans-serif";
      c.style.wordWrap="break-word";
      break;
    case "l":
      c.style.display="block";
      c.style.paddingLeft="3";
      c.style.paddingRight="3";
      c.style.height="16px";
      c.style.overflow="hidden";
      break;
    case "a":
      c.style.backgroundColor="white";
      c.style.color="black";
      if(c.displaySpan){
        c.displaySpan.style.color="green"
      }
      break;
    case "b":
      c.style.backgroundColor="#3366cc";
      c.style.color="white";
      if(c.displaySpan){
        c.displaySpan.style.color="white"
      }
      break;
    case "c":
      c.style.cssFloat="left";
      break;
    case "d":
      c.style.cssFloat="right";
      c.style.width=100-p+"%";
      if(w=="query"){
        c.style.fontSize="10px";
        c.style.textAlign="right";
        c.style.color="green";
        c.style.paddingTop="3px"
      }else{
        c.style.color="#696969"
      }
      break
  }
}

function db(){
  p=65;
  if(w=="query"){
    var wb=110;
    var Sa=calculateWidth();
    var tb=(Sa-wb)/Sa*100;
    p=tb
  }else{
    p=65
  }
  if(ya){
    p=99.99
  }
}
function Gb(i){
  db();
  var Ub="font-size: 13px; font-family: arial,sans-serif; word-wrap:break-word; ";
  var Vb="display: block; padding-left: 3; padding-right: 3; height: 16px; overflow: hidden; ";
  var bc="background-color: white; ";
  var qb="background-color: #3366cc; color: white ! important; ";
  var ub="display: block; margin-left: 0%; width: "+p+"%; float: left; ";
  var Ga="display: block; margin-left: "+p+"%; ";
  if(w=="query"){
    Ga+="font-size: 10px; text-align: right; color: green; padding-top: 3px; "
  }else{
    Ga+="color: #696969; "
  }
  D(".mAutoComplete",Ub);
  D(".lAutoComplete",Vb);
  D(".aAutoComplete *",bc);
  D(".bAutoComplete *",qb);
  D(".cAutoComplete",ub);
  D(".dAutoComplete",Ga);
  setStyleForElement(i,"mAutoComplete")
}

// Called from sendRPCResponse...
// i = fr.lyr
// cs = list of comlete strings...
// Hb = list of results...
// was rb
function displaySuggestedList(i,cs){
  while(i.childNodes.length>0) {
    i.removeChild(i.childNodes[0]);
  }
  // For each element in our list, we create:
  // <DIV (u) - mousedown/mouseover/mouseout aAutoComplete>
  //   <SPAN (ka) lAutoComplete>
  //     <SPAN (ua) cAutoComplete>
  //        bug tracking
  //     </SPAN (ua)>
  //     <SPAN (ea) dAutoComplete>
  //        500,000 results
  //     </SPAN (ea)>
  //   </SPAN>
  // </DIV (u)>
  var len=cs.length;
  if (len > 10) len= 10;
  for(var f=0; f<len; ++f){
    var u=document.createElement("DIV");
    setStyleForElement(u,"aAutoComplete");
    u.onmousedown=Cb;
    u.onmouseover=pb;
    u.onmouseout=ec;
    var ka=document.createElement("SPAN");
    setStyleForElement(ka,"lAutoComplete");
    var ua=document.createElement("SPAN");
    ua.innerHTML=cs[f]; //replace(/\s/g, "&nbsp;"); // the text for the suggested result...
    var ea=document.createElement("SPAN");
    setStyleForElement(ea,"dAutoComplete");
    setStyleForElement(ua,"cAutoComplete");
    u.displaySpan=ea;
    ka.appendChild(ua);
    u.appendChild(ka);
    i.appendChild(u)
  }
}

function D(name,gb){
  if(Ka){
    var I=document.styleSheets[0];
    if(I.addRule){
      I.addRule(name,gb)
    }else if(I.insertRule){
      I.insertRule(name+" { "+gb+" }",I.cssRules.length)
    }
  }
}

// Was function jb...
// returns an XMLHttp object... gets it in an IE/Mozilla friendly way..
function getXMLHTTP(){
  var A=null;
  try{
  }catch(e){
    try{
      A=new ActiveXObject("Microsoft.XMLHTTP")
    } catch(oc){
      A=null
    }
  }
  if(!A && typeof XMLHttpRequest != "undefined") {
    A=new XMLHttpRequest()
  }
  return A
}

// This function uses the xmlHttp object to send a message back to server...
// This is the primary function that dynamically communicates with server.

function callServer(prefix){
  Rb = (prefix.length > 2) ? prefix.substring(0, 2) : prefix; 
  if(xmlHttp&&xmlHttp.readyState!=0){
    xmlHttp.abort()
  }
  xmlHttp=getXMLHTTP();
  if(xmlHttp){
    //xmlHttp.open("GET","/fs/" + countrySite + "/FSServe?fn=citySuggest&prefix="+Rb,true);
    xmlHttp.open("GET","/biz/city_dropdown.jsp?v=1&prefix="+Rb+"&filterCountry="+filterCountryCode,true);
    // Note that thsis function will ONLY be called when we get a complete
    // response back from server!!
    xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4&&xmlHttp.responseText) {
        var frameElement=B;
        if(xmlHttp.responseText.charAt(0)=="<"){
          ct[idx].timeoutAdjustment--
        }else{
          // The response text gets executed as javascript...
          eval(xmlHttp.responseText)
          if (prefix.length > 2) hideLyr();
        }
      }
    }
    ;
    // DON'T TRY TO TALK WHEN WE'RE LOCAL...
    // Comment out when running from a local file...
    xmlHttp.send(null)
  }
}

// Select suggested entry...
// wa is the value to set the inputfield to...
// was S
function selectEntry(Wa){
  ct[idx].inputField.value=Wa.replace(/&amp;/g, "&");
  aa=Wa
}


function handleFocus(field, index) {
  idx = index;
  initialize(field, 'us');
  //idx = i;
}
