var who;
var ESC=27;
var TAB=9;
var ALT=18;
var UP=38;
var DOWN=40;
var LEFT=37;
var RIGHT=39;
var ENTER=13;
var SHIFT=16;
var lastKey=0;
function keyDown(e){
var pK=document.all?window.event.keyCode:e.which;
var _3=String.fromCharCode(pK).toLowerCase();
lastKey=pK;
if(who!=null){
who(pK,_3);
}
}
function keysInit(_4){
document.onkeydown=keyDown;
who=_4;
if(document.layers){
document.captureEvents(Event.KEYPRESS);
}
}
function noEnter(){
return lastKey!=ENTER;
}
var _toolong,_lastsent,_timeout,_itemCount,_idletimer,_cursel,_target;
var _prevsel;
var _inputcode=null,_searchtype;
var _targetBG;
var _input=null;
var _numChoices;
var sbHttp=null;
var _stop;
var _chars=3;
var _sboxminwidth;
var _clientsbcb;
var _sbcountrycode;
function cancelSmartBox(){
keysInit(null);
if(_inputcode!=null&&_inputcode.value!=null&&_inputcode.value.length<1){
_setValue(0);
}
abortSmartBox();
closeSmartBox();
_input=null;
_stop=false;
}
function abortSmartBox(){
if(sbHttp!=null){
if(sbHttp.inprogress){
sbHttp.cancelRequest();
}
}
}
function closeSmartBox(){
if(_target!=null){
_target.style.display="none";
_target.innerHTML="";
}
if(_targetBG!=null){
_targetBG.style.display="none";
}
_stop=true;
}
function initSmartBox(_5,_6,_7,_8,_9,_a){
_inputcode=_input=null;
cancelSmartBox();
var _b=document.getElementsByTagName("body")[0];
_target=document.getElementById("smartbox");
if(!_target){
_target=document.createElement("div");
_target.id="smartbox";
_target.style.zIndex=51;
_target.style.position="absolute";
_target.style.display="none";
_target.style.width="auto";
_b.appendChild(_target);
}
_target.className=_7+"smartboxResults";
_targetBG=document.getElementById("smartboxBG");
if(!_targetBG){
_targetBG=document.createElement("iframe");
_targetBG.id="smartboxBG";
_targetBG.style.zIndex=50;
_targetBG.setAttribute("scrolling","no");
_targetBG.setAttribute("frameborder","0");
_targetBG.style.position="absolute";
_targetBG.style.display="none";
_b.appendChild(_targetBG);
}
if(isNaN(parseInt(_9))){
_sboxminwidth=-1;
}else{
_sboxminwidth=parseInt(_9);
}
keysInit(keypressed);
_input=_5;
_inputcode=_6;
_searchtype=_7;
_lastsent="";
_timeout=_8;
_clientsbcb=_a;
var x=findPosX(_5);
var y=findPosY(_5)+_5.offsetHeight+1;
_target.style.top=y+"px";
_target.style.left=x+"px";
if(_idletimer){
clearTimeout(_idletimer);
_idletimer="";
}
_toolong=false;
_lastsent="";
_cursel=-1;
_prevsel=-1;
_stop=false;
}
function _runSearch(_e){
if(_f==null){
_f=new R9HTTPXml();
}
if(!_f.inprogress){
if(_lastsent==_input.value||_input.value.length<_chars){
return;
}
window.status="searching...";
_lastsent=_input.value;
var url="/m/smarty?";
var _11="where="+encodeURIComponent(_lastsent);
var _f=new R9HTTPXml();
_11+="&lc=en&lc_cc=US";
if(_searchtype=="air"){
_11+="&s=1";
}else{
if(_searchtype=="car"){
_11+="&s=2";
}else{
if(_searchtype=="hotel"){
_11+="&s=3";
}else{
if(_searchtype=="any"){
_11+="&s=4";
}
}
}
}
if(_sbcountrycode!=null&&_sbcountrycode.length>0){
_11+="&cc="+_sbcountrycode;
}
_11+="&f=h";
_f.init(url,_11);
try{
_f.setTimeout(10000);
_f.asyncGET(new _Callback(_e));
}
catch(e){
alert(e);
}
}else{
alert("busy");
}
}
function setSbCountryCode(_12){
_sbcountrycode=_12;
}
function clearSbCountryCode(){
_sbcountrycode=null;
}
function getSbIndex(_13){
var _14=_getSmartboxList();
var _15=0;
for(var i=0;i<_14.childNodes.length;i++){
if(_13==_14.childNodes[i]){
_15=i;
break;
}
}
return _15;
}
function _sbMouseOut(_17){
var obj=_17?_17.target:this;
_cursel=-1;
selChoice(-1);
}
function _sbMouseDown(_19){
var obj=_19?_19.target:this;
_cursel=getSbIndex(obj);
_setValue(_cursel);
closeSmartBox();
}
function _sbMouseOver(_1b){
var obj=_1b?_1b.target:this;
_cursel=getSbIndex(obj);
selChoice(_cursel);
}
function _showChoices(){
_target.style.display="inline";
if(_sbShowBGIframe()){
_targetBG.style.display="inline";
}
if(_sboxminwidth>_target.offsetWidth){
_targetBG.style.width=_sboxminwidth+"px";
_target.style.width=_sboxminwidth+"px";
}else{
_targetBG.style.width=_target.offsetWidth+"px";
}
_targetBG.style.height=_target.offsetHeight+"px";
_targetBG.style.top=_target.style.top;
_targetBG.style.left=_target.style.left;
}
function _hideChoices(){
_target.style.display="none";
_targetBG.style.display="none";
}
function _getSmartboxList(){
var ul;
for(var i=0;i<_target.childNodes.length;i++){
var _1f=_target.childNodes[i];
if(_1f.nodeName=="UL"){
ul=_1f;
break;
}
}
return ul;
}
function _Callback(_20){
this.onError=function(_21,_22){
};
this.onLoad=function done(_23){
window.status="";
if(!_23.cancelled&&(_input==_20)){
_target.innerHTML=_23.getText();
var _24=_getSmartboxList();
_itemCount=_24.childNodes.length;
if(_itemCount>0){
for(var i=0;i<_24.childNodes.length;i++){
li=_24.childNodes[i];
li.onmousedown=_sbMouseDown;
li.onmouseover=_sbMouseOver;
li.onmouseout=_sbMouseOut;
}
_target.style.width="auto";
_showChoices();
}else{
_hideChoices();
}
_cursel=0;
_prevsel=0;
selChoice(0);
}
};
}
function _setValue(_26){
if(_26<0){
_lastsent="";
try{
_inputcode.value="";
_clientsbcb(null);
}
catch(e){
}
}else{
if(_itemCount>0){
var _27=_getSmartboxList();
var _28=_27.childNodes[_26];
var _29=_28.id.split("-");
var id;
var _2b;
if(_29.length>=2){
id=_29[1];
}
if(_29.length>=3){
_2b=_29[2];
}
_inputcode.value=id;
_input.value=_28.innerHTML;
try{
if(typeof _clientsbcb=="function"){
var _2c=new Object();
_2c.str=_28.innerHTML;
_2c.hc=_2b;
_2c.id=id;
_clientsbcb(_2c);
}
}
catch(ignored){
}
}
}
}
function selChoice(_2d){
var _2e=_getSmartboxList();
if(_2e.childNodes.length>0){
if(_prevsel>=0){
var _2f=_2e.childNodes[_prevsel];
_2f.className=_2f.className.replace(/ *smartboxItemHi/,"");
}
if(_2d>=0){
if(_2e.childNodes.length>0){
var cur=_2e.childNodes[_2d];
cur.className=cur.className+" smartboxItemHi";
}
_prevsel=_2d;
}
}
}
var _pressed=0;
function keypressed(_31,_32){
clearTimeout(_idletimer);
_pressed=new Date().getTime();
switch(_31){
case LEFT:
case UP:
_cursel=_cursel-1;
if(_cursel<0){
_cursel=0;
}
selChoice(_cursel);
break;
case RIGHT:
case DOWN:
_cursel++;
if(_cursel>=_itemCount){
_cursel=_itemCount-1;
}
selChoice(_cursel);
break;
case ENTER:
if(_itemCount>0){
_setValue(_cursel);
closeSmartBox();
}
break;
case ESC:
closeSmartBox();
break;
case TAB:
if(_cursel>=0&&_cursel<_itemCount){
_setValue(_cursel);
}
case ALT:
case SHIFT:
break;
default:
_setValue(-1);
_idletimer=self.setTimeout("idle()",_timeout);
}
}
function sbNoEnter(){
var v=(_stop==null||_stop!=true);
_stop=false;
return (v?true:noEnter());
}
function idle(_34){
if(noEnter()){
var now=new Date().getTime();
if(now-_pressed>_timeout){
clearTimeout(_idletimer);
_typer(_input);
}else{
clearTimeout(_idletimer);
_idletimer=self.setTimeout("idle()",_timeout);
}
}
}
function _typer(_36){
if((_input!=null)&&_input.value.length>0){
abortSmartBox();
_runSearch(_36);
}else{
_setValue(-1);
closeSmartBox();
}
}
function _sbShowBGIframe(){
return (window.opera)?false:true;
}
// r9compressed
