(function(){SS.entities.QueryState=function(){this.isReturnUpdated=new YAHOO.util.CustomEvent("isReturnUpdated",this);this.directOnlyUpdated=new YAHOO.util.CustomEvent("directOnlyUpdated",this);this.passengersChanged=new YAHOO.util.CustomEvent("passengersChanged",this)};var A=SS.util.gettext;SS.entities.QueryState.prototype={oPlaceId:"",oPlaceName:"",oPlaceNameEN:"",iPlaceId:"",oCityId:"",iCityId:"",iPlaceName:"",iPlaceNameEN:"",oPlaceRawText:"",iPlaceRawText:"",isReturn:true,directOnly:true,flexibleDates:true,wholeYear:false,oDatecode:"",iDatecode:"",language:"",currency:"",geoIP:"",shortDateFormat:"",today:"",adults:1,children:0,infants:0,newwindow:false,showSelectedFlights:false,oCountryId:"",iCountryId:"",owfc:"",iwfc:"",leg:"o",rootUrl:"",addLangToPath:true,airlineFilter:"",langInPath:"",appendSSS:false,ucy:"",setOPlace:function(F,D,B,C,E){this.oPlaceId=F;this.oPlaceName=D;if(C==null){C=""}this.oPlaceRawText=SS.util.trim(C);this.oCityId=E;this.oPlaceNameEN=B},setIPlace:function(F,D,B,C,E){this.iPlaceId=F;this.iPlaceName=D;if(C==null){C=""}this.iPlaceRawText=SS.util.trim(C);this.iCityId=E;this.iPlaceNameEN=B},setDepartureDate:function(B){this.oDatecode=B},setReturnDate:function(B){this.iDatecode=B},setIsReturn:function(B){this.isReturn=!!B;this.isReturnUpdated.fire()},setDirectOnly:function(B){this.directOnly=!!B},setFlexibleDates:function(B){this.flexibleDates=B},setPassengers:function(I,H,D){var C=this.adults,E=this.children,G=this.infants;var F;F=parseInt(I,10);if(F<1){F=1}this.adults=F;F=parseInt(H,10);if(isNaN(F)){F=0}this.children=F;F=parseInt(D,10);if(isNaN(F)){F=0}this.infants=F;var B=new SS.core.Cookie("scanner");B.adults=this.adults;B.children=this.children;B.infants=this.infants;B.store(240,"/","",false);if(C!=this.adults||E!=this.children||G!=this.infants){this.passengersChanged.fire(this.adults,this.children,this.infants)}},setOutboundWFC:function(B){if(!$L.isString(B)){this.owfc=""}else{this.owfc=B}},setInboundWFC:function(B){if(!$L.isString(B)){this.iwfc=""}else{this.iwfc=B}},preparePlaceName:function(D,B){var C=D;if(B!=""&&SS.util.isNonLatinAlphLanguage(this.language)){C=B}return encodeURL(C.replace(/ /g,"-").replace(/\//g,"-")).toLowerCase()},init:function(){var C=SS.data.sc;var B=C.oplace;this.oPlaceId=B.id.toLowerCase();this.oPlaceName=B.name.toLowerCase();this.oPlaceNameEN=B.nameEn.toLowerCase();this.oCountryId=B.countryId.toUpperCase();this.oCountryName=B.countryName;this.oCityId=B.cityID;var D=C.iplace;this.iPlaceId=D.id.toLowerCase();this.iPlaceName=D.name.toLowerCase();this.iPlaceNameEN=D.nameEn.toLowerCase();this.iCountryId=D.countryId;this.iCountryName=D.countryName;this.iCityId=D.cityID;this.ucy=C.ucy;this.isReturn=C.isReturn;this.directOnly=C.directOnly;this.oDatecode=C.oDatecode;this.iDatecode=C.iDatecode;this.language=C.language.toLowerCase();this.currency=C.currency.toLowerCase();this.flexibleDates=C.flexibleDates;this.wholeYear=C.wholeYear;this.geoIP=C.gip;this.shortDateFormat=C.shortdateformat;this.today=C.today;this.adults=C.adults;this.children=C.children;this.infants=C.infants;this.newwindow=C.newwindow==1;this.leg=C.leg;this.rootUrl=C.rootUrl;this.wholeYear=C.wholeYear==1;this.addLangToPath=C.addLangToPath==1;this.langInPath=C.langInPath;this.airlineFilter=C.airlineFilter;this.appendSSS=C.appendSSS==1},url:function(){var M="",S="",B="",H=false,G=false;var C=SS.util.isRegion(this.oPlaceId)?this.oCountryId:this.oPlaceId;var L=SS.util.isRegion(this.iPlaceId)?this.iCountryId:this.iPlaceId;var D=SS.util.isRegion(this.oPlaceId)?this.oCountryName:this.oPlaceName;var E=SS.util.isRegion(this.iPlaceId)?this.iCountryName:this.iPlaceName;var J=(C!="");var F=(this.oPlaceRawText!=""&&!SS.util.matchesEverywhere(this.oPlaceRawText));var P=(L!="");var I=(this.iPlaceRawText!=""&&!SS.util.matchesEverywhere(this.iPlaceRawText));var C=SS.util.isRegion(this.oPlaceId)?this.oCountryId:this.oPlaceId;var L=SS.util.isRegion(this.iPlaceId)?this.iCountryId:this.iPlaceId;var D=SS.util.isRegion(this.oPlaceId)?this.oCountryName:this.oPlaceName;var E=SS.util.isRegion(this.iPlaceId)?this.iCountryName:this.iPlaceName;var J=(C!="");var F=(this.oPlaceRawText!=""&&!SS.util.matchesEverywhere(this.oPlaceRawText));var P=(L!="");var I=(this.iPlaceRawText!=""&&!SS.util.matchesEverywhere(this.iPlaceRawText));if(J&&(P||!I)){if(this.addLangToPath&&this.language!="en"){M+="/"+this.language}if(P){M+="/"+A("flights")}else{M+="/"+A("flights-from")}if(this.showSelectedFlights){M+="/results"}M+="/"+C;if(P){M+="/"+L}if(this.oDatecode!=""){var Q=SS.util.fnStr2DteFull(this.oDatecode);if(this.flexibleDates){M+="/"+SS.util.fnXXRes(maText["maMNNorm_"+Q.getMonth()],this.language)+"-20"+this.oDatecode.substr(0,2)}else{M+="/"+this.oDatecode}}else{G=true}if(!this.directOnly){if(!this.flexibleDates&&C.length>2&&L.length>2){B+="si=1&"}else{B+="di=0&"}}if(this.isReturn){if(this.iDatecode!=""){var Q=SS.util.fnStr2DteFull(this.iDatecode);if(this.flexibleDates){M+="/"+SS.util.fnXXRes(maText["maMNNorm_"+Q.getMonth()],this.language)+"-20"+this.iDatecode.substr(0,2)}else{M+="/"+this.iDatecode}}}if(G){B+="rtn="+(this.isReturn?"1":"0")+"&"}if(SS.util.isCityOrAirport(C)&&SS.util.isCityOrAirport(L)){if(this.oDatecode===""){S=A("st_f_cym")}else{if(this.flexibleDates){S=A("st_f_c")}else{S=A("st_f_d")}}}else{S=A("st_f_b")}var O="";if(this.oDatecode!=""){var N=SS.util.fnStr2DteFull(this.oDatecode);O+="-"+SS.util.fnXXRes(A("st_in"))+"-"+SS.util.fnXXRes(A("maMNNorm_"+N.getMonth()),this.language)+"-20"+this.oDatecode.substr(0,2);if(this.isReturn){if(this.oDatecode.substring(0,4)!=this.iDatecode.substring(0,4)){var R=SS.util.fnStr2DteFull(this.iDatecode);O+="-"+SS.util.fnXXRes(A("st_and"))+"-"+SS.util.fnXXRes(A("maMNNorm_"+R.getMonth()),this.language)+"-20"+this.iDatecode.substr(0,2)}}}S+="-"+A("st_from")+"-"+this.preparePlaceName(this.oPlaceName,this.oPlaceNameEN);if(P){S+="-"+A("st_to")+"-"+this.preparePlaceName(this.iPlaceName,this.iPlaceNameEN)}S+=O+".html"}else{if((SS.util.matchesEverywhere(this.oPlaceRawText)||!F)&&(SS.util.matchesEverywhere(this.iPlaceRawText)||!I)){M="/"+this.language;S=maText.st_rm}else{S="search.html";if(!J){if(!F){B+="ote=1&"}else{B+="ot="+encodeURL(this.oPlaceRawText)+"&"}}else{B+="oplace="+C+"&"}if(!P){if(!I){B+="ite=1&"}else{B+="it="+encodeURL(this.iPlaceRawText)+"&"}}else{B+="iplace="+L+"&"}if(this.oDatecode!=""){B+="odate="+this.oDatecode+"&"}if(this.isReturn){if(this.iDatecode!=""){B+="idate="+this.iDatecode+"&"}}B+="rtn="+(this.isReturn?"1":"0")+"&"}}if(this.owfc!=""){B+="owfc="+this.owfc+"&"}if(this.iwfc!=""){B+="iwfc="+this.iwfc+"&"}if(this.appendSSS){B+="sss="+SS.domainConstants.BETAParam+"&"}var K=M+"/"+S;if(B!=""){K+="?"+B.replace(/&$/,"")}K=this.rootUrl+K;return K.toLowerCase()}}}());