if(typeof (bsn_main_search)=="undefined"){_b=bsn_main_search={}}if(typeof (_b.Autosuggest)=="undefined"){_b.Autosuggest={}}else{alert("Autosuggest is already set! a")}_b.AutoSuggest=function(E,D){if(!document.getElementById){return 0}this.fld=_b.DOM.gE(E);if(!this.fld){return 0}this.sInp="";this.nInpC=0;this.aSug=[];this.iHigh=0;this.cancelShow=false;this.submitEventChanged=false;if(document.all){this.isMouseDown=false}this.oP=D?D:{};var A,B={minchars:1,meth:"get",varname:"input",className:"autosuggest",timeout:2500,delay:500,offsety:-5,shownoresults:true,noresults:"No results!",maxheight:250,cache:false,maxentries:25};for(A in B){if(typeof (this.oP[A])!=typeof (B[A])){this.oP[A]=B[A]}}var C=this;this.fld.onkeydown=function(F){return C.onKeyDown(F)};this.fld.onkeyup=function(F){return C.onKeyUp(F)};this.fld.setAttribute("autocomplete","off");this.addListener(this.fld,"blur",function(F){if(!C.isMouseDown){return C.clearSuggestions()}})};_b.AutoSuggest.prototype.addListener=function(B,C,A){if(window.addEventListener){B.addEventListener(C,A,false)}else{B.attachEvent("on"+C,A)}};_b.AutoSuggest.prototype.onKeyDown=function(G){var E=(window.event)?window.event.keyCode:G.keyCode;var D=38;var F=40;var C=13;var B=9;var H=27;var A=1;switch(E){case C:if(this.iHigh==0){this.onReturnKeyPress()}else{this.setHighlightedValue();A=0}break;case D:this.changeHighlight(E);A=0;break;case F:this.changeHighlight(E);A=0;break;case H:this.clearSuggestions();break}return A};_b.AutoSuggest.prototype.onReturnKeyPress=function(){};_b.AutoSuggest.prototype.onKeyUp=function(F){var D=(window.event)?window.event.keyCode:F.keyCode;var C=38;var E=40;var B=13;var A=1;switch(D){default:if(this.fld.value.length<=1){this.sInp=this.fld.value;this.clearSuggestions()}else{this.getSuggestions(this.fld.value)}}return A};_b.AutoSuggest.prototype.getSuggestions=function(G){if(G==this.sInp){return 0}this.cancelShow=false;this.sInp=G;if(G.length<this.oP.minchars){this.aSug=[];this.nInpC=G.length;return 0}var D=this.nInpC;this.nInpC=G.length?G.length:0;var B=this.aSug.length;if(this.nInpC>D&&B&&B<this.oP.maxentries&&this.oP.cache){var A=[];for(var E=0;E<B;E++){if(this.aSug[E].value.substr(0,G.length).toLowerCase()==G.toLowerCase()){A.push(this.aSug[E])}}this.aSug=A;this.createList(this.aSug);return false}else{var F=this;var C=this.sInp;clearTimeout(this.ajID);this.ajID=setTimeout(function(){F.doAjaxRequest(C)},this.oP.delay)}return false};_b.AutoSuggest.prototype.doAjaxRequest=function(C){if(C!=this.fld.value){return false}var G=this;if(typeof (this.oP.script)=="function"){var D=this.oP.script(encodeURIComponent(this.sInp))}else{var D=this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp)}if(!D){return false}var B=this.oP.meth;var C=this.sInp;var A=function(H){G.setSuggestions(H,C)};var E=function(H){};var F=new _b.Ajax();F.makeRequest(D,B,A,E)};_b.AutoSuggest.prototype.cancelSuggestions=function(){this.cancelShow=true};_b.AutoSuggest.prototype.setSuggestions=function(req,input){if(input!=this.fld.value||this.cancelShow){return false}this.aSug=[];if(this.oP.json){var jsondata=eval("("+req.responseText+")");for(var i=0;i<jsondata.results.length;i++){this.aSug.push({id:jsondata.results[i].id,value:jsondata.results[i].value,info:jsondata.results[i].info,tipe:jsondata.results[i].tipe})}}else{var xml=req.responseXML;var results=xml.getElementsByTagName("results")[0].childNodes;for(var i=0;i<results.length;i++){if(results[i].hasChildNodes()){this.aSug.push({id:results[i].getAttribute("id"),value:results[i].childNodes[0].nodeValue,info:results[i].getAttribute("info"),tipe:results[i].getAttribute("tipe")})}}}this.idAs="as_"+this.fld.id;this.createList(this.aSug)};_b.AutoSuggest.prototype.createList=function(L){var A=this;_b.DOM.remE(this.idAs);this.killTimeout();if(L.length==0&&!this.oP.shownoresults){return false}var B=_b.DOM.cE("div",{id:this.idAs,className:this.oP.className});if(document.all){A.isMouseDown=false;B.onmousedown=function(R){A.isMouseDown=true;return false}}var Q=_b.DOM.cE("table",{id:"as_table",cellSpacing:0,cellPadding:2,border:0});if(document.all){Q.width="95%"}else{Q.width="100%"}var K=_b.DOM.cE("tbody",{id:"as_tbody"});for(var J=0;J<L.length;J++){var F=L[J].value;if(F.length>50){var G=F.substr(0,45)+"..."}else{var G=F}var D=L[J].info?'<div style="font-size:10px;text-align:left;">'+L[J].info+"</div>":"";var C=L[J].tipe?L[J].tipe:"";var E,I;if(global.lang=="ind"){if(C=="company"){E="Perusahaan";I="#CC9900"}else{if(C=="street"||C=="place"){E="Lokasi";I="#339933"}else{E="Zona";I="#9999FF"}}}else{if(C=="company"){E="Company Name";I="#CC9900"}else{if(C=="place"||C=="street"){E="Location";I="#339933"}else{E="Zone";I="#9999FF"}}}G='<div style="font-size:11px;text-align:left;"><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td width="75%" align="left" style="font-weight:bold;">'+G+'</td><td width="25%" align="right" rowspan="2" style="color:'+I+'" valign="top">'+E+"</td></tr><tr><td>"+D+"</td></table></div>";var M=_b.DOM.cE("tr",{});var H=_b.DOM.cE("td",{},G,true);H.style.cursor="default";H.title=F;H.name=J+1;H.onclick=function(){A.setHighlightedValue();return false};H.onmouseover=function(){A.setHighlight(this.name)};M.appendChild(H);K.appendChild(M)}Q.appendChild(K);B.appendChild(Q);var P=document.createElement("hr");B.appendChild(P);var O=document.createElement("div");O.style.cssText="padding-left:2px";O.innerHTML='<div class="Link17 ver_10" align="left"><a href="http://'+location.hostname+document.getElementById("linkForIndonesia").innerHTML+"?q="+encodeURIComponent(this.fld.value)+'" target="_blank">Show all results for "'+this.fld.value+'"</a></div>';B.appendChild(O);var N=_b.DOM.getPos(this.fld);if(!document.layers&&!document.all){B.style.left=(N.x+1)+"px"}else{B.style.left=N.x+"px"}B.style.top=(N.y+this.fld.offsetHeight+this.oP.offsety+4)+"px";B.style.width=(this.fld.offsetWidth-12)+"px";B.onmouseover=function(){A.killTimeout()};document.getElementsByTagName("body")[0].appendChild(B);this.iHigh=0;var A=this;this.toID=setTimeout(function(){A.clearSuggestions()},this.oP.timeout)};_b.AutoSuggest.prototype.changeHighlight=function(B){var D=_b.DOM.gE("as_tbody");if(!D){return false}if(!this.submitEventChanged){_b.DOM.gE("fSdSearch").onsubmit=function(G){return false};this.submitEventChanged=true}var F,A=5;if(B==40){F=this.iHigh+1}else{if(B==38){F=this.iHigh-1}}if(F>D.childNodes.length){F=D.childNodes.length}if(F<1){F=1}var C=$(this.idAs);var E=D.childNodes[F-1].childNodes[0];if(B==40&&E.offsetTop+E.offsetHeight>C.scrollTop+C.offsetHeight){C.scrollTop=E.offsetTop+E.offsetHeight-C.offsetHeight+12}else{if(B==38&&E.offsetTop<C.scrollTop){C.scrollTop=E.offsetTop}}this.setHighlight(F)};_b.AutoSuggest.prototype.setHighlight=function(C){var B=_b.DOM.gE("as_tbody");if(!B){return false}if(this.iHigh>0){this.clearHighlight()}this.iHigh=Number(C);var A=B.childNodes[this.iHigh-1];A.childNodes[0].className="as_highlight";this.killTimeout()};_b.AutoSuggest.prototype.clearHighlight=function(){var B=_b.DOM.gE("as_tbody");if(!B){return false}if(this.iHigh>0){var A=B.childNodes[this.iHigh-1];A.childNodes[0].className="";this.iHigh=0}};_b.AutoSuggest.prototype.setHighlightedValue=function(){if(this.iHigh){if(this.aSug[this.iHigh-1]){var A=this.aSug[this.iHigh-1].info?(this.aSug[this.iHigh-1].value?", ":"")+this.aSug[this.iHigh-1].info.replace("Add :",""):"";this.sInp=this.fld.value=this.aSug[this.iHigh-1].value+A}this.fld.focus();if(this.fld.selectionStart){this.fld.setSelectionRange(this.sInp.length,this.sInp.length)}if(typeof (this.oP.callback)=="function"){this.oP.callback(this.aSug[this.iHigh-1])}}};_b.AutoSuggest.prototype.killTimeout=function(){clearTimeout(this.toID)};_b.AutoSuggest.prototype.resetTimeout=function(){clearTimeout(this.toID);var A=this;this.toID=setTimeout(function(){A.clearSuggestions()},1000)};_b.AutoSuggest.prototype.clearSuggestions=function(){this.killTimeout();var A=_b.DOM.gE(this.idAs);var C=this;_b.DOM.gE("fSdSearch").onsubmit=function(D){return submitSearch("fSdSearch");return false};this.submitEventChanged=false;if(A){var B=new _b.Fader(A,1,0,250,function(){_b.DOM.remE(C.idAs)})}};if(typeof (_b.Ajax)=="undefined"){_b.Ajax={}}_b.Ajax=function(){this.req={};this.isIE=false};_b.Ajax.prototype.makeRequest=function(C,B,A,D){if(B!="POST"){B="GET"}this.onComplete=A;this.onError=D;var E=this;if(window.XMLHttpRequest){this.req=new XMLHttpRequest();this.req.onreadystatechange=function(){E.processReqChange()};this.req.open("GET",C,true);this.req.send(null)}else{if(window.ActiveXObject){this.req=new ActiveXObject("Microsoft.XMLHTTP");if(this.req){this.req.onreadystatechange=function(){E.processReqChange()};this.req.open(B,C,true);this.req.send()}}}};_b.Ajax.prototype.processReqChange=function(){if(this.req.readyState==4){if(this.req.status==200){this.onComplete(this.req)}else{this.onError(this.req.status)}}};if(typeof (_b.DOM)=="undefined"){_b.DOM={}}_b.DOM.cE=function(F,B,A,E){var G=document.createElement(F);if(!G){return 0}for(var C in B){G[C]=B[C]}var D=typeof (A);if(D=="string"&&!E){G.appendChild(document.createTextNode(A))}else{if(D=="string"&&E){G.innerHTML=A}else{if(D=="object"){G.appendChild(A)}}}return G};_b.DOM.gE=function(C){var A=typeof (C);if(A=="undefined"){return 0}else{if(A=="string"){var B=document.getElementById(C);if(!B){return 0}else{if(typeof (B.appendChild)!="undefined"){return B}else{return 0}}}else{if(typeof (C.appendChild)!="undefined"){return C}else{return 0}}}};_b.DOM.remE=function(A){var B=this.gE(A);if(!B){return 0}else{if(B.parentNode.removeChild(B)){return true}else{return 0}}};_b.DOM.getPos=function(C){var C=this.gE(C);var B=C;var D=0;if(B.offsetParent){while(B.offsetParent){D+=B.offsetLeft;B=B.offsetParent}}else{if(B.x){D+=B.x}}var B=C;var A=0;if(B.offsetParent){while(B.offsetParent){A+=B.offsetTop;B=B.offsetParent}}else{if(B.y){A+=B.y}}return{x:D,y:A}};if(typeof (_b.Fader)=="undefined"){_b.Fader={}}_b.Fader=function(B,F,E,A,D){if(!B){return 0}this.e=B;this.from=F;this.to=E;this.cb=D;this.nDur=A;this.nInt=50;this.nTime=0;var C=this;this.nID=setInterval(function(){C._fade()},this.nInt)};_b.Fader.prototype._fade=function(){this.nTime+=this.nInt;var A=Math.round(this._tween(this.nTime,this.from,this.to,this.nDur)*100);var C=A/100;if(this.e.filters){try{this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity=A}catch(B){this.e.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+A+")"}}else{this.e.style.opacity=C}if(this.nTime==this.nDur){clearInterval(this.nID);if(this.cb!=undefined){this.cb()}}};_b.Fader.prototype._tween=function(B,A,D,C){return A+((D-A)*(B/C))};var options_search={script:function(A){return"http://"+location.hostname+"/indonesia/search/indonesia_search_location.php?q="+A+"&province=2&lang="+global.lang},varname:"q",json:true,shownoresults:false,timeout:300000,minchars:2,maxresults:10,callback:function(B){if(B){if(B.info=="zone"){var C=encodeURIComponent(B.value).toLowerCase();C=C.replace(/%20/gi,"+");C=C.replace("+district","");window.location.href="http://"+location.hostname+"/indonesia/bali/zone/"+C+"/"}else{if(B.tipe=="company"){var A=B.id.split("|");window.location.href="http://"+location.hostname+"/businessfinder/indonesia/"+global.langUrl+"bali/company_detail.php?companyid="+A[3]+"&branch_id="+A[4]}else{var A=B.id.split("|");window.location.href="http://"+location.hostname+"/indonesia/"+global.langUrl+"bali/travel/travel_id_"+A[0]+"/travel_site_"+A[1]+"/travel_no_"+A[2]+"/"}}return false}}};var as_json_main_search=new bsn_main_search.AutoSuggest("q",options_search);