var JSON;if(!JSON){JSON={};}
(function(){"use strict";function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==='string'){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());;(function(){var reISO=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/;var reMsAjax=/^\/Date\((d|-|.*)\)\/$/;var parseFunction=JSON.parse;JSON.parse=function(string,f)
{return parseFunction(string,function(key,value){if(typeof value==='string'){var a=reISO.exec(value);if(a)
return new Date(Date.UTC(+a[1],+a[2]-1,+a[3],+a[4],+a[5],+a[6]));a=reMsAjax.exec(value);if(a){var b=a[1].split(/[-,.]/);return new Date(+b[0]);}}
return value;});};})();;BFApplicationConstants={BING_MAP_KEY:"AmOeiRA2dDQAfg0qwcVq42XgIsgeZvUGbiCLnjdGCGxbG9_zEViRJs2Vcdiopc1e",images:{BASIC_PUSHPIN_URL:"http://hotel.volagratis.it/HotelAvailabilitySearch/imgs/mapicons/iconr.png",SELECTED_PUSHPIN_URL:"http://hotel.volagratis.it/HotelAvailabilitySearch/imgs/mapicons/poi_purple.png",BUTTON_LOADER_URL:"/images/orange-spinner.gif",DATEPICKER_ICON:"/images/results/datepicker.gif",WAITING_PAGE:"/images/results/maremonti2.png"},DATEPICKER_DELAY:200,BASIC_PUSHPIN_WIDTH:24,BASIC_PUSHPIN_HEIGHT:34,XHR_METHOD:"GET",XHR_RETURN_TYPE:"json",XHR_CACHE:false,XHR_ERROR_HANDLER:function(XMLHttpRequest,textStatus,errorThrown){if(errorThrown){BFUtils.log("An error occured during XHR",errorThrown);}},CONTEXT_PATH:"/vg1/vacanze",INIT_PATH:"/initavailableproducts.action",PRODUCTS_PATH:"/filteravailableproducts.action",DETAIL_PATH:"/viewproductdetails.action",WORKFLOW_PATH:"/entryworkflow.action",PRODUCTS_GRID_PATH:"/viewproductsgrid.action",hotelDescriptions:['GENERAL','LOCATION','ROOMS','RESTAURANT','FACILITIES','LOBBY','EXTERIOR','SPORT','DIRECTION','CANCELLATIONPOLICY','PAYMENT','DEFAULT'],discountableOptions:{DEFAULT:["enrollmentAmount","openingFee","commission","insurance"],FLIGHT:["flight","baggages","speedyBoarding"],HOTEL:["hotel"],PACKAGE:["extraServices","totalAgencyCommission"]}};jQuery.ajaxSetup({cache:BFApplicationConstants.XHR_CACHE,dataType:BFApplicationConstants.XHR_RETURN_TYPE,contentType:"application/x-www-form-urlencoded;charset=UTF-8",type:BFApplicationConstants.XHR_METHOD,error:BFApplicationConstants.XHR_ERROR_HANDLER,beforeSend:function(jqXHR,settings){if(typeof BFSearchResultsManager!="undefined"){BFSearchResultsManager.getInstance().setState(BFSearchResultsLoadingState);}
return true;},complete:function(jqXHR,textStatus){if(typeof BFSearchResultsManager!="undefined"){BFSearchResultsManager.getInstance().setState(BFSearchResultsReadyState);}}});;BFPushpin=function(config)
{this.setMap(config.map);this.set("selected",config.selected);this.set("position",config.position);this.set("title",config.title||"");this.set("description",config.description||"");this.set("category",config.category||"");this.set("amount",config.amount||0);this.set("value",config.value||"");this.pinContainer=document.createElement("div");};BFPushpin.prototype=new google.maps.OverlayView();BFPushpin.prototype.getBounds=function()
{return new google.maps.LatLngBounds(this.position,this.position);};BFPushpin.prototype.getPoint=function()
{var bounds=this.getBounds();var projection=this.getProjection();var sw=projection.fromLatLngToDivPixel(bounds.getSouthWest());var ne=projection.fromLatLngToDivPixel(bounds.getNorthEast());return new google.maps.Point(sw.x,ne.y);};BFPushpin.prototype.getSuperContainer=function()
{var panes=this.getPanes();return jQuery(panes?panes.overlayImage:"");};BFPushpin.prototype.getContainer=function()
{return jQuery(this.pinContainer);};BFPushpin.prototype._generatePopupContent=function()
{var controller=new BFBaseViewController({model:{title:this.title,description:this.description,amount:this.amount,active:false,category:this.category,value:this.value,action:this.selected?"hide":"show"},template:"BFMapPopupView"});return controller.generateHTML();};BFPushpin.prototype.showPopup=function()
{var wrapper=document.createElement("div");wrapper.innerHTML=this._generatePopupContent();wrapper.className="map-popup";wrapper.style.height="70px";var popup=new google.maps.InfoWindow({content:wrapper});var activeWindows=this.map.get("activeWindows");for(var i=0;i<activeWindows.length;i++)
{activeWindows[i].close();}
activeWindows.push(popup);popup.open(this.map,this);};BFPushpin.prototype._addListeners=function()
{var self=this;var domContainer=this.getContainer().get(0);google.maps.event.addDomListener(domContainer,'click',function(){self.showPopup();});};BFPushpin.prototype.onAdd=function()
{var content='<div class="map-pin-content">'+BFUtils.currencyFormat(this.amount)+'</div>';this.getContainer().addClass("map-pin-container").html(content).appendTo(this.getSuperContainer());this._addListeners();};BFPushpin.prototype.onRemove=function()
{this.getContainer().remove();};BFPushpin.prototype.draw=function()
{var point=this.getPoint();this.getContainer().css({left:point.x+"px",top:point.y+"px"});};BFPushpin.prototype.setVisible=function(visible)
{this.getSuperContainer().css("display",visible?"block":"none");};BFPushpin.prototype.getPosition=function()
{return this.position;};BFMapFacade=function(){};BFMapFacade.load=function(config)
{var map=null;try
{var container=document.getElementById(config.container);var cfg={mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:false,zoom:config.zoom||10,styles:[{featureType:"poi",elementType:"labels",stylers:[{visibility:"off"}]}]};var bounds=new google.maps.LatLngBounds();if(!isNaN(config.latitude)&&!isNaN(config.longitude)&&!config.pushpins)
{cfg.center=new google.maps.LatLng(config.latitude,config.longitude);bounds.extend(cfg.center);}
map=new google.maps.Map(container,cfg);map.set("activeWindows",[]);if(config.pushpins instanceof Array&&config.pushpins.length>0)
{var pins=[];for(var i=0;i<config.pushpins.length;i++)
{pins.push(BFMapFacade._configurePushpin(map,config.pushpins[i],bounds));}
if(config.pushpins.length>1)
{map.fitBounds(bounds);}
else
{map.setCenter(bounds.getCenter());map.setZoom(config.zoom||10);}
for(var p in pins)
{var pin=pins[p];if(pin.selected)
{pin.showPopup();}}}}
catch(e)
{BFUtils.log("Error loading map",e,"error");}
finally
{return map;}};BFMapFacade._configurePushpin=function(map,markerConfig,bounds)
{var pin=new BFPushpin({"map":map,title:markerConfig.title,selected:markerConfig.selected,position:new google.maps.LatLng(markerConfig.latitude,markerConfig.longitude),amount:markerConfig.amount,description:markerConfig.description,category:markerConfig.category,value:markerConfig.value});bounds.extend(pin.position);return pin;};;BFSearchFormPeriodModeStartDateEndDate=function(controller){this.controller=controller;};BFSearchFormPeriodModeStartDateEndDate.prototype.toString=function(){return"BFSearchFormPeriodModeStartDateEndDate";};BFSearchFormPeriodModeStartDateEndDate.prototype.drawControls=function(){this.controller._buildFromDateCombo();this.controller._buildToDateCombo();};BFSearchFormPeriodModeStartDateEndDate.prototype.toggleHandler=function()
{$("[bf_mode]").addClass("display-none");$("[bf_mode='BFSearchFormPeriodModeStartDateEndDate']").removeClass("display-none");var selectedDates=[null,null];var items=[];if(this.controller.periodsCombo)
{items=this.controller.periodsCombo.getSelectedItems();if(items.length>0)
{selectedDates=BFSearchFormDataParser.getDateRangeFromItems(items);}
this.controller.periodsCombo.destroy();this.controller.periodsCombo=null;}
var selectables=this.getSelectableDates();this.controller._buildFromDateCombo({minDate:selectables[0],maxDate:selectables[selectables.length-1],selectedDate:selectedDates[0],selectableDates:selectables,disabled:false});this.controller._buildToDateCombo({minDate:selectables[0],maxDate:selectables[selectables.length-1],selectedDate:selectedDates[1],selectableDates:selectables,disabled:!(selectedDates[1]instanceof Date)});};BFSearchFormPeriodModeStartDateEndDate.prototype.getSelectableDates=function()
{var selectedDestinations=this.controller.destinationsCombo.getSelectedItems();var duration=this.controller.durationCombo.getSelectedItems()[0];var groups=this.controller.dataParser.getPeriodsComboGroups(duration.value,selectedDestinations,this.getSelectedAirports());var items=groups[0].items;var dates=[];for(var i in items)
{dates.push.apply(dates,items[i].customData.dates);}
dates.sort(BFArrayUtils.dateAscSort);return BFArrayUtils.arrayWithoutDuplicates(dates);};BFSearchFormPeriodModeStartDateEndDate.prototype.getSelectedAirports=function(){return this.controller.isOnlyAccomodationOnly()?this.controller.airportsCombo.checkboxGroups[0].items:this.controller.airportsCombo.getSelectedItems();};BFSearchFormPeriodModeStartDateEndDate.prototype.durationComboCloseHandler=function()
{var selectedDestinations=this.controller.destinationsCombo.getSelectedItems();var selectedAirports=this.getSelectedAirports();var duration=this.controller.durationCombo.getSelectedItems()[0];var toCombo=this.controller.toDateCombo;var fromCombo=this.controller.fromDateCombo;if(!duration)
{fromCombo.setDisabled(true);toCombo.setDisabled(true);return;}
$("#switch-container").removeClass("visibility-hidden");var groups=this.controller.dataParser.getPeriodsComboGroups(duration.value,selectedDestinations,selectedAirports);var range=BFSearchFormDataParser.getDateRangeFromItems(groups[0].items);var currentFromDate=fromCombo.getSelectedDate();fromCombo.disabled=false;fromCombo.selectableDates=toCombo.selectableDates=this.getSelectableDates();fromCombo.selectedDate=currentFromDate instanceof Date&&BFArrayUtils.arrayContainsObject(fromCombo.selectableDates,currentFromDate)?currentFromDate:null;fromCombo.setDateRange(range).draw();$(fromCombo).trigger(BFComboDidClose,[true]);};BFSearchFormPeriodModeStartDateEndDate.prototype.toggleRoomsViewStatus=function()
{var toCombo=this.controller.toDateCombo;var fromCombo=this.controller.fromDateCombo;var durationCombo=this.controller.durationCombo;var destinationsCombo=this.controller.destinationsCombo;var airportsCombo=this.controller.airportsCombo;this.controller.roomsController.setViewAsDisabled(destinationsCombo.getSelectedCheckboxes().length==0||(airportsCombo.getSelectedCheckboxes().length==0&&!this.controller.isAccomodationOnly())||durationCombo.getSelectedCheckboxes().length==0||fromCombo.getSelectedDate()==null||toCombo.getSelectedDate()==null);this.controller._roomsViewWasDisabled=this.controller.roomsController.viewIsDisabled;};BFSearchFormPeriodModeStartDateEndDate.prototype.mergeDateFields=function(){try{var sel=this.controller.viewSelector;var from=jQuery(sel+" input[name='fromDate']");var to=jQuery(sel+" input[name='toDate']");if(from.length>0&&to.length>0){jQuery(this.controller.roomsController.viewSelector).append('<input type="hidden" name="search.departureIntervals" value="'+from.val()+'-'+to.val()+'" />');from.remove();to.remove();}}catch(e){BFUtils.log("An error occured trying to merge fromDate and toDate fields.",e);}};BFSearchFormPeriodModeStartDateEndDate.prototype.disableControls=function(){this.controller.fromDateCombo.setDisabled(true);this.controller.toDateCombo.setDisabled(true);$("#switch-container").addClass("visibility-hidden");};BFSearchFormPeriodModeStartDateEndDate.prototype.prepopulateControls=function(){var toCombo=this.controller.toDateCombo;var fromCombo=this.controller.fromDateCombo;try{var selectedDestinations=this.controller.destinationsCombo.getSelectedItems();var duration=this.controller.durationCombo.getSelectedItems()[0];var groups=this.controller.dataParser.getPeriodsComboGroups(duration.value,selectedDestinations,this.getSelectedAirports());var range=BFSearchFormDataParser.getDateRangeFromItems(groups[0].items);var selectedDates=BFSearchFormDataParser.getDateRangeFromItems(this.controller.selections.periods);fromCombo.disabled=false;fromCombo.selectableDates=toCombo.selectableDates=this.getSelectableDates();fromCombo.reset(true).setDateRange(range).draw().setSelectedDate(selectedDates[0]);new BFToDateComboUpdateCommand(this.controller).execute();toCombo.setSelectedDate(selectedDates[1]);}catch(e){BFUtils.log("An error occured prepopulating date combos.",e);}};;BFSearchFormPeriodModePeriods=function(controller){this.controller=controller;};BFSearchFormPeriodModePeriods.prototype.toString=function(){return"BFSearchFormPeriodModePeriods";};BFSearchFormPeriodModePeriods.prototype.drawControls=function(){this.controller._buildPeriodsCombo();};BFSearchFormPeriodModePeriods.prototype.toggleHandler=function()
{$("[bf_mode]").addClass("display-none");$("[bf_mode='BFSearchFormPeriodModePeriods']").removeClass("display-none");var d1=this.controller.fromDateCombo.getSelectedDate();var d2=this.controller.toDateCombo.getSelectedDate();var range=[null,null];if(d1 instanceof Date&&d2 instanceof Date)
{range=[parseInt(BFUtils.dateToString(d1),10),parseInt(BFUtils.dateToString(d2),10)];}
if(this.controller.fromDateCombo)
{this.controller.fromDateCombo.destroy();this.controller.fromDateCombo=null;}
if(this.controller.toDateCombo)
{this.controller.toDateCombo.destroy();this.controller.toDateCombo=null;}
this.controller._buildPeriodsCombo({disabled:false});var selectedAirports=this.controller.airportsCombo.getSelectedItems();var selectedDestinations=this.controller.destinationsCombo.getSelectedItems();var duration=this.controller.durationCombo.getSelectedItems()[0];var items=duration?this.controller.dataParser.getPeriodsComboGroups(duration.value,selectedDestinations,selectedAirports)[0].items:[];var updatedItems=[];var index=0;for(var j=0;j<items.length;j++)
{if(items[j].separator)
{index=j;break;}}
for(var i=0;i<items.length;i++)
{var item=items[i];var values=item.value.split("-");var from=parseInt(values[0],10);var to=parseInt(values[1],10);item.checked=(range[1]>=from&&range[0]<=to)&&i>index;updatedItems.push(item);}
this.controller.periodsCombo.checkboxGroups=[{items:updatedItems}];this.controller.periodsCombo.disabled=false;this.controller.periodsCombo.reset().draw();};BFSearchFormPeriodModePeriods.prototype.durationComboCloseHandler=function()
{var selectedAirports=this.controller.isOnlyAccomodationOnly()?this.controller.airportsCombo.checkboxGroups[0].items:this.controller.airportsCombo.getSelectedItems();var selectedDestinations=this.controller.destinationsCombo.getSelectedItems();var duration=this.controller.durationCombo.getSelectedItems()[0];if(!duration)
{this.controller.periodsCombo.setDisabled(true);return;}
$("#switch-container").removeClass("visibility-hidden");var previuosSelection=this.controller.periodsCombo.getSelectedItems();var newGroups=duration?this.controller.dataParser.getPeriodsComboGroups(duration.value,selectedDestinations,selectedAirports):[];this.controller.periodsCombo.checkboxGroups=BFSearchFormDataParser.getGroupsPreservingPreviousSelections(previuosSelection,newGroups);this.controller.periodsCombo.disabled=false;this.controller.periodsCombo.reset().draw();};BFSearchFormPeriodModePeriods.prototype.mergeDateFields=function(){};BFSearchFormPeriodModePeriods.prototype.toggleRoomsViewStatus=function(){this.controller.roomsController.setViewAsDisabled(this.controller.destinationsCombo.getSelectedCheckboxes().length==0||(this.controller.airportsCombo.getSelectedCheckboxes().length==0&&!this.controller.isAccomodationOnly())||this.controller.durationCombo.getSelectedCheckboxes().length==0||this.controller.periodsCombo.getSelectedCheckboxes().length==0);this.controller._roomsViewWasDisabled=this.controller.roomsController.viewIsDisabled;};BFSearchFormPeriodModePeriods.prototype.disableControls=function(){this.controller.periodsCombo.setDisabled(true);$("#switch-container").addClass("visibility-hidden");};BFSearchFormPeriodModePeriods.prototype.prepopulateControls=function(){try{var selectedDestinations=this.controller.destinationsCombo.getSelectedItems();var selectedAirports=this.controller.airportsCombo.getSelectedItems();var duration=this.controller.durationCombo.getSelectedItems()[0];var groups=this.controller.dataParser.getPeriodsComboGroups(duration.value,selectedDestinations,selectedAirports);var updatedGroups=this.controller.dataParser.getUpdatedCheckboxGroupItemsWithSelection(groups,this.controller.selections.periods);this.controller.periodsCombo.checkboxGroups=updatedGroups;this.controller.periodsCombo.draw().setDisabled(false);}catch(e){BFUtils.log("An error occured prepopulating periods combos.",e);}};;BFImagesPreloader=function(images){if(!(images instanceof Array)){throw new Error("Invalid BFImagePreloader configuration: missing images array!");}
this.images=images;};BFImagesPreloader.prototype.load=function(){for(var i=0;i<this.images.length;i++){var image=new Image();image.src=this.images[i];}};;BFScrollManager=function(config){if(typeof config!="object"||!config.scrollAreaSelector||!config.itemsSelector||!config.controlToggleClass){throw new Error("Invalid BFScrollManager configuration");}
this.scrollAreaSelector=config.scrollAreaSelector;this.itemsSelector=config.itemsSelector;this.controlToggleClass=config.controlToggleClass;this.scrollType=config.scrollType||"horizontal";this.backControlSelector=config.backControlSelector||null;this.nextControlSelector=config.nextControlSelector||null;this.animationDuration=config.animationDuration||150;this.toggleClassAction=config.toggleClassAction||"add";this.animationType=config.animationType||"linear";var $areas=this.getAreas();var $items=jQuery(this.itemsSelector,$areas);this.itemSize=config.itemSize||(this.scrollType=="horizontal"?$items.outerWidth(true):$items.outerHeight(true));this.callback=config.callback||null;this._isScrolling=false;this._clickEvent="click.BFScrollManager";$areas.css("overflow","hidden");$areas.append('<div class="bf-scrollmanager-wrapper bf-scrollmanager-'+this.scrollType+'"></div>');var instance=this;$areas.each(function(){var $area=jQuery(this);var $areaItems=jQuery(instance.itemsSelector,$area);jQuery(".bf-scrollmanager-wrapper",$area).append($areaItems);});this.areaSize=this.scrollType=="horizontal"?$areas.width():$areas.height();this.scrollBy=config.scrollBy||this.getItemsCountForSingleFrame();this._setUpControls();};BFScrollManager.prototype._setUpControls=function(){var instance=this;if(this.getItemsCountForSingleFrame()>=this.getFirstLevelItems().length){jQuery(this.backControlSelector).remove();jQuery(this.nextControlSelector).remove();return;}
jQuery(this.backControlSelector).unbind(this._clickEvent).bind(this._clickEvent,function(){instance.scroll(-1);});jQuery(this.nextControlSelector).unbind(this._clickEvent).bind(this._clickEvent,function(){instance.scroll(+1);});};BFScrollManager.prototype._toggleHandler=function(){var $areas=this.getAreas();var $items=this.getFirstLevelItems();var $backControl=jQuery(this.backControlSelector);var $nextControl=jQuery(this.nextControlSelector);var scroll=this.getCurrentScroll();var add=(this.toggleClassAction=="add");var instance=this;if(scroll>0){add?$backControl.addClass(this.controlToggleClass):$backControl.removeClass(this.controlToggleClass);$backControl.unbind(this._clickEvent).bind(this._clickEvent,function(){instance.scroll(-1);});}else{add?$backControl.removeClass(this.controlToggleClass):$backControl.addClass(this.controlToggleClass);$backControl.unbind(this._clickEvent);}
if(scroll+this.areaSize<$items.length*this.itemSize){add?$nextControl.addClass(this.controlToggleClass):$nextControl.removeClass(this.controlToggleClass);$nextControl.unbind(this._clickEvent).bind(this._clickEvent,function(){instance.scroll(+1);});}else{add?$nextControl.removeClass(this.controlToggleClass):$nextControl.addClass(this.controlToggleClass);$nextControl.unbind(this._clickEvent);}};BFScrollManager.prototype._scrollBy=function(scroll){var instance=this;var $backControl=jQuery(this.backControlSelector);var $nextControl=jQuery(this.nextControlSelector);this.getAreas().animate(this.scrollType=="horizontal"?{scrollLeft:scroll}:{scrollTop:scroll},this.animationDuration,this.animationType,function(){instance.isScrolling=false;if($backControl.length>0&&$nextControl.length>0){instance._toggleHandler();}
if(typeof instance.callback=="function"){instance.callback();}});};BFScrollManager.prototype.getAreas=function(){return jQuery(this.scrollAreaSelector);};BFScrollManager.prototype.getFirstLevelItems=function(){return jQuery(this.itemsSelector,this.getAreas().get(0));};BFScrollManager.prototype.getItemsCountForSingleFrame=function(){return Math.ceil(this.areaSize/this.itemSize);};BFScrollManager.prototype.getNumberOfFrames=function(){var $items=this.getFirstLevelItems();return Math.ceil($items.length/this.getItemsCountForSingleFrame());};BFScrollManager.prototype.getCurrentScroll=function(){var $areas=this.getAreas();return this.scrollType=="horizontal"?$areas.scrollLeft():$areas.scrollTop();};BFScrollManager.prototype.getCurrentItemsRange=function(){var $areas=this.getAreas();var $items=this.getFirstLevelItems();var first=Math.ceil(this.getCurrentScroll()/this.itemSize);var last=first+this.getItemsCountForSingleFrame()-1;var maxIndex=$items.length-1;return[first,(last>maxIndex?maxIndex:last)];};BFScrollManager.prototype.indexShouldBeVisible=function(index){var range=this.getCurrentItemsRange();return index>=range[0]&&index<=range[1];};BFScrollManager.prototype.scroll=function(direction){if(isNaN(direction)||Math.abs(direction)!=1){throw new Error("Invalid direction! Valid directions are +1 or -1");}
if(this.isScrolling){return;}
var newScroll=this.getCurrentScroll()+(this.itemSize*direction*this.scrollBy);var instance=this;var scrollSize=999999;if((direction>=0&&newScroll<=scrollSize-this.areaSize)||(direction<0&&newScroll>=0)){this.isScrolling=true;this._scrollBy(newScroll);}};BFScrollManager.prototype.scrollToIndex=function(index){if(this.indexShouldBeVisible(index)){return;}
var range=this.getCurrentItemsRange();var position=index*this.itemSize;var scroll=position-(position%this.areaSize);this._scrollBy(scroll);};BFScrollManager.prototype.reset=function(){this.scrollToIndex(0);};;BFUtils=function(){};BFUtils.log=(function(){if(typeof console!="undefined")
{return function(message,error,level)
{var errorAvailable=error&&typeof error=="object";var extendedMessage=errorAvailable?(message+" - "+error.message):message;if(level&&typeof console[level]=="function")
{console[level](extendedMessage);}
else
{console.log(extendedMessage);}
if(errorAvailable&&typeof console.dir=="function")
{console.dir(error);}}}
return function(){};})();BFUtils.isSuccessfullAjaxResponse=function(xhr)
{if(typeof xhr!="object")
{return false;}
return(xhr.status==200||xhr.status==0);};BFUtils.traceBadAjaxResponse=function(url,xhr)
{BFUtils.log("[Bad ajax response!]"+"\n[url required] "+url+"\n[status] "+xhr.status+"\n[statusText] "+xhr.statusText+"\n[responseText] "+jQuery.trim(xhr.responseText)+"\n[responseXML] "+xhr.responseXML+"\n[end trace]");};BFUtils.elementIsInView=function(element)
{var scrollTop=jQuery(document).scrollTop();var sum=Math.ceil(element.height()+element.offset().top);return sum>scrollTop;};BFUtils.scrollToElement=function(obj,margin)
{if(obj)
{var doc=jQuery(document);var docScroll=doc.scrollTop();var elementTop=obj.offset().top;var elementHeight=obj.outerHeight();var elementOffset=elementHeight+elementTop;var windowHeight=jQuery(window).height();var pageOffset=windowHeight+docScroll;var delta=elementOffset-pageOffset;var margin=margin||15;if(elementOffset>pageOffset)
{jQuery("html,body").animate({scrollTop:Math.round(docScroll+delta)+margin},300);}
else if(docScroll>elementTop)
{jQuery("html,body").animate({scrollTop:elementTop-margin},300);}}};BFUtils.buildActionURL=function(action,data)
{var loc=window.location;var url=loc.protocol+"//"+loc.host+action;if(data&&typeof data=="object")
{url+="?"+jQuery.queryString.toQueryString({object:data});}
return url;};BFUtils.goToActionWithData=function(action,data)
{window.location=BFUtils.buildActionURL(action,data);};BFUtils.currencyFormat=function(value,addSpace,showDecimal,locale,currencySymbol)
{var locale=locale||Globalize.culture().name;var formattedNumber=Globalize.format(parseFloat(value,10),"n"+(showDecimal?"":"0"),locale);return formattedNumber+(!addSpace?"":" ")+(currencySymbol||BFLocalizedStrings.CURRENCY_SYMBOL);};BFUtils.formatDate=function(date)
{var dateString=date.toString();try
{var options=jQuery.datepicker.regional[''];var parsedDate=$.datepicker.parseDate("yymmdd","20"+dateString,options);return $.datepicker.formatDate("D dd/mm",parsedDate,options);}
catch(e)
{BFUtils.log("An error occured formatting a date",e);return dateString;}};BFUtils.setComboIndexForValue=function(combo,value)
{var index=0;jQuery(combo).find("option").each(function(){if(jQuery(this).val()==value){jQuery(combo).prop("selectedIndex",index);return;}
index++;});};BFUtils.fakeRadio=function(groupName)
{jQuery("[bf_checkboxgroup='"+groupName+"']").bind("click",function(){jQuery("[bf_checkboxgroup='"+groupName+"']:checked").attr("checked",false);jQuery(this).attr("checked","checked");});};BFUtils.popup=function(node)
{var anchor=jQuery(node);var url=anchor.attr("href");window.open(url,"","width=600,height=450,scrollbars=1,location=0");return false;};BFUtils.setContainerError=function(data)
{if(data.element.type=="hidden"){return;}
var parentNode=jQuery(data.element).parent(),context=data.context,groups=data.groups,element=data.element;if(!parentNode){return;}
if(context&&groups){var gname;for(gname in groups){if(groups[gname].indexOf(element.name)>-1&&data.valid){var controls=groups[gname].split(" ");for(var i=0;i<controls.length;i++){var cForm=context.currentForm||context.form.currentForm,mForm=context.form.check?context.form:context,field=cForm.elements[controls[i]];if(!mForm.check(field)&&element){mForm.showLabel(element,mForm.errorMap[controls[i]]);data.valid=false;break;}}}}}
jQuery(parentNode)[!data.valid?"addClass":"removeClass"](data.className||"error-container");};BFUtils.dialog=function(config){var dom=config.dom||null,callbacks=config.callbacks||{}
buttons=config.buttons||{},options={autoOpen:false,modal:true,width:400,resizable:false,draggable:false,title:"Message"};if(!dom){return};if(buttons.open){buttons.open.click(function(){dom.dialog("open")
dom.trigger("open");});}
if(buttons.close){buttons.close.click(function(){dom.dialog("close")
dom.trigger("close");});}
if(buttons.submit){buttons.submit.click(function(){dom.trigger("submit");});}
dom.dialog(jQuery.extend(options,config.dialog));return dom;};BFUtils.safejQuerySelector=function(selector)
{return selector.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g,'\\$1');};BFUtils.placeHolder=function()
{if(!("placeholder"in document.createElement("input")))
{var phHandler=function()
{var node=jQuery(this);var placeHolder=node.attr("placeholder");var value=node.val();if(jQuery.trim(value)==""){node.css("color","#cccccc").val(placeHolder);}else if(value==placeHolder){node.css("color","#000000").val("");}};jQuery("input[placeholder]").bind({focus:phHandler,blur:phHandler}).trigger("blur");}};BFUtils.ieSelectFix=function()
{if(navigator.userAgent.toLowerCase().indexOf("msie")==-1)
{return;}
jQuery("select").each(function(){var select=jQuery(this);var originalSize=select.width();var originalPosition=select.css("position")||"relative";var originalZIndex=select.css("z-index")||0;select.bind("focus",function(){jQuery(this).css({width:"auto",position:"absolute","z-index":99999});});select.bind("blur",function(){jQuery(this).css({width:originalSize+"px",position:originalPosition,"z-index":originalZIndex});});select.bind("change",function(){jQuery(this).css({width:originalSize+"px",position:originalPosition,"z-index":originalZIndex});});});};BFUtils.isIDevice=function()
{var client=navigator.userAgent.toLowerCase();return(client.indexOf("iphone")!=-1||client.indexOf("ipad")!=-1||client.indexOf("ipod")!=-1);};BFUtils.triggerPageScroll=function()
{var top=jQuery(document).scrollTop();jQuery(window).trigger("scroll").scrollTop(top);};BFUtils.stringToDate=function(string)
{var s=String(string);s=(s.length==6?"20":"")+s;return new Date(parseInt(s.substring(0,4),10),parseInt(s.substring(4,6),10)-1,parseInt(s.substring(6,8),10));};BFUtils.dateToString=function(date)
{if(!(date instanceof Date))
{throw new Error("Not a valid date object!");}
var y=String(date.getFullYear());var m=String(date.getMonth()+1);var d=String(date.getDate());return BFStringUtils.zeroPrefix(y)+BFStringUtils.zeroPrefix(m)+BFStringUtils.zeroPrefix(d);};BFUtils.destroyXHR=function(xhr)
{if(!xhr)
{return;}
if(xhr.readyState!=4)
{xhr.abort();}
xhr=null;};BFUtils.airportNameFromCode=function(code)
{var dictionary=BFSearchResultsManager.getInstance().airportsDictionary;return dictionary[code]||code;};BFUtils.getOrderedMinMax=function(objects)
{var v1=objects[0].refValue;var v2=pbjects[1].refValue;return[Math.min(v1,v2),Math.max(v1,v2)];};BFUtils.imageFallBack=function(img)
{img.src=BFSearchResultsManager.getInstance().params.missingPhotoURL;img.className="hotel-image cursor-default";img.onabort=null;img.onerror=null;};BFUtils.getPriceThresholds=function(prices)
{prices.sort(BFArrayUtils.numericAscSort);var len=prices.length;if(len<4)
{return prices;}
var top10=len>10?Math.floor(len*0.1):1;if(top10>10)
{top10=10;}
var lowPriceThreshold=Math.max.apply(null,prices.slice(0,top10));var middlePriceThreshold=Math.max.apply(null,prices.slice(top10+1,len-top10));var highPriceThreshold=Math.max.apply(null,prices);return[lowPriceThreshold,middlePriceThreshold,highPriceThreshold];};BFUtils.automatizeSuggester=function(autocomplete,selectHandler)
{if(typeof autocomplete!="object"||!autocomplete.selector)
{throw new Error("Invalid argument");}
var eventName="blur.autoComplete";autocomplete.unbind(eventName).bind(eventName,function(e){var $this=$(this);var $widget=$this.autocomplete("widget");var $options=$("li",$widget);var currentValue=$this.val();if($.trim(currentValue)!="")
{for(var i=0,e=$options.length;i<e;i++)
{if($($options.get(i)).text()==currentValue)
{return;}}}
var $firstOption=$options.first();if($firstOption.length==1)
{$this.val($firstOption.text());}
if(typeof selectHandler=="function")
{selectHandler(e,{item:$firstOption.length==1?$firstOption.data("item.autocomplete"):null});}});};;BFObjectUtils=function(){};BFObjectUtils.objectType=function(object)
{if(object===undefined)
{return"undefined";}
if(object===null)
{return"null";}
var constructor=object.constructor.toString();var results=constructor.match(/function ([^\(]{1,})/);if(results instanceof Array&&results.length==2)
{return results[1];}
return"Anonymous";};BFObjectUtils.isSimpleType=function(object)
{var keys={"Boolean":0,"String":0,"Number":0,"null":0,"undefined":0};return(BFObjectUtils.objectType(object)in keys);};BFObjectUtils.compareObjects=function(a,b)
{var typeA=BFObjectUtils.objectType(a);var typeB=BFObjectUtils.objectType(b);var aIsSimple=BFObjectUtils.isSimpleType(a);function isSameObject(obj1,obj2)
{if(typeA=="Function")
{return obj1.toString()===obj2.toString();}
return JSON.stringify(obj1)===JSON.stringify(obj2);};if((typeA!=typeB)||(aIsSimple&&(a!=b))||(!aIsSimple&&(!isSameObject(a,b)))){return false;}
return true;};BFObjectUtils.anyObject=function(struct)
{if(typeof struct!="object")
{throw new Error("Invalid arguments");}
for(var i in struct)
{return struct[i];}};BFObjectUtils.anyKeyInObject=function(object,keyToAvoid)
{if(typeof object!="object")
{throw new Error("Invalid arguments");}
for(var k in object)
{if(keyToAvoid&&(k==keyToAvoid))
{continue;}
return k;}};BFObjectUtils.valuesListForObject=function(object)
{if(typeof object!="object")
{throw new Error("Invalid arguments");}
var values=[];for(var i in object)
{values.push(object[i]);}
return values;};BFObjectUtils.objectKeysCount=function(object)
{if(typeof object!="object")
{throw new Error("Invalid arguments");}
var count=0;for(var i in object)
{count++;}
return count;};BFObjectUtils.orderedKeyListForObject=function(object,sorterFunction)
{if(typeof object!="object")
{throw new Error("Invalid arguments");}
var list=[];var sf=sorterFunction||function(a,b)
{return a>b?1:-1;};for(var i in object)
{list.push(i);}
list.sort(sf);return list;};BFObjectUtils.serializeObjectForAjaxCall=function(obj)
{if(typeof obj!="object")
{throw new Error("Invalid arguments");}
var queryString=[];for(var i in obj)
{if(obj[i]instanceof Array)
{var arr=obj[i];for(var j=0;j<arr.length;j++)
{queryString.push(i+"="+escape(arr[j]));}}
else
{queryString.push(i+"="+escape(obj[i]));}}
return queryString.join("&");};;BFStringUtils=function(){};BFStringUtils.stringReverse=function(string){return string.split('').reverse().join('');};BFStringUtils.zeroPrefix=function(number){return number<10?"0"+number:String(number);};BFStringUtils.generateUID=function(){if(!window.BF_ID_COUNT){window.BF_ID_COUNT=0;}
return"bf_id_"+(window.BF_ID_COUNT++);};BFStringUtils.removeExceedingWords=function(string,maxChars){while(string.length>maxChars){string=string.substring(0,string.lastIndexOf(" "));}
return string;};BFStringUtils.capitalize=function(string,recursive){if(BFObjectUtils.objectType(string)!="String"){throw new Error("Invalid argument");}
if(string.length==0)return string;var words=string.split(" ");for(w=0;w<words.length;w++){words[w]=words[w].charAt(0).toUpperCase()+words[w].substring(1);if(recursive===false){break;}}
return words.join(" ");};;BFDateUtils=function(){};BFDateUtils.MINUTES_IN_DAY=60*24;BFDateUtils.SECONDS_IN_DAY=60*BFDateUtils.MINUTES_IN_DAY;BFDateUtils.MILLISECONDS_IN_DAY=1000*BFDateUtils.SECONDS_IN_DAY;BFDateUtils.isLeapYear=function(year)
{if(isNaN(parseInt(year,10))||String(year).length!=4)
{throw new Error("Invalid year!");}
return(year%400==0)||((year%100!=0)&&(year%4==0));};BFDateUtils.nextLeapYear=function(year)
{var y=new Date().getFullYear();if(!isNaN(parseInt(year,10))&&String(year).length==4)
{y=year;}
if(BFDateUtils.isLeapYear(y))
{return y+4;}
while(!BFDateUtils.isLeapYear(y))
{y=parseInt(y,10)+1;}
return y;};BFDateUtils.dateByAddingDatePart=function(date,datePart,value)
{var Y=date.getFullYear();var M=date.getMonth();var D=date.getDate();var h=date.getHours();var m=date.getMinutes();var s=date.getSeconds();switch(datePart)
{case"year":return new Date(Y+value,M,D,h,m,s);case"month":return new Date(Y,M+value,D,h,m,s);case"day":return new Date(Y,M,D+value,h,m,s);case"hour":return new Date(Y,M,D,h+value,m,s);case"minute":return new Date(Y,M,D,h,m+value,s);case"second":return new Date(Y,M,D,h,m,s+value);default:return date;}};BFDateUtils.dateDiff=function(date1,date2)
{if(!(date1 instanceof Date)||!(date2 instanceof Date))
{throw new Error("Invalid date objects!");}
var t1=date1.getTime();var t2=date2.getTime();return Math.max(t1,t2)-Math.min(t1,t2);};BFDateUtils.monthsDiff=function(d1,d2)
{var months;months=(d1.getFullYear()-d2.getFullYear())*12;months-=d2.getMonth();months+=d1.getMonth();return months;};BFDateUtils.daysDiff=function(d1,d2)
{return Math.floor(BFDateUtils.dateDiff(d1,d2)/BFDateUtils.MILLISECONDS_IN_DAY);};BFDateUtils.datesBetweenDates=function(date1,date2)
{if(!(date1 instanceof Date)||!(date2 instanceof Date))
{throw new Error("Invalid date objects!");}
var daysDiff=Math.ceil(BFDateUtils.dateDiff(date2,date1)/BFDateUtils.MILLISECONDS_IN_DAY);var dates=[];var t1=date1.getTime();var t2=date2.getTime();var minDate=Math.min(t1,t2)==t1?date1:date2;for(var i=1;i<daysDiff;i++)
{dates.push(BFDateUtils.dateByAddingDatePart(minDate,"day",i));}
return dates;};;BFArrayUtils=function(){};BFArrayUtils.alphabeticInsensitiveAscSort=function(a,b)
{return a.toLowerCase()>b.toLowerCase()?1:-1;};BFArrayUtils.alphabeticInsensitiveDescSort=function(a,b)
{return a.toLowerCase()<b.toLowerCase()?1:-1;};BFArrayUtils.alphabeticAscSort=function(a,b)
{return a>b?1:-1;};BFArrayUtils.alphabeticDescSort=function(a,b)
{return a<b?1:-1;};BFArrayUtils.numericAscSort=function(a,b)
{return parseFloat(a)>parseFloat(b)?1:-1;};BFArrayUtils.numericDescSort=function(a,b)
{return parseFloat(a)<parseFloat(b)?1:-1;};BFArrayUtils.dateAscSort=function(a,b)
{return a.getTime()>b.getTime()?1:-1;};BFArrayUtils.dateDescSort=function(a,b)
{return a.getTime()<b.getTime()?1:-1;};BFArrayUtils.isConsistentArray=function(array)
{return array instanceof Array&&array.length>0;};BFArrayUtils.arrayContainsObject=function(array,object)
{if(!(array instanceof Array)||!object)
{throw new Error("Invalid arguments");}
for(var i in array)
{if(BFObjectUtils.compareObjects(array[i],object))
{return true;}}
return false;};BFArrayUtils.arrayWithoutDuplicates=function(array)
{if(!(array instanceof Array))
{throw new Error("Invalid arguments");}
var objects={};var singles=[];for(var i in array)
{var serializedObject=JSON.stringify(array[i]);objects[serializedObject]=0;}
for(var j in objects)
{singles.push(JSON.parse(j));}
return singles;};BFArrayUtils.arrayWithGroupedObjects=function(array)
{var groups={};if(!(array instanceof Array)||array.length==0||arguments.length<2)
{throw new Error("Invalid configuration");}
var topArguments=arguments;function groupBy(obj)
{var array=[];for(var i=1;i<topArguments.length;i++)
{var key=topArguments[i];array.push(obj[key]);}
return array;};for(var i in array)
{var values=groupBy(array[i]);var group=groups;for(var j=0;j<values.length;j++)
{var key=values[j];group=(group[key]||(group[key]=j===values.length-1&&[]||{}));}
group=(group instanceof Array?group:[]).push(array[i]);}
return groups;};BFArrayUtils.capitalizeArray=function(array,recursive)
{if(!(array instanceof Array))
{throw new Error("Invalid argument");}
for(s=0;s<array.length;s++)
{array[s]=BFStringUtils.capitalize(array[s],recursive);}
return array;};;BFNumberUtils=function(){};BFNumberUtils.getAverage=function(numbers){var total=0;for(var i in numbers){total+=numbers[i];}
return total/numbers.length;};BFNumberUtils.getRanges=function(numberOfRanges,numbers){numbers.sort(BFArrayUtils.numericAscSort);var numbersInRange=Math.ceil(numbers.length/numberOfRanges);var max=numbers.length;var ranges=[];for(var i=0;i<numberOfRanges;i++){var from=i*numbersInRange;var to=from+numbersInRange;var chunk=numbers.slice(from,to>max?max:to);ranges.push(Math.max.apply(null,chunk));}
return ranges;};;BFCommandsQueue=function(commands){this._commands=[];if(commands instanceof Array){for(var i=0,e=commands.length;i<e;i++){var cmd=commands[i];if(typeof cmd=="function"){this._commands.push(cmd);}}}};BFCommandsQueue.executeAll=function(commands,context){var scope=context||window;if(commands instanceof Array){for(var i=0,e=commands.length;i<e;i++){var cmd=commands[i];if(cmd instanceof Function){cmd.call(scope);}}}};BFCommandsQueue.prototype.add=function(command){if(typeof command!="function"){throw new Error("BFCommandsQueue.add() accepts only functions!");}
this._commands.push(command);};BFCommandsQueue.prototype.get=function(index){if(typeof index<0||index>this._commands.length-1){throw new Error("Invalid BFCommandsQueue index");}
return this._commands[index];};BFCommandsQueue.prototype.execute=function(index,context){var scope=context||window;if(index){this._commands[index].call(scope);}else{for(var i=0,e=this.commands.length;i<e;i++){this._commands[i].call(scope);}}};;BFMultiCheckboxItemModelAdapter=function(config){if(typeof config!="object"){config={};}
this.config=config;};BFMultiCheckboxItemModelAdapter.prototype.adapt=function(){var modelInterface={id:"",label:"",value:"",checked:false,separator:false,order:0,customData:{}};var adapted={};var clonedConfig=jQuery.extend({},this.config);for(var i in modelInterface){adapted[i]=clonedConfig[i]||modelInterface[i];delete clonedConfig[i];}
jQuery.extend(true,adapted.customData,clonedConfig);return adapted;};;BFMultiCheckboxItemFactory=function(){};BFMultiCheckboxItemFactory.prototype.toString=function(){return"BFMultiCheckboxItemFactory";};BFMultiCheckboxItemFactory.createItem=function(config){return new BFMultiCheckboxItem(new BFMultiCheckboxItemModelAdapter(config).adapt());};BFMultiCheckboxItemFactory.createItems=function(objects){var items=[];for(var i in objects){items.push(BFMultiCheckboxItemFactory.createItem(objects[i]));}
return items;};;BFSearchFormDataParser=function(data)
{this.data=data;var previousOrder=-1;var count=0;for(var i in this.data.periods)
{var period=this.data.periods[i];var order=period.order;if(previousOrder>=0&&(order-previousOrder>1))
{for(var j=0;j<count;j++)
{this.data.periods[j].custom=true;}
break;}
previousOrder=order;count++;}};BFSearchFormDataParser.prototype.destinationHasValidOffers=function(destination)
{if(!this.data.priceThreshold)
{return true;}
var availableAirports=destination.a;var offers=[];for(var d in availableAirports)
{var availableAirport=availableAirports[d];if(this.airportHasValidOffers(availableAirport))
{return true;}}
return false;};BFSearchFormDataParser.prototype.airportHasValidOffers=function(airport)
{if(!this.data.priceThreshold)
{return true;}
for(var i in airport)
{var offers=airport[i];for(var o in offers)
{if(offers[o].p[0]<=this.data.priceThreshold)
{return true;}}}
return false;};BFSearchFormDataParser.prototype.getDestinationComboGroups=function()
{var groups=[];var destinations=jQuery.extend({},this.data).destinations;var areas=destinations.areas;try
{for(var i in areas)
{var group={groupLabel:i,items:[]};var area=areas[i];for(var j in area)
{var destination=area[j];if(this.destinationHasValidOffers(destination))
{group.items.push({label:destination.l,value:destination.v,checked:false});}}
if(group.items.length>0)
{groups.push(group);}}}
catch(e)
{BFUtils.log("An error occured while trying to parse data to retrieve groups for destinationCombo.",e);}
finally
{return groups;}};BFSearchFormDataParser.prototype.getDurationsComboGroups=function(selectedDestinations,selectedAirports)
{if(!(selectedDestinations instanceof Array)||!(selectedAirports instanceof Array))
{throw new Error("Invalid arguments");}
var availableDurations=jQuery.extend({},this.data).durations;var destinations=jQuery.extend({},this.data).destinations;var areas=destinations.areas;var group={groupLabel:"",items:[]};var durations=[];try
{for(var i in areas)
{var area=areas[i];for(var j in area)
{var destination=area[j];for(var x in selectedDestinations)
{if(selectedDestinations[x].value!=destination.v)
{continue;}
var availableAirports=destination.a;for(var a in selectedAirports)
{var airport=selectedAirports[a];for(var d in availableAirports)
{var availableAirport=availableAirports[d];for(var k in availableAirport)
{var airportEntries=availableAirport[k];if(k==airport.value)
{for(var e in airportEntries)
{var entry=airportEntries[e];if(!this.data.priceThreshold||entry.p[0]<=this.data.priceThreshold)
{durations=durations.concat(entry.d);}}}}}}}}}
durations.sort(BFArrayUtils.numericAscSort);durations=BFArrayUtils.arrayWithoutDuplicates(durations);for(var q in durations)
{var dr=durations[q];group.items.push({label:availableDurations[dr],value:dr});}}
catch(e)
{BFUtils.log("An error occured while trying to parse data to retrieve groups for durationsCombo.",e);}
finally
{return[group];}};BFSearchFormDataParser.prototype.getDurationsIds=function(durationsComboGroups)
{var items=durationsComboGroups[0].items;var values=[];for(var i in items)
{values.push(items[i].value);}
return values;};BFSearchFormDataParser.prototype.getPeriodsRanges=function(duration,selectedDestinations,selectedAirports)
{if(isNaN(duration)||!(selectedDestinations instanceof Array)||!(selectedAirports instanceof Array))
{throw new Error("Invalid arguments");}
var areas=jQuery.extend({},this.data).destinations.areas;var durations=this.getDurationsIds(this.getDurationsComboGroups(selectedDestinations,selectedAirports));var periods=[];var instance=this;function isValidEntry(entry)
{if(instance.data.priceThreshold&&entry.p[0]>instance.data.priceThreshold)
{return false;}
for(var i in entry.d)
{if(entry.d[i]==duration)
{return true;}}
return false;};try
{for(var i in areas)
{var area=areas[i];for(var j in area)
{var destination=area[j];for(var x in selectedDestinations)
{if(selectedDestinations[x].value!=destination.v)
{continue;}
var availableAirports=destination.a;for(var a in selectedAirports)
{var airport=selectedAirports[a];for(var d in availableAirports)
{var availableAirport=availableAirports[d];for(var k in availableAirport)
{var airportEntries=availableAirport[k];if(k==airport.value)
{for(var e in airportEntries)
{var entry=airportEntries[e];if(isValidEntry(entry))
{periods.push(entry.i);}}}}}}}}}}
catch(e)
{BFUtils.log("An error occured while trying to parse data to retrieve groups for durationsCombo.",e);}
finally
{return periods;}};BFSearchFormDataParser.prototype.getPeriodsComboGroups=function(duration,selectedDestinations,selectedAirports)
{if(isNaN(duration)||!(selectedDestinations instanceof Array)||!(selectedAirports instanceof Array))
{throw new Error("Invalid arguments");}
var durations=this.getDurationsIds(this.getDurationsComboGroups(selectedDestinations,selectedAirports));var availableDurations=jQuery.extend({},this.data).durations;var group={groupLabel:"",items:[]};var availablePeriods=jQuery.extend({},this.data).periods;var periods=this.getPeriodsRanges(duration,selectedDestinations,selectedAirports);for(var p in availablePeriods)
{var period=availablePeriods[p];var item={label:period.label,order:period.order,customData:{custom:period.custom||false,dates:[]}};for(var i in periods)
{var currentPeriod=periods[i];if(!(currentPeriod[0]>=period.interval[0]&&currentPeriod[0]<=period.interval[1]))
{continue;}
var startDate=BFUtils.stringToDate(currentPeriod[0]);var endDate=BFUtils.stringToDate(currentPeriod[1]);var currentDates=BFDateUtils.datesBetweenDates(startDate,endDate);currentDates=[startDate].concat(currentDates);if(currentDates.length>1)
{currentDates.push(endDate);}
currentDates.sort(BFArrayUtils.dateAscSort);item.customData.dates.push.apply(item.customData.dates,currentDates);}
if(item.customData.dates.length>0)
{item.value=BFUtils.dateToString(item.customData.dates[0])+"-"+BFUtils.dateToString(item.customData.dates[item.customData.dates.length-1]);group.items.push(item);}}
var customPeriodsAvailable=false;for(var w=0;w<group.items.length;w++)
{var currentItem=group.items[w];if(currentItem.customData.custom)
{customPeriodsAvailable=true;}
if(customPeriodsAvailable&&group.items[w+1]&&!group.items[w+1].customData.custom)
{currentItem.separator=true;break;}}
return[group];};BFSearchFormDataParser.prototype.getAirportsComboGroups=function(selectedDestinations)
{if(!(selectedDestinations instanceof Array))
{throw new Error("Invalid arguments");}
var group={groupLabel:"",items:[]};var destinations=jQuery.extend({},this.data).destinations;var areas=destinations.areas;var processedAirports={};try
{for(var i in areas)
{var area=areas[i];for(var j in area)
{var destination=area[j];for(var x in selectedDestinations)
{if(selectedDestinations[x]!=destination.v)
{continue;}
var airports=destination.a;for(var d in airports)
{var airport=airports[d];for(var k in airport)
{if(!processedAirports[k]&&this.airportHasValidOffers(airport))
{processedAirports[k]=destinations.airports[k];}}}}}}
for(var p in processedAirports)
{group.items.push({label:processedAirports[p],value:p});}
group.items.sort(function(a,b){var labelA=a.label?jQuery.trim(a.label).toLowerCase():"";var labelB=b.label?jQuery.trim(b.label).toLowerCase():"";return labelA>labelB?1:-1;});}
catch(e)
{BFUtils.log("An error occured while trying to parse data to retrieve groups for airportsCombo.",e);}
finally
{return[group];}};BFSearchFormDataParser.getDateRangeFromItems=function(items)
{if(!(items instanceof Array))
{throw new Error("Invalid arguments");}
var from=[];var to=[];var range=[null,null];try
{for(var i in items)
{var item=items[i];var values=item.value?item.value.split("-"):item.split("-");from.push(parseInt(values[0],10));to.push(parseInt(values[1],10));}
range=[BFUtils.stringToDate(Math.min.apply(null,from)),BFUtils.stringToDate(Math.max.apply(null,to))];var now=new Date();if(range[0].getTime()<now.getTime())
{range[0]=new Date(now.getFullYear(),now.getMonth(),now.getDate()+1);}}
catch(e)
{BFUtils.log("An error occured while trying to parse data for date range.",e);}
finally
{return range;}};BFSearchFormDataParser.prototype.getUpdatedCheckboxGroupItemsWithSelection=function(groups,selection)
{if(!(groups instanceof Array)||!(selection instanceof Array))
{throw new Error("Invalid arguments");}
var updatedGroups=[];for(var i in groups)
{var group=groups[i];var updatedGroup={groupLabel:group.groupLabel,items:[]};for(var j in group.items)
{var item=group.items[j];var duplicate=false;for(var k in updatedGroups){var gItems=updatedGroups[k].items;for(var z=0;z<gItems.length;z++)
{if(gItems[z].value==item.value)
{duplicate=true;break;}}}
if(!duplicate)
{for(var x in selection)
{if(item.value==selection[x])
{item.checked=true;break;}}}
updatedGroup.items.push(item);}
updatedGroups.push(group);}
return updatedGroups;};BFSearchFormDataParser.getGroupsPreservingPreviousSelections=function(previousSelection,currentGroups)
{if(!(previousSelection instanceof Array)||!(currentGroups instanceof Array))
{throw new Error("Invalid arguments");}
for(var i in currentGroups)
{var items=currentGroups[i].items;for(var j in items)
{var item=items[j];for(var k in previousSelection)
{var selectedItem=previousSelection[k];if(selectedItem.value==item.value)
{item.checked=true;break;}}}}
return currentGroups;};;BFImageNavigatorThumbsLoaded="BFImageNavigatorThumbsLoaded";BFImageNavigator=function(config)
{if(!(config.images instanceof Array)||!config.containerSelector)
{throw new Error("Invalid configuration data for BFImageNavigator.");}
this.visibleThumbs=config.visibleThumbs||3;this.images=config.images;this.containerSelector=config.containerSelector;this.thumbSize=config.thumbSize||[60,60];this.unableToLoadMessage="Unable to load images. Please, check your internet connection and try again.";this.id=BFStringUtils.generateUID();this.loadingTemplate='<div class="bf-imagenavigator-loading">loading...</div>';this.template='<div class="bf-imagenavigator-content"></div>'+'<div class="bf-imagenavigator-thumbs">'+'<div class="bf-arrow-container">'+'<div class="bf-arrow-top"></div>'+'</div>'+'<div class="bf-thumbs-wrapper"></div>'+'<div class="bf-arrow-container">'+'<div class="bf-arrow-bottom"></div>'+'</div>'+'</div>';this.scrollManager=null;var instance=this;jQuery(this).bind(BFImageNavigatorThumbsLoaded,function(){instance._drawMainContainer(instance.template);instance._drawThumbsContainer();instance.drawPic(0);instance._addListeners();});};BFImageNavigator.prototype._resizeImageToFit=function(pic)
{var pic=jQuery(this.containerSelector+" .bf-imagenavigator-content img:first");var picContainer=jQuery(this.containerSelector+" .bf-imagenavigator-content");var descriptionHeight=jQuery(this.containerSelector+" .bf-description").height();var picHeight=pic.height();var picContainerHeight=picContainer.height();if(picHeight+descriptionHeight>picContainerHeight-10)
{pic.animate({height:picContainerHeight-descriptionHeight-10},400);}};BFImageNavigator.prototype._freshURL=function(url)
{return url+"?_="+new Date().getTime().toString()+Math.round(Math.random()*999).toString();};BFImageNavigator.prototype._allThumbsLoadFailHandler=function()
{jQuery(this.containerSelector+" .bf-imagenavigator-loading").html(this.unableToLoadMessage);};BFImageNavigator.prototype.preloadThumbs=function()
{var instance=this;var imagesToLoad=this.images.length;var thumbsLoaded=0;var thumbsSkipped=0;var parseCount=0;var thumbWidth=this.thumbSize[0];var thumbHeight=this.thumbSize[1];var instance=this;function processImage()
{var img=new Image(thumbWidth,thumbHeight);img.src=instance._freshURL(instance.images[parseCount].previewUrl);img.id="i"+parseCount;jQuery(img).bind("load",function()
{thumbsLoaded++;(parseCount>=imagesToLoad)?jQuery(instance).trigger(BFImageNavigatorThumbsLoaded):processImage();});function skip(e)
{var img=jQuery(e.target);thumbsSkipped++;instance.images[img.attr("id").substring(1)].broken=true;BFUtils.log("[BFImageNavigator] unable to load: "+img.attr("src")+", image has been skipped");if(thumbsSkipped>=imagesToLoad){return instance._allThumbsLoadFailHandler();}
if(parseCount>=imagesToLoad)
{return jQuery(instance).trigger(BFImageNavigatorThumbsLoaded);}
else
{processImage();}};parseCount++;jQuery(img).bind({error:skip,abort:skip});};processImage();};BFImageNavigator.prototype._drawMainContainer=function(template)
{var baseNode=document.createElement("div");baseNode=jQuery(baseNode);baseNode.addClass("bf-imagenavigator-container clearfix");baseNode.html(template);jQuery(this.containerSelector).html(baseNode);};BFImageNavigator.prototype._getSafeImages=function()
{var safeImages=[];for(var i=0,e=this.images.length;i<e;i++)
{var img=this.images[i];if(!img.broken)
{safeImages.push(img);}}
return safeImages;};BFImageNavigator.prototype._drawThumbsContainer=function()
{var thumbs=[];var safeImages=this._getSafeImages();for(var i=0,e=safeImages.length;i<e;i++)
{thumbs.push('<img class="bf-imagenavigator-thumb" src="'+safeImages[i].previewUrl+'" index="'+i+'" />');}
jQuery(this.containerSelector+" .bf-imagenavigator-thumbs .bf-thumbs-wrapper").html(thumbs.join(""));jQuery(this.containerSelector+" .bf-imagenavigator-thumb:first").addClass("bf-active");if(safeImages.length>this.visibleThumbs)
{jQuery(this.containerSelector+" .bf-arrow-container:last").addClass("bf-arrow-active");}};BFImageNavigator.prototype._imageLoadedHandler=function(e)
{var pic=e.data.pic;var title=e.data.title.replace(/'/g,"\'");var instance=e.data.instance;var html='<img src="'+pic.src+'" /><span class="bf-description">'+title+'</span>';jQuery(instance.containerSelector+" .bf-imagenavigator-content").html(html);jQuery(instance.containerSelector+" .bf-description").html(title);instance._resizeImageToFit();};BFImageNavigator.prototype._imageBrokenHandler=function(e)
{jQuery(this.containerSelector+" .bf-imagenavigator-content").html("Broken image");};BFImageNavigator.prototype.drawPic=function(index)
{var instance=this;var safeImages=this._getSafeImages();try
{var pic=safeImages[index];var img=new Image();img.src=this._freshURL(pic.url);jQuery(this.containerSelector+" .bf-imagenavigator-content").html("loading...");jQuery(img).bind({error:this._imageBrokenHandler,abort:this._imageBrokenHandler}).bind("load",{instance:this,pic:img,title:pic.title},this._imageLoadedHandler);}
catch(e)
{BFUtils.log("BFImageNavigator error",e);}};BFImageNavigator.prototype._thumbClickHandler=function(e)
{var thumb=jQuery(this);var index=thumb.attr("index");var instance=e.data.instance;thumb.parent().children().removeClass("bf-active");thumb.addClass("bf-active");instance.drawPic(index);};BFImageNavigator.prototype._addListeners=function()
{var instance=this;this.scrollManager=new BFScrollManager({scrollType:"vertical",scrollAreaSelector:this.containerSelector+" .bf-thumbs-wrapper",itemsSelector:".bf-imagenavigator-thumb",backControlSelector:this.containerSelector+" .bf-arrow-container:first",nextControlSelector:this.containerSelector+" .bf-arrow-container:last",controlToggleClass:"bf-arrow-active",toggleClassAction:"add",itemSize:69});jQuery(this.containerSelector).delegate(".bf-imagenavigator-thumb:not(.bf-active)","click",{instance:this},this._thumbClickHandler);};BFImageNavigator.prototype.draw=function()
{this._drawMainContainer(this.loadingTemplate);this.images.length?this.preloadThumbs():this._allThumbsLoadFailHandler();};;BFMultiCheckboxItem=function(config){if(typeof config!="object"){config={};}
this.id=config.id&&jQuery.trim(config.id)!=""?config.id:BFStringUtils.generateUID();this.label=config.label||"";this.value=config.value||"";this.checked=config.checked===true?true:false;this.separator=config.separator===true?true:false;this.order=config.order||0;this.customData=config.customData||{};};BFMultiCheckboxItem.prototype.getItem=function(){return jQuery("#"+this.id);};BFMultiCheckboxItem.prototype.setChecked=function(checked){var node=this.getItem();var c=checked===false?false:true;this.checked=c;node.prop("checked",c);};BFMultiCheckboxItem.prototype.setSeparator=function(separator){this.separator=separator;separator?this.getItem().addClass("bf-separator"):this.getItem().removeClass("bf-separator");};;BFComboWillClose="BFComboWillClose";BFComboDidClose="BFComboDidClose";BFComboOpen="BFComboOpen";BFComboMaxSelectionReached="BFComboMaxSelectionReached";BFComboMaxSelectionExceeded="BFComboMaxSelectionExceeded";BFComboLoaded="BFComboLoaded";BFMultiCheckboxCombo=function(config){if(typeof config!="object"){config={};}
this.id=config.id||BFStringUtils.generateUID();this.name=config.name;this.checkboxGroups=config.checkboxGroups||[];this.containerSelector=config.containerSelector;this.placeholder=config.placeholder||"";this.maxSelection=config.maxSelection||1;this.maxSelectionAlertMessage=config.maxSelectionAlertMessage||"Max selections exceeded!";this.maxSelectionAlertAutoRemoveTimeout=config.maxSelectionAlertAutoRemoveTimeout||0;this.maxSelectionAlertAutoRemoveDuration=config.maxSelectionAlertAutoRemoveDuration||500;this.disabled=config.disabled||false;this.maxHeight=BFUtils.isIDevice()?0:(config.maxHeight||0);this.columns=config.columns||1;this.onOpen=config.onOpen||null;this.onWillClose=config.onWillClose||null;this.onDidClose=config.onDidClose||null;this.onChange=config.onChange||null;this.onAutoSelection=config.onAutoSelection||null;this.onMaxSelectionReached=config.onMaxSelectionReached||null;this.onMaxSelectionExceeded=config.onMaxSelectionExceeded||null;this.onLoad=config.onLoad||null;this.selectedItemsSorting=config.selectedItemsSorting||function(a,b){return a.label.toLowerCase()>b.label.toLowerCase()?1:-1;};this._template='<div class="bf-field-container" id="'+this.id+'">'+'<div class="bf-combo bf-closed">'+'<div class="bf-combo-header">'+'<div class="bf-combo-expand"></div>'+'<div class="bf-combo-field">#PLACEHOLDER</div>'+'</div>'+'<div class="bf-combo-body">'+'<div class="bf-body-wrapper">'+'<div class="bf-columns">'+'#CHECKBOX_GROUPS'+'</div>'+'</div>'+'</div>'+'</div>'+'</div>';this._clickOutExceptionClasses=["bf-close"];this._lastSelectionList="";this._columnsHaveBeenAdjusted=false;};BFMultiCheckboxCombo.prototype._createItems=function(){for(var i in this.checkboxGroups){var group=this.checkboxGroups[i];group.items=BFMultiCheckboxItemFactory.createItems(group.items);}};BFMultiCheckboxCombo.prototype._buildMaxSelectionAlertMarkup=function(){var html='<div class="bf-combo-tooltip">'+'<div class="bf-content">'+
this.maxSelectionAlertMessage+'<div class="bf-close"></div>'+'</div>'+'</div>';return html;};BFMultiCheckboxCombo.prototype._buildBodyMarkup=function(){var html="";try{for(var i=0;i<this.checkboxGroups.length;i++){html+='<div class="bf-group">';var group=this.checkboxGroups[i];if(jQuery.trim(group.groupLabel)!=""){html+='<strong class="bf-group-label">'+group.groupLabel+'</strong>';}
for(var j=0;j<group.items.length;j++){var item=group.items[j];html+='<span class="bf-checkbox-wrapper#SP"#S><input type="checkbox" name="#N" value="#V" id="#I" bf_group="#BG" bf_item="#BI"#C /><label for="#I">#L</label></span>'.replace(/#N/,this.name).replace(/#V/,item.value).replace(/#L/,item.label).replace(/#I/g,item.id).replace(/#BG/g,i).replace(/#BI/g,j).replace(/#C/g,item.checked?' checked="checked"':"").replace(/#SP/g,item.separator?" bf-separator":"").replace(/#S/g,(jQuery.trim(item.value)==""&&jQuery.trim(item.label)=="")?' style="display:none"':"");}
html+='</div>';}}catch(e){BFUtils.log("An error occured trying to generate markup for BFMultiCheckboxCombo.",e);}finally{return html;}};BFMultiCheckboxCombo.prototype._clickoutHandler=function(e){var target=jQuery(e.target);var instance=e.data.instance;var isOutside=(function(node){var parent=jQuery(node);for(var i=0;i<instance._clickOutExceptionClasses.length;i++){if(parent.hasClass(instance._clickOutExceptionClasses[i])){return false;}}
try{while(parent.length>0){if(parent.attr("id")==instance.id){return false;}
parent=parent.parent();}}catch(e){}
return true;})(e.target);if(isOutside&&instance.isOpened()){instance.toggle(e);instance.getMaxSelectionAlertBox().remove();}};BFMultiCheckboxCombo.prototype._selectionHandler=function(e){var instance=e.data.instance;var $selectedInput=jQuery(e.target);var selectedValue=$selectedInput.val();var modelItem=instance.getItemById($selectedInput.attr("id"));setTimeout(function(){if(instance.maxSelection==1){instance.reset(true);$selectedInput.prop("checked",true);}
var selectedItems=instance.getSelectedItems();jQuery(instance).trigger("change",[$selectedInput,selectedValue]);if(selectedItems.length>instance.maxSelection){instance.showMaxSelectionAlert(e);jQuery(instance).trigger(BFComboMaxSelectionExceeded,[$selectedInput,selectedValue]);}else{modelItem.setChecked($selectedInput.prop("checked")?true:false);var text=selectedItems.length>0?instance.getSelectionList():instance.placeholder;instance.setDisplayedText(text);if(selectedItems.length==instance.maxSelection){jQuery(instance).trigger(BFComboMaxSelectionReached,[$selectedInput,selectedValue]);if(instance.maxSelection==1){instance.toggle();}}}},0);};BFMultiCheckboxCombo.prototype._injectComboMarkup=function(){var HTML=this._template.replace(/#PLACEHOLDER/,this.placeholder).replace(/#CHECKBOX_GROUPS/,this._buildBodyMarkup());jQuery(this.containerSelector).html(HTML);};BFMultiCheckboxCombo.prototype._adjustBodyPosition=function(){var combo=this.getCombo();var body=this.getBody();var height=combo.outerHeight();var bodyHeight=body.outerHeight();var offset=combo.position();try
{body.css({top:parseInt(height+offset.top,10)+"px",left:offset.left+"px"});}
catch(e)
{BFUtils.log("Error adjusting combo position",e,"error");}};BFMultiCheckboxCombo.prototype._setBodySize=function(){var body=this.getBody();var bodyWidth=body.outerWidth(true);var bodyHeight=body.outerHeight();var computedWidth=this.getHeader().outerWidth(true);if(bodyWidth<=computedWidth){body.css("width",computedWidth);}
if(jQuery.browser.msie&&this.isSimple()){var $wrapper=body.find(".bf-checkbox-wrapper");var $label=$wrapper.find("label");var padding=parseInt($label.css("padding-left"),10)+parseInt($label.css("padding-right"),10);$label.css("width",$wrapper.width()-padding);}
body.find(".bf-columns").css(navigator.userAgent.toLowerCase().indexOf("msie 6")!=-1?"height":"max-height",bodyHeight>this.maxHeight&&this.maxHeight>0?this.maxHeight+"px":"auto");};BFMultiCheckboxCombo.prototype._windowResizeHandler=function(e){var instance=e.data.instance;var timer=instance.getResizeTimer();if(instance.isOpened()){if(timer){clearTimeout(timer);}
instance.setResizeTimer(function(){instance._adjustBodyPosition();});}};BFMultiCheckboxCombo.prototype._addListeners=function(){var instance=this;this.getHeader().unbind("click."+this.id).bind("click."+this.id,{instance:this},this.toggle);jQuery("body").unbind("click."+this.id).bind("click."+this.id,{instance:this},this._clickoutHandler);this.getBody().undelegate("input","click").delegate("input","click",{instance:this},this._selectionHandler);jQuery(this).unbind();jQuery(window).unbind("resize."+this.id).bind("resize."+this.id,{instance:this},this._windowResizeHandler);if(typeof this.onWillClose=="function"){jQuery(this).bind(BFComboWillClose,this.onWillClose);}
if(typeof this.onDidClose=="function"){jQuery(this).bind(BFComboDidClose,this.onDidClose);}
if(typeof this.onOpen=="function"){jQuery(this).bind(BFComboOpen,this.onOpen);}
if(typeof this.onChange=="function"){jQuery(this).bind("change",this.onChange);}
if(typeof this.onMaxSelectionReached=="function"){jQuery(this).bind(BFComboMaxSelectionReached,this.onMaxSelectionReached);}
if(typeof this.onMaxSelectionExceeded=="function"){jQuery(this).bind(BFComboMaxSelectionExceeded,this.onMaxSelectionExceeded);}
if(typeof this.onLoad=="function"){jQuery(this).bind(BFComboLoaded,this.onLoad);}};BFMultiCheckboxCombo.prototype._displayPreselectedList=function(){if(this.getSelectedCheckboxes().length>0){var list=this.getSelectionList();this._lastSelectionList=list;this.setDisplayedText(jQuery.trim(list)!=""?list:this.placeholder);}};BFMultiCheckboxCombo.prototype._uncheckGroupItems=function(){for(var g in this.checkboxGroups){var group=this.checkboxGroups[g];for(var i in group.items){group.items[i].checked=false;}}};BFMultiCheckboxCombo.prototype.autoSelectIfSingleOption=function(){var checkboxes=this.getCheckboxes();if(checkboxes.length==1){checkboxes.prop("checked",true);var list=this.getSelectionList();this._lastSelectionList=list;this.setDisplayedText(list);jQuery(this).trigger("change");}};BFMultiCheckboxCombo.prototype.getContainer=function(){return jQuery("#"+this.id);};BFMultiCheckboxCombo.prototype.getCombo=function(){return jQuery("#"+this.id+" .bf-combo");};BFMultiCheckboxCombo.prototype.getHeader=function(){return jQuery("#"+this.id+" .bf-combo-header");};BFMultiCheckboxCombo.prototype.getExpander=function(){return jQuery("#"+this.id+" .bf-combo-expand");};BFMultiCheckboxCombo.prototype.getBody=function(){return jQuery("#"+this.id+" .bf-combo-body");};BFMultiCheckboxCombo.prototype.getField=function(){return jQuery("#"+this.id+" .bf-combo-field");};BFMultiCheckboxCombo.prototype.getMaxSelectionAlertBox=function(){return jQuery("#"+this.id+" .bf-combo-tooltip");};BFMultiCheckboxCombo.prototype.getColumnsWrapper=function(){return jQuery("#"+this.id+" .bf-columns");};BFMultiCheckboxCombo.prototype.getCheckboxes=function(){return this.getColumnsWrapper().find("input[type='checkbox']");};BFMultiCheckboxCombo.prototype.getSelectedCheckboxes=function(){return this.getColumnsWrapper().find("input[type='checkbox']:checked");};BFMultiCheckboxCombo.prototype.getSelectionList=function(){var items=this.getSelectedItems().sort(this.selectedItemsSorting);var labels=[];for(var i=0;i<items.length;i++){var label=items[i].label;if(jQuery.trim(label)!=""){labels.push(label);}}
return labels.join(", ");};BFMultiCheckboxCombo.prototype.getSelectedValues=function(){var values=[];this.getSelectedCheckboxes().each(function(){values.push(jQuery(this).val());});return values;};BFMultiCheckboxCombo.prototype.getSelectedItems=function(){var instance=this;var items=[];this.getSelectedCheckboxes().each(function(){var node=jQuery(this);var groupCount=node.attr("bf_group");var itemCount=node.attr("bf_item");var item=instance.checkboxGroups[groupCount].items[itemCount];items.push(item);});return items;};BFMultiCheckboxCombo.prototype.getItemById=function(id){for(var i=0;i<this.checkboxGroups.length;i++){var group=this.checkboxGroups[i];for(var j=0;j<group.items.length;j++){var item=group.items[j];if(item.id==id){return item;}}}
return null;};BFMultiCheckboxCombo.prototype.setDisabled=function(disable){this.disabled=!(disable===false);var container=this.getContainer();var cls="bf-field-disabled";if(this.disabled&&this.isOpened()){this.toggle();}
this.getHeader().unbind("click",this.toggle);if(this.disabled){container.addClass(cls);}else{container.removeClass(cls);this.getHeader().bind("click",{instance:this},this.toggle);}
return this;};BFMultiCheckboxCombo.prototype.setDisplayedText=function(text){this.getField().html(text).attr("title",text);return this;};BFMultiCheckboxCombo.prototype.showMaxSelectionAlert=function(e){var instance=e.data.instance;var target=jQuery(e.target);var body=this.getBody();target.prop("checked",false);if(this.getMaxSelectionAlertBox().length==0){body.find("div:first").append(instance._buildMaxSelectionAlertMarkup());var tipBox=this.getMaxSelectionAlertBox();if(instance.maxSelectionAlertAutoRemoveTimeout>0){setTimeout(function(){tipBox.animate({opacity:0},{duration:instance.maxSelectionAlertAutoRemoveDuration,complete:function(){tipBox.remove();}});},instance.maxSelectionAlertAutoRemoveTimeout);}
this.getMaxSelectionAlertBox().find(".bf-close").bind("click",function(){tipBox.remove()});}
var targetPosition=target.position();var box=this.getMaxSelectionAlertBox();var cols=body.find(".bf-columns");var paddingDiff=parseInt(cols.css("padding-left"),10)+parseInt(cols.css("padding-right"),10);box.css({top:(box.outerHeight(true)/2)+"px",width:(body.width()-paddingDiff*2)+"px"});};BFMultiCheckboxCombo.prototype.isOpened=function(){return!this.getCombo().hasClass("bf-closed");};BFMultiCheckboxCombo.prototype.getColumnSize=function(){var wrapper=this.getColumnsWrapper();var width=wrapper.width();var paddingDelta=parseInt(wrapper.css("padding-left"),10)+parseInt(wrapper.css("padding-right"),10);return Math.round((width-paddingDelta)/this.columns);};BFMultiCheckboxCombo.prototype.toggle=function(e){var instance=e&&e.data&&e.data.instance?e.data.instance:this;instance.getCombo().toggleClass("bf-closed");if(instance.isOpened()){instance._setBodySize();instance._adjustBodyPosition();if(instance.columns>1&&!instance._columnsHaveBeenAdjusted){jQuery(instance.containerSelector+' .bf-columns').masonry({columnWidth:instance.getColumnSize(),itemSelector:'.bf-group',resizeable:false,animate:false});instance._columnsHaveBeenAdjusted=true;}
jQuery(instance).trigger(BFComboOpen);}else{jQuery(instance).trigger(BFComboWillClose);var currentSelectionList=instance.getSelectionList();var comboHasBeenModified=currentSelectionList!=instance._lastSelectionList;instance._lastSelectionList=currentSelectionList;jQuery(instance).trigger(BFComboDidClose,[comboHasBeenModified]);}
return this;};BFMultiCheckboxCombo.prototype.reset=function(hard){if(hard){this._uncheckGroupItems();}
this.getSelectedCheckboxes().prop("checked",false);this.setDisplayedText(this.placeholder);this._columnsHaveBeenAdjusted=false;this._lastSelectionList="";return this;};BFMultiCheckboxCombo.prototype.destroy=function(){this.reset();this.getContainer().remove();this.getHeader().unbind("click."+this.id);jQuery(this).unbind();jQuery("body").unbind("click."+this.id);jQuery(window).unbind("resize."+this.id);return this;};BFMultiCheckboxCombo.prototype.getResizeTimer=function(){return window[this.id+"_resize_timer"];};BFMultiCheckboxCombo.prototype.setResizeTimer=function(handler){window[this.id+"_resize_timer"]=setTimeout(handler,0);};BFMultiCheckboxCombo.prototype.isSimple=function(){return this.columns==1&&this.maxSelection==1;};BFMultiCheckboxCombo.prototype.draw=function(){if(this.getContainer().length>0){this.destroy();}
this._createItems();this._injectComboMarkup();this._displayPreselectedList();if(this.maxSelection==1){this.getContainer().addClass("bf-single-selection");}
this._addListeners();this.setDisabled(this.disabled);jQuery(this).trigger(BFComboLoaded);return this;};;BFDatePickerCombo=function(config){BFMultiCheckboxCombo.call(this,config);var now=new Date();this.minDate=config.minDate||new Date(now.getFullYear()-1,now.getMonth(),now.getDate());this.maxDate=config.maxDate||new Date(now.getFullYear()+1,now.getMonth(),now.getDate());this.selectedDate=config.selectedDate||null;this.numberOfMonths=config.numberOfMonths||1;this.hiddenDateFormat=config.hiddenDateFormat||"yymmdd";this.dateFormat=config.dateFormat||"D dd/mm/yy";this.selectableDates=config.selectableDates||[];this._clickOutExceptionClasses=["ui-icon","ui-datepicker-prev","ui-datepicker-next","ui-state-default"];};BFDatePickerCombo.prototype=new BFMultiCheckboxCombo;BFDatePickerCombo.prototype._buildBodyMarkup=function(){return'<input type="hidden" name="'+this.name+'" /><div id="'+this.id+'-picker"></div>';};BFDatePickerCombo.prototype._selectionHandler=function(e){var instance=e.data.instance;var datePicker=instance.getDatePicker();var selectedDate=datePicker.datepicker("getDate");instance.getDateInput().val(jQuery.datepicker.formatDate(instance.hiddenDateFormat,selectedDate));instance.setDisplayedText(instance.getSelectionList());jQuery(instance).trigger("change",[null,selectedDate]);instance.toggle();};BFDatePickerCombo.prototype._displayPreselectedList=function(){if(jQuery.trim(this.getDateInput().val())!=""){var list=this.getSelectionList();this._lastSelectionList=list;this.setDisplayedText(list);}};BFDatePickerCombo.prototype.getDatePicker=function(){return jQuery("#"+this.id+"-picker");};BFDatePickerCombo.prototype.getDateInput=function(){return this.getBody().find("input:hidden");};BFDatePickerCombo.prototype.reset=function(hard){BFMultiCheckboxCombo.prototype.reset.call(this);if(hard){this.selectedDate=null;}
this.getDateInput().val("");this.getDatePicker().datepicker("destroy");return this;};BFDatePickerCombo.prototype.getSelectionList=function(){if(this.getDateInput().val()==""){return"";}
var selectedDate=this.getDatePicker().datepicker("getDate");return jQuery.datepicker.formatDate(this.dateFormat,selectedDate);};BFDatePickerCombo.prototype.getSelectedDate=function(){var dateString=this.getDateInput().val();return dateString==""?null:BFUtils.stringToDate(dateString);};BFDatePickerCombo.prototype.setSelectedDate=function(date){this.getDatePicker().datepicker("setDate",date);this.getDateInput().val(jQuery.datepicker.formatDate(this.hiddenDateFormat,date));var selection=this.getSelectionList();this.setDisplayedText(selection);this._lastSelectionList=selection;return this;};BFDatePickerCombo.prototype.setDateRange=function(min,max){this.minDate=!max&&min instanceof Array?min[0]:min;this.maxDate=!max&&min instanceof Array?min[1]:max;return this;};BFDatePickerCombo.prototype.draw=function(){BFMultiCheckboxCombo.prototype.draw.call(this);var instance=this;this.getContainer().addClass("bf-datepicker");this.getDatePicker().datepicker({minDate:this.minDate,maxDate:this.maxDate,numberOfMonths:this.numberOfMonths>0?this.numberOfMonths:1,defaultDate:this.selectedDate,beforeShowDay:function(date){if(instance.selectableDates.length<1){return[true,""];}
for(var i in instance.selectableDates){if(instance.selectableDates[i].getTime()==date.getTime()){return[true,""];}}
return[false,""];},onSelect:function(){instance._selectionHandler({data:{"instance":instance}});}});if(this.selectedDate){this.setSelectedDate(this.selectedDate);this._displayPreselectedList();}
return this;};;BFSubmitButton=function(config){if(!(config instanceof Object)){config={};}
if(!(config.submitFunction instanceof Function)||!config.containerSelector){throw new Error("Invalid BFSubmitButton configuration!");}
this.containerSelector=config.containerSelector;this.submitFunction=config.submitFunction;this.formSelector=config.formSelector||"";this.label=config.label||"";this.waitingLabel=config.waitingLabel||null;this.disableAfterClick=config.disableAfterClick===false?false:true;this.loaderPath=config.loaderPath||"";this.width=config.width||-1;this.height=config.height||-1;this._id=BFStringUtils.generateUID();this._template='<div class="bf-submit-button" id="'+this._id+'">'+'<div class="bf-submit-mask"></div>'+'<img class="bf-loader display-none" src="'+this.loaderPath+'" />'+'<div class="bf-right-cap"></div>'+'<div class="bf-label">#L</div>'+'</div>';};BFSubmitButton.prototype._clickHandler=function(e){var instance=e.data.instance;var $button=instance.getButton();var $label=instance.getLabel();var $loader=instance.getLoader();var $mask=instance.getMask();if(instance.disableAfterClick){$button.unbind("click",instance._clickHandler).addClass("bf-submit-button-disabled");if(instance.loaderPath!=""){$loader.removeClass("display-none");}}
if(instance.waitingLabel&&instance.waitingLabel!=instance.label){$label.html(instance.waitingLabel);}
if(instance.submitFunction()===false){$button.bind("click",{"instance":instance},instance._clickHandler).removeClass("bf-submit-button-disabled");$loader.addClass("display-none");$label.html(instance.label);}};BFSubmitButton.prototype._addListeners=function(){this.getButton().unbind("click",this._clickHandler).bind("click",{instance:this},this._clickHandler);};BFSubmitButton.prototype.getContainer=function(){return jQuery(this.containerSelector);};BFSubmitButton.prototype.getButton=function(){return jQuery("#"+this._id);};BFSubmitButton.prototype.getForm=function(){return jQuery(this.formSelector);};BFSubmitButton.prototype.getLabel=function(){return this.getButton().find(".bf-label");};BFSubmitButton.prototype.getLoader=function(){return this.getButton().find(".bf-loader");};BFSubmitButton.prototype.getMask=function(){return this.getButton().find(".bf-button-mask");};BFSubmitButton.prototype.isDisabled=function(){return this.getButton().hasClass("bf-submit-button-disabled");};BFSubmitButton.prototype.setDisabled=function(disabled){var $button=this.getButton();if(disabled){$button.unbind("click",this._clickHandler).addClass("bf-submit-button-disabled");}else{$button.bind("click",{instance:this},this._clickHandler).removeClass("bf-submit-button-disabled");}};BFSubmitButton.prototype.draw=function(){jQuery(this.containerSelector).empty().append(this._template.replace(/#L/,this.label));var $button=this.getButton();if(this.width>0){$button.css("width",this.width+"px");}
if(this.height>0){$button.css("height",this.height+"px");}
this._addListeners();};;BFAirportsComboUpdateCommand=function(controller)
{this.controller=controller;};BFAirportsComboUpdateCommand.prototype.execute=function()
{try
{var selectedDestinations=this.controller.destinationsCombo.getSelectedValues();var groups=this.controller.dataParser.getAirportsComboGroups(selectedDestinations);var airportsCombo=this.controller.airportsCombo;if(groups[0].items.length>0)
{var previousSelection=airportsCombo.getSelectedItems();if(previousSelection.length>0)
{groups=BFSearchFormDataParser.getGroupsPreservingPreviousSelections(previousSelection,groups);}
airportsCombo.checkboxGroups=groups;airportsCombo.disabled=this.controller.isAccomodationOnly();airportsCombo.draw();this.controller.toggleAccomodationOnly(groups);}
else
{airportsCombo.setDisabled(true);this.controller.durationCombo.setDisabled(true);this.controller.periodMode.disableControls();this.controller.getAccomodationOnlyField().attr({disabled:"disabled",checked:false});}
this.controller.periodMode.toggleRoomsViewStatus();}
catch(e)
{BFUtils.log("An error occured executing BFAirportsComboUpdateCommand.",e);}};;BFDurationComboUpdateCommand=function(controller){this.controller=controller;};BFDurationComboUpdateCommand.prototype.execute=function(){var destinationsCombo=this.controller.destinationsCombo
var airportsCombo=this.controller.airportsCombo;var durationCombo=this.controller.durationCombo;try{var selectedAirports=this.controller.isOnlyAccomodationOnly()?airportsCombo.checkboxGroups[0].items:airportsCombo.getSelectedItems();if(selectedAirports.length>0){var newGroups=this.controller.dataParser.getDurationsComboGroups(destinationsCombo.getSelectedItems(),selectedAirports);durationCombo.checkboxGroups=BFSearchFormDataParser.getGroupsPreservingPreviousSelections(durationCombo.getSelectedItems(),newGroups);durationCombo.disabled=false;durationCombo.draw();}else{durationCombo.setDisabled(true);this.controller.periodMode.disableControls();}
airportsCombo.setDisabled(this.controller.isAccomodationOnly());this.controller.periodMode.toggleRoomsViewStatus();}catch(e){BFUtils.log("An error occured executing BFDurationComboUpdateCommand.",e);}};;BFPeriodComboUpdateCommand=function(controller){this.controller=controller;};BFPeriodComboUpdateCommand.prototype.execute=function(){try{this.controller.periodMode.toggleRoomsViewStatus();this.controller.periodMode.durationComboCloseHandler();}catch(e){BFUtils.log("An error occured executing BFPeriodComboUpdateCommand.",e);}};;BFToDateComboUpdateCommand=function(controller)
{this.controller=controller;};BFToDateComboUpdateCommand.prototype.execute=function()
{try
{var fromDateCombo=this.controller.fromDateCombo;var toDateCombo=this.controller.toDateCombo;var d=fromDateCombo.getSelectedDate();if(d instanceof Date)
{var currentToDate=toDateCombo.getSelectedDate();var count=toDateCombo.selectableDates.length;var firstDate=toDateCombo.selectableDates[0];var lastDate=toDateCombo.selectableDates[count-1];var lastMonth=lastDate.getMonth();toDateCombo.minDate=BFArrayUtils.arrayContainsObject(toDateCombo.selectableDates,d)?d:firstDate;toDateCombo.maxDate=lastDate;while(BFDateUtils.daysDiff(toDateCombo.maxDate,toDateCombo.minDate)>60&&count>0)
{toDateCombo.maxDate=toDateCombo.selectableDates[--count];}
toDateCombo.selectedDate=currentToDate instanceof Date&&BFArrayUtils.arrayContainsObject(toDateCombo.selectableDates,currentToDate)?currentToDate:null;toDateCombo.disabled=false;toDateCombo.draw();}
else
{toDateCombo.reset().setDisabled(true);}
var periodMode=this.controller.periodMode;setTimeout(function(){periodMode.toggleRoomsViewStatus();},100);}
catch(e)
{BFUtils.log("An error occured executing BFToDateComboUpdateCommand.",e);}};;BFViewControllerModelChange="BFViewControllerModelChange";BFBaseViewController=function(config){if(typeof config!="object"){config={};}
this.parentViewSelector=config.parentViewSelector;this.parentViewController=config.parentViewController;this.template=config.template;this.model=config.model||{};this.viewIsDisabled=config.viewIsDisabled||false;this.viewIsOnlyChild=config.viewIsOnlyChild||false;this.viewSelector=null;this.mask=null;this.id=config.id||BFStringUtils.generateUID();jQuery(this).bind(BFViewControllerModelChange,this._modelChangeHandler);};BFBaseViewController.prototype.getClassName=function(){return"BFBaseViewController";};BFBaseViewController.prototype._adjustMask=function(e){var instance=(e&&e.data&&e.data.instance)?e.data.instance:this;if(!instance.mask){return;}
var view=jQuery(instance.viewSelector);var offset=view.offset();jQuery(instance.mask).css({"width":(view.outerWidth()+2)+"px","height":(view.outerHeight()+2)+"px","top":Math.round(offset.top)+"px","left":Math.round(offset.left)+"px"});};BFBaseViewController.prototype._createMaskForView=function(){if(!this.mask){var mask=document.createElement("div");this.mask="#"+this.id+"-mask";jQuery(mask).addClass("view-mask").attr("id",this.id+"-mask").appendTo("body");this._adjustMask();jQuery(window).bind("resize",{instance:this},this._adjustMask);}};BFBaseViewController.prototype.setViewAsDisabled=function(disable){var instance=this;this.viewIsDisabled=disable;if(this.viewSelector){if(this.mask&&!this.viewIsDisabled){jQuery(this.mask).remove();this.mask=null;jQuery(this.viewSelector).removeClass("disabled-view");}else if(this.viewIsDisabled){jQuery().ready(function(){instance._createMaskForView();instance._adjustMask();jQuery(instance.viewSelector).addClass("disabled-view");});}}};BFBaseViewController.prototype.getAncestralViewController=function(){if(!this.parentViewController){return null;}
var parent=this;try{while(parent.parentViewController){parent=parent.parentViewController;}}catch(e){parent=null;}finally{return parent;}};BFBaseViewController.prototype._applyTemplate=function(config){if(typeof config!="object"){config={};}
var baseSettings={runnable_functions:true,filter_data:false};var settings=typeof config.settings=="object"?jQuery.extend(true,baseSettings,config.settings):baseSettings;var view=jQuery(this.viewSelector);if(this.viewSelector&&typeof this.model=="object"){try{try{view.setTemplateElement(this.template,config.includes||null,settings);}catch(e){BFUtils.log('An error occurred setting template element "'+this.template+'"',e);}
try{view.processTemplate(this.model);}catch(e){BFUtils.log('An error occurred processing template "'+this.template+'"',e);}
if(this.viewIsDisabled){this.setViewAsDisabled(true);}}catch(e){BFUtils.log('An error occured during template rendering. Template: "'+this.template+'"',e);}}};BFBaseViewController.prototype._modelChangeHandler=function(e){e.stopImmediatePropagation();e.target.loadView();};BFBaseViewController.prototype.getMask=function(){return jQuery(this.mask);};BFBaseViewController.prototype.cleanView=function(){if(!this.viewSelector){return;}
if(this.hasChildControllers()){for(var c in this.childControllers){this.childControllers[c].cleanView();}}
jQuery(this.viewIsOnlyChild?this.parentViewSelector:this.viewSelector).empty();};BFBaseViewController.prototype.loadView=function(){if(this.viewSelector&&jQuery(this.viewSelector).length==1){this.cleanView();}else{var container=jQuery(this.parentViewSelector);if(container.length!=1){throw new Error("BFViewController exception: parentViewSelector ("+this.parentViewSelector+") returns "+container.length+" elements!");}
if(this.viewIsOnlyChild){jQuery(this.parentViewSelector).empty();}
container.append('<div id="'+this.id+'" class="view-wrapper" bf_controller="'+this.getClassName()+'"></div>');this.viewSelector="#"+this.id;var instance=this;jQuery().ready(function(){if(instance.viewIsDisabled){setTimeout(function(){instance._adjustMask();},250);}});}
this._applyTemplate();};BFBaseViewController.prototype.generateHTML=function(){return jQuery("<div></div>").setTemplateElement(this.template).processTemplate(this.model).html();};BFBaseViewController.prototype.setModel=function(model){if(typeof this.model=="object"){this.model=model;jQuery(this).trigger(BFViewControllerModelChange);}};BFBaseViewController.prototype.isSafeModel=function(){return this.model instanceof Object&&BFObjectUtils.objectKeysCount(this.model)>0;};BFBaseViewController.prototype._addListeners=function(){};BFBaseViewController.prototype.hasChildControllers=function(){if(!this.childControllers instanceof Object){return false;}
for(var c in this.childControllers){if(!this.childControllers[c]instanceof BFBaseViewController){return false;}}
return true;};BFBaseViewController.prototype.getChildController=function(controllerName){if(!this.hasChildControllers()){return null;}
for(var c in this.childControllers){var controller=this.childControllers[c];if(c==controllerName){return controller;}
if(controller.hasChildControllers()){var childController=controller.getChildController(controllerName);if(childController){return childController;}}}
return null;};;BFSearchFormViewController=function(config)
{if(!(config instanceof Object))
{config={};}
BFBaseViewController.call(this,config);this.dataParser=new BFSearchFormDataParser(this.model);this.submitButton=config.submitButton;this.destinationsCombo=null;this.airportsCombo=null;this.durationCombo=null;this.fromDateCombo=null;this.toDateCombo=null;this.periodsCombo=null;this.roomsController=null;this.selections=config.selections||null;this.maxPassengers=config.maxPassengers||10;this.periodMode=new BFSearchFormPeriodModeStartDateEndDate(this);this.datePickerFormat=config.datePickerFormat||null;this._roomsViewWasDisabled=true;};BFSearchFormViewController.prototype=new BFBaseViewController;BFSearchFormViewController.prototype.getClassName=function()
{return"BFSearchFormViewController";};BFSearchFormViewController.prototype.toggleOkButton=function(combo)
{var target=combo.getExpander();combo.getSelectedCheckboxes().length>0?target.addClass("bf-combo-ok"):target.removeClass("bf-combo-ok");};BFSearchFormViewController.prototype.toggleRoomsView=function()
{this._roomsViewWasDisabled=this.roomsController.viewIsDisabled;this.roomsController.setViewAsDisabled(true);};BFSearchFormViewController.prototype.togglePeriodMode=function(e)
{var instance=e.data.instance;instance.periodMode=instance.periodMode instanceof BFSearchFormPeriodModePeriods?new BFSearchFormPeriodModeStartDateEndDate(instance):new BFSearchFormPeriodModePeriods(instance);try
{instance.periodMode.toggleHandler();}
catch(e)
{BFUtils.log("An error occured switch between periodMode.",e);}};BFSearchFormViewController.prototype.getAccomodationOnlyField=function()
{return jQuery("#accomodation-only");};BFSearchFormViewController.prototype.isOnlyAccomodationOnly=function()
{try
{var items=this.airportsCombo.checkboxGroups[0].items;return items.length==1&&jQuery.trim(items[0].label)==""&&jQuery.trim(items[0].value)=="";}
catch(e)
{return false;}};BFSearchFormViewController.prototype.isAccomodationOnly=function()
{return this.getAccomodationOnlyField().prop("checked");};BFSearchFormViewController.prototype.isAccomodationOnlyEnabled=function()
{return!this.getAccomodationOnlyField().attr("disabled");};BFSearchFormViewController.prototype.toggleAccomodationOnly=function(groups)
{var accomodationOnly=this.getAccomodationOnlyField();var firstItem=groups&&groups.length>0?groups[0].items[0]:null;var accomodationOnlyAvailable=firstItem&&jQuery.trim(firstItem.label)==""&&jQuery.trim(firstItem.value)=="";var isOnlyAccomodation=this.isOnlyAccomodationOnly();if(!accomodationOnlyAvailable)
{accomodationOnly.prop("checked",false).prop("disabled",true);return;}
accomodationOnly.removeAttr("disabled");if(isOnlyAccomodation||this.selections&&this.selections.accomodationOnly)
{accomodationOnly.prop({checked:true,disabled:isOnlyAccomodation});if(this.airportsCombo)
{this.airportsCombo.setDisabled(true);}}
var accomodationOnlyItem=this.airportsCombo.checkboxGroups[0].items[0];accomodationOnlyItem.setChecked(this.isAccomodationOnly());};BFSearchFormViewController.prototype._buildThresholdRadios=function()
{var thresholds=this.model.thresholds;if(!(thresholds instanceof Array)||thresholds.length==0)
{return;}
var $container=$("#price-threshold-container");if($container.length!=1)
{BFUtils.log("Container length: "+$container.length,null,"warn");return;}
var HTML="";var count=1;for(var i in thresholds)
{var value=thresholds[i];var amount=BFUtils.currencyFormat(value);var string='<input type="radio" name="threshold" value="$V" id="$ID" /><label for="$ID">$FV</label>';HTML+=string.replace(/\$V/g,value).replace(/\$ID/g,"t"+count).replace(/\$FV/g,amount);count++;}
$container.html('<input type="radio" name="threshold" value="0" id="t0" checked="checked" /><label for="t0">Qualsiasi prezzo</label>'+HTML);};BFSearchFormViewController.prototype._buildDestinationsCombo=function(config)
{var instance=this;if(!this.destinationsCombo)
{var customSettings=config||{};var group=this.dataParser.getDestinationComboGroups();var handler=function(e,modified){this.getExpander().removeClass("bf-combo-ok");if(modified||instance._roomsViewWasDisabled)
{new BFAirportsComboUpdateCommand(instance).execute();if(this.getSelectedItems().length>0&&(!instance.airportsCombo.disabled||instance.isAccomodationOnly()))
{new BFDurationComboUpdateCommand(instance).execute();if(!instance.durationCombo.disabled)
{new BFPeriodComboUpdateCommand(instance).execute();}}}
instance.roomsController.setViewAsDisabled(instance._roomsViewWasDisabled);};var defaultSettings={containerSelector:"#destination-combo-container",placeholder:BFLocalizedStrings.DESTINATION_PLACEHOLDER,checkboxGroups:group,maxSelection:3,maxSelectionAlertMessage:BFLocalizedStrings.MAX_GEO_AREAS_TIP,maxSelectionAlertAutoRemoveTimeout:1500,name:"search.destinationTags",maxHeight:this.model.maxDestinationsComboHeight||220,columns:this.model.maxDestinationsComboColumns||3,onChange:function(e){instance.toggleOkButton(this);},onOpen:function(){instance.toggleRoomsView();},onDidClose:handler,onAutoSelection:handler};this.destinationsCombo=new BFMultiCheckboxCombo(jQuery.extend(true,defaultSettings,customSettings));if(this.selections&&this.selections.destinations instanceof Array&&this.selections.destinations.length>0)
{try
{this.destinationsCombo.checkboxGroups=this.dataParser.getUpdatedCheckboxGroupItemsWithSelection(group,this.selections.destinations);}
catch(e)
{BFUtils.log("An error occurred trying to prepopulate destinationsCombo. ",e);}}}
this.destinationsCombo.draw();};BFSearchFormViewController.prototype._buildAirportsCombo=function(config)
{var instance=this;if(!this.airportsCombo)
{var customSettings=config||{};var handler=function(e,modified){this.getExpander().removeClass("bf-combo-ok");if(modified||instance._roomsViewWasDisabled){new BFDurationComboUpdateCommand(instance).execute();if(!instance.durationCombo.disabled){new BFPeriodComboUpdateCommand(instance).execute();}}
instance.roomsController.setViewAsDisabled(instance._roomsViewWasDisabled);};var defaultSettings={containerSelector:"#airports-combo-container",placeholder:BFLocalizedStrings.DEPARTURE_PLACEHOLDER,maxSelection:3,checkboxGroups:[],disabled:true,maxSelectionAlertMessage:BFLocalizedStrings.MAX_AIRPORTS_TIP,maxSelectionAlertAutoRemoveTimeout:1500,name:"search.departureAirports",maxHeight:this.model.maxAirportsComboHeight||165,onOpen:function(){instance.toggleRoomsView();},onChange:function(e){instance.toggleOkButton(this);},onDidClose:handler,onAutoSelection:handler};this.airportsCombo=new BFMultiCheckboxCombo(jQuery.extend(true,defaultSettings,customSettings));if(this.selections&&(this.selections.departures instanceof Array&&this.selections.departures.length>0||this.selections.accomodationOnly))
{try
{var selectedDestinations=this.destinationsCombo.getSelectedValues();var selection=this.selections.departures.length>0?this.selections.departures:[""];this.airportsCombo.disabled=this.selections.accomodationOnly;this.airportsCombo.checkboxGroups=this.dataParser.getUpdatedCheckboxGroupItemsWithSelection(this.dataParser.getAirportsComboGroups(selectedDestinations),selection);}
catch(e)
{BFUtils.log("An error occured trying to prepopulate airportsCombo.",e);}}}
this.airportsCombo.draw();this.toggleAccomodationOnly(this.airportsCombo.checkboxGroups);};BFSearchFormViewController.prototype._buildDurationCombo=function(config)
{var instance=this;if(!this.durationCombo)
{var customSettings=config||{};var handler=function(e,modified)
{if(modified||instance._roomsViewWasDisabled)
{new BFPeriodComboUpdateCommand(instance).execute();}
instance.roomsController.setViewAsDisabled(instance._roomsViewWasDisabled);};var defaultSettings={containerSelector:"#duration-combo-container",placeholder:BFLocalizedStrings.DURATION_PLACEHOLDER,checkboxGroups:[],maxSelection:1,disabled:true,name:"search.iduration",maxHeight:this.model.maxDurationComboHeight||120,onOpen:function(){instance.toggleRoomsView();},onDidClose:handler,onAutoSelection:handler};this.durationCombo=new BFMultiCheckboxCombo(jQuery.extend(true,defaultSettings,customSettings));if(this.selections&&this.selections.duration)
{try
{this.durationCombo.disabled=false;var groups=this.dataParser.getDurationsComboGroups(this.destinationsCombo.getSelectedItems(),this.airportsCombo.getSelectedItems());var selection=[parseInt(this.selections.duration,10)];this.durationCombo.checkboxGroups=this.dataParser.getUpdatedCheckboxGroupItemsWithSelection(groups,selection);}
catch(e)
{BFUtils.log("An error occured trying to prepopulate durationCombo.",e);}}}
this.durationCombo.draw();};BFSearchFormViewController.prototype._buildPeriodsCombo=function(config)
{var instance=this;if(!this.periodsCombo)
{var customSettings=config||{};var handler=function(e,modified)
{this.getExpander().removeClass("bf-combo-ok");if(modified||instance._roomsViewWasDisabled)
{instance.periodMode.toggleRoomsViewStatus();}
instance.roomsController.setViewAsDisabled(instance._roomsViewWasDisabled);};var defaultSettings={containerSelector:"#periods-combo-container",placeholder:BFLocalizedStrings.PERIOD_PLACEHOLDER,checkboxGroups:[],maxSelection:2,maxSelectionAlertMessage:BFLocalizedStrings.MAX_MONTHS_TIP,maxSelectionAlertAutoRemoveTimeout:1500,disabled:true,name:"search.departureIntervals",selectedItemsSorting:function(a,b){return a.value>b.value?1:-1;},maxHeight:this.model.maxPeriodsComboHeight||90,onChange:function(e){instance.toggleOkButton(this);},onOpen:function(){instance.toggleRoomsView();},onDidClose:handler,onAutoSelection:handler};this.periodsCombo=new BFMultiCheckboxCombo(jQuery.extend(true,defaultSettings,customSettings));if(this.selections&&this.selections.periods)
{try
{var duration=this.durationCombo.getSelectedItems()[0];this.periodsCombo.disabled=false;var groups=this.dataParser.getPeriodsComboGroups(duration.value,this.destinationsCombo.getSelectedItems(),this.airportsCombo.getSelectedItems());var selection=[parseInt(this.selections.periods,10)];this.periodsCombo.checkboxGroups=this.dataParser.getUpdatedCheckboxGroupItemsWithSelection(groups,selection);}
catch(e)
{BFUtils.log("An error occured trying to prepopulate periodsCombo.",e);}}}
this.periodsCombo.draw();};BFSearchFormViewController.prototype.getThresholdsRadios=function()
{return $("#price-threshold-container input[name='threshold']");};BFSearchFormViewController.prototype.prepareForSubmit=function()
{this.getAccomodationOnlyField().removeAttr("disabled");if(this.isAccomodationOnly())
{this.airportsCombo.reset();}
this.periodMode.mergeDateFields();};BFSearchFormViewController.prototype._addListeners=function()
{var instance=this;this.getAccomodationOnlyField().unbind("click").bind("click",function(){try
{instance.airportsCombo.reset(true);var accomodationOnlyItem=instance.airportsCombo.checkboxGroups[0].items[0];accomodationOnlyItem.setChecked(instance.isAccomodationOnly());}
catch(e)
{BFUtils.log("an error uccurred checking accomodationOnly",e);}
setTimeout(function(){jQuery(instance.airportsCombo).trigger(BFComboDidClose,[true]);},100);});jQuery("#switch-container .switch-link").unbind("click").bind("click",{instance:this},this.togglePeriodMode);};BFSearchFormViewController.prototype._buildRoomsView=function(config)
{if(!this.roomsController)
{var customSettings=config||{};var defaultSettings={parentViewSelector:"#rooms-container",template:"BFRoomsView",model:this.model,selections:this.selections&&this.selections.rooms instanceof Array?this.selections.rooms:null,viewIsDisabled:!(this.selections instanceof Object)};this.roomsController=new BFSearchFormRoomsViewController(jQuery.extend(true,defaultSettings,customSettings));}
this.roomsController.loadView();};BFSearchFormViewController.prototype._buildFromDateCombo=function(config)
{if(!this.fromDateCombo)
{var instance=this;var customSettings=config||{};var handler=function(e,modified)
{if(modified||instance._roomsViewWasDisabled)
{new BFToDateComboUpdateCommand(instance).execute();}
instance.roomsController.setViewAsDisabled(instance._roomsViewWasDisabled);};var defaultSettings={containerSelector:"#from-date-combo-container",placeholder:BFLocalizedStrings.SELECT,name:"fromDate",disabled:true,onChange:function(e){instance.toggleOkButton(this);},dateFormat:this.datePickerFormat,onOpen:function(){instance.toggleRoomsView();},onDidClose:handler,onAutoSelection:handler};this.fromDateCombo=new BFDatePickerCombo(jQuery.extend(true,defaultSettings,customSettings));}
this.fromDateCombo.draw();};BFSearchFormViewController.prototype._buildToDateCombo=function(config)
{if(!this.toDateCombo)
{var instance=this;var customSettings=config||{};var selectedFromDate=this.fromDateCombo.getSelectedDate();var handler=function(e,modified){instance.periodMode.toggleRoomsViewStatus();instance.roomsController.setViewAsDisabled(instance._roomsViewWasDisabled);};var defaultSettings={containerSelector:"#to-date-combo-container",placeholder:BFLocalizedStrings.SELECT,name:"toDate",dateFormat:this.datePickerFormat,disabled:true,onChange:function(e){instance.toggleOkButton(this);},onOpen:function(){instance.toggleRoomsView();},onDidClose:handler,onAutoSelection:handler};this.toDateCombo=new BFDatePickerCombo(jQuery.extend(true,defaultSettings,customSettings));}
this.toDateCombo.draw();};BFSearchFormViewController.prototype.isSafeModel=function()
{var m=this.model;return(BFBaseViewController.prototype.isSafeModel.call(this)&&(m.periods instanceof Array&&m.periods.length>0&&typeof m.durations=="object"&&typeof m.destinations=="object"));};BFSearchFormViewController.prototype.validateChildren=function()
{return this.roomsController.validateChildren();};BFSearchFormViewController.prototype.validatePassengersCount=function()
{if(this.roomsController.getPassengersCount()>this.maxPassengers)
{alert(BFLocalizedStrings.MAX_PASSENGERS_EXCEEDED);return false;}
return true;};BFSearchFormViewController.prototype.loadView=function()
{if(!this.isSafeModel())
{throw new Error("Invalid BFSearchFormViewController configuration. Missing or corrupted model data.");}
BFBaseViewController.prototype.loadView.call(this);jQuery("[bf_mode='"+this.periodMode.toString()+"']").removeClass("display-none");this._buildDestinationsCombo();this._buildAirportsCombo();this._buildDurationCombo();this.periodMode.drawControls();this._buildRoomsView();this.submitButton.draw();this._addListeners();if(this.selections instanceof Object)
{this.periodMode.prepopulateControls();if(this.selections.accomodationOnly)
{this.getAccomodationOnlyField().prop("checked",true);}
if(this.isOnlyAccomodationOnly())
{this.getAccomodationOnlyField().prop("disabled",true);}
jQuery(this.destinationsCombo).trigger(BFComboDidClose);}
else
{this.destinationsCombo.autoSelectIfSingleOption();this.airportsCombo.autoSelectIfSingleOption();this.durationCombo.autoSelectIfSingleOption();var _self=this;setTimeout(function(){jQuery(_self.destinationsCombo).trigger(BFComboDidClose,[true]);},100);}};;BFRoomsSelectionChangeEvent="BFRoomsSelectionChangeEvent";BFChildrenSelectionChangeEvent="BFChildrenSelectionChangeEvent";BFSearchFormRoomsViewController=function(config){BFBaseViewController.call(this,config);this.selections=config.selections||null;this._cachedHeight=0;};BFSearchFormRoomsViewController.prototype=new BFBaseViewController;BFSearchFormRoomsViewController.prototype.getClassName=function(){return"BFSearchFormRoomsViewController";};BFSearchFormRoomsViewController.prototype.getPassengersCount=function(){var passengers=0;try{jQuery(".adults-selection").each(function(){passengers+=parseInt(jQuery(this).val(),10);});jQuery(".children-selection").each(function(){passengers+=parseInt(jQuery(this).val(),10);});}catch(e){BFUtils.log("An error occured while counting selected passengers.",e);}finally{return passengers;}};BFSearchFormRoomsViewController.prototype._toggleChildrenCombos=function(e){var node=jQuery(this);var instance=e.data.instance;var requiredChildren=parseInt(node.val(),10);var childrenRow=jQuery(".children-row",node.closest("table"));var childrenCombosContainer=jQuery(".children-combos",childrenRow);var currentCombos=jQuery("select",childrenCombosContainer);var recordId=childrenCombosContainer.closest("table").attr("id").replace(/[^0-9]/g,"");var combosDelta=Math.abs(requiredChildren-currentCombos.length);var childrenAgesLabel=jQuery(".children-label .children-ages",childrenRow);var childAgeLabel=jQuery(".children-label .child-age",childrenRow);if(requiredChildren>0){jQuery("#form-content .search-box").css("height","auto");}
if(requiredChildren>0){childrenRow.removeClass("hidden");if(currentCombos.length<requiredChildren){var html=[];var maxAge=instance.model.maxChildrenAge+1;jQuery(instance.viewSelector+" .invalid-field").remove();for(var i=0;i<combosDelta;i++){html.push('<select name="search.rooms['+recordId+'].childrenAge['+(currentCombos.length+i)+']">');html.push('<option value="">-</option>');for(var k=0;k<maxAge;k++){html.push('<option value="k">k</option>'.replace(/k/gi,k));}
html.push('</select>');}
childrenCombosContainer.append(html.join(""));jQuery("select",childrenCombosContainer).bind("change",{instance:instance},instance._resetChildrenAgeAlerts);}else{for(var j=combosDelta;j>0;j--){jQuery("select:last",childrenCombosContainer).unbind("change",instance._resetChildrenAgeAlerts).remove();}}}else{currentCombos.remove();childrenRow.addClass("hidden");}
if(requiredChildren>1){childrenAgesLabel.removeClass("display-none");childAgeLabel.addClass("display-none");}else{childrenAgesLabel.addClass("display-none");childAgeLabel.removeClass("display-none");}
jQuery(instance).trigger(BFChildrenSelectionChangeEvent,[requiredChildren,recordId]);};BFSearchFormRoomsViewController.prototype._resetChildrenAgeAlerts=function(e){jQuery(".children-combos select").each(function(){var combo=jQuery(this);var container=combo.parent();if(jQuery("select option:selected[value='']",container).length==0){jQuery(".invalid-field",container).remove();}});};BFSearchFormRoomsViewController.prototype.checkChildrenAge=function(e){jQuery(".children-combos select").each(function(){var combo=jQuery(this);var container=combo.parent();if(jQuery("select option:selected[value='']",container).length>0){if(jQuery(".invalid-field",container).length==0){container.append('<div class="invalid-field">'+BFLocalizedStrings.AGECHILD_ERROR+'</div>');combo.trigger("change");}}else{jQuery(".invalid-field",container).remove();}});};BFSearchFormRoomsViewController.prototype.validateChildren=function(){var valid=true;var instance=this;jQuery(this.viewSelector+" .children-combos select").each(function(idx,item){if(item.selectedIndex==0){valid=false;instance.checkChildrenAge({data:{"instance":instance}});}});return valid;};BFSearchFormRoomsViewController.prototype._toggleRooms=function(e){var node=jQuery(this);var instance=e.data.instance;var requiredRooms=parseInt(node.val(),10);var currentRoomsRecords=jQuery(instance.viewSelector+" table");var lastNode=jQuery(instance.viewSelector+" table:last");var roomsContainer=lastNode.parent();var roomsDelta=Math.abs(requiredRooms-currentRoomsRecords.length);var childrenDisplayed=jQuery(".children-combos select").length>0;jQuery("#form-content .search-box").css("height",requiredRooms>1||childrenDisplayed?"auto":this._cachedHeight+"px");jQuery("body").focus();jQuery(instance.viewSelector+" .room-col").css("visibility",requiredRooms>1?"visible":"hidden");if(requiredRooms>currentRoomsRecords.length){for(var i=0;i<roomsDelta;i++){var newNode=lastNode.clone();var newRoomNumber=currentRoomsRecords.length+i;jQuery("tr.header-row td:first, .details-row td:first, .children-combos",newNode).html("");jQuery(".children-row",newNode).addClass("hidden");var newHTML=newNode.html().replace(/\[[0-9]\]/g,"["+newRoomNumber+"]");newNode.html(newHTML);jQuery("span.room-number",newNode).html(newRoomNumber+1);newNode.attr("id","room-"+newRoomNumber);roomsContainer.append(newNode);jQuery(".adults-selection",newNode).prop("selectedIndex",1);jQuery(".children-selection",newNode).prop("selectedIndex",0);}}else{for(var j=roomsDelta;j>0;j--){jQuery("table:last",roomsContainer).remove();}}
instance._addListeners();jQuery(instance).trigger(BFRoomsSelectionChangeEvent,[requiredRooms]);};BFSearchFormRoomsViewController.prototype._addListeners=function(){jQuery("#multiproduct-rooms-selected").unbind("change").bind("change",{instance:this},this._toggleRooms);jQuery(this.viewSelector+" select.children-selection").unbind("change").bind("change",{instance:this},this._toggleChildrenCombos);};BFSearchFormRoomsViewController.prototype.loadView=function(){BFBaseViewController.prototype.loadView.call(this);this._cachedHeight=jQuery("#form-content .search-box").height();this._addListeners();if(this.selections){jQuery("#multiproduct-rooms-selected").prop("selectedIndex",this.selections.length-1).trigger("change");for(var i=0;i<this.selections.length;i++){var selection=this.selections[i];jQuery("select[name='search\\.rooms\\["+i+"\\]\\.adults']").prop("selectedIndex",selection.adults-1);if(selection.children&&selection.childrenAge.length>0){jQuery("select[name='search\\.rooms\\["+i+"\\]\\.children']").prop("selectedIndex",selection.childrenAge.length).trigger("change");for(var j=0;j<selection.childrenAge.length;j++){jQuery("select[name='search\\.rooms\\["+i+"\\]\\.childrenAge\\["+j+"\\]']").prop("selectedIndex",selection.childrenAge[j]+1);}}}}};;BFEditRoomsViewController=function(config){BFSearchFormViewController.call(this,config);this.modalWindowSelector=config.modalWindowSelector||"";};BFEditRoomsViewController.prototype=new BFSearchFormViewController;BFEditRoomsViewController.prototype.getClassName=function(){return"BFEditRoomsViewController";};BFEditRoomsViewController.prototype._addListeners=function(){var instance=this;var modalWindow=jQuery(this.modalWindowSelector);jQuery("#save-edit-passengers").unbind("click."+this.id).bind("click."+this.id,function(){if(instance.validateChildren()){if(instance.validatePassengersCount()){jQuery("#edit-trip-option-form").get(0).submit();}}});jQuery("#abort-edit-passengers").unbind("click."+this.id).bind("click."+this.id,function(){modalWindow.dialog("isOpen")?modalWindow.dialog("close"):modalWindow.dialog("open");});};BFEditRoomsViewController.prototype.loadView=function(){BFBaseViewController.prototype.loadView.call(this);this._buildRoomsView();this._addListeners();};;if(!ch){var ch={};}
if(!ch.exm){ch.exm={};}
if(!ch.exm.utils){ch.exm.utils={};};(function(){ch.exm.utils.AnalyticsCfg={hashes:[{key:"*/vg1/airlines.d*",value:"/flightstatus/autocomplete",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/booking/booking1.actio*",value:"/booking/passenger_details",semboxtps:"S02",semboxtpp:"A42"},{key:"*/vg1/booking/booking3.actio*",value:"/booking/billing",semboxtps:"S02",semboxtpp:"P02"},{key:"*/vg1/booking/booking4.actio*",value:"/booking/booking_details",semboxtps:"S02",semboxtpp:"A45"},{key:"*/vg1/booking/checkvoucher.actio*",value:"/booking/check_voucher",semboxtps:"S02",semboxtpp:"A99"},{key:"*/vg1/booking/printable.actio*",value:"/booking/print_booking4",semboxtps:"S02",semboxtpp:"A46"},{key:"*/vg1/conditions.d*",value:"/booking/contractual_conditions",semboxtps:"S02",semboxtpp:"A47"},{key:"*/vg1/flightstatus/byairport.d*",value:"/flightstatus/search_byairport",semboxtps:"S02",semboxtpp:"A48"},{key:"*/vg1/flightstatus/byflight.d*",value:"/flightstatus/search_byflight",semboxtps:"S02",semboxtpp:"A48"},{key:"*/vg1/flightstatus/byroute.d*",value:"/flightstatus/search_byroute",semboxtps:"S02",semboxtpp:"A48"},{key:"*/vg1/indexpricefinder.actio*",value:"/flight/pricefinder/homepage",semboxtps:"S02",semboxtpp:"A32"},{key:"*/vg1/messagepopup.d*",value:"/booking/openpopup",semboxtps:"S02",semboxtpp:"A99"},{key:"*/vg1/msghelp.d*",value:"/flight/search/bestrpice_help",semboxtps:"S02",semboxtpp:"A99"},{key:"*/vg1/mypage/confirmed.actio*",value:"/mypage/confirmed_flights",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/deleted.actio*",value:"/mypage/deleted_flights",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/forgotpassword.d*",value:"/mypage/forgot_psswd",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/lastflights.actio*",value:"/mypage/deptd_flights",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/login.actio*",value:"/mypage/login",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/mydetails.actio*",value:"/mypage/personal_details",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/mysearch.actio*",value:"/mypage/recent_searched",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/myVouchersList.actio*",value:"/mypage/voucher_list",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/nextflights.actio*",value:"/mypage/next_flights",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/sendemail.actio*",value:"/mypage/resend_email",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/sendmypassword.actio*",value:"/mypage/resend_psswd",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/updatemydetails.actio*",value:"/mypage/update_details",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/mypage/waiting.actio*",value:"/mypage/on_hold_flights",semboxtps:"S02",semboxtpp:"A49"},{key:"*/vg1/others/others/sendgroupsmail.actio*",value:"/flight/group_enquiry",semboxtps:"S02",semboxtpp:"A99"},{key:"*/vg1/others/popupgroups.actio*",value:"/flight/show_popup_group_enquiry",semboxtps:"S02",semboxtpp:"A99"},{key:"*/vg1/pricefinderconfig.actio*",value:"/flight/pricefinder/config",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/pricefinder_refine.actio*",value:"/flight/pricefinder/refine_search",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/pricefinder_result.actio*",value:"/flight/pricefinder/results",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/priceperiods.actio*",value:"/flight/pricefinder/calendar",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/pricesearchindex.actio*",value:"/flight/pricesearch/homepage",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/pricesearch_result.actio*",value:"/flight/pricesearch/results",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/pricesearchresult.actio*",value:"/flight/pricesearch/results/filters",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/pricesearchstatic.actio*",value:"/flight/pricesearch/direct_links",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/pro/accountstatus.d*",value:"/agencies/check_account",semboxtps:"S98",semboxtpp:"P16"},{key:"*/vg1/pro/index.d*",value:"/agencies/homepage",semboxtps:"S98",semboxtpp:"P16"},{key:"*/vg1/pro/moneytransferrequest.d*",value:"/agencies/accredit_account",semboxtps:"S98",semboxtpp:"P16"},{key:"*/vg1/pro/mybooking.d*",value:"/agencies/search_bookings",semboxtps:"S98",semboxtpp:"P16"},{key:"*/vg1/pro/mylastbookings.d*",value:"/agencies/backoffice",semboxtps:"S98",semboxtpp:"P16"},{key:"*/vg1/psearchconfig.actio*",value:"/flight/pricesearch/config",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/registration/userconfirm.actio*",value:"/mypage/confirm_registration_from_email",semboxtps:"S21",semboxtpp:"L21"},{key:"*/vg1/rss.d*",value:"/flight/search/rss",semboxtps:"S99",semboxtpp:"A99"},{key:"*/vg1/rssServic*",value:"/rss",semboxtps:"S99",semboxtpp:"A99"},{key:"*/vg1/search1.d*",value:"rimanda alla home in caso di errori",semboxtps:"S02",semboxtpp:"A52"},{key:"*/vg1/search2.d*",value:"/flight/search/choose_dates",semboxtps:"S19",semboxtpp:"A24"},{key:"*/vg1/search3.d*",value:"/flight/search/search_flights",semboxtps:"S20",semboxtpp:"A24"},{key:"*/vg1/searching.d*",value:"/flight/search/launch_search",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/search/results.actio*",value:"/flight/search/results",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/search/selectleg.actio*",value:"/flight/search/change_leg",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/search/tripdetails.actio*",value:"/flight/search/trip_details",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/simplesearch.actio*",value:"/flight/pricefinder/basic_search",semboxtps:"S32",semboxtpp:"A32"},{key:"*/vg1/suggest/Countrie*",value:"utility",semboxtps:"S99",semboxtpp:"A99"},{key:"*/vg1/suggest/GeographicalAre*",value:"utility",semboxtps:"S99",semboxtpp:"A99"},{key:"*/vg1/timetable/maplowcost.actio*",value:"/flight/lowcost_map",semboxtps:"S17",semboxtpp:"A50"},{key:"*/vg1/timetable/timetable.actio*",value:"/flight/timetable",semboxtps:"S18",semboxtpp:"A51"},{key:"*/vg1/timetable/timetablecanceloutbound.actio*",value:"/flight/cancel_selected_leg_dep",semboxtps:"S18",semboxtpp:"A51"},{key:"*/vg1/timetable/timetablesearch.actio*",value:"/flight/results_timetable_dep",semboxtps:"S18",semboxtpp:"A51"},{key:"*/vg1/timetable/timetablesearchreturn.actio*",value:"/flight/results_timetable_ret",semboxtps:"S18",semboxtpp:"A51"},{key:"*/vg1/timetable/timetableselectedoutbound.actio*",value:"/flight/selected_leg_dep",semboxtps:"S18",semboxtpp:"A51"},{key:"*/vg1/timetable/timetableselectedreturn.actio*",value:"/flight/results_timetable_all",semboxtps:"S18",semboxtpp:"A51"},{key:"*/vg1/userloginform.d*",value:"/mypage/login",semboxtps:"S34",semboxtpp:"A49"},{key:"*/vg1/userregistration.d*",value:"/mypage/confirm_registration",semboxtps:"S21",semboxtpp:"A49"},{key:"*/vg1/userregistrationform.d*",value:"/mypage/form_new_user",semboxtps:"S21",semboxtpp:"A49"},{key:"*/vg1/userunsuscribe.d*",value:"/mypage/unsubscribe",semboxtps:"S21",semboxtpp:"A49"},{key:"*/vg1/voli.d*",value:"/flight/homepage",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/flights.d*",value:"/flight/homepage",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/flug.d*",value:"/flight/homepage",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/voli-offerte-speciali.d*",value:"/flight/merchandising_page",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/vols.d*",value:"/flight/homepage",semboxtps:"S02",semboxtpp:"A24"},{key:"*/vg1/waitdeeplink.d*",value:"/flights/waiting_deeplink",semboxtps:"S22",semboxtpp:"A99"},{key:"*HotelAvailabilitySearch/hotel.d*",value:"/hotels/results_page",semboxtps:"S03",semboxtpp:"A26"},{key:"*HotelAvailabilitySearch/goto.d*",value:"/hotels/loading_page",semboxtps:"S03",semboxtpp:"A26"},{key:"*vg1/booking/hotelinfo.actio*",value:"/hotels/room_types",semboxtps:"S03",semboxtpp:"A53"},{key:"*/payment/pay.pay*",value:"/booking/payment",semboxtps:"S23",semboxtpp:""},{key:"*/vg1/vacanze.action",value:"/holidays/home",semboxtps:"S09",semboxtpp:"A25"},{key:"*/vg1/vacanze/flightsandhotel_preparepage.actio*",value:"/holidays/services_flight-hotel",semboxtps:"S09",semboxtpp:"A41"},{key:"*/vg1/vacanze/productservices_preparepage.actio*",value:"/holidays/services_packageTO",semboxtps:"S09",semboxtpp:"A41"},{key:"*/vg1/vacanze/quotedynamic_preparepage.actio*",value:"/holidays/estimate_flight-hotel",semboxtps:"S09",semboxtpp:"A39"},{key:"*/vg1/vacanze/quotestatic_preparepage.actio*",value:"/holidays/estimate_packageTO",semboxtps:"S09",semboxtpp:"A39"},{key:"*/vg1/vacanze/searchavailableproducts.actio*",value:"/holidays/results",semboxtps:"S09",semboxtpp:"A25"},{key:"*/vg1/vacanze/waitingsearch.actio*",value:"/holidays/waiting->results",semboxtps:"S09",semboxtpp:"A25"},{key:"*/vg1/vacanze/waitingchoosehf.actio*",value:"/holidays/waiting->services_flight-hotel",semboxtps:"S09",semboxtpp:"A25"},{key:"*/vg1/vacanze/waitingservices.actio*",value:"/holidays/waiting->services_packageTO",semboxtps:"S09",semboxtpp:"A25"},{key:"*/vg1/vacanze/waitingquote.actio*",value:"/holidays/waiting->estimate",semboxtps:"S09",semboxtpp:"A25"},{key:"*/vg1/messagepopup.do*",value:"contractual-conditions",semboxtps:"S24",semboxtpp:"A99"},{key:"*/offers/flights/*",value:"offerte-voli",semboxtps:"S52",semboxtpp:"P02"},{key:"*/offres/vols/*",value:"offerte-voli",semboxtps:"S52",semboxtpp:"P02"},{key:"*/offerte/voli/*",value:"offerte-voli",semboxtps:"S52",semboxtpp:"P02"},{key:"*/angebote/fluege/*",value:"offerte-voli",semboxtps:"S52",semboxtpp:"P02"},{key:"*/offerte/hotel/*",value:"offerte-hotel",semboxtps:"S52",semboxtpp:"P03"},{key:"*/offres/hotels/*",value:"offerte-hotel",semboxtps:"S52",semboxtpp:"P03"},{key:"*/vg1/pricemap.actio*",value:"/flight/pricemap",semboxtps:"S17",semboxtpp:"A50"}]}})();;if(!ch){var ch={};}
if(!ch.exm){ch.exm={};}
if(!ch.exm.utils){ch.exm.utils={};};(function(){var loc=window.location+"",hashes=ch.exm.utils.AnalyticsCfg.hashes,ap=ch.exm.utils.AnalyticsParametrizer={startup:function(){for(var i=0,l=hashes.length;i<l;i++){if(loc.match(new RegExp(hashes[i].key.replace(/\*/g,".").replace(/\?/,"\\?")))){this.parameter=hashes[i].value;this.semboxtps=hashes[i].semboxtps;this.semboxtpp=hashes[i].semboxtpp;break;};}!this.parameter&&(this.parameter=window.location.pathname);},parameter:""};ap.startup();})();;
