// generated Sun Nov 22 06:09:31 EST 2009

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 pK2=String.fromCharCode(pK).toLowerCase();lastKey=pK;if(who!=null){who(pK,pK2)}}function keysInit(callback){document.onkeydown=keyDown;who=callback;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;var _kayakSmartUrl="/m/smarty?";var _forceSelection=true;var _forceSingle=false;var _sbextraargs="";function cancelSmartBox(){keysInit(null);if((_forceSelection||(_forceSingle&&_itemCount==1))&&_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(where,wherecode,searchtype,timeout,minwidth,valuesetcb,smarturl,forcesel,extraargs,forcesingle){_inputcode=_input=null;if(forcesel!=null){_forceSelection=forcesel}else{_forceSelection=true}if(forcesingle!=null){_forceSingle=forcesingle}else{_forceSingle=false}if(smarturl){_kayakSmartUrl=smarturl}else{_kayakSmartUrl="/m/smarty?"}if(extraargs){_sbextraargs=extraargs}else{_sbextraargs=""}cancelSmartBox();var body=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";body.appendChild(_target)}_target.className=searchtype+"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";body.appendChild(_targetBG)}if(isNaN(parseInt(minwidth))){_sboxminwidth=-1}else{_sboxminwidth=parseInt(minwidth)}keysInit(keypressed);_input=where;_inputcode=wherecode;_searchtype=searchtype;_lastsent="";_timeout=timeout;_clientsbcb=valuesetcb;var x=findPosX(where);var y=findPosY(where)+where.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(input){if(sbHttp==null){sbHttp=new R9HTTPXml()}if(!sbHttp.inprogress){if(_lastsent==_input.value||_input.value.length<_chars){return}window.status="searching...";_lastsent=_input.value;var buffer="where="+encodeURIComponent(_lastsent);var sbHttp=new R9HTTPXml();buffer+="&lc=en&lc_cc=US";if(_searchtype=="air"){buffer+="&s=1"}else{if(_searchtype=="car"){buffer+="&s=2"}else{if(_searchtype=="hotel"){buffer+="&s=3"}else{if(_searchtype=="any"){buffer+="&s=4"}else{if(_searchtype=="crc"){buffer+="&s=5"}else{if(_searchtype=="crcg"){buffer+="&s=6"}else{if(_searchtype=="deal"){buffer+="&s=7"}else{if(_searchtype=="crcga"){buffer+="&s=8"}else{if(_searchtype=="hotelname"){buffer+="&s=11"}else{buffer+="&s="+_searchtype}}}}}}}}}if(_sbcountrycode!=null&&_sbcountrycode.length>0){buffer+="&cc="+_sbcountrycode}buffer+="&f=h";buffer+=_sbextraargs;sbHttp.init(_kayakSmartUrl,buffer);try{sbHttp.setTimeout(10000);sbHttp.asyncGET(new _Callback(input))}catch(e){alert(e)}}else{alert("busy")}}function setSbCountryCode(code){_sbcountrycode=code}function clearSbCountryCode(){_sbcountrycode=null}function getSbIndex(elem){var list=_getSmartboxList();var retIndex=0;if(list&&list.childNodes){for(var i=0;i<list.childNodes.length;i++){var item=list.childNodes[i];if(elem==item){retIndex=i;break}var itemChildMatch=false;for(var j=0;j<item.childNodes.length;j++){if(elem==item.childNodes[j]){retIndex=i;itemChildMatch=true;break}}if(itemChildMatch){break}}}return retIndex}function _sbMouseOut(event){var obj=event?event.target:this;_cursel=-1;selChoice(-1)}function _sbMouseDown(event){var obj=event?event.target:this;_cursel=getSbIndex(obj);_setValue(_cursel);closeSmartBox()}function _sbMouseOver(event){var obj=event?event.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";_target.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;if(_target.childNodes){for(var i=0;i<_target.childNodes.length;i++){var node=_target.childNodes[i];if(node.nodeName=="UL"){ul=node;break}}}return ul}function _Callback(input){this.onError=function(status,statusText){};this.onLoad=function done(client){window.status="";if(!client.cancelled&&(_input==input)){_target.innerHTML=client.getText();var list=_getSmartboxList();if(list&&list.childNodes){_itemCount=list.childNodes.length}else{_itemCount=0}if(_itemCount>0){for(var i=0;i<list.childNodes.length;i++){li=list.childNodes[i];li.onmousedown=_sbMouseDown;li.onmouseover=_sbMouseOver;li.onmouseout=_sbMouseOut}_target.style.width="auto";_showChoices()}else{_hideChoices()}_cursel=(_forceSelection||(_forceSingle&&_itemCount==1)?0:-1);_prevsel=_cursel;selChoice(_cursel)}}}function _setValue(newi){if(newi<0){_lastsent="";try{var codechg=(_inputcode.value!="");_inputcode.value="";if(codechg){_clientsbcb(null)}}catch(e){}}else{if(_itemCount>0){var list=_getSmartboxList();if(list==null||list.childNodes==null){return}var selected=list.childNodes[newi];var fields=selected.id.split("-");var id;if(fields.length>1){id=fields[1]}_inputcode.value=id;if(selected.innerText!=undefined){_input.value=selected.innerText}else{_input.value=selected.textContent}try{if(typeof _clientsbcb=="function"){var cbData=new Object();cbData.str=selected.innerHTML;cbData.type=fields[0];cbData.id=id;if(fields.length>2){cbData.hc=fields[2]}if(fields.length>3){if(cbData.type=="hotel"){cbData.hid=fields[3]}else{cbData.lmid=fields[3]}}_clientsbcb(cbData)}}catch(ignored){}}}}function selChoice(newi){var list=_getSmartboxList();if(list&&list.childNodes&&list.childNodes.length>0){if(_prevsel>=0){var prev=list.childNodes[_prevsel];if(prev.className){prev.className=prev.className.replace(/ *smartboxItemHi/,"")}else{prev.className=""}}if(newi>=0){if(list.childNodes.length>0){var cur=list.childNodes[newi];cur.className=cur.className+" smartboxItemHi"}_prevsel=newi}}}var _pressed=0;function keypressed(keycode,keyvalue){clearTimeout(_idletimer);_pressed=new Date().getTime();switch(keycode){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(input){if(noEnter()){_input.focus();var now=new Date().getTime();if(now-_pressed>_timeout){clearTimeout(_idletimer);_typer(_input)}else{clearTimeout(_idletimer);_idletimer=self.setTimeout("idle()",_timeout)}}}function _typer(input){if((_input!=null)&&_input.value.length>0){abortSmartBox();_runSearch(input)}else{_setValue(-1);closeSmartBox()}}function _sbShowBGIframe(){return(window.opera)?false:true};

var jsck_smartboxcore="v287";
// generation time: 6ms
