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;});};})();;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;};;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);}}});;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);}};;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;};;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);};;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();};;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;};;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();};;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();};;BFHotelSearchController=function(config)
{if(typeof config!="object"){config={};}
this.ACCONLYRADIO="radio";this.ACCONLYCHECK="checkbox";this.validationError="";this.validationErrorFields=[];BFBaseViewController.call(this,config);this.template=config.template;this.parentViewSelector=config.parentViewSelector;this.viewSelector=null;this.viewIsDisabled=config.viewIsDisabled||false;this.selections=config.selections||[];this.accOnlyInput=this._setDefault(config.accOnlyInput,this.ACCONLYCHECK);if(this.model){this.model.accOnlyInput=this.accOnlyInput;}
this.delayFromToday=this._setDefault(config.delayFromToday,30);this.delayReturnFromDepart=this._setDefault(config.delayReturnFromDepart,7);this.searchButton=this._setDefault(config.searchButton,null);this.searchButtonWidth=this._setDefault(config.searchButtonWidth,null);this.searchButtonLabel=this._setDefault(config.searchButtonLabel,BFLocalizedStrings.SEARCH);this.formId=this._setDefault(config.formId,"#search-form");this.roomController=null;this.submitButton=null;this.depDateId=this._setDefault(config.depDateId,"#arrivalDate_cal");this.depDateId_alternate=this._setDefault(config.depDateId_alternate,"#arrivalDate");this.minDepDate=this._createDate(this._setDefault(config.minDepDate,""),"yymmdd");this.retDateId=this._setDefault(config.retDateId,"#departureDate_cal");this.retDateId_alternate=this._setDefault(config.retDateId_alternate,"#departureDate");this.depIntervalId=this._setDefault(config.depIntervalId,"#search_departureIntervals");this.depAirportContainer=this._setDefault(config.depAirportContainer,"#depAirport");this.depAirportId=this._setDefault(config.depAirportId,"#search_departureAirports");this.depAirportId_alternate=this._setDefault(config.depAirportId_alternate,"#search_departureAirports_id");this.accomodationCheckbox=this._setDefault(config.accomodationCheckbox,"#search_accomodationOnly");this.accomodation_alternate=this._setDefault(config.accomodationCheckbox,"#search_accomodationOnly_value");this.accomodationRadioFalse=this._setDefault(config.accomodationRadioFalse,"#search_accomodationOnly_false");this.accomodationInput=this._setDefault(config.accomodationInput,this.accOnlyInput==this.ACCONLYCHECK?"#search_accomodationOnly":"#search_accomodationOnly_true");this.defaultAccomodationOnly=this._setDefault((config.defaultAccomodationOnly==="true"),true);this.iFrame=this._setDefault((config.iFrame==="true"),false);this.submitToHotel=this._setDefault((config.submitToHotel==="true"),false);this.baseDomain=this._setDefault(config.baseDomain,"http://hotel.volagratis.it");this.fieldsToDisable=["#arrivalDate","#arrivalDate_cal","#departureDate","#departureDate_cal","#search_departureAirports","#search_accomodationOnly","#submitButton"];this.displayDateFormat=this._setDefault(config.displayDateFormat,"dd/mm/yy");this.submitDateFormat=this._setDefault(config.submitDateFormat,"yymmdd");this.hotelDateFormat=this._setDefault(config.submitDateFormat,"yy-mm-dd");if(this.selections.periods){this._parseDates();}};BFHotelSearchController.prototype=new BFBaseViewController;BFHotelSearchController.prototype.getClassName=function()
{return"BFHotelSearchController";};BFHotelSearchController.prototype.initAutocomplete=function(target_id,alternate_id)
{};BFHotelSearchController.prototype.initDepAirportAutocomplete=function(target_id,alternate_id)
{var self=this;var $suggester=jQuery(target_id);function onSelect(e,ui)
{var $hiddenField=jQuery(alternate_id);var value=ui&&ui.item&&ui.item.idAirport?ui.item.idAirport:"";$hiddenField.val(value);};$suggester.autocomplete({search:function(event,ui){self.showSpinner(target_id);},open:function(event,ui){self.hideSpinner(target_id);},close:function(event,ui){self.hideSpinner(target_id);},source:function(request,response){jQuery.ajax({url:"/suggester/autocompleter?modules=airports&lang="+self._getLanguage(),dataType:"json",minLength:3,autoFocus:true,data:{key:request.term,cityPart:request.term},success:function(data){response(jQuery.map(data.items[0].entries,function(item){return{label:item.label,value:item.label,idAirport:item.code!="NOTFOUND"?item.code:""}}));},error:function(jqXHR,textStatus,errorThrown)
{if(typeof console!="undefined"){console.warn(errorThrown);console.info(textStatus);console.debug(jqXHR);}},beforeSend:function(){}});},select:onSelect});BFUtils.automatizeSuggester($suggester,onSelect);};BFHotelSearchController.prototype._getLanguage=function()
{var language="en";try{language=Globalize.culture().language;}catch(exception){BFUtils.log("Unable to find Globalize language");}
return language;};BFHotelSearchController.prototype.initCalendar=function(field_id,hidden_id,minDate)
{return jQuery(field_id).datepicker({altField:hidden_id,beforeShow:function(evt,ui){ui.dpDiv[0].style.margin="0px";$(this).dialog("widget").css("z-index",20);},minDate:typeof(minDate)!="undefined"?minDate:new Date(),altFormat:this.submitDateFormat,dateFormat:this.displayDateFormat,numberOfMonths:2});};BFHotelSearchController.prototype._setCalendarMinReturnDate=function(date)
{var fromDateSelected=jQuery(this.depDateId).datepicker("getDate");if(!(fromDateSelected instanceof Date))
{return;}
jQuery(this.retDateId).datepicker("option","minDate",BFDateUtils.dateByAddingDatePart(fromDateSelected,"day",1));};BFHotelSearchController.prototype.setArrivalDate=function(date)
{jQuery(this.depDateId).val(jQuery.datepicker.formatDate(this.displayDateFormat,date));jQuery(this.depDateId_alternate).val(jQuery.datepicker.formatDate(this.submitDateFormat,date));};BFHotelSearchController.prototype.setReturnDate=function(date)
{jQuery(this.retDateId).val(jQuery.datepicker.formatDate(this.displayDateFormat,date));jQuery(this.retDateId_alternate).val(jQuery.datepicker.formatDate(this.submitDateFormat,date));};BFHotelSearchController.prototype.setDefaultArrivalDate=function(delayFromToday)
{if(isNaN(delayFromToday)){delayFromToday=7;}
var _depDate=new Date();_depDate.setDate(_depDate.getDate()+delayFromToday);this.setArrivalDate(_depDate);};BFHotelSearchController.prototype.setDefaultReturnDate=function(delayFromDepDate)
{if(isNaN(delayFromDepDate)){delayFromDepDate=2;}
var _retDateStr=jQuery(this.depDateId_alternate).val();var _retDate=new Date(_retDateStr.substr(0,4),_retDateStr.substr(4,2)-1,_retDateStr.substr(6,2));_retDate.setDate(_retDate.getDate()+delayFromDepDate);this.setReturnDate(_retDate);};BFHotelSearchController.prototype._parseDates=function()
{var dates=this.selections.periods[0].split("-");this._depDate=this._createDate(dates[0],this.submitDateFormat);this._retDate=this._createDate(dates[1],this.submitDateFormat);};BFHotelSearchController.prototype._createDate=function(date,format)
{if(date.length==0){return new Date();}
var resultDate=new Date();switch(format){case"yymmdd":resultDate=new Date(date.substr(0,4),date.substr(4,2)-1,date.substr(6,2));break;default:BFUtils.log("WARNING: Format "+format+" not yet implemented");break;}
return resultDate;};BFHotelSearchController.prototype.toggleAirports=function(target_id,isChecked)
{if(!jQuery(target_id)){return;}
if(this._isHideAirports()){this._hideAirports(isChecked);}
jQuery(target_id).attr("disabled",isChecked);if(!this._isAccomodationOnly()){jQuery(target_id).focus();}
this.unHighlightErrorFields();};BFHotelSearchController.prototype._hideAirports=function(isChecked)
{$container=jQuery(this.depAirportContainer);isChecked?$container.hide():$container.show();};BFHotelSearchController.prototype.checkEmptyField=function(value_id,visible_id)
{if(jQuery(value_id).val().length==0){this.validationError+="\n Field "+visible_id+" is empty";this.validationErrorFields.push(visible_id);return false;}
return true;};BFHotelSearchController.prototype.formatDateField=function()
{var result=true;var $depDate=jQuery(this.depDateId_alternate);var $retDate=jQuery(this.retDateId_alternate);if($depDate.length==0||$retDate.length==0)
{return false;}
var depDate=$depDate.val();var retDate=$retDate.val();if(depDate.length<=0)
{this.validationError+="\n Departure date is empty";this.validationErrorFields.push(this.depDateId)
result=false;}
if(retDate.length<=0)
{this.validationError+="\n Return date is empty";this.validationErrorFields.push(this.retDateId)
result=false;}
if(result)
{var today=new Date();var _depDate=this._createDate(depDate,this.submitDateFormat);if(BFDateUtils.daysDiff(_depDate,today)<0)
{this.validationError+="\n Departure date is in the past!";this.validationErrorFields.push(this.depDateId);result=false;}
var _retDate=this._createDate(retDate,this.submitDateFormat);if(BFDateUtils.daysDiff(_retDate,today)<0)
{this.validationError+="\n Return date is in the past!";this.validationErrorFields.push(this.retDateId);result=false;}}
if(!result)
{return result;}
jQuery(this.depIntervalId).val(depDate+"-"+retDate);return result;};BFHotelSearchController.prototype.checkForm=function()
{var result=true;this.validationError="";this.validationErrorFields=[];result=this.formatDateField();if(!this._isAccomodationOnly()){result=this.checkEmptyField(this.depAirportId_alternate,this.depAirportId)&&result;}
result=this.roomController.validateChildren()&&result;return result;};BFHotelSearchController.prototype.validateForm=function()
{var result=this.checkForm();if(!result){this.highlightErrorFields();BFUtils.log("error validating form: "+this.validationError,null,"error");return result;}
this.setAccomodationOnly();this.disableUnusedFields();return result;};BFHotelSearchController.prototype.highlightErrorFields=function()
{var fields=this.validationErrorFields;for(var i in fields){var $container=jQuery(fields[i]).parent();if($container.find(".invalid-field").length==0){$container.append('<div class="invalid-field">'+BFLocalizedStrings.REQUIRED_FIELD+'</div>');}}};BFHotelSearchController.prototype.unHighlightErrorFields=function()
{jQuery(".invalid-field",this.viewSelector).remove();};BFHotelSearchController.prototype.disableUnusedFields=function()
{for(var key in this.fieldsToDisable){try{jQuery(this.fieldsToDisable[key]).attr("disabled",true);}catch(e){BFUtils.log("Error disabling field "+this.fieldsToDisable[key],e,"error");}}};BFHotelSearchController.prototype.resetForm=function()
{for(var key in this.fieldsToDisable){try{jQuery(this.fieldsToDisable[key]).attr("disabled",false);}catch(e){BFUtils.log("Error disabling field "+this.fieldsToDisable[key],e,"error");}}
this.toggleAirports(this.depAirportId,this._isAccomodationOnly());this.toggleAirports(this.depAirportId_alternate,this._isAccomodationOnly());};BFHotelSearchController.prototype._isAccomodationOnly=function()
{return jQuery(this.accomodationInput).prop("checked");};BFHotelSearchController.prototype._isHideAirports=function()
{return this.accOnlyInput==this.ACCONLYRADIO;};BFHotelSearchController.prototype.setAccomodationOnly=function()
{jQuery(this.accomodation_alternate).val(this._isAccomodationOnly());};BFHotelSearchController.prototype.selectAccomodationOnly=function(isChecked)
{jQuery(this.accomodationInput).prop("checked",isChecked);if(this._isHideAirports()){jQuery(this.accomodationRadioFalse).prop("checked",!isChecked);}};BFHotelSearchController.prototype.showSpinner=function(target_id)
{jQuery(target_id).addClass("waiting");};BFHotelSearchController.prototype.hideSpinner=function(target_id)
{jQuery(target_id).removeClass("waiting");};BFHotelSearchController.prototype._addListeners=function()
{var self=this;jQuery(this.depDateId).datepicker("option","onSelect",function(dateText,inst){self.unHighlightErrorFields();self.setDefaultReturnDate(self.delayReturnFromDepart);self._setCalendarMinReturnDate(jQuery(self.depDateId).val());});jQuery(this.retDateId).datepicker("option","onSelect",function(dateText,inst){if(!self.formatDateField()){self.highlightErrorFields();BFUtils.log("Date Error"+self.validationError);;}});this._bindAccomodationOnlyInput(self);jQuery(this.formId).bind("submit",function(){self.onBeforeSubmit();});this.submitButton.getButton().bind("keyup",function(event){self._evaluateEnter(event);});if(this.iFrame){jQuery(this.accomodationInput).bind("change",function(){self._resizeIFrame();});jQuery(this.roomController).bind(BFRoomsSelectionChangeEvent,function(){self._resizeIFrame();});jQuery(this.roomController).bind(BFChildrenSelectionChangeEvent,function(){self._resizeIFrame();});}};BFHotelSearchController.prototype._bindAccomodationOnlyInput=function(instance)
{jQuery("#search_accomodationOnly_label").bind("click",function(){jQuery(instance.accomodationInput).prop("checked",!instance._isAccomodationOnly());jQuery(instance.accomodationInput).trigger("change");});jQuery(instance.accomodationRadioFalse).bind("change",function(){jQuery(instance.accomodationInput).trigger("change");});jQuery(this.accomodationInput).bind("change",function(){instance.toggleAirports(instance.depAirportId,instance._isAccomodationOnly());instance.toggleAirports(instance.depAirportId_alternate,instance._isAccomodationOnly());});};BFHotelSearchController.prototype._evaluateEnter=function(event)
{var pressedKey=event.keyCode||event.which;if(pressedKey==13){this._submitFunction();}};BFHotelSearchController.prototype.onBeforeSubmit=function()
{try{return this.validateForm();}catch(exception){BFUtils.log(exception);return false;}};BFHotelSearchController.prototype.loadView=function()
{BFBaseViewController.prototype.loadView.call(this);this.initDepAirportAutocomplete(this.depAirportId,this.depAirportId_alternate);if(this.selections.periods){this.setArrivalDate(this._depDate);this.setReturnDate(this._retDate);}else{this.setDefaultArrivalDate(this.delayFromToday);this.setDefaultReturnDate(this.delayReturnFromDepart);}
this.initCalendar(this.depDateId,this.depDateId_alternate,this.minDepDate);var fromDateSelected=jQuery(this.depDateId).datepicker("getDate");this.initCalendar(this.retDateId,this.retDateId_alternate,fromDateSelected instanceof Date?BFDateUtils.dateByAddingDatePart(fromDateSelected,"day",1):null);this.selectAccomodationOnly(this.defaultAccomodationOnly);if(this.selections.accomodationOnly!=undefined){this.selectAccomodationOnly(this.selections.accomodationOnly);}
if(this.selections.accomodationOnly!=undefined&&!this.selections.accomodationOnly){if(typeof this.selections.departureAirports==="object"){jQuery(this.depAirportId_alternate).val(this.selections.departureAirports.value);jQuery(this.depAirportId).val(this.selections.departureAirports.key);}else if(this.selections.departureAirports&&this.selections.departureAirports[0].length>0){BFUtils.log("Departure in areasJSON object is not defined: rollback to departureAirports[]",null,"warn");jQuery(this.depAirportId_alternate).val(this.selections.departureAirports[0]);jQuery(this.depAirportId).val(this.selections.departureAirports[0]);}}
this.roomController=new BFSearchFormRoomsViewController({model:this.model,template:"BFRoomsViewHotel",parentViewController:this,parentViewSelector:"#rooms-container",selections:this.selections?this.selections.rooms:null});var self=this;this.roomController.loadView();if(this.searchButton){this.submitButton=this._initSubmitButton();if(this.submitButton!=null&&jQuery(this.searchButton).length>0){this.submitButton.draw();this.submitButton.getButton().attr("tabIndex","0");jQuery("#submitButton").remove();}}
this._addListeners();this.resetForm();};BFHotelSearchController.prototype._initSubmitButton=function()
{var self=this;return new BFSubmitButton({formSelector:this.formId,containerSelector:this.searchButton,label:this.searchButtonLabel,width:self.searchButtonWidth,loaderPath:BFApplicationConstants.images.BUTTON_LOADER_URL,submitFunction:function(){return self._submitFunction();}});};BFHotelSearchController.prototype._submitFunction=function()
{if(this.validateForm())
{if(this.iFrame&&this.submitToHotel&&this._isAccomodationOnly())
{this.hotelSearch();return false;}
return jQuery(this.formId).get(0).submit();}
return false;};BFHotelSearchController.prototype.hotelSearch=function()
{};BFHotelSearchController.prototype._setDefault=function(paramValue,defaultValue)
{return typeof(paramValue)!="undefined"?paramValue:defaultValue;};BFHotelSearchController.prototype._resizeIFrame=function()
{try{setHeight();}catch(exception){BFUtils.log("error resizing iFrame: function parent.calcHeight() doesn't exists - "+exception);}};;BFHotelSearchCityController=function(config)
{BFHotelSearchController.call(this,config);this.destId=this._setDefault(config.destId,"#search_destinations");this.destId_alternate=this._setDefault(config.destId_alternate,"#search_destinations_city");this.fieldsToDisable.push("#search_destinations");this.model.useCitySearch=true;};BFHotelSearchCityController.prototype=new BFHotelSearchController;BFHotelSearchCityController.prototype.initAutocomplete=function(target_id,alternate_id)
{var self=this;function onSelect(e,ui)
{var $hiddenField=jQuery(alternate_id);var value=ui&&ui.item&&ui.item.idCity?ui.item.idCity:"";$hiddenField.val(value);};var $suggester=jQuery(target_id);$suggester.autocomplete({search:function(event,ui){self.showSpinner(target_id);},open:function(event,ui){self.hideSpinner(target_id);},close:function(event,ui){self.hideSpinner(target_id);},source:function(request,response){jQuery.ajax({url:"/suggester/proxy/hotelCity?language="+self._getLanguage()+"&formatType=json&content=json&start=0&count=Infinity",dataType:"json",data:{name:request.term,cityPart:request.term},success:function(data){if(data.items.length==0)
{data.items[0]={name:"La ricerca non ha prodotto nessun risultato"};}
response(jQuery.map(data.items,function(item){return{label:item.name,value:item.name,idCity:item.idCity}}));},error:function(jqXHR,textStatus,errorThrown){BFUtils.log(errorThrown,null,"warn");BFUtils.log(textStatus,null,"info");BFUtils.log(jqXHR,null,"debug");self.hideSpinner(target_id);},beforeSend:function(){}});},minLength:3,select:onSelect});BFUtils.automatizeSuggester($suggester,onSelect);};BFHotelSearchCityController.prototype.validateForm=function()
{var result=BFHotelSearchController.prototype.checkForm.call(this);result=this.checkEmptyField(this.destId_alternate,this.destId)&&result;if(!result){this.highlightErrorFields();BFUtils.log("error validating form: "+this.validationError,null,"error");return result;}
this.setAccomodationOnly();this.disableUnusedFields();return result;};BFHotelSearchCityController.prototype.hotelSearch=function()
{var qs="?idCurrency=EUR&max_distance=5&withAvailability=Y";qs+="&requestOrigin=formVacanze&extCode=-&closeToCenter=Y";qs+="&addresses_idx=&addresses_obj=";qs+="&useRoomForm=true";qs+="&idCity="+jQuery(this.destId_alternate).val();var _depDate=this._createDate(jQuery(this.depDateId_alternate).val(),this.submitDateFormat);var _retDate=this._createDate(jQuery(this.retDateId_alternate).val(),this.submitDateFormat);qs+="&outboundDate="+jQuery.datepicker.formatDate(this.hotelDateFormat,_depDate);qs+="&outboundDay="+jQuery.datepicker.formatDate("dd",_depDate);qs+="&outboundMonthYear="+jQuery.datepicker.formatDate("mmyy",_depDate);qs+="&returnDate="+jQuery.datepicker.formatDate(this.hotelDateFormat,_retDate);qs+="&returnDay="+jQuery.datepicker.formatDate("dd",_retDate);qs+="&returnMonthYear="+jQuery.datepicker.formatDate("mmyy",_retDate);jQuery(this.roomController.viewSelector+" select").each(function(idx,item){if(item.id=="multiproduct-rooms-selected")
qs+="&roomListSize="+item.value;if(item.name.search(/childrenAge/i)>0)
{return;}
var fieldname=item.name.replace(/search.rooms/i,"roomList");qs+="&"+fieldname+"="+item.value;});parent.location.href=this.baseDomain+"/HotelAvailabilitySearch/search.do"+qs;};BFHotelSearchCityController.prototype._addListeners=function()
{BFHotelSearchController.prototype._addListeners.call(this);var self=this;var $cityField=jQuery(this.destId);var $airportField=jQuery(this.depAirportId);$cityField.unbind("focus.BF").unbind("mouseup.BF").bind({"focus.BF":function(){$cityField.val("").parent().find(".invalid-field").remove();jQuery(self.destId_alternate).val("");return false;},"mouseup.BF":function(){return false;}});$airportField.unbind("focus.BF").unbind("mouseup.BF").bind({"focus.BF":function(){$airportField.val("").parent().find(".invalid-field").remove();jQuery(self.depAirportId_alternate).val("");return false;},"mouseup.BF":function(){return false;}});};BFHotelSearchCityController.prototype.loadView=function()
{BFHotelSearchController.prototype.loadView.call(this);this.initAutocomplete(this.destId,this.destId_alternate);if(typeof this.selections.destinationCities==="object")
{jQuery(this.destId_alternate).val(this.selections.destinationCities.value);jQuery(this.destId).val(this.selections.destinationCities.key);if(typeof this.selections.departureAirports=="object")
{jQuery(this.depAirportId_alternate).val(this.selections.departureAirports.value);jQuery(this.depAirportId).val(this.selections.departureAirports.key);}}
else if(this.selections.destinationCities&&this.selections.destinationCities[0].length>0)
{BFUtils.log("destinations in areasJSON object is not defined: rollback to destinationCities[]",null,"warn");jQuery(this.destId_alternate).val(this.selections.destinationCities[0]);jQuery(this.destId).val(this.selections.destinationCities[0]+" (provvisorio)");}};;BFHotelSearchAirportController=function(config)
{BFHotelSearchController.call(this,config);this.destId=this._setDefault(config.destId,"#search_destinations");this.destId_alternate=this._setDefault(config.destId_alternate,"#search_destinations_airport");this.fieldsToDisable.push("#search_destinations");this.model.useAirportSearch=true;};BFHotelSearchAirportController.prototype=new BFHotelSearchController;BFHotelSearchAirportController.prototype.initAutocomplete=function(target_id,alternate_id)
{var self=this;var $suggester=jQuery(target_id);function onSelect(e,ui)
{var $hiddenField=jQuery(alternate_id);var value=ui&&ui.item&&ui.item.idAirport?ui.item.idAirport:"";$hiddenField.val(value);};$suggester.autocomplete({search:function(event,ui){self.showSpinner(target_id);},open:function(event,ui){self.hideSpinner(target_id);},close:function(event,ui){self.hideSpinner(target_id);},source:function(request,response){jQuery.ajax({url:"/suggester/autocompleter?modules=airports&lang="+self._getLanguage(),dataType:"json",data:{key:request.term,cityPart:request.term},success:function(data){response(jQuery.map(data.items[0].entries,function(item){return{label:item.label,value:item.label,idAirport:item.code!="NOTFOUND"?item.code:""}}));},error:function(jqXHR,textStatus,errorThrown){BFUtils.log(errorThrown,null,"warn");BFUtils.log(textStatus,null,"info");BFUtils.log(jqXHR,null,"debug");}});},minLength:3,select:onSelect});BFUtils.automatizeSuggester($suggester,onSelect);};BFHotelSearchAirportController.prototype.validateForm=function()
{var result=BFHotelSearchController.prototype.checkForm.call(this);result=this.checkEmptyField(this.destId_alternate,this.destId)&&result;if(!result){this.highlightErrorFields();BFUtils.log("error validating form: "+this.validationError,null,"error");return result;}
this.setAccomodationOnly();this.disableUnusedFields();return result;};BFHotelSearchAirportController.prototype._addListeners=function()
{BFHotelSearchController.prototype._addListeners.call(this);var self=this;var $depField=jQuery("#search_departureAirports");var $destField=jQuery("#search_destinations");$depField.unbind("focus.BF").unbind("mouseup.BF").bind({"focus.BF":function(){console.log("focus");$depField.val("").parent().find(".invalid-field").remove();jQuery("#search_departureAirports_id").val("");return false;},"mouseup.BF":function(){return false;}});$destField.unbind("focus.BF").unbind("mouseup.BF").bind({"focus.BF":function(){console.log("focus");$destField.val("").parent().find(".invalid-field").remove();jQuery("#search_destinations_airport").val("");return false;},"mouseup.BF":function(){return false;}});};BFHotelSearchAirportController.prototype.loadView=function()
{BFHotelSearchController.prototype.loadView.call(this);this.initAutocomplete(this.destId,this.destId_alternate);if(typeof this.selections.destinationAirports==="object")
{jQuery("#search_destinations").val(this.selections.destinationAirports.key);jQuery("#search_destinations_airport").val(this.selections.destinationAirports.value);}
else if(this.selections.destinationAirports&&this.selections.destinationAirports[0].length>0)
{BFUtils.log("destinations in areasJSON object is not defined: rollback to destinationAirports[]",null,"warn");jQuery(this.destId_alternate).val(this.selections.destinationAirports[0]);jQuery(this.destId).val(this.selections.destinationAirports[0]+" (provvisorio)");}};;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();})();;
