function processSearchForm(b,h,d){try{var n=true;$(b.EMBEDDED_TRANSACTION).val(h.transaction.embedded);$.each(h.defaults,function(x,w){$("#"+x,b).val(w)});var u;h.departure=new Date();h.departure.setDate(h.departure.getDate()-1);var k;var l=$("fieldset.places:visible",b);var o=l.length;l.each(function(w){u=$(this).find(".departDate").datepicker("getDate");if(h.mode=="multicity"&&u!=null){var x=true;$(this).find(".airport").each(function(){if(this.value==""){if(this.id.indexOf("B_LOCATION")!=-1&&$("#dep_"+(w+1)).val().length==3){this.value=$("#dep_"+(w+1)).val().toUpperCase()}else{if(this.id.indexOf("E_LOCATION")!=-1&&$("#arr_"+(w+1)).val().length==3){this.value=$("#arr_"+(w+1)).val().toUpperCase()}}}if(this.value!=""){x=false}});if(x){o--}}});l.slice(0,o).each(function(w){var x=$(this).find(".departDate");u=x.datepicker("getDate");$(this).find(".airport").each(function(){n=n&&validate(this.value.length==3,h.errors.invalidAirport,$(this).siblings(":visible:last"))});if(!n){return false}k=getRange($(this).find(".departure .airport").val(),h);n=validate(u!=null,h.errors.invalidDepartureTime,x)&&validate(($(this).find(".departDate").val().indexOf("yyyy")==-1),h.errors.invalidDepartureTime,x)&&validate(u>=h.departure,h.errors.beforePreviousFlight,x)&&validate(u>=k.startDate,h.errors.beforeTimerange,x)&&validate(u<=k.endDate,h.errors.afterTimerange,x);if(!n){return false}$("#B_DATE_"+(w+1)).val(getAmadeusFormattedDate(u));h.departure=u});if(!n){return false}if(b.TRIP_TYPE.value==h.RETURN){var i=$(b.arrivalDate);u=i.datepicker("getDate");if(u!=null){b.B_DATE_2.value=getAmadeusFormattedDate(u);if(!validate(u>=h.departure,"[T] return is before departure",i)){return false}h.arrival=u}else{b.TRIP_TYPE.value=h.ONEWAY;b.B_DATE_2.value=""}}else{}var c=0;var v=0;var r=0;var q=0;var m=9;var t;$(".traveller",b).val("");$.each(h.pax,function(w,x){if(x=="INF"){q=parseInt(b.INF.value)}else{t=parseInt(b[x].value);$(".traveller",b).slice(r,t+r).val(x);r+=t;if(x=="CHD"){c=t}else{v+=t}}});if(!validate(r<=m,h.errors.maxNumberOfPassangers)||!validate(q<=v,h.errors.maxNumberOfInfants)||!validate(r>0,h.errors.atLeastOnePassanger)||!validate(v>0,h.errors.atLeastOneAdult)){return false}$(".infant",b).val("FALSE").slice(0,q).val("TRUE");if($("#searchByExactDates:visible").is(":checked")){console.debug("searchByExactDates: "+h.mode);$(b.PRICING_TYPE).val("O");$(b.DISPLAY_TYPE).val("2");if(h.mode=="stopover"||h.mode=="openjaw"){$(b.EMBEDDED_TRANSACTION).val(h.transaction.airComplex)}}if(h.mode=="stopover"){if(o<3){$("#PRICING_TYPE").val("O");$("#amadeus_profile").append('<input type="hidden" name="PBI_NO_ERT_OUTPUT" id="PBI_NO_ERT_OUTPUT" value="FALSE"" />')}else{$("#amadeus_profile").append('<input type="hidden" name="PBI_NO_ERT_OUTPUT" id="PBI_NO_ERT_OUTPUT" value="TRUE"" />');$("#amadeus_profile").append('<input type="hidden" name="OUTPUT_STRUCTURE" id="OUTPUT_STRUCTURE" value="RECOMMENDATION"" />')}}if($("#giftcertificate:visible").is(":checked")){b.action="/origo-portlets/amadeus/amadeusServlet";$(b.SO_SITE_MOP_CREDIT_CARD).remove();$(b.SO_SITE_MOP_EXT).remove()}else{b.action=h.testMode&&!$("#submit-amadeus").is(":checked")?h.portlet:h.url}var f,a=null;$(".staff:visible > #staffId").each(function(){n=validate(this.value!="",h.errors.noStaffIdFound,this)&&validate(!isNaN(this.value*1),h.errors.staffIdOnlyNumbers,this)&&validate(this.value.length==10,h.errors.staffIdToShort,this);if(n){a="STAFF_ID";f=this.value}});$(".expense:visible > #expenseAccount").each(function(){if(a!=null){return}n=validate(this.value!="",h.errors.noExpenseAccountFound,this);if(n){a="EXPENSE_ACCOUNT";f=this.value}});$(".corporateCodes:visible > #ddCode").each(function(){if(a!=null){return}n=validate(this.value!="",h.errors.noDDCodeSelected,this);if(n){a="DD_CODE";f=this.value}});if(a==null&&$("#external_remark_code").val()!=""){a=$("#external_remark_code").val();f=$("#external_remark_value").val()}if(!n){return false}if(h.cookies){}var p=$(b.B_LOCATION_1).val();var e=$(b.E_LOCATION_1).val();var g=$(b.SO_GL);h.checkTimeframe=false;h.departureFormated=getFormattedDate(h.departure);h.arrivalFormated=h.arrival?getFormattedDate(h.arrival):"";var j="";if(b.EMBEDDED_TRANSACTION.value!=h.transaction.air){j=$("#COMMERCIAL_FARE_FAMILY_1").val();if(b.TRIP_TYPE.value==h.RETURN||b.TRIP_TYPE.value==h.ONEWAY){h.checkTimeframe=true}}else{h.checkOwd=false}if(b.TRIP_TYPE==h.ONEWAY){h.checkOwd=true}if(a==null){seleroAmadeusManager.getSettingsForBookingQuery(p,e,h.departureFormated,h.arrivalFormated,j,g.val(),h.checkTimeframe,h.checkOwd,h.serviceFeeEnabled,function(w){amadeusCallback(w,h,b,d)})}else{seleroAmadeusManager.getSettingsForBookingQueryWithCode(p,e,h.departureFormated,h.arrivalFormated,j,g.val(),h.checkTimeframe,h.checkOwd,h.serviceFeeEnabled,a,f,h.context,h.ddCodePricing,function(w){amadeusCallback(w,h,b,d)})}setBookingEngineCookies(b,h);return true}catch(s){return false}}function setBookingEngineCookies(e,c){var g=new Date();var a;var h;var b;var f=c.context;g.setTime(g.getTime()+(24*60*60*1000));SetCookie("contextName",f,g);SetCookie("confMode",c.mode,g);for(var d=0;d<e.elements.length;d++){a=e.elements[d].type;h=e.elements[d].name;b=e.elements[d].id;if(((a!="hidden")&&(a!="button"))||b.indexOf("B_LOCATION")!=-1||b.indexOf("E_LOCATION")!=-1){if(a=="radio"||a=="checkbox"){SetCookie(b,e.elements[d].checked,g)}else{if(e.elements[d].value!=null){SetCookie(b,e.elements[d].value,g)}}}}}function amadeusCallback(d,b,c,f){var e=new Date();e.setDate(e.getDate()+3);var a=b.departure<e?"3":"7";if(c.TRIP_TYPE.value!=b.RETURN&&c.TRIP_TYPE.value!=b.ONEWAY){a=c.DATE_RANGE_VALUE_1.value}if(c.TRIP_TYPE==b.ONEWAY){if(d.owdAirportRouting.fareFamily!=null){setFareFamily(d,a,c)}else{c.EMBEDDED_TRANSACTION.value=b.transaction.air}}else{if(b.owdEnabled){if(d.owdAirportRouting.owdEnabled){setFareFamily(d,a,c)}else{if(d.owdAirportRouting.fareFamily!=null){setValue("COMMERCIAL_FARE_FAMILY_1",d.owdAirportRouting.fareFamily.fareFamily)}}}}if(d.outsideTimeframe){console.debug("fligh is outside timeframe:  "+b.mode);if(b.mode=="openjaw"||b.mode=="openjaw"){c.EMBEDDED_TRANSACTION.value=b.transaction.aircomplex}else{c.EMBEDDED_TRANSACTION.value=b.transaction.air}if(document.getElementById("COMMERCIAL_FARE_FAMILY_1")!=null&&document.getElementById("CABIN")!=null){document.getElementById("CABIN").selectedIndex=document.getElementById("COMMERCIAL_FARE_FAMILY_1").selectedIndex}$(".cabinFamilies",c).hide();$(".fareFamilies",c).show()}if(b.flightScheduleOfficeId!=null&&b.flightScheduleOfficeId.length>0&&(c.EMBEDDED_TRANSACTION.value==b.transaction.air||$("#searchByExactDates").is(":checked"))){$(c.SO_SITE_OFFICE_ID).val(b.flightScheduleOfficeId)}loadServiceFeeXML(d.serviceFee,c);if(c.EMBEDDED_TRANSACTION.value==b.transaction.air){$("#PRICING_TYPE").remove()}f(c)}function loadServiceFeeXML(b,a){$(a.SO_SITE_PROMPT_FEE).val(b.promptFee);$(a.SO_LANG_SERVICE_FEE_CHARGE).val(b.serviceFeeCharge);$(a.SO_GL).val(b.soGl)}function setFareFamily(c,a,b){setValue("COMMERCIAL_FARE_FAMILY_1",c.owdAirportRouting.fareFamily.fareFamily);$(b.PRICING_TYPE).val("O");$(b.DATE_RANGE_VALUE_1).val(a);$(b.DATE_RANGE_VALUE_2).val(a)}function setValue(c,a){var b=document.getElementById(c);if(b!=null){if(b.tagName=="SELECT"){b.options[b.selectedIndex].value=a}else{if(b.tagName=="INPUT"){b.value=a}}}}function getRange(e,d){var b=d.calendarRange[e];if(typeof b=="undefined"){b=d.calendarRange.XXX}var a=new Date();for(var c in b){c=c<a?a:c}return b}function setCookieValues(e,g){var a;var f=GetCookie("contextName");var d;if(f==g){for(var c=0;c<e.elements.length;c++){a=e.elements[c].type;d=e.elements[c].disabled;var b=e.elements[c].id;if(((a!="hidden")&&(a!="button")&&(!d))||b.indexOf("B_LOCATION")!=-1||b.indexOf("E_LOCATION")!=-1){f=GetCookie(b);if(f!=null&&f!="undefined"){setBookingEngineCookieValue(e.elements[c],f)}}}}}function setBookingEngineCookieValue(element,val){if(element!=null){if(element.tagName=="SELECT"){for(var i=0;i<element.options.length;i++){if(element.options[i].value==val){element.options[i].selected=true}}if(element.id.indexOf("dep_dropdown")!=-1){if($("#"+element.id).is(":visible")){$("#"+element.id+" option:contains("+val+")").attr("selected",true);$("#"+element.id).triggerHandler("change",true)}}else{if(element.id.indexOf("arr_dropdown")!=-1){if($("#"+element.id).is(":visible")){$("#"+element.id+" option:contains("+val+")").attr("selected",true)}}}}else{if(element.tagName=="INPUT"){if(val!=null){if(element.type=="checkbox"){element.checked=eval(val)}else{if(element.type=="radio"){element.checked=eval(val)}else{element.value=unescape(val)}}}}}}}function initBooking(conf,form){var elemFocusOn;conf.form=form;if(conf.cookies){}function getRange(airport){var range=conf.calendarRange[airport];if(typeof range!="undefined"){return range}return conf.calendarRange.XXX}function dateRange(input,data,i){var oneYearAhead=new Date();oneYearAhead.setDate(oneYearAhead.getDate()+365);if(typeof i=="undefined"){i="1"}var range=getRange($("#B_LOCATION_"+i).val(),conf);var arrival,depart=null;if(conf.mode=="return"){if(input.id=="departDate-"+i){arrival=$("#arrivalDate-"+i).val().indexOf("y")<0?$("#arrivalDate-"+i).datepicker("getDate"):null;if(arrival!=null){if(i>1){return{maxDate:oneYearAhead,minDate:range.startDate,numberOfMonths:[1,1]}}else{return{maxDate:oneYearAhead,minDate:range.startDate}}}}else{if(input.id=="arrivalDate-"+i){depart=$("#departDate-"+i).val().indexOf("y")<0?$("#departDate-"+i).datepicker("getDate"):null;if(depart!=null){if(!conf.restrictOnlyDepCal){return{minDate:depart,maxDate:range.endDate,numberOfMonths:[1,1]}}else{return{minDate:depart,maxDate:oneYearAhead,numberOfMonths:[1,1]}}}}}}else{if(conf.mode!="oneway"&&i>1){arrival=$("#departDate-"+(i-1)).datepicker("getDate");if(arrival!=null){if(i>1){return{minDate:arrival,maxDate:range.endDate,numberOfMonths:[1,1]}}else{return{minDate:arrival,maxDate:range.endDate}}}}}return{minDate:range.startDate,maxDate:range.endDate}}function initAmadeusCalendar(){$("#departDate-1, #arrivalDate-1").datepicker({beforeShow:dateRange}).each(function(i,cal){if(cal.value==""&&conf.dateFormat&&conf.dateFormat.indexOf("?")<0){cal.value=conf.dateFormat+"yy"}})}if(conf.locale!="en"){calendarCallbacks.push(function(){initAmadeusCalendar()})}else{initAmadeusCalendar()}function removeFlight(){slide($("fieldset.places:gt(0):visible:last",form),"hide",legCount)}function addFlight(){if(conf.legs<conf.maxLegs){var flight;if(conf.legs>=$("fieldset.places",form).length){var last=$("fieldset.places:last",form);flight=last.clone(false).hide().insertAfter(last);flight.each(function(i,item){var places=$(item);places.find("div").each(function(j,label){label.id=incrementStr(label.id)});places.find("input, select").each(function(j,label){label.id=incrementStr(label.id);label.name=incrementStr(label.name);if(label.id.indexOf("B_LOCATION_")!=-1||label.id.indexOf("E_LOCATION_")!=-1){label.name=label.id}});places.find("label").each(function(j,label){$(label).attr("for",incrementStr($(label).attr("for")))});places.find(".airport").val("");places.find("input.location").each(function(i,el){addInputEvent(el)});addSelectEvent(places.find("select.location"));addAjaxAirportEvent(places.find("div.ajaxOpenPanelImg"));$(".ajaxOpenPanelImg").click(function(e){e.stopPropagation()});$(".panelContent").click(function(e){e.stopPropagation()});places.find("select.location").each(function(j,label){initAirports(label,conf,form)});places.find(".arrivals").remove();places.find(".amadeusDateRange, .ui-datepicker-trigger, .generated").remove();var id=parseInt(conf.legs)+1;$('<input type="text" name="departDate" class="departDate amadeusDateRange" id="departDate-'+id+'" />').insertAfter(places.find("label.amadeusDate")).datepicker({beforeShow:function(input,data){return dateRange(input,data,id)}});if(conf.legs>1){$('<input type="hidden" id="B_DATE_'+(conf.legs+1)+'" name="B_DATE_'+(conf.legs+1)+'" value="" class="amadeusDate generated" />').insertAfter(places.find(".amadeusDate"))}})}else{flight=$("fieldset.places",form)[conf.legs]}slide(flight,"show",legCount)}}function slide(elems,type,callback){var elements=$(elems);elements.animate({height:type,opacity:type},1000,function(){if(jQuery.browser.msie){this.style.removeAttribute("filter")}if(jQuery.isFunction(callback)){callback()}});if(elements.length==0&&jQuery.isFunction(callback)){callback()}}$(".addFlight").click(addFlight);$(".removeFlight").click(removeFlight);function legCount(){conf.legs=$("fieldset.places:visible",form).length;if(conf.legs<conf.maxLegs){$(".addFlight",form).parent().fadeTo("slow",1)}else{$(".addFlight",form).parent().fadeTo("slow",0.33)}if(conf.legs<2){$(".removeFlight",form).parent().fadeTo("slow",0.33)}else{$(".removeFlight",form).parent().fadeTo("slow",1)}return conf.legs}function addSelectEvent(el){$(el,form).change(function(event,checkArrival){var orderNr=(this.id.substring(this.id.length-1))-1;if(this.id.indexOf("dep")!=-1&&this.selectedIndex>0){updateArrivalAirports(this.value,this.id,conf.context,conf.locale,orderNr)}if(this.value==$(this).next().next().val()){return}$(this).next().next().val(this.value);if(this.id.indexOf("dep")!=-1){if(this.value!=""){updateArrivalAirports(this.value,this.id,conf.context,conf.locale,orderNr)}}})}function addAjaxAirportEvent(el){$(el,form).click(function(){var id=this.id;if(this.id.indexOf("ajax_dep")!=-1){var orderNr=(this.id.substring(this.id.length-1));seleroAmadeusManager.getDepartureAirportsByContext(conf.context,conf.locale,(orderNr-1),function(data){$("#ajaxAirportsDeparturePanel_"+orderNr).html(processAjaxPanelData(data,"B_LOCATION_",orderNr,"dep_"));$(("#panelContent_"+id)).show("slow")})}else{if(this.id.indexOf("ajax_arr")!=-1){var orderNr=this.id.substring(this.id.length-1);var depAirp=$("#B_LOCATION_"+orderNr).val();if(depAirp==""){alert(conf.errors.missingDepAirp)}else{seleroAmadeusManager.getAjaxArrivalAirports(depAirp,conf.context,conf.locale,(orderNr-1),function(data){$("#ajaxAirportsArrivalPanel_"+orderNr).html(processAjaxPanelData(data,"E_LOCATION_",orderNr,"arr_"));$("#panelContent_"+id).show("slow")})}}}})}function processAjaxPanelData(data,location,orderNr,airpField){var continents=[];$.each(data,function(){if(continents[this.continent]==null){continents[this.continent]=""}if(!this.hideForPanelDisplay){continents[this.continent]+="<li><a href='#' onClick=\"setAjaxAirport('"+location+orderNr+"','"+this.code+"','"+airpField+orderNr+"','"+this.name+"')\"><span id='"+this.code+"'>"+this.name+" ("+this.code+")</span></a></li>"}});var str="";str+=getPanelHtml(continents,"IS","GL");str+=getPanelHtml(continents,"EU");str+=getPanelHtml(continents,"E2");str+=getPanelHtml(continents,"US","UC");return str}function getPanelHtml(continents,code,code2){if(continents[code]!=null&&continents[code]!=""){var tmp="";tmp='<ul class="'+code+'" ><label class="panelLabel">'+eval("conf.ajaxPanelLabel."+code)+"</label>"+continents[code];if(code2!=null&&continents[code2]!=null&&continents[code2]!=""){tmp+='<label class="panelLabel second">'+eval("conf.ajaxPanelLabel."+code2)+"</label>"+continents[code2]}tmp+="</ul>";return tmp}else{return""}}function updateArrivalAirports(depAirp,depAirpId,context,locale,orderNr){var arrival=$("#arr"+depAirpId.substring(3));var current=arrival.next().next();seleroAmadeusManager.getArrivalAirports(depAirp,context,locale,orderNr,function(data){$(arrival).empty();$.each(data,function(key,value){$("<option/>").val(key).text(value).appendTo(arrival);if(current.val()==key){arrival.val(key)}});current.val(arrival.val())})}function addInputEvent(el){el.value="";$(el).bind("click",function(){$(el).focus()});$(el).bind("focus",function(){$(el).select();elemFocusOn=el.id});if(!conf.ajaxLookupAirportDropdown){$(el,form).autocomplete(seleroAmadeusManager.getAirports,{minChars:3,matchSubset:1,matchContains:1,cacheLength:10,selectOnly:1,onItemSelect:function(li){selectAirport(li,el)}})}else{$(el,form).autocomplete(getAjaxAirport,{minChars:3,matchSubset:1,matchContains:1,cacheLength:0,selectOnly:1,onItemSelect:function(li){selectAirport(li,el)}})}}function getAjaxAirport(query,callback){var depAirp="";if(elemFocusOn.indexOf("arr")!=-1){var orderNr=elemFocusOn.substring(elemFocusOn.indexOf("_")+1);depAirp=$("#B_LOCATION_"+orderNr).val()}seleroAmadeusManager.getAjaxAirport(query,conf.context,elemFocusOn,depAirp,conf.locale,callback)}function selectAirport(li,el){if(li.extra){$(el).focus().next().val(li.extra[0].toUpperCase())}}$("input.location",form).change(function(event){$(this).focus()});function toggleInput(){$("input.location",form).show().each(function(i,el){el.value=""});$("input.airport",form).each(function(i,el){el.value=""});$("div.ajaxOpenPanelImg",form).show();$("select.location",form).hide()}function toggleSelect(){$("select.location",form).show().each(function(i,el){var current=$(el).next().next();if(current.val()!=""){$(this).val(current.val()).triggerHandler("change",true)}else{if(this.value.length==3){current.val(this.value)}}}).triggerHandler("change");$("input.location",form).hide();$("div.ajaxOpenPanelImg",form).hide()}function twoLegs(maxTwo,callback){if(conf.legs<2){addFlight()}if(maxTwo){slide($("fieldset.places:gt(1)",form),"hide",callback);conf.legs=2}else{if(jQuery.isFunction(callback)){callback()}}}function oneLeg(callback){slide($("fieldset.places",form).slice(1),"hide",callback);conf.legs=1}function showControls(callback){slide($(".controls",form),"show",callback)}function hideControls(callback){slide($(".controls",form),"hide",callback)}function hideArrivals(){$(".arrivals",form).hide()}function showArrivals(){$(".arrivals",form).fadeTo("slow",1).show();$("#arrivalDate-1").datepicker("enable")}function fadeArrivals(){$(".arrivals",form).fadeTo("slow",0.33);$("#arrivalDate-1").val("");$("#arrivalDate-1").datepicker("disable")}function hideExampleText(){$("div.example",form).hide()}function showExampleText(type){$(".example."+type,form).show().siblings(".example").hide()}function returnTrip(){$(form.TRIP_TYPE).val(conf.RETURN)}function oneWayTrip(){$(form.TRIP_TYPE).val(conf.ONEWAY)}function multiTrip(){$(form.TRIP_TYPE).val(conf.MULTICITY)}function loadContext(ctx){conf.url=ctx.amadeusUrl.url;var office=$.trim(ctx.advancedSettings.flightScheduleOfficeId);conf.checkOwd=ctx.advancedSettings.enableOwdRoutings;conf.owdEnabled=ctx.advancedSettings.enableOwdRoutings;conf.serviceFeeEnabled=ctx.advancedSettings.serviceFeeEnabled;conf.ddCodePricing=ctx.advancedSettings.ddCodePricing;conf.flightScheduleOfficeId=office;conf.hideCabinAndClass=ctx.advancedSettings.hideCabinAndClass;conf.onlyScheduleDriven=ctx.advancedSettings.onlyScheduleDriven;conf.restrictOnlyDepCal=ctx.advancedSettings.restrictBookingDays&&ctx.advancedSettings.nrOfBookingDays>0;conf.ajaxLookupAirportDropdown=ctx.advancedSettings.ajaxLookupAirportDropdown;conf.context=ctx.contextName;conf.locale=ctx.domain;conf.transaction.embedded=$.trim(ctx.amadeusUrl.embeddedTransaction);conf.defaults={PRICING_TYPE:ctx.basicSettings.pricing_type,DISPLAY_TYPE:ctx.basicSettings.DISPLAY_TYPE,DATE_RANGE_VALUE_1:ctx.basicSettings.DATE_RANGE_VALUE_1,DATE_RANGE_VALUE_2:ctx.basicSettings.DATE_RANGE_VALUE_2,SO_SITE_OFFICE_ID:$.trim(ctx.officeId.officeId)};conf.giftcertificate={allow:ctx.advancedSettings.allowGiftCertificates,checked:ctx.advancedSettings.defaultGiftCertificateChecked,disabled:ctx.advancedSettings.disableGiftCertificate};conf.links=[$.trim(ctx.advancedSettings.link1Url),$.trim(ctx.advancedSettings.link2Url)];conf.allArrivalAirports=ctx.allArrivalAirports;conf.allDepartureAirports=ctx.allDepartureAirports;conf.fareFamilies=[ctx.fareFamily1,ctx.fareFamily2,ctx.fareFamily3];conf.cabins=ctx.advancedSettings.cabin==null?new Array(3):ctx.advancedSettings.cabin.split(",");conf.cabinTranslations=ctx.cabinTranslations;conf.useExpenseAccount=ctx.advancedSettings.useExpenseAccount;conf.useStaffIdLayout=ctx.advancedSettings.useStaffIdLayout;conf.calendarRange=ctx.calendarRange;initConf(conf,form);if(conf.ajaxLookupAirportDropdown||conf.mode=="multicity"){toggleInput();if(!conf.ajaxLookupAirportDropdown){$("div.ajaxOpenPanelImg",form).hide()}}else{toggleSelect()}$(form).attr("action",ctx.amadeusUrl.url);$("input.generated",form).remove();$(ctx.basicSettings.allHtmlHiddenParams).appendTo(form);$(ctx.advancedSettings.allHtmlHiddenParams).appendTo(form);if(ctx.allHtmlDynamicParameters!=""){$(ctx.allHtmlDynamicParameters).appendTo(form)}$(form.EMBEDDED_TRANSACTION).val(ctx.amadeusUrl.embeddedTransaction);$(form.LANGUAGE).val(ctx.amadeusUrl.languageCode);$(form.SITE).val(ctx.amadeusUrl.siteCode);$(form.AMADEUS_URL).val(ctx.amadeusUrl.url);$(form.CONTEXT_NAME).val(ctx.contextName);$(form.SO_SITE_OFFICE_ID).val($.trim(ctx.officeId.officeId));$(form.SO_GL).val(ctx.SO_GL)}function setLayout(type,init){conf.mode=type;if(type=="return"){hideExampleText();oneLeg(hideControls);returnTrip();showArrivals();if(conf.ajaxLookupAirportDropdown){toggleInput()}else{toggleSelect()}}else{if(type=="oneway"){showExampleText(type);oneLeg(hideControls);oneWayTrip();fadeArrivals();if(conf.ajaxLookupAirportDropdown){toggleInput()}else{toggleSelect()}}else{multiTrip();showExampleText(type);hideArrivals();if(type=="multicity"){twoLegs(false,showControls);toggleInput();if(!conf.ajaxLookupAirportDropdown){$("div.ajaxOpenPanelImg",form).hide()}}if(type=="openjaw"){twoLegs(true,hideControls);if(conf.ajaxLookupAirportDropdown){toggleInput()}else{if(!init&&conf.context==conf.contexts[type]){$("select.location").each(function(j,label){initAirports(label,conf,form)})}toggleSelect()}}if(type=="stopover"){twoLegs(false,showControls);if(conf.ajaxLookupAirportDropdown){toggleInput()}else{if(!init&&conf.context==conf.contexts[type]){$("select.location").each(function(j,label){initAirports(label,conf,form)})}toggleSelect()}}}}if(!init&&conf.context!=conf.contexts[type]){seleroAmadeusManager.getAmadeusSearch(conf.contexts[type],conf.locale,loadContext)}else{initFareType(conf,form)}}$("input.lookup").each(function(i,el){addInputEvent(el)});addSelectEvent("select.location");addAjaxAirportEvent("div.ajaxOpenPanelImg");$(".triptype",form).click(function(event){setLayout(event.target.value)});$(".trip-type-tabs li",form).click(function(){var self=$(this);self.addClass("selected").siblings().removeClass("selected");setLayout(self.find("a").attr("href").substring(1));return false});var hash=window.location.hash.substring(1);var confModeCookie=GetCookie("confMode");var contextNameCookie=GetCookie("contextName");$.each(conf.contexts,function(i,context){if(confModeCookie==i&&contextNameCookie==context&&$("#"+i).length>0){hash=confModeCookie}});if(hash.length<1){hash=$(".triptype:checked",form).val();if(!hash){var tab=$(".trip-type-tabs li.selected a");if(tab.length>0){hash=tab.attr("href").substring(1)}}}if(hash!=null&&hash.length>0){$.each(conf.contexts,function(i,context){if(hash==i){conf.mode=hash;$(".trip-type-tabs li").removeClass("selected");$("#"+hash).addClass("selected").attr("checked",true);if(conf.context!=context){seleroAmadeusManager.getAmadeusSearch(context,conf.locale,loadContext)}}})}setLayout(conf.mode,true);if(conf.ajaxLookupAirportDropdown){$.each(conf.defaultAirports,function(field,value){$("#"+field).val(value)})}setCookieValues(form,conf.context);$.each(conf.selected,function(id,value){$("#"+id).val(value)});return true}function initAirports(b,a,c){var d=(b.id.substring(b.id.length-1))-1;if(b.id.indexOf("dep")!=-1&&!a.ajaxLookupAirportDropdown){var e=$("#"+b.id);if(d<a.allDepartureAirports.length){}if(a.mode!="multicity"){seleroAmadeusManager.getDepartureAirportsByContext(a.context,a.locale,d,function(f){if(f!=null){loadAirports(f,e,b.id)}})}}}function loadAirports(a,c,b){if(a!=null){$(c).empty();$.each(a,function(){$("<option/>").val(this.code).text(this.name).appendTo(c)});$("#dep"+b.substring(3)).next().next().val("");$("#"+b).trigger("change")}}function initFareType(a,c){var b=!(a.hideCabinAndClass||a.onlyScheduleDriven)&&(a.mode=="return"||a.mode=="oneway");toogle(".fareFamilies",b,c);toogle(".cabinFamilies",!a.hideCabinAndClass&&(a.onlyScheduleDriven||!b),c)}function initConf(a,c){$(".giftcertificate",c).each(function(){var e=$(this).children("input");e.attr("checked",a.giftcertificate.checked||e.is(":checked")).attr("disabled",a.giftcertificate.disabled);return a.giftcertificate.allow?$(this).show():$(this).hide()});toogle(".expense",a.useExpenseAccount,c);toogle(".staff",a.useStaffIdLayout,c);initFareType(a,c);$(".other-options").each(function(e){if(a.links[e]!=""){$(this).show().children("a").attr("href",a.links[e])}else{$(this).hide()}});$("select.location").each(function(f,e){initAirports(e,a,c)});var b=$(".fare select",c).empty();$(".fareFamilies select",c).each(function(){$.each(a.fareFamilies,function(f,e){if(e!=null){$("<option/>").val(e.fareFamily).text(e.translated).appendTo(b[0])}})});var d=$(".cabinFamilies select",c).empty();$(".cabinFamilies select",c).each(function(){$.each(a.cabins,function(e,f){if(f!=null){$("<option/>").val(a.cabins[e]).text(a.cabinTranslations[a.cabins[e]]).appendTo(d[0])}})})}function toogle(a,d,b){var c=b?$(a,b):$(a);if(d){c.show()}else{c.hide()}}function setAirports(b,c,a){$("."+b+" .dropdown.location",c).each(function(f){try{for(var d in a){throw (null)}throw ("empty")}catch(h){if(h){return}}var g=this.value;var j=$(this).empty();$.each(a,function(e,k){$("<option/>").val(k.code).text(k.name).appendTo(j);if(g==k.code){j.val(g)}})})}function incrementStr(b){if(typeof b!="undefined"&&b.length>0){var a=parseInt(b.substr(b.length-1,1));if(!isNaN(a)){return b.substr(0,b.length-1)+(a+1)}return b+1}return b}function getAmadeusFormattedDate(a){var b=a.getFullYear();if((a.getMonth()+1)<10){b+="0"}b+=""+(a.getMonth()+1);if(a.getDate()<10){b+="0"}b+=""+a.getDate();b+="0000";return b}function getFormattedDate(a){return a.getDate()+"."+(a.getMonth()+1)+"."+a.getFullYear()}function validate(b,c,a){if(!b){alert(c);$(a).focus()}return b}function setAjaxAirport(b,a,c,e){$("#"+b).val(a);$("#"+c).val(e);if(c.indexOf("dep")!=-1){var d=(c.substring(c.length-1));$("#E_LOCATION_"+d).val("");$("#arr_"+d).val("")}$("#panelContent_ajax_"+c).hide()};