/* generated Fri Jan 27 16:10:50 EST 2012 */

R9.extend("airportPicker",{hasAirports:function(){return !!jq("#airportListContainer input[name=customairport]").size()},select:function(h){var g=document.customair,e=[],c=4;if(typeof g.customairport.length==="undefined"){if(g.customairport.checked){e.push(g.customairport.value)}}else{var f=g.customairport;for(var d=0;d<f.length;d++){if(f[d].checked){e.push(f[d].value)}}}if(e.length==0){alert("Du skal v\u00E6lge mindst \u00E9n lufthavn.");return}if(e.length>c){alert("Du kan h\u00F8jest v\u00E6lge 4 lufthavne.");return}var b=e.join(", "),a=jq("#sbhint").val();if(a){jq("#cacode").val(a)}h({id:b.length>3?"C-"+jq("#cacode").val()+"-"+jq("#radius").val():b,name:b});jq(this.selector).r9dialog("destroy").remove()},selector:"#customAirportDlg",setMap:function(a){jq("#customAirportsMapDiv").css("background-image","url("+a+")")},show:function(a){var b={startcode:typeof a.code==="function"?a.code():a.code,startlocation:typeof a.location==="function"?a.location():a.location};if(a.hint){b.sbhint=a.hint}jq.ajax({type:"GET",url:this.url,data:b,dataType:"html",success:function(d){var c=jq(d);c.find("#customAirportSearchBtn").button().click(function(){R9.airportPicker.select(a.callback);return false});c.find("#customAirportRefreshBtn").click(function(){R9.airportPicker.update();return false});c.find("#calocation").smartbox({callback:function(e){jq("#cacode").val(e.id);if(e.type=="ap"||e.type=="city"){var f=e.id.split("/");if(f.length>1){document.getElementById("cacode").value=e.id=f[1]}jq("#sbhint").val("");jq("#radiusTD").css("visibility","visible")}else{if(e.type){jq("#cacode").val("");jq("#sbhint").val(e.id);jq("#radiusTD").css("visibility","hidden")}}R9.airportPicker.update()},minWidth:175,smartUrl:"/f/smarty"});c.find("#radius").change(function(){R9.airportPicker.update();return false});c.r9dialog({position:["center",155],title:a.title,width:625})},error:function(d,e,c){alert(e)},cache:false})},update:function(){jq.ajax({type:"GET",url:this.url,data:{dataonly:"true",cacode:document.getElementById("cacode").value,calocation:document.getElementById("calocation").value,radius:document.getElementById("radius").value,sbhint:document.getElementById("sbhint").value},dataType:"html",success:function(a){jq("#customAirportsActionButtons").show();jq("#airportListContainer").html(a);jq("#customAirportsActionButtons")[R9.airportPicker.hasAirports()?"show":"hide"]()},error:function(b,c,a){alert(c)},cache:false})},url:"/s/run/toolbox/customairports"});R9.extend("fd.flights",{AbstractForm:function(a){R9.fd.ODForm.call(this,a)}});R9.fd.flights.AbstractForm.prototype=R9.fd.ODForm.prototype.beget();R9.extend("fd.flights.AbstractForm.prototype",{loadHistory:function(d,b,e){R9.fd.ODForm.prototype.loadHistory.call(this);var a=this;a.setSourceForHistory(e);a.isSubmitted=false;a.suppressBuzzCal=e;if(b>=0){if(e){skipCompare=true}var c=a.history[b];if(c){a.loadHistoryItem(c,e)}if(e){skipCompare=false}}a.e.personality.value="";a.hasAutoloadedHistoryAlready=true;return false}});R9.extend("fd.flights",{MultiCityForm:function(a){R9.fd.flights.AbstractForm.call(this,a)}});R9.fd.flights.MultiCityForm.prototype=R9.fd.flights.AbstractForm.prototype.beget();R9.extend("fd.flights.MultiCityForm.prototype",{bindDatepicker:function(){var a=this;jq.each(this.departDate,function(b,c){jq("#depart_date"+b).datepicker({altField:"#depart_date_dom"+b+"label",beforeShow:a.resetMinDate,defaultDate:c||null})})},bindEvents:function(){R9.fd.flights.AbstractForm.prototype.bindEvents.call(this);this.bindDatepicker();this.bindOneWay();this.bindSmartbox()},bindOneWay:function(){jq(this.e).find("input[name=oneway]").click(jq.proxy(this.toggleOneWay,this))},bindSmartbox:function(){var b=this.e;var a=this;jq("input.mcsearchbox[id^=destination]").each(function(){var c=this.id.substring(11),d=jq("#destcode"+c);jq(this).smartbox({callback:function(e){d.val(e?e.id:"")},callbackWithNull:true,minWidth:180,recentList:a.smartboxHistory})});jq("input.mcsearchbox[id^=origin]").each(function(){var c=this.id.substring(6),d=jq("#origincode"+c);jq(this).smartbox({callback:function(e){d.val(e?e.id:"")},callbackWithNull:true,minWidth:180,recentList:a.smartboxHistory}).focus(function(){if(!this.value&&!jq(this).data("prefill")){jq(this).data("prefill",true);try{if(c-0>0){var g=(c-0-1),f=b["destination"+g],e=b["destcode"+g];this.value=f.value;d.val(e.value);this.focus();setTimeout(function(){jq("#"+this.id).select()},50)}}catch(h){}}})})},loadHistoryItem:function(c,g){var b=this,h=b.e,a=b.getTodayDate();jq(h.travelers).val(c.travelers);jq(h.cabin).val(c.cabin);h.prefer_nonstop.checked=c.snonstop;h.fid.value=c.fid;for(var f=0;f<b.maxLegs;f++){if(f<c.leg.length){h["origin"+f].value=c.leg[f].origin;h["destination"+f].value=c.leg[f].destination;h["destcode"+f].value="";h["origincode"+f].value="";h["nearbyO"+f].checked=c.leg[f].nearbyO;h["nearbyD"+f].checked=c.leg[f].nearbyD;var d=new Date(Date.parse(c.leg[f].leave));if(d!=null&&d.getTime()>=a.getTime()){jq("#depart_date"+f).datepicker("setDate",d);jq("#depart_date_dom"+f+"label").text(jq.datepicker.formatDate("D d. M yy",d))}else{if(g){alert("Datoerne for denne flys\u00F8gning er udl\u00F8bet. Indtast venligst nye datoer.")}h["depart_date"+f].value="";g=false}jq(h["depart_time"+f]).val(c.leg[f].timechoice)}else{h["origin"+f].value="";h["destination"+f].value="";h["destcode"+f].value="";h["origincode"+f].value="";h["nearbyO"+f].checked=false;h["nearbyD"+f].checked=false;h["depart_date"+f].value="";jq(h["depart_time"+f]).val("a")}}h.recent.value="Y";if(g){uncheckcomparetos(h);submitRecentFlight()}},loadSettings:function(a){R9.fd.flights.AbstractForm.prototype.loadSettings.call(this,a);this.cabin=a.cabin;this.departDate=a.departDate;this.maxLegs=a.maxLegs;this.travelers=a.travelers;this.useLast=!!a.useLast},onLoad:function(){R9.fd.flights.AbstractForm.prototype.onLoad.call(this);var a=this,c=a.e;if(c.Search){c.Search.disabled=false}if(a.useLast){a.loadHistory(null,0,false)}a.setDefaultVals();setCmp2Count();R9LoadFinished=new Date();var b=R9LoadFinished.getTime()-R9StartPage.getTime();recordEvent("client page load","front door","flights","ms",b);if(a.submitOnPost){setTimeout(function(){jq(c).submit()},250)}},onSubmit:function(){R9.fd.flights.AbstractForm.prototype.onSubmit.call(this);if(!this.isSubmitted){this.disableSearchButton();document.lasttab.havesearched.value="true";this.swapButtons();this.isSubmitted=true;Profiler.markSearchStart();var a=this.generateSearchUrl();if(a!=null){document.location.href=a;return false}return true}else{return false}},setDefaultVals:function(){var a=this,b=a.e;if(a.cabin){b.cabin.value=a.cabin}if(a.travelers){b.travelers.value=a.travelers}},toggleOneWay:function(){if(!this.e.oneway[2].checked){if(this.e.oneway.length>3&&this.e.oneway[3].checked){location.href="/flights?mc=w"}else{location.href="/flights"+(this.e.oneway[1].checked?"?oneway=y":"")}}},toggleFlexCategory:function(){},resetMinDate:function(a,b){var d=parseInt(b.id.slice(b.id.length-1),10);if(d>0){var e=null,c=d-1;while(e==null&&c>=0){e=jq("#depart_date"+c).datepicker("getDate");c--}if(e){jq("#depart_date"+d).datepicker("option","minDate",e)}}}});R9.extend("fd.flights",{Form:function(a){R9.fd.ODForm.call(this,a)}});R9.fd.flights.Form.prototype=R9.fd.flights.AbstractForm.prototype.beget();R9.extend("fd.flights.Form.prototype",{bindEvents:function(){R9.fd.flights.AbstractForm.prototype.bindEvents.call(this);this.bindBuzzCalendar();this.bindOneWay();this.bindSmartbox();this.bindAirportPicker();this.bindDoublePicker();this.bindFlexDates()},bindBuzzCalendar:function(){jq(this.e).bind("checkBuzzCalendar",jq.proxy(this.checkBuzzCalendar,this))},bindOneWay:function(){jq(this.e).find("input[name=oneway]").click(jq.proxy(this.toggleOneWay,this))},bindSmartbox:function(){var a=this;jq("#destination,#origin").focus(function(){a.clearHelpText(this)}).smartbox({callback:function(d){var b=this.name=="origin",c=jq(b?"#origincode":"#destcode").val(d?d.id:"");if(d){if(d.type=="ap"){compare2chk();a.checkBuzzCalendar()}else{if(d.type==="isl"){this.value=d.str;c.val("")}else{this.value="";c.val("");if(d.type){R9.airportPicker.show(jq.extend({hint:d.id},b?R9.fd.flights.airportPickerSettings.from:R9.fd.flights.airportPickerSettings.to))}}}}},callbackWithNull:true,minWidth:180,smartUrl:a.smartUrl,recentList:a.smartboxHistory}).blur(function(){compare2chk();a.checkBuzzCalendar()})},checkBuzzCalendar:function(a,g){var j=this,h=j.e;if(j.isBuzzCalendarEnabled&&!j.flyNow&&!j.suppressBuzzCal){if(h.oneway[0].checked){var b=h.origincode.value,c=h.destcode.value,i=h.depart_date.value;b=!b?h.origin.value:b.substr(0,3);c=!c?h.destination.value:c.substr(0,3);if(b.length==3&&c.length==3&&b.indexOf("C-")!=0&&c.indexOf("C-")!=0){var f;if(g&&g.length==6){f=new Date(parseInt(g.substr(0,4),10),parseInt(g.substr(4,2),10)-1,15);i=buzzCalDateFormat(parseInt(g.substr(4,2),10),15,parseInt(g.substr(0,4),10))}else{f=jq("#depart_date").datepicker("getDate")||new Date()}if(f){var d=b+c+f.getMonth()+"|"+f.getFullYear();if(j.lastBuzzCalDate===null||d!=j.lastBuzzCalDate){fetchBuzzCalendar(b.toUpperCase(),c.toUpperCase(),i);j.lastBuzzCalDate=d}}}}else{jq("#farehistorycalendarcollapsed").hide()}}},getSharedParams:function(){var a=this.e;setupSearchParams(["origin=",a.origin.value,"&origincode=",a.origincode.value,"&destination=",a.destination.value,"&destinationcode=",a.destcode.value,"&nearbyO=",(a.nearbyO.checked?"y":"n"),"&nearbyD="+(a.nearbyD.checked?"y":"n")].join(""))},isOneWaySelected:function(a){return(this.flyNow||(a||jq(this.e.oneway).filter(":checked").val())==="y")},isValid:function(){var d=this.getData(),f=this.isOneWaySelected(d.oneway),c=(d.dtFlexCat=="weekend"),e=(d.dtFlexCat=="openflex"),b=null;var a=/^[1-9]/;if(!d.origin){b='Indtast venligst en "fra"-lufthavn.'}else{if(!d.destination){b='Indtast venligst en "til"-lufthavn.'}else{if(!d.depart_date&&!c){b="Indtast venligst en afrejsedato."}else{if(!f&&!c&&!e&&!d.return_date){b='Indtast venligst en hjemrejsedato.  Hvis du vil s\u00F8ge p\u00E5 en enkeltrejse, s\u00E5 klik venligst p\u00E5 alternativknappen "Enkeltrejse" ovenfor.'}else{if(d.origin===d.destination){b='Indtast venligst unikke "fra" og "til"-lufthavne.'}else{if(!f&&!c&&e&&(!d.lengthofstay||d.lengthofstay.match(a)==null)){b="Angiv et gyldigt antal n\u00E6tter p\u00E5 destinationen."}}}}}}return(this.error=b)===null},loadSettings:function(b){var a=this;R9.fd.flights.AbstractForm.prototype.loadSettings.call(a,b);a.cabin=b.cabin;a.flyNow=!!b.flyNow;a.departTime=b.departTime;a.isBuzzCalendarEnabled=!!b.isBuzzCalendarEnabled;a.lastAirport=b.lastAirport;a.lastBuzzCalDate=null;a.returnTime=b.returnTime;a.smartUrl=b.smartUrl;a.suppressBuzzCal=!!b.suppressBuzzCal;a.travelers=b.travelers;a.defaultFlexVal=b.defaultFlexVal||"";a.departDate=b.departDate;a.isOpenFlexEnabled=!!b.isOpenFlexEnabled;a.returnDate=b.returnDate;a.smartboxHistory=b.smartboxHistory;a.flexDateCategory=b.flexDateCategory;a.useLast=!!b.useLast},onLoad:function(){R9.fd.flights.AbstractForm.prototype.onLoad.call(this);var a=this,c=a.e;if(c.Search){c.Search.disabled=false}a.setDefaultVals();if(a.useLast){a.loadHistory(null,0,false)}setCmp2Count();R9LoadFinished=new Date();var b=R9LoadFinished.getTime()-R9StartPage.getTime();recordEvent("client page load","front door","flights","ms",b);if(this.flexDateCategory!=null&&this.flexDateCategory.length>0){jq(":radio[value="+this.flexDateCategory+"]").prop("checked",true)}if(jq("#lengthofstay").val().length==0){jq("#lengthofstay").val("6-8")}if(this.submitOnPost){setTimeout(function(){jq(c).submit()},250)}},onSubmit:function(){R9.fd.flights.AbstractForm.prototype.onSubmit.call(this);Profiler.markSearchStart();if(!this.isSubmitted){if(this.isValid()){if(comparewindows(this.e)){this.disableSearchButton();document.lasttab.havesearched.value="true";this.swapButtons();this.isSubmitted=true;var a=generateSearchUrl(this.e);if(a!=null){loadResults(a);return false}return true}else{popupBlockerMsg(this.e)}}else{alert(this.error)}}return false},setDefaultVals:function(){var a=this,b=a.e;if(a.cabin){b.cabin.value=a.cabin}if(a.departTime){b.depart_time.value=a.departTime}if(a.returnTime){b.return_time.value=a.returnTime}if(a.travelers){b.travelers.value=a.travelers}},toggleOneWay:function(){if(!this.e.oneway[3].checked){if(this.e.oneway[2].checked){location.href="/flights?mc=y"}else{this.getSharedParams();location.href="/flights"+((this.e.oneway[1].checked)?"?oneway=y":"")}}},bindAirportPicker:function(){jq("#customFrom a").click(function(){R9.airportPicker.show(R9.fd.flights.airportPickerSettings.from);return false});jq("#customTo a").click(function(){R9.airportPicker.show(R9.fd.flights.airportPickerSettings.to);return false})},bindDoublePicker:function(){var a=this;R9.dp.doublePicker({altField:"#depart_date_domlabel",defaultDate:jq.r9datepicker.parseDate(this.departDate),onSelect:function(){a.checkBuzzCalendar();a.calcNewReturnDateForOpenFlex()},selector:"#depart_date"},{altField:"#return_date_domlabel",defaultDate:jq.r9datepicker.parseDate(this.returnDate),onSelect:function(){checkWeekendDates()},selector:"#return_date"})},bindFlexDates:function(){var a=this;jq("#myDatesFlexible").click(function(){jq(".flexDateLink").hide();jq(".flexDateType").show();jq("#datesPlusMinusThree").prop("checked",true);a.toggleFlexCategory();return false});jq("input[name=dtFlexCat]").change(function(){a.toggleFlexCategory()})},calcNewReturnDateForOpenFlex:function(){var c=jq("#depart_date").datepicker("getDate");if(c!=null){c.setDate(c.getDate()+34);jq("#calc_return_date_domlabel").text(jq.datepicker.formatDate("D d. M yy",c));var b=jq.datepicker.formatDate("dd.mm.yy",c);var a="til "+b+" ";jq("#calc_numerical_return_date").text(a,c)}else{jq("#calc_return_date_domlabel").text("");jq("#calc_numerical_return_date").text("")}},loadHistoryItem:function(i,b){var j=this,g=j.e,d=j.getTodayDate();if(j.hasAutoloadedHistoryAlready){g.origin.value=i.leg[0].origin;j.clearHelpText(g.destination);g.destination.value=i.leg[0].destination;g.destcode.value="";g.origincode.value="";g.fid.value=i.fid;var k=new Date(Date.parse(i.leg[0].leave)),c=new Date(Date.parse(i.leg[i.leg.length-1].leave));if(k!=null&&k.getTime()>=d.getTime()){jq("#depart_date").datepicker("setDate",k);jq("#depart_date_domlabel").text(jq.datepicker.formatDate("D d. M yy",k));if(i.leg.length==2){var h=new Date(Date.parse(i.leg[1].leave));jq("#return_date").datepicker("setDate",h);jq("#return_date_domlabel").text(jq.datepicker.formatDate("D d. M yy",h))}}else{if(!i.weekend){if(b){alert("Datoerne for denne flys\u00F8gning er udl\u00F8bet. Indtast venligst nye datoer.")}jq("#depart_date,#return_date").datepicker("setDate",null);jq("#depart_date_domlabel,#return_date_domlabel").text("dd.mm.yy");b=false}}}g.nearbyO.checked=i.leg[0].nearbyO;g.nearbyD.checked=i.leg[0].nearbyD;g.prefer_nonstop.checked=i.snonstop;var a=(window.location.search.indexOf("travelers=")!=-1);if(j.hasAutoloadedHistoryAlready||!a){jq(g.travelers).val(i.travelers)}jq(g.cabin).val(i.cabin);jq(g.depart_time).val(i.leg[0].timechoice);jq(g.depart_date_flex).val(i.leg[0].flexdate);if(i.leg.length==2){jq(g.return_time).val(i.leg[1].timechoice);jq(g.return_date_flex).val(i.leg[1].flexdate)}var f=(window.location.search.indexOf("return_date=")!=-1);if(i.leg.length==1&&(j.hasAutoloadedHistoryAlready||!f)){if(!j.flyNow){g.oneway[1].checked=true;if(i.leg[0].flexdate==""||i.leg[0].flexdate=="exact"){jq("#datesExact").prop("checked",true)}else{jq("#datesPlusMinusThree").prop("checked",true)}}}else{g.oneway[0].checked=true;try{if((i.leg[0].flexdate==""||i.leg[0].flexdate=="exact")&&(i.leg[1].flexdate==""||i.leg[1].flexdate=="exact")){jq("#datesExact").prop("checked",true)}else{jq("#datesPlusMinusThree").prop("checked",true)}}catch(g){jq("#datesExact").prop("checked",true)}}if(i.weekend){jq("#datesWeekend").prop("checked",true);jq(g.weekend_depart_date).val(i.leg[0].leave);jq(g.weekend_depart).val(i.leg[0].day1);jq(g.weekend_return).val(i.leg[0].day2)}else{if(i.leg.length==2&&i.leg[1].flexdate=="open"){jq("#datesOpenFlex").prop("checked",true);jq(g.lengthofstay).val(i.openflexrange)}}j.toggleFlexCategory();j.toggleOneWay();g.recent.value="Y";if(b){uncheckcomparetos(g);submitRecentFlight()}},toggleFlexCategory:function(){var a=this,b="exact";var d=jq("input[name=dtFlexCat]:checked").val();var c=d.substring(0,1).toUpperCase()+d.slice(1);if(d=="exact"){jq("#leaveDateFlex,#returnDateFlex").val("exact")}else{if(d=="plusminusthree"){if(jq("#leaveDateFlex").val()===b&&jq("#returnDateFlex").val()===b){jq("#leaveDateFlex,#returnDateFlex").val(a.defaultFlexVal)}}else{if(d=="weekend"){jq("#leaveDateFlex,#returnDateFlex").val("exact")}else{if(d=="openflex"){jq("#leaveDateFlex,#returnDateFlex").val("exact");a.calcNewReturnDateForOpenFlex()}}}}jq(".flexAware").hide();jq(".flexAware"+c).show();if(d=="openflex"){jq(".hideOpenFlex").hide();jq(".showOpenFlex").show()}else{jq(".hideOpenFlex").show();jq(".showOpenFlex").hide()}if(d!="exact"){jq(".flexDateLink").hide();jq(".flexDateType").show()}},toggleOneWay:function(){if(this.flyNow){jq(".roundtriponly, #compareToRow, .flexdate, .daterow, .recentarea").hide()}else{if(this.e.oneway.length>2&&this.e.oneway[2].checked){location.href="/flights?mc=y"}else{jq("#returnDateTD, #return_flex_td, .roundtriponly").css("visibility",this.e.oneway[1].checked?"hidden":"");compare2chk();this.checkBuzzCalendar();if(this.e.oneway[1].checked){var a=jq("input[name=dtFlexCat]:checked").val();if(a=="weekend"||a=="openflex"){jq("#datesExact").prop("checked",true)}}}}this.toggleFlexCategory()}});R9.extend("fd.flights.airportPickerSettings",{from:{callback:function(b){var a=document.flights;a.origincode.value=b.id;a.origin.value=b.name;a.nearbyO.checked=false;compare2chk();jq(a).trigger("checkBuzzCalendar")},code:function(){return document.flights.origincode.value},location:function(){return document.flights.origin.value},title:"V\u00E6lg afrejselufthavne"},to:{callback:function(b){var a=document.flights;a.destcode.value=b.id;a.destination.value=b.name;a.nearbyD.checked=false;compare2chk();jq(a).trigger("checkBuzzCalendar")},code:function(){return document.flights.destcode.value},location:function(){return document.flights.destination.value},title:"V\u00E6lg ankomstlufthavne"}});function submitRecentFlight(){setTimeout(function(){jq(document.flights).submit()},500)}function toggleMoreOptions(){var b=document.getElementById("moreflightoptions");if(b!=null){var a=(((navigator.appName).indexOf("Microsoft")>-1)?true:false);if(b.style.display=="block"||b.style.display=="table-row"){b.style.display="none";document.getElementById("moreflightoptionslink").innerHTML="Flere s\u00F8gekriterier"}else{if(a){b.style.display="block"}else{b.style.display="table-row"}document.getElementById("moreflightoptionslink").innerHTML="F\u00E6rre s\u00F8gekriterier"}}}function toggleFlexDates(a,b){jq("#datesExact").prop("checked",!a);jq("#datesPlusMinusThree").prop("checked",!a).trigger("change");alert("toggle flex dates old")}function fetchBuzzCalendar(a,c,b){jq.ajax({type:"GET",url:"/h/farealert",data:{forcedisplay:true,nolink:"Y",calendar:true,o:a,d:c,depart_date:b},dataType:"html",success:function(d){jq("#fhCalContainer").empty();if(d.length>100){jq("#fdmktblob").hide();jq("#fhCalContainer").append(d);jq("#farehistorycalendar").show();jq(".dialog_top").hide().show()}else{jq("#farehistorycalendarcollapsed").hide()}},cache:true})}function checkWeekendDates(){compare2chk()}function calMonthChanged(a){jq(document.flights).trigger("checkBuzzCalendar",[a])}function gotoCreateAlert(){document.location.href="/alerts?action=prepop"}function showAlertAjaxReg(){if(AjaxReg.alreadyRegistered){gotoCreateAlert()}AjaxReg.regtype="alert";try{AjaxReg.defaultAirportCode=document.getElementById("origin").value}catch(a){}AjaxReg.ui.register(gotoCreateAlert)}var form;

;var jsck_fdflight_da_dk="v425";
/* et=4, mt=5, c=p4, i=sparkle010, v=R114, cc=4, r=none */

