function populateHotels(a,b){if(a.length>0){$("#hotelsSearchTerm").val(a);$("#hotelsSearchTerm").css("color","#000000")}else{$("#hotelsSearchTerm").val(b);$("#hotelsSearchTerm").css("color","#D1D1D1")}}function checkDate(a){x=a.split("|");var b=0;var c=0;compareDate=new Date(x[2],x[1]-1,x[0]);today=new Date;c=compareDate-today;b=Math.round(c/(1e3*60*60*24));return b}BookingForm={formId:"#ryanairBookingForm",market:"ie",page:"HOME",pos:"BOOKING_FORM",hotelsCode:"BOOKINGHOTELS",carsCode:"HERTZ",inputValue:null,feed:null,animSpeed:100,maxInNarrowPopup:20,maxPopupColumns:5,details:{},cars:null,useCookies:true,cookieTimeout:365,maxRecSearches:6,maxPax:25,balearicsConfirm:false,sameDateConfirm:false,cache:{},calendarTestRegEx:/^[0-3][0-9]\/[0-1][0-9]\/2[0-9]{3}$/,routeBlockTpl:'<div class="routeBlock popupElement">',countryHeaderTpl:'<h4 class="countryName">::name::</h4>',newColTpl:'</div><div class="routeBlock popupElement">',airpLinkTpl:'<a class="outRoute" href="#::code::" title="::code::">::name::</a>',_navigate:function(a,b){c="highlighted";el=$(a+" .routeBlock .outRoute."+c);if(b=="up"){if(el.size()>0&&el.prev().length>0)el.removeClass(c).prev().addClass(c);else $(a+" .routeBlock .outRoute").removeClass(c).last().addClass(c)}else if(b=="down"){if(el.size()>0&&el.next().length>0)el.removeClass(c).next().addClass(c);else $(a+" .routeBlock .outRoute").removeClass(c).first().addClass(c)}el=$(a+" .routeBlock .outRoute."+c);$(a+" .popupHeader p span").text(el.text());return this},_noAccents:function(a){charmap={"ę":"e","ó":"o","ą":"a","ś":"s","ł":"l","ż":"z","ź":"z","ć":"c","ń":"n","ù":"u","û":"u","ü":"u","ÿ":"y","à":"a","â":"a","ç":"c","é":"e","è":"e","ê":"e","ë":"e","ï":"i","î":"i","ô":"o","á":"a","í":"i","ñ":"n","ú":"u","ì":"i","ò":"o","ä":"a","ö":"o","ß":"s","ã":"a","õ":"o","å":"a","ø":"o","ő":"o","ű":"u","ť":"t","ů":"u","ý":"y","ž":"z","č":"c","ď":"d","ě":"e","ň":"n","ř":"r","š":"s"};for(key in charmap)a=a.replace(key,charmap[key]);return a},_loadDefaultValuesFor:function(a){if(!this.inputValue)this.inputValue=[];$(this.formId+" "+a).each(function(){if(this.id==""){do{val=Math.floor(Math.random()*3405691582)}while($("#"+val).size()>0);this.id=val}BookingForm.inputValue[this.id]=this.value});return this},_isRouteAvailable:function(a,b){if(!a||!b)return false;return BookingForm.feed.routes[a].toString().indexOf(b)>=0?true:false},_flightFromProcessState:function(){R=$("#fromRoutes");iata=R.find(".outRoute.highlighted").attr("title");if(!iata)iata=R.find(".outRoute:first").attr("title");airportName=this._getAirportNameByCode(iata);if(iata&&airportName){this.details.fromLoc=iata;if(!this._isRouteAvailable(this.details.fromLoc,this.details.toLoc)){this.details.toLoc=null}this._sortRoutes(this.details.fromLoc)}else{this.details.fromLoc=null;this.details.toLoc=null}return this},_flightToProcessState:function(){R=$("#toRoutes");iata=R.find(".outRoute.highlighted").attr("title");if(!iata)iata=R.find(".outRoute:first").attr("title");airportName=this._getAirportNameByCode(iata);this.details.toLoc=iata&&airportName?iata:null;return this},_getAirportNameByCode:function(a){if(!a||!this.feed||!this.feed.airports)return null;for(i in this.feed.airports){for(j in this.feed.airports[i]){if(j.toString().toLowerCase()==a.toLowerCase())return this.feed.airports[i][j]}}return null},_getAirportSearchResults:function(a,b){if(!a)return null;arr=[];searchTermNoAccLC=this._noAccents(a).toLowerCase();if(b){if(a.length>1){for(keyx in this.feed.airports){for(keyy in this.feed.airports[keyx]){if(this._noAccents(this.feed.airports[keyx][keyy].toLowerCase()).indexOf(searchTermNoAccLC)>=0||keyy.toLowerCase().indexOf(a)===0){arr.push({code:keyy,name:this.feed.airports[keyx][keyy]})}}}}else{for(keyx in this.feed.airports){for(keyy in this.feed.airports[keyx]){if(this._noAccents(this.feed.airports[keyx][keyy].toLowerCase()).indexOf(searchTermNoAccLC)===0){arr.push({code:keyy,name:this.feed.airports[keyx][keyy]})}}}}}else{if(!this.details.fromLoc)return null;routes=this.feed.routes[this.details.fromLoc];if(a.length>1){$.each(routes,function(b,c){name=BookingForm._getAirportNameByCode(c);if(BookingForm._noAccents(name.toLowerCase()).indexOf(searchTermNoAccLC)>=0||c.toLowerCase().indexOf(a)===0){arr.push({code:c,name:name})}})}else{$.each(routes,function(a,b){name=BookingForm._getAirportNameByCode(b);if(BookingForm._noAccents(name.toLowerCase()).indexOf(searchTermNoAccLC)===0){arr.push({code:b,name:name})}})}}ret="";arr.sort(function(b,c){xRes=b.name.indexOf(a);yRes=c.name.indexOf(a);if(xRes<yRes)return-1;if(xRes>yRes)return 1;return 0});for(i in arr)ret+=this.airpLinkTpl.replace(/::code::/g,arr[i].code).replace(/::name::/g,arr[i].name);return ret},_getPopupContent:function(a){if(!a||!a.action)return"";if(this.cache[a.action])return this.cache[a.action];if(this.cache[a.action+a.extra])return this.cache[a.action+a.extra];structure=this.routeBlockTpl;size=test=0;if(a.action=="from"){if(this.renderedOutboundList)return this.renderedOutboundList;for(x in this.feed.airports)for(y in this.feed.airports[x])++size;for(x in this.feed.countries)++size;elPerCol=Math.ceil(size/this.maxPopupColumns);for(i in this.feed.countries){if(!this.feed.airports[this.feed.countries[i].code])continue;structure+=this.countryHeaderTpl.replace(/::name::/g,this.feed.countries[i].name);if(test<elPerCol){++test}else{structure+=this.newColTpl;test=0}for(key in this.feed.airports[this.feed.countries[i].code]){structure+=this.airpLinkTpl.replace(/::code::/g,key).replace(/::name::/g,this._getAirportNameByCode(key));if(test<elPerCol){++test}else{structure+=this.newColTpl;test=0}}}this.cache[a.action]=structure+"</div>";return this.cache[a.action]}else if(a.action=="to"){if(!a.extra)return"";size=0;cSize=0;test=0;retAirports=$.extend(true,{},this.feed.airports);testList=this.feed.routes[a.extra].toString();for(x in retAirports){incSize=true;for(y in retAirports[x]){if(testList.indexOf(y)<0){retAirports[x][y]=null}else if(incSize){++cSize;incSize=false}}}for(e in this.feed.routes[a.extra])size++;extended=size>this.maxInNarrowPopup?true:false;size+=cSize;elPerCol=Math.ceil(size/this.maxPopupColumns);if(extended){for(keyi in this.feed.countries){showCountryHeader=true;for(keyx in retAirports[this.feed.countries[keyi].code]){if(retAirports[this.feed.countries[keyi].code][keyx]!=null){if(test>=elPerCol){structure+=this.newColTpl;test=0}if(showCountryHeader){structure+=this.countryHeaderTpl.replace(/::name::/g,this.feed.countries[keyi].name);++test;if(test>=elPerCol){structure+=this.newColTpl;test=0}showCountryHeader=false}structure+=this.airpLinkTpl.replace(/::code::/g,keyx).replace(/::name::/g,this._getAirportNameByCode(keyx));++test}}}}else{route=this.feed.routes[a.extra].sort(function(a,b){aName=BookingForm._getAirportNameByCode(a).toLowerCase();bName=BookingForm._getAirportNameByCode(b).toLowerCase();if(aName<bName)return-1;if(aName>bName)return 1;return 0});for(key in route){structure+=this.airpLinkTpl.replace(/::code::/g,route[key]).replace(/::name::/g,this._getAirportNameByCode(route[key]))}}this.cache[a.action+a.extra]=structure+"</div>";return this.cache[a.action+a.extra]}return""},_setCookie:function(a,b,c){exDate=new Date;exDate.setDate(exDate.getDate()+c);cVal=escape(b)+(c==null?"":";expires="+exDate.toUTCString())+";path=/";document.cookie=a+"="+cVal;return this},_getCookie:function(a){for(i=0,arrC=document.cookie.split(";");i<arrC.length;++i){x=arrC[i].substr(0,arrC[i].indexOf("="));y=arrC[i].substr(arrC[i].indexOf("=")+1);x=x.replace(/^\s+|\s+$/g,"");if(x==a)return unescape(y)}},_initFromCookies:function(){if(this.useCookies){if(cookie=this._getCookie("recentsearches")){this.details.recentSearches=cookie.split(",").slice(0,this.maxRecSearches);$("#recentSearches ul li").remove();for(key in this.details.recentSearches){v=this.details.recentSearches[key].split("|");if(key==0){if(!this.details.fromLoc)this.details.fromLoc=v[0];if(!this.details.toLoc)this.details.toLoc=v[1];this._sortRoutes(this.details.fromLoc);if(this._isPreIE(7))$(function(){$("#flightFrom, #flightTo").change()});else $("#flightFrom, #flightTo").change()}else{$("#recentSearches ul").append('<li><a href="#" title="'+v[0]+"-"+v[1]+'">'+this._getAirportNameByCode(v[0])+" - "+this._getAirportNameByCode(v[1])+"</a></li>")}if(!this.details.recentSearches.length||this.details.recentSearches.length<2){$("#recentSearches").hide();break}if(this.maxRecSearches==key)break}$("#recentSearches ul li:last").addClass("last")}else{$("#recentSearches").hide()}if(this._getCookie("tt")=="1")$("#tt2").click();else $("#tt1").click();$(function(){bookingDate=BookingForm._getCookie("bdate");if(bookingDate&&!BookingForm._isPreIE(6)){bookingDate=bookingDate.split("|");depDate=new Date(bookingDate[0].substring(0,4),parseInt(bookingDate[0].substring(4,6),10)-1,bookingDate[0].substring(6,8));$("#departureInput").after(function(){return'<input type="hidden" id="'+this.id+'Hid">'}).datepicker("option","altField","#departureInputHid").datepicker("setDate",depDate).change();$("#arrivalInput").datepicker("option","minDate",depDate);if($("#arrivalInput:not(.readOnly)").size()>0){$("#arrivalInput").after(function(){return'<input type="hidden" id="'+this.id+'Hid">'}).datepicker("option","altField","#arrivalInputHid").datepicker("setDate",new Date(bookingDate[1].substring(0,4),parseInt(bookingDate[1].substring(4,6),10)-1,bookingDate[1].substring(6,8))).change()}}else{$("#departureInput").val(BookingForm.inputValue["departureInput"]).change();if($("#tt1").is(":checked"))$("#arrivalInput").val(BookingForm.inputValue["arrivalInput"]).change()}})}return this},_isPreIE:function(a){return $.browser.msie&&parseInt($.browser.version,10)<=a?true:false},_initPreIE8ver:function(){if(this._isPreIE(8)&&!this.preIE8initialized){$("div:first").before($("#fromRoutes")).before($("#toRoutes"));if(parseInt($.browser.version,10)<7){$(".bookingFormPopup").prepend('<iframe src="javascript:false;" frameborder="0"></iframe>')}this.preIE8initialized=true}return this},_preIE8AlignPopup:function(a,b){if(this._isPreIE(8)){calcLeft=a.offset().left-(b.outerWidth()-a.outerWidth())+120;calcTop=a.offset().top+a.outerHeight();b.css({left:calcLeft,top:calcTop})}return this},_sortRoutes:function(a){this.feed.routes[a]=(new Array(this.feed.routes[a]))[0].sort(function(a,b){return BookingForm._getAirportNameByCode(a)>BookingForm._getAirportNameByCode(b)?1:0});return this},_tabEventHandler:function(){$("#bookingFormTabs li").click(function(){$("#bookingFormTabs li").each(function(a){$(this).removeClass("activeTab");$("#body_"+this.id).hide()});$(this).addClass("activeTab");$("#body_"+this.id).show()});return this},_defaultInputEventHandler:function(){$(this.formId+' input[type="text"]').focus(function(a){$(this).addClass("hasFocus modified");if(this.value==BookingForm.inputValue[this.id])this.value=""}).blur(function(a){$(this).removeClass("hasFocus");if(this.value==""||this.value==BookingForm.inputValue[this.id])$(this).removeClass("modified").val(BookingForm.inputValue[this.id])}).click(function(){$(this).select()}).change(function(){if(this.value==BookingForm.inputValue[this.id]){$(this).removeClass("modified").val(BookingForm.inputValue[this.id])}else $(this).addClass("modified")}).keydown(function(a){switch(parseInt(a.keyCode?a.keyCode:a.which)){case 9:$(this).trigger("frnavtab");break;case 13:$(this).trigger("frnaventer");break;case 38:$(this).trigger("frnavup");break;case 40:$(this).trigger("frnavdown");break;default:$(this).trigger("frnavanyotherkey");break}}).keypress(function(a){switch(parseInt(a.keyCode?a.keyCode:a.which)){case 13:if(BookingForm.isWin51==undefined)BookingForm.isWin51=window.navigator.userAgent.indexOf("Windows 5.1")>0?true:false;if($.browser.msie&&parseInt($.browser.version,10)<=6&&!BookingForm.isWin51)$(this).trigger("frnaventer");break}});$(this.formId+" input,"+this.formId+" form").attr("autocomplete","off");$(function(){$(".calSelector").datepicker({numberOfMonths:2,defaultDate:"+1d",duration:BookingForm.animSpeed,changeMonth:true,changeYear:true,firstDay:1,dateFormat:"dd/mm/yy",altFormat:"dd|mm|yy",minDate:new Date,maxDate:"+12m",showButtonPanel:true,onSelect:function(a,b){hidElId="#"+this.id+"Hid";if($(hidElId).size()<1){$(this).after('<input type="hidden" id="'+this.id+'Hid">')}$(this).datepicker("option","altField",hidElId);hidEl=$(hidElId);d=hidEl.val().split("|");d=new Date(d[2],d[1]-1,d[0]);if(this.id=="departureInput"){arrInput=$("#arrivalInput");arrInput.datepicker("option","minDate",d);if($("#tt1").is(":checked")&&(arrInput.val()==""||arrInput.val()===BookingForm.inputValue["arrivalInput"])){if($("#arrivalInputHid").size()<1){arrInput.after('<input type="hidden" id="arrivalInputHid">')}arrInput.datepicker("setDate",d).change();$("#arrivalInputHid").val(hidEl.val())}}else if(this.id=="check-in"){(nD=new Date).setTime(d.getTime()+864e5);$("#check-out").datepicker("option","minDate",null).datepicker("setDate",nD).datepicker("option","minDate",d).change();if($("#check-outHid").size()<1){$(this).after('<input type="hidden" id="check-outHid">')}$("#check-outHid").val(nD.getDate()+"|"+(nD.getMonth()+1)+"|"+nD.getFullYear())}else if(this.id=="pickupDate"){$("#returnDate").datepicker("option","minDate",d)}$(this).change()}}).bind({frnavanyotherkey:function(){if(!$(this).datepicker("widget").is(":visible"))$(this).datepicker("show")},blur:function(){v=$("#"+this.id).val();if(!v||!BookingForm.calendarTestRegEx.test(v))$("#"+this.id+"Hid").remove()}}).bind("frnaventer frnavtab",function(){c=$(this).datepicker("widget").find(".ui-state-active");if(c.size()>0)c.click();else $("#"+this.id+"Hid").remove()})});return this},_initFlightTabState:function(){this.details.returnFlight=$("#tt1").is(":checked")?true:false;if($("input[name='tripType']:checked").val()=="RoundTrip")this.details.returnFlight=true;if($("input[name='tripType']:checked").val()=="OneWay")this.details.returnFlight=false;if($("#tripTypeBookingForm").val()=="RoundTrip")this.details.returnFlight=true;if($("#tripTypeBookingForm").val()=="OneWay")this.details.returnFlight=false;this.details.flexiFare=$("#flexiFare").is(":checked")?"columenView":"";if($("#flexiFare").val()=="on")this.details.flexiFare="columenView";this.details.termsAccepted=$("#termsAccept").is(":checked")?"yes":"no";this.details.adults=$("#adultPax").val();this.details.children=$("#childPax").val();this.details.infants=$("#infantPax").val();this.details.balearics="NO";if($("#departureInputHid").size()>0){this.details.departureDate=$("#departureInputHid").val().split("|")}if($("#arrivalInputHid").size()>0){this.details.arrivalDate=$("#arrivalInputHid").val().split("|")}this._initPreIE8ver();$("#tt1").focus();return this},_processState:function(){this._initFlightTabState();if(!this.details.fromLoc){alert(this.feed.notifications.selectdep);return 1}if(!this.details.toLoc){alert(this.feed.notifications.selectarr);return 2}if(!this.details.departureDate||this.details.departureDate==""){alert(this.feed.notifications.selectdepdate);return 3}if(this.details.returnFlight&&(!this.details.arrivalDate||this.details.arrivalDate=="")){alert(this.feed.notifications.selectarrdate);return 4}if(this.details.adults<1&&this.details.children>0){alert(this.feed.notifications.childunder16);return 5}if(this.details.adults<1){alert(this.feed.notifications.onepaxneeded);return 6}if(this.feed.balearicroutes.indexOf(this.details.fromLoc+this.details.toLoc)>-1){this.details.balearics=confirm(this.feed.notifications.balearics,"balearicsConfirm")?"YES":"NO"}departure=this.details.departureDate.reverse().join("");arrival=this.details.returnFlight?this.details.arrivalDate.reverse().join(""):"";if(departure==arrival&&!confirm(this.feed.notifications.samedatetrip,"sameDateConfirm")){return 7}depDate=(new Date(this.details.departureDate[0],this.details.departureDate[1]-1,this.details.departureDate[2])).toDateString();today=(new Date).toDateString();if(depDate==today&&!confirm(this.feed.notifications.traveltoday,"sameDateConfirm")){return 8}if(parseInt(this.details.adults)+parseInt(this.details.children)>this.maxPax){alert(this.feed.notifications.maxpaxreached.replace("{maxpax}",this.maxPax));return 9}if(parseInt(this.details.infants)>parseInt(this.details.adults)){alert(this.feed.notifications.numinfants);return 10}venRegEx=/(TSF)|(VCE)/;venRegExOut=/(VCE)/;if(venRegEx.test(this.details.fromLoc+this.details.toLoc)&&(departure>="20110601"&&departure<="20111204"||arrival>="20110601"&&arrival<="20111204")){alert(this.feed.notifications.trevisoclosure);if(departure>="20110601"&&arrival<="20111204"){if(this.details.fromLoc=="TSF")this.details.fromLoc="VCE";else if(this.details.toLoc=="TSF")this.details.toLoc="VCE"}}else if(venRegExOut.test(this.details.toLoc)&&(departure<"20110601"||departure>"20111204"||arrival<"20110601"||arrival>"20111204")){alert(this.feed.notifications.trevisoclosure);if(departure<"20110601"||departure>"20111204"){if(this.details.fromLoc=="VCE")this.details.fromLoc="TSF";else if(this.details.toLoc=="VCE")this.details.toLoc="TSF"}}if(this.details.termsAccepted=="no"){$(".terms").addClass("important");alert(this.feed.notifications.acceptterms);return 3735928559}return 0},_flightTabEventHandler:function(){$("#tt1").click(function(a){A=$("#arrivalInput").removeAttr("disabled").removeClass("readOnly");if(A.val()=="")A.val(BookingForm.inputValue[A.attr("id")])});$("#tt2").click(function(a){$("#arrivalInput").attr("disabled",true).addClass("readOnly").val("").removeClass("modified");$("#arrivalInputHid").remove()});if($("#tt2").is(":checked"))$("#tt2").click();$(".closePopup").click(function(a){a.preventDefault()});$("#fromDD").click(function(a){R=$("#fromRoutes");R.find(".routeBlock").remove();R.find(".popupBody").prepend(BookingForm._getPopupContent({action:"from"}));B=R.find(".routeBlock");B.filter(":not(:has(.outRoute))").remove();B.addClass("narrow").filter(":last").addClass("lastBlock");$("#toRoutes").hide();R.removeClass("short-list");BookingForm._preIE8AlignPopup($("#flightFrom"),R);R.fadeIn(BookingForm.animSpeed)});$("#toDD").click(function(a){if(!BookingForm.details.fromLoc||!BookingForm.feed.routes[BookingForm.details.fromLoc])return;size=0;test=1;for(a in BookingForm.feed.routes[BookingForm.details.fromLoc])size++;elPerCol=Math.ceil(size/BookingForm.maxPopupColumns);extended=size>BookingForm.maxInNarrowPopup?true:false;R=$("#toRoutes");R.find(".routeBlock").remove();R.find(".popupBody").prepend(BookingForm._getPopupContent({action:"to",extra:BookingForm.details.fromLoc}));if(extended)R.removeClass("short-list").find(".routeBlock").addClass("narrow");else R.addClass("short-list").find(".routeBlock").removeClass("narrow");B=R.find(".routeBlock");B.filter(":not(:has(.outRoute))").remove();B.filter(":last").addClass("lastBlock");$("#fromRoutes").hide();BookingForm._preIE8AlignPopup($("#flightTo"),R);R.fadeIn(BookingForm.animSpeed)});$("#fromRoutes .outRoute").live({mousedown:function(){iata=$(this).attr("title");airportName=BookingForm._getAirportNameByCode(iata);BookingForm.details.fromLoc=iata;BookingForm.details.toLoc=null;BookingForm._sortRoutes(BookingForm.details.fromLoc);$("#flightFrom").val(airportName).change();$("#flightTo").val(BookingForm.inputValue[$("#flightTo").id]).change();$("#fromRoutes").hide()},mouseenter:function(a){$("#fromRoutes .popupHeader p span").text($(this).text());$(".highlighted").removeClass("highlighted");$(this).addClass("highlighted")},mouseleave:function(a){$("#fromRoutes .popupHeader p span").text("")}});$("#flightFrom").blur(function(a){$("#fromRoutes").hide()}).bind({frnaventer:function(a){BookingForm._flightFromProcessState();R=$("#flightTo");if(!BookingForm.details.toLoc)R.removeClass("modified").val(BookingForm.inputValue[R.attr("id")]);$(this).change();$("#fromRoutes").hide()},frnavtab:function(a){BookingForm._flightFromProcessState();if(!BookingForm.details.toLoc)$("#flightTo").val("")},frnavup:function(a){BookingForm._navigate("#fromRoutes","up")},frnavdown:function(a){BookingForm._navigate("#fromRoutes","down")}}).change(function(a){if(BookingForm.details.fromLoc)$(this).val(BookingForm._getAirportNameByCode(BookingForm.details.fromLoc)).addClass("modified")}).keyup(function(a){if(a.keyCode==27||a.keyCode==13||a.keyCode==37||a.keyCode==38||a.keyCode==39||a.keyCode==40)return true;R=$("#fromRoutes");R.addClass("short-list").find(".routeBlock").removeClass("narrow").not(":first").remove();R.find(".outRoute, .countryName").remove();inputValue=$("#flightFrom").val().toLowerCase();if(!inputValue.length){R.hide();return}if(ret=BookingForm._getAirportSearchResults(inputValue,true)){R.find(".routeBlock").append(ret)}if(R.find(".outRoute").size()>0){BookingForm._preIE8AlignPopup($(this),R);R.fadeIn(BookingForm.animSpeed)}else{R.hide()}R.find(".popupHeader p span").text(R.find(".outRoute:first").text());R.find(".routeBlock:last").addClass("lastBlock")});$("#toRoutes .outRoute").live({mousedown:function(){iata=$(this).attr("title");airportName=BookingForm._getAirportNameByCode(iata);BookingForm.details.toLoc=iata;$("#flightTo").val(airportName).change();$("#toRoutes").hide()},mouseenter:function(a){$("#toRoutes .popupHeader p span").text($(this).text());$(".highlighted").removeClass("highlighted");$(this).addClass("highlighted")},mouseleave:function(a){$("#toRoutes .popupHeader p span").text("")}});$("#flightTo").blur(function(a){$("#toRoutes").hide()}).change(function(a){if(BookingForm.details.toLoc)$(this).val(BookingForm._getAirportNameByCode(BookingForm.details.toLoc)).addClass("modified")}).bind({frnaventer:function(a){BookingForm._flightToProcessState();$(this).change();$("#toRoutes").hide()},frnavtab:function(a){BookingForm._flightToProcessState()},frnavup:function(a){BookingForm._navigate("#toRoutes","up")},frnavdown:function(a){BookingForm._navigate("#toRoutes","down")}}).keyup(function(a){if(a.keyCode==27||a.keyCode==13||a.keyCode==37||a.keyCode==38||a.keyCode==39||a.keyCode==40)return true;R=$("#toRoutes");R.addClass("short-list").find(".routeBlock").removeClass("narrow").not(":first").remove();R.find(".outRoute, .countryName").remove();inputValue=$("#flightTo").val().toLowerCase();if(!inputValue.length){R.hide();return}if(content=BookingForm._getAirportSearchResults(inputValue,false)){R.find(".routeBlock").append(content)}if(R.find(".outRoute").size()>0){BookingForm._preIE8AlignPopup($(this),R);R.fadeIn(BookingForm.animSpeed)}else{R.hide()}R.find(".popupHeader p span").text(R.find(".outRoute:first").text());R.find(".routeBlock:last").addClass("lastBlock")});$("#recentSearches li a").live({mousedown:function(a){route=this.title.split("-");BookingForm.details.fromLoc=route[0];BookingForm.details.toLoc=route[1];BookingForm._sortRoutes(BookingForm.details.fromLoc);$("#flightFrom, #flightTo").change()},click:function(a){a.preventDefault();$("#fromRoutes").hide()},mouseenter:function(){$("#fromRoutes .popupHeader p span").text(BookingForm._getAirportNameByCode(this.title.split("-")[0]))},mouseleave:function(){$("#fromRoutes .popupHeader p span").text("")}});$("#flightBookingForm").submit(function(a){if(BookingForm._processState()!=0)return false;depDate=BookingForm.details.departureDate.join("");arrDate=BookingForm.details.arrivalDate?BookingForm.details.arrivalDate.join(""):"";bookingDetails={ADULT:BookingForm.details.adults,BalearicUserAnswer:BookingForm.details.balearics,CHILD:BookingForm.details.children,INFANT:BookingForm.details.infants,SearchBy:BookingForm.details.flexiFare,acceptTerms:BookingForm.details.termsAccepted,culture:BookingForm.market,date1:depDate,date2:BookingForm.details.returnFlight?arrDate:"",language:"",m1:depDate+"a"+BookingForm.details.fromLoc+BookingForm.details.toLoc,m1DO:"0",m1DP:"0",m2:BookingForm.details.returnFlight?arrDate+BookingForm.details.toLoc+"a"+BookingForm.details.fromLoc:"",m2DO:"0",m2DP:"0",mode:"0",module:"SB",nom:BookingForm.details.returnFlight?"2":"1",oP:"",pM:"0",pT:BookingForm.details.adults+"ADULT",page:"SELECT",rP:"",sector1_d:BookingForm.details.toLoc,sector1_o:"a"+BookingForm.details.fromLoc,sector_1_d:BookingForm.details.departureDate[2],sector_1_m:BookingForm.details.departureDate[1]+BookingForm.details.departureDate[0],sector_2_d:BookingForm.details.returnFlight?BookingForm.details.arrivalDate[2]:"00",sector_2_m:BookingForm.details.returnFlight?BookingForm.details.arrivalDate[1]+BookingForm.details.arrivalDate[0]:"--",tc:"1",travel_type:"on"};$('#flightBookingForm input[type="hidden"]').remove();$.each(bookingDetails,function(a,b){$("#flightBookingForm").append('<input type="hidden" value="'+b+'" id="'+a+'" name="'+a+'" >')});if(BookingForm.useCookies){BookingForm._setCookie("tt",$("#tt1").is(":checked")?"0":"1",BookingForm.cookieTimeout);BookingForm._setCookie("bdate",depDate+"|"+(arrDate?arrDate:""),BookingForm.cookieTimeout);if($("input[name='tripType']:checked").val()){BookingForm._setCookie("tt",$("input[name='tripType']:checked").val()=="RoundTrip"?"0":"1",BookingForm.cookieTimeout)}if($("#tripTypeBookingForm").val()){BookingForm._setCookie("tt",$("#tripTypeBookingForm").val()=="RoundTrip"?"0":"1",BookingForm.cookieTimeout)}if(!BookingForm.details.recentSearches)BookingForm.details.recentSearches=[];route=BookingForm.details.fromLoc+"|"+BookingForm.details.toLoc;for(key in BookingForm.details.recentSearches){if(BookingForm.details.recentSearches[key].indexOf(route)>=0){BookingForm.details.recentSearches.splice(key,1);break}}BookingForm.details.recentSearches.unshift(route);BookingForm._setCookie("recentsearches",BookingForm.details.recentSearches.toString(),BookingForm.cookieTimeout)}});return this},_hotelsInputEventHandler:function(){$("#bookHotelForm").submit(function(a){searchTerm=$("#hotelsSearchTerm").val().replace(/</g,"<").replace(/>/g,">");if(!searchTerm||searchTerm==""||searchTerm=="Destination e.g. city, hotel name"){alert("Please enter a destination or hotel name");return false}data={ss:searchTerm==BookingForm.inputValue[$("#hotelsSearchTerm").attr("id")]?"":searchTerm};if($("#check-inHid").size()>0){x=$("#check-inHid").val().split("|");data.checkin_monthday=x[0],data.checkin_year_month=x[2]+"-"+x[1]}else{alert("Please enter a check-in date");return false}if($("#check-outHid").size()>0){x=$("#check-outHid").val().split("|");data.checkout_monthday=x[0],data.checkout_year_month=x[2]+"-"+x[1]}else{alert("Please enter a check-out date");return false}numdays=checkDate($("#check-inHid").val());if(numdays<0){alert("Please enter a valid check-in date");return false}numdays=checkDate($("#check-outHid").val());if(numdays<0){alert("Please enter a valid check-out date");return false}$("#bookHotelForm input.hDyn").remove();$.each(data,function(a,b){$("#bookHotelForm").append('<input type="hidden" class="hDyn" name="'+a+'" value="'+b+'">')});xt_ad("PUB-["+BookingForm.market.toUpperCase()+"]-["+BookingForm.page+"_"+BookingForm.pos+"]-["+BookingForm.page+"]-[0]-[0]-["+BookingForm.market.toUpperCase()+"_"+BookingForm.page+"_"+BookingForm.pos+"]-["+BookingForm.hotelsCode+"]")});return this},_carsInputEventHandler:function(a){$("#carPickup").change(function(a){$("#pickupLocation *:not(:first)").remove();loc=BookingForm.cars.feed.visiblemarkets[$(this).val().toLowerCase()];if(loc){$.each(loc,function(a,b){$("#pickupLocation").append('<option value="'+a+'">'+b+" ("+a+")</option>")})}});$("#bookingFormTab3").click(function(b){if(!BookingForm.cars){$.getJSON(a,function(a){BookingForm.cars={};BookingForm.cars.feed=a;$.each(BookingForm.cars.feed.countries,function(a,b){if(BookingForm.cars.feed.visiblemarkets[a.toLowerCase()]){$("#carPickup").append('<option value="'+a+'">'+b+"</option>")}$("#ctryResidence").append('<option value="'+a+'">'+b+"</option>")})})}});$("#carHireForm").submit(function(a){xt_ad("PUB-["+BookingForm.market.toUpperCase()+"]-["+BookingForm.page+"_"+BookingForm.pos+"]-["+BookingForm.page+"]-[0]-[0]-["+BookingForm.market.toUpperCase()+"_"+BookingForm.page+"_"+BookingForm.pos+"]-["+BookingForm.carsCode+"]");pD=$("#pickupDateHid").val().split("|");rD=$("#returnDateHid").val().split("|");$('input[name="Pday"]').val(pD[0]);$('input[name="Pmoyr"]').val(pD[1]+pD[2]);$('input[name="Rday"]').val(rD[0]);$('input[name="Rmoyr"]').val(rD[1]+rD[2])});return this},IEprompt:function(a){var b=navigator.userAgent.indexOf("MSIE 7")>0;if(b){}else{alert(a)}},IEconfirm:function(a,b){if(window["BookingForm."+b]==true)return true;var c=navigator.userAgent.indexOf("MSIE 7")>0;if(c){}else{return confirm(a)}},init:function(a){if(a.id)this.formId=a.id;if(!a.feedUrl||a.feedUrl=="")throw"Missing required parameter: feedUrl";if(a.market)this.market=a.market;if(a.animSpeed)this.animSpeed=a.animSpeed;if(a.details)this.details=a.details;if(a.useCookies)this.useCookies=a.useCookies;if(a.maxInNarrowPopup)this.maxInNarrowPopup=a.maxInNarrowPopup;if(a.maxPopupColumns)this.maxPopupColumns=a.maxPopupColumns;if(a.cookieTimeout)this.cookieTimeout=a.cookieTimeout;if(a.fromLoc)this.details.fromLoc=a.fromLoc;if(a.toLoc)this.details.toLoc=a.toLoc;$.getJSON(a.feedUrl,function(a){BookingForm.feed=a;tmpArr=[];for(key in BookingForm.feed.countries)tmpArr.push({code:key,name:BookingForm.feed.countries[key]});BookingForm.feed.countries=tmpArr;BookingForm.feed.countries.sort(function(a,b){aName=a.name.toLowerCase();bName=b.name.toLowerCase();if(aName<bName)return-1;if(aName>bName)return 1;return 0});BookingForm._tabEventHandler();$(BookingForm.formId+" .ajaxLoader").hide();$("#body_bookingFormTab1").show();BookingForm._initFromCookies()});$(".bookingFormPopup *:not(.closePopup)").addClass("popupElement");this._loadDefaultValuesFor('input[type="text"]')._defaultInputEventHandler()._initFlightTabState()._flightTabEventHandler()._hotelsInputEventHandler()._carsInputEventHandler(a.carsFeedUrl);return this}};$(document).click(function(a){if(!$(a.target).is("#fromDDImg, #toDDImg, .bookingFormPopup, .arrIcon, .popupElement h4.countryName")){$(".bookingFormPopup").fadeOut(BookingForm.animSpeed)}}).keydown(function(a){if(a.keyCode==27)$(".bookingFormPopup").fadeOut(BookingForm.animSpeed)});
