(function(n,t,i){n.MasterModel=Backbone.DeepModel.extend({initialize:function(n){n=n||{};this.url=n.url;this.init&&this.init(n)},commonSetup:function(n){this.attributes=n;var t=this.attributes.LocalFile||!1},addTraceInfoToSession:function(n){var t,u,r,i;if(!n||!_.isObject(n)||_.isEmpty(n))return!1;if(t="trace",u=[n],Modernizr.sessionstorage)try{if(r=window.sessionStorage.getItem(t),r&&(i=JSON.parse(r),_.isArray(i)))return i.splice(0,0,n),this.saveObjectToSessionStorage(t,i),!0;this.saveObjectToSessionStorage(t,u)}catch(f){}},saveLayerToSessionStorage:function(t){t=t||this;var i=t.id+"_"+n.sessionStorageKey,r=t.attributes;this.saveObjectToSessionStorage(i,r)},setValueInSessionStorage:function(i,r,u){u=u||this;var e=u.id+"_"+n.sessionStorageKey,f=t.parseJSON(window.sessionStorage.getItem(e));return f?(f[i]=r,window.sessionStorage.setItem(e,JSON.stringify(f)),this):!1},cloneSessionStorageOnFindAndBookContinue:function(){this.cloneFBModelToSessionStorage(n.BookingModel.BookingLayer.id);this.cloneFBModelToSessionStorage(n.BookingModel.UiLayer.id);this.cloneFBModelToSessionStorage(n.BookingModel.BookingLayer.id)},cloneFBModelToSessionStorage:function(t){var i=window.sessionStorage.getItem(t+"_"+n.sessionStorageKey);window.saveObjectToSessionStorage(t+"_"+n.sessionStorageKeyBase,i)},clearSessionStorage:function(t){t=t||this;var i=t.id+"_"+n.sessionStorageKey,r=t.attributes;if(Modernizr.sessionstorage)try{window.sessionStorage.removeItem(i)}catch(u){}},clearSessionStorageBase:function(t){t=t||this;var i=t.id+"_"+n.sessionStorageKeyBase,r=t.attributes;if(Modernizr.sessionstorage)try{window.sessionStorage.removeItem(i)}catch(u){}},saveObjectToSessionStorage:function(n,t){if(Modernizr.sessionstorage)try{window.sessionStorage.removeItem(n);window.sessionStorage.setItem(n,JSON.stringify(t))}catch(i){}},saveAllStoragePropertiesToLocalStorage:function(n){_.isEmpty(n.DateStorageStr)||this.saveStoragePropertiesToLocalStorage(n.DateStorageStr,"dateStorage");_.isEmpty(n.PartyCompStorageStr)||this.saveStoragePropertiesToLocalStorage(n.PartyCompStorageStr,"partyCompStorage");_.isEmpty(n.RouteStorageStr)||(this.saveStoragePropertiesToLocalStorage(n.CmsContext.DestinationPageId,"destinationPageId"),this.saveStoragePropertiesToLocalStorage(n.RouteStorageStr,"routeStorage",n.CmsContext.DestinationPageId))},saveStoragePropertiesToLocalStorage:function(n,t,i){if(Modernizr.localstorage)try{i?localStorage.setItem(t+"_"+i,n):localStorage.setItem(t,n)}catch(r){}},saveStoragePropertiesToSessionStorage:function(n,t,i){i?this.saveObjectToSessionStorage(t+"_"+i,n):this.saveObjectToSessionStorage(t,n)},path:{RouteDate:"RouteDateByTripType",SailingsFares:"BookingSteps.SailingsFaresByTripType",Cabins:"BookingSteps.Cabins.Legs",OnboardExtra:"BookingSteps.OnboardExtra.Legs",PassengersVehicles:"BookingSteps.PassengersVehiclesByTripType",PassengersVehiclesByTripType:function(n){return this.PassengersVehicles+"."+n+".Legs"},PassengerDetails:"BookingSteps.PassengerDetails.Legs",PayingCustomer:"BookingSteps.PassengerDetails.PayingCustomer",DestinationDeals:"BookingSteps.DestinationDeals",VehicleDetails:"BookingSteps.VehicleDetails.Legs",LowFares:"BookingSteps.LowFares.Legs"},getRouteDateObj:function(n,t,i){return this.getTripTypeObj(this.path.RouteDate,n,t,i)},getRouteDateStepObj:function(n,t){return this.getTripTypeObj(this.path.RouteDate,n,i,t)},getSailingsFaresObj:function(n,t,i){return this.getTripTypeObj(this.path.SailingsFares,n,t,i)},getTripTypeObj:function(n,t,i,r){return this.get(this.getTripTypePath(n,t,i,r))},getRouteDatePath:function(n,t,i){return this.getTripTypePath(this.path.RouteDate,n,t,i)},getSailingsFaresPath:function(n,t,i){return this.getTripTypePath(this.path.SailingsFares,n,t,i)},getLowFaresObj:function(n){return this.get(this.path.LowFares+"."+n)},getTripTypePath:function(n,t,i,r){return t=t||this.getTripType(),i?r?n+"."+t+".Legs."+i+"."+r:n+"."+t+".Legs."+i:r?n+"."+t+"."+r:n+"."+t},getTripType:function(){var n=this.get("TripType");return n?n:"Efp"}})})(window.STENA=window.STENA||{},jQuery),function(n){n.AppTextModel=n.MasterModel.extend({init:function(){var n=this},bootstrap:function(){n.AppText=this.get("Content.AppTexts")}})}(window.STENA=window.STENA||{},jQuery),function(n,t,i){n.UILayerModel=n.MasterModel.extend({initSet:function(i){var r=this;this.commonSetup(i);n.AppText=n.AppText?_.extend(n.AppText,this.get("Content.AppTexts")):this.get("Content.AppTexts");n.ErrorText=n.ErrorText?_.extend(n.ErrorText,this.get("Content.ErrorTexts")):this.get("Content.ErrorTexts");n.$window=n.$window||t(window);n.BookingModel.BookingLayer.on("show:ModelStateError",function(n,t){r.showLightBox(t)})},defaults:{id:this.id},getBookingSummary:function(){return this.get("BookingSteps.PaymentDetails.BookingSummary")},getUpSelling:function(){return this.get("BookingSteps.PaymentDetails.UpSelling")},getPaymentMethods:function(){return this.get("BookingSteps.PaymentDetails.PaymentMethods")},getLocale:function(){return this.get("Locale")},getPaymentSelectedMethodAndType:function(n,t){var i=_.find(this.getPaymentMethods(),function(t){return t.Code===n}),r=null;return i&&t&&(r=_.find(i.PaymentTypes,function(n){return n.Code===t})),{type:r,method:i}},removeInvoiceCustomer:function(){var i=n.BookingModel.BookingLayer.getPaymentMethod(),t=this.getPaymentSelectedMethodAndType(i,null);t.method&&(delete t.method.InvoiceCustomer,t=this.getPaymentSelectedMethodAndType(i,null),t&&t.method&&delete t.method.InvoiceCustomer)},getShouldOpenInNewWindow:function(n,t){var i=this.getPaymentSelectedMethodAndType(n,t),r=!1;return i.type&&(r=i.type.UseNewWindow),r},getCustomerCategories:function(n,t){t=t||this.getTripType();var i=this.path.PassengersVehiclesByTripType(t);return n?this.get(i+"."+n+".CustomerCategories"):{Out:this.get(i+".Out.CustomerCategories"),Home:this.get(i+".Home.CustomerCategories")}},getPassengerDetailsCustomerCategories:function(n){return this.get("BookingSteps.PassengerDetails.Legs."+n+".CustomerCategories")},getVehicleByType:function(n,t){var r=this.get(this.path.PassengersVehiclesByTripType(this.getTripType())+".Legs."+t+".Vehicles"),i=_.filter(r,function(t){return t.Type==n});return i=_.first(i),i?i:!1},getVehicles:function(n){var i=this.getTripType(),t=this.path.PassengersVehiclesByTripType(i);return n?this.get(t+"."+n+".Vehicles"):{Out:this.get(t+".Out.Vehicles"),Home:this.get(t+".Home.Vehicles")}},getTrailers:function(n){var i=this.getTripType(),t=this.path.PassengersVehiclesByTripType(i);return n?this.get(t+"."+n+".Trailers"):{Out:this.get(t+".Out.Trailers"),Home:this.get(t+".Home.Trailers")}},hasMandatoryVehicleRegNo:function(n){return this.get("BookingSteps.VehicleDetails.Legs."+n+".MandatoryVehicleRegistrationNumber")},hasMandatoryTrailerRegNo:function(n){return this.get("BookingSteps.VehicleDetails.Legs."+n+".MandatoryTrailerRegistrationNumber")},showTypeOfVehicle:function(){return this.get("BookingSteps.VehicleDetails.ShowTypeOfVehicle")},getDestinationDeals:function(){return this.get("BookingSteps.DestinationDeals.Arrangements")},getDisplaySettings:function(){return this.get("DisplaySettingsByRoute")},getAvailableProducts:function(n){return this.getProductList(n)},getBlockMessage:function(t,i,r){var u,h,f,c;if(r=r||"BookingSteps.SailingsFaresByTripType",u=this.getTripTypePath(r,i,t),h=!this.get(u+".HasNoDepartures"),h)return!1;var e=n.AppText.SailingsFares,o=[{key:this.get(u+".HasInvalidVehicleForThisContext"),message:e.VehicleNotValidInThisContext},{key:this.get(u+".HasInvalidTrailerForThisContext"),message:e.TrailerNotValidInThisContext},{key:this.get(u+".HasInvalidCustomerCategoryForThisContext"),message:e.CustomerCategoryNotValidInThisContext}],l=e.NoDeparturesWarning,s;for(f=0,c=o.length;f<c;f++)if(o[f].key){s=o[f].message;break}return s?s:l},getDatePickerData:function(n,t){t=t||this.getTripType();n=n||"Out";var r=_.extend({},this.getRouteDateObj(t,n)),u=[];return _.each(["BookableDates","NotBookableDates","LastDepartureDate","FirstDepartureDate"],function(n){var t,f,o,e,s;r!==i?_.has(r,n)&&((n==="LastDepartureDate"||n==="FirstDepartureDate")&&(t=r[n],t==null&&n==="LastDepartureDate"&&(t=new Date,t=t.setDate(t.getDate()+730),f=_utils.getDateObj(t),o=f.year+"-"+f.month+"-"+f.day,t=o),t==null&&n==="FirstDepartureDate"&&(t=new Date,t=t.setDate(t.getDate()),e=_utils.getDateObj(t),s=e.year+"-"+e.month+"-"+e.day,t=s),r[n]=t),u.push(n)):STENA.log("An error occurred")}),_.pick(r,u)},getDepartures:function(n,t){var r=this.getSailingsFaresObj(t,n,"Departures"),i=this.getSailingsFaresObj(t,n,"AlternativeRouteDepartures");if(i&&i.length>0){var u=!!(i[0].Products[0].PackagePrice&&i[0].Products[0].TotalPrice),f=[],e=i[0].RouteName,o=i[0].LegName,s={RouteName:e,AlternativeRouteBegins:!0,LegName:o,ShowBothPrices:u};return r&&r.length!==0||(r=[{NoSailingsOnSelectedDay:!0,ShowBothPrices:u}]),f.push(r,s,i),_.flatten(f)}return r},getProductList:function(n,t){return this.getSailingsFaresObj(t,n,"ProductList")},getTransferDestinations:function(n,t){var i=2;return t=="Out"&&(i=1),n!==null?_.filter(this.getRouteDateStepObj("Transfer","TransferDestinations"),function(t){return t.TransferDirection===n&&t.FerryLegNumber===i}):this.getRouteDateStepObj("Transfer","TransferDestinations")},getRoutes:function(t,i){return i=i||"Routes",t=t||this.getTripType(),t==n.tripTypeEnum.SpecialOffer?this.getRouteDateStepObj(t,i):t==n.tripTypeEnum.Daytrip?this.getRouteDateStepObj(t,i):t==n.tripTypeEnum.Cruise?this.getRouteDateStepObj(t,i):t==n.tripTypeEnum.Transfer?this.getRouteDateStepObj(t,i):this.getRouteDateStepObj(t,i)},getExternalRoutes:function(n){return n=n||this.getTripType(),this.getRouteDateStepObj(n,"ExternalRoutes")||[]},getTransferDestination:function(n,i,r,u){var f=this.getTransferDestinations(null,null);return _.find(f,function(n){return n.TransferRouteCode===i&&t.trim(n.DestinationDescriptionText)===t.trim(r)&&n.FerryLegNumber===u})},getRouteCode:function(n,t){return this.getRouteDateObj(t,n,"RouteCode")},getRouteDate:function(n,t){return this.getRouteDateObj(t,n)},getOppositeRoute:function(n,t){if(!n)return!1;var r=this.getRoutes(t),u=_.find(r,function(t){return t.Value===n}),i;return u&&(i=_.find(r,function(n){return n.Value===u.ReturnRouteCode})),{RouteCode:i?i.Value:"",RouteName:i?i.Text:""}},getCabins:function(n){return this.get("BookingSteps.Cabins.Legs."+n+".Cabins")},getCabinMaps:function(n){return this.get("BookingSteps.Cabins.Legs."+n+".CabinMaps")},getCabinMapInfo:function(n,t){var r=this.getCabins(n),i=_.find(r,function(n){return n.Id==t});return i?i.CabinsInfo:[]},getOnboardExtras:function(n,t){return"undefined"==typeof t?this.get("BookingSteps.OnboardExtra.Legs."+n):_.find(this.get("BookingSteps.OnboardExtra.Legs."+n+".Categories"),function(n){return n.Code===t})},getPassengerDetails:function(){return this.get("BookingSteps.PassengerDetails")},getPaymentDetails:function(){return this.get("BookingSteps.PaymentDetails")},getPaymentDetailsAncillaries:function(){return this.get("BookingSteps.PaymentDetails.Ancillaries")},getExternalInsuranceProducts:function(){var n=this.getPaymentDetailsAncillaries();return n.ExternalInsuranceProducts},getShowExternalInsuranceAmendmentWarning:function(){var n=this.getPaymentDetailsAncillaries();return n.ShowAmendmentWarning},getCountries:function(){return this.get("BookingSteps.PassengerDetails.Countries")},getGenders:function(){return this.get("BookingSteps.PassengerDetails.Genders")},getSpecialNeeds:function(){return this.get("BookingSteps.PassengerDetails.SpecialNeeds")},ShowDateOfBirth:function(){return this.get("BookingSteps.PassengerDetails.ShowDateOfBirth")},ShowGuestlistEmail:function(){return this.get("BookingSteps.PassengerDetails.ShowGuestlistEmail")},CheckExtraMemberInGuestlist:function(){return this.get("BookingSteps.PassengerDetails.CheckExtraMemberInGuestlist")},RemoveArrangementsForExtraMemberNotTravelling:function(){return this.get("BookingSteps.PassengerDetails.RemoveArrangementsForExtraMemberNotTravelling")},getIsAgentBooking:function(){return this.get("BookingSteps.PassengerDetails.IsAgentBooking")},getVisaRequired:function(n){return this.get("BookingSteps.PassengerDetails.Legs."+n+".VisaRequired")},hasQAS:function(){return this.get("BookingSteps.PassengerDetails.QuickSearchEnabled")},getMandatoryFields:function(i){var u=this.get("ValidationRules."+i),r=[],f=i;return t.validator.addMethod("validateNoHtml",function(n){var t=document.createElement("DIV");return t.innerHTML=n,_.isEmpty(n)||(t.textContent||t.innerText)===n&&n.indexOf("&#")<0},n.ErrorText.ClientValidation.pattern),_.each(u,function(n,t){var i,e,o,u,s;if(f=="PayingCustomer"&&t=="Address1"&&(n.validateNoHtml=!0),n.required){if(typeof n.required=="string"&&n.required.substr(0,8)=="function"){i=n.required.replace(/\\/g,"");try{e=i.substr(i.indexOf("(")+1,i.indexOf(")")-i.indexOf("(")-1);o=i.substr(i.indexOf("{")+1,i.indexOf("}")-i.indexOf("{")-1);n.required=new Function(e,o)}catch(h){}}r.push(t)}n.pattern&&(typeof n.pattern=="string"&&(u=n.pattern.replace(/.*\/([gimy]*)$/,"$1"),s=n.pattern.replace(new RegExp("^/(.*?)/"+u+"$"),"$1"),n.pattern=new RegExp(s,u)),r.push(t))}),r},getFormSettings:function(n){return{rules:this.get("ValidationRules."+n),messages:this.get("ValidationMessages."+n)}},addTestValidationMessages:function(){return this.set("ValidationMessages",["Validation test messages #1","Validation test messages #2","Validation test messages #3"],{silent:!0}),this},clearValidationMessages:function(){return this.set("ValidationMessages",null,{silent:!0}),this},getValidationMessages:function(){var t=this.get("ValidationMessages"),n=[];return _.each(t,function(t){n.push(t.Message)}),n},getCompleteValidationMessages:function(){return this.get("ValidationMessages")},hasValidationMessages:function(){return this.get("HasValidationMessages")},getCabinArrangements:function(n,t){var r=this.getCabins(n),i=_.find(r,function(n){return n.Id==t});return i?i.Arrangements:[]},isOnlyAvailableByFoot:function(n,t){var i=this.path.PassengersVehiclesByTripType(n);return t?this.get(i+"."+t+".OnlyAvailableByFoot"):this.get(i+".Out.OnlyAvailableByFoot")||this.get(i+".Home.OnlyAvailableByFoot")},isReturnTripAllowed:function(n){var t=this.get(this.getRouteDatePath(n))||{},r=t.NoReturnTripAllowed===i?!1:t.NoReturnTripAllowed;return!r},isReturnTripMandatory:function(n){var t=this.get(this.getRouteDatePath(n))||{},r=t.OneWayNotAllowed===i?!1:t.OneWayNotAllowed;return!r},isOfferCodeSecured:function(n){var t=this.get(this.getRouteDatePath(n));return t&&t.IsOfferCodeSecured},isContractRateAllowed:function(){return this.get("IsContractRateAllowed")},setOfferCodeSecured:function(n,t){var i=this.getRouteDatePath(n),r=this.get(i);r&&this.set(i+".IsOfferCodeSecured",t)},showLightBox:function(t){var i=this;i.lightBoxError=new n.widgets.lightboxError({uiData:{Id:"ModelStateError",Header:t.msg.MessageHeader,Body:t.msg.Message,CmsYesOrContinueButtonText:"Common.Ok",el:".tpl_modelStateLightboxError-target"},proceedEvent:function(){var t=n.BookingModel.BookingLayer;t.isUpdatingVersion=!0;t.clearSessionStorage(n.BookingModel.BookingLayer);t.clearSessionStorage(n.BookingModel.UiLayer);t.clearSessionStorageBase(n.BookingModel.BookingLayer);t.clearSessionStorageBase(n.BookingModel.UiLayer);window.location="/"}});i.lightBoxError.show()},getEnableMonthView:function(){return this.get("EnableMonthView")},getRouteSpecificContent:function(n){return n?this.get("RouteSpecificContent.Routes."+n):this.get("RouteSpecificContent.Routes")},getAppText:function(n){return this.get("Content.AppTexts."+n)}})}(window.STENA=window.STENA||{},jQuery),function(n){n.ModelExtensions=n.ModelExtensions||{};n.ModelExtensions.validations={offerCode:function(){var t=this.getTripType(),i=this.getCmsOfferCode()||"";return i!=""&&!this.getCmsOfferCodeIsValid()?this.validations.isOfferCodeSecured(t)?this.getCmsOfferCodeSecurityId()==""||this.getCmsOfferCodeSecurityId()==null?n.ErrorText.RouteDate.OfferCodeIsSecured:n.ErrorText.RouteDate.InvalidOfferCodeSecureId:n.ErrorText.RouteDate.InvalidOfferCode:!0},routeSelected:function(t){if(t=t||this.getTripType(),t===n.tripTypeEnum.FerryAccommodation)return!0;var i=n.ErrorText.PassengersVehicles.MustBeSelected||"Unspecified error occurred. (routeSelected)";return this.get("OneWay")||t===n.tripTypeEnum.Daytrip||t===n.tripTypeEnum.SpecialOffer||t===n.tripTypeEnum.Transfer||t===n.tripTypeEnum.Cruise?this.getRouteDateObj(t,"Out","RouteCode")?!0:!1:this.get("OneWay")?i:this.getRouteDateObj(t,"Out","RouteCode")&&this.getRouteDateObj(t,"Home","RouteCode")?!0:i},transferDestinations:function(){var t=this.getTripType(),i=n.AppText.FindAndBook.SelectTransferDestination||"Unspecified error occurred. (transferdestination not selected)";return t===n.tripTypeEnum.Transfer?this.get("OneWay")?this.getRouteDateObj(t,"Out","TransferRouteCodeToFerry")!=null&&this.getRouteDateObj(t,"Out","TransferRouteCodeFromFerry")!=null?!0:i:this.getRouteDateObj(t,"Out","TransferRouteCodeToFerry")!=null&&this.getRouteDateObj(t,"Out","TransferRouteCodeFromFerry")!=null&&this.getRouteDateObj(t,"Home","TransferRouteCodeToFerry")!=null&&this.getRouteDateObj(t,"Home","TransferRouteCodeFromFerry")!=null?!0:i:!0},customerCategories:function(){var u=this.getTripType();if(u===n.tripTypeEnum.FerryAccommodation)return!0;var i=this.getSelectedPassengers(),f=this,t={Home:0,Out:0},r=n.ErrorText.PassengersVehicles.MustSelectMandCustCat||"Unspecified error occurred. (customerCategory)";return this.isDifferentPartySize()?(t.Out=n.ModelExtensions.validations.getApprovedPassengers(i,"Out"),t.Home=n.ModelExtensions.validations.getApprovedPassengers(i,"Home"),t.Home>0&&t.Out>0?!0:{Message:r,IsBusinessRuleFault:!0,Type:"MustSelectMandCustCat"}):(t.Out=n.ModelExtensions.validations.getApprovedPassengers(i,"Out"),t.Out>0?!0:{Message:r,IsBusinessRuleFault:!0,Type:"MustSelectMandCustCat"})},passengerDetails:function(){return!0},vehicleCategories:function(){var e=this.getTripType();if(e===n.tripTypeEnum.FerryAccommodation||n.BookingModel.UiLayer.isOnlyAvailableByFoot(e,"Out"))return!0;var o=this,f={Home:!1,Out:!1},t=this.getVehicle("Out"),i=this.getVehicle("Home"),u="Unspecified error occurred. (vehicleCategories)",r;return this.isDifferentPartySize()?!(_utils.isInResponsiveMode()&&this.getActiveStep()==="FindAndBook")&&(!t.SelectedVehicle.Type||!i.SelectedVehicle.Type)?{Message:n.ErrorText.PassengersVehicles.MustSelectVehiclesOrPassengers,IsBusinessRuleFault:!1,Type:"NoSelectionDone"}:t.HasVehicle&&t.HasVehicle==!0&&t.SelectedVehicle&&t.SelectedVehicle.Type!="null"&&(r=t.SelectedVehicle.Code=="BIC"?n.ModelExtensions.validations.getAllPassengers(this.getSelectedPassengers(),"Out"):n.ModelExtensions.validations.getApprovedPassengers(this.getSelectedPassengers(),"Out"),t.SelectedVehicle.NoOf>r)?{Message:n.ErrorText.PassengersVehicles.TooManyVehicles||u,IsBusinessRuleFault:!0,Type:"TooManyVehicles Out"}:i.HasVehicle&&i.HasVehicle==!0&&i.SelectedVehicle&&i.SelectedVehicle.Type!="null"&&(r=i.SelectedVehicle.Type=="BIC"?n.ModelExtensions.validations.getAllPassengers(this.getSelectedPassengers(),"Home"):n.ModelExtensions.validations.getApprovedPassengers(this.getSelectedPassengers(),"Home"),i.SelectedVehicle.NoOf>r)?{Message:n.ErrorText.PassengersVehicles.TooManyVehicles||u,IsBusinessRuleFault:!0,Type:"TooManyVehicles Home"}:(f.Out=n.ModelExtensions.validations.checkVehicles(t),f.Home=n.ModelExtensions.validations.checkVehicles(i),f.Out&&f.Home?!0:{Message:u,IsBusinessRuleFault:!1,Type:"Unspecified client vehicleError"}):!(_utils.isInResponsiveMode()&&this.getActiveStep()==="FindAndBook")&&!t.SelectedVehicle.Type?{Message:n.ErrorText.PassengersVehicles.MustSelectVehiclesOrPassengers,IsBusinessRuleFault:!1,Type:"NoSelectionDone"}:t.HasVehicle&&t.HasVehicle==!0&&t.SelectedVehicle&&t.SelectedVehicle.Type!="null"&&(r=t.SelectedVehicle.Type=="BIC"?n.ModelExtensions.validations.getAllPassengers(this.getSelectedPassengers(),"Out"):n.ModelExtensions.validations.getApprovedPassengers(this.getSelectedPassengers(),"Out"),t.SelectedVehicle.NoOf>r)?{Message:n.ErrorText.PassengersVehicles.TooManyVehicles||u,IsBusinessRuleFault:!0,Type:"TooManyVehicles"}:n.ModelExtensions.validations.checkVehicles(t)?!0:{Message:u,IsBusinessRuleFault:!1,Type:"Unspecified client vehicleError"}},getApprovedPassengers:function(n,t){var i=0;return _.each(n[t],function(n){n.Code!="INFANT"&&n.Code!="CHILD"&&(i+=parseInt(n.NoOf))}),i},getAllPassengers:function(n,t){var i=0;return _.each(n[t],function(n){i+=parseInt(n.NoOf)}),i},checkVehicles:function(n){return n.HasVehicle!=!0?!0:n.HasVehicle&&n.HasVehicle==!0&&n.SelectedVehicle.Type!="null"&&n.SelectedVehicle.NoOf>0||n.HasVehicle==!1?!0:!1},validateOutBeforeReturn:function(t){if(t=t||this.getTripType(),n.BookingModel.BookingLayer.attributes.OneWay)return!0;var i=n.BookingModel.BookingLayer.getSailingsFaresObj(t,"Out"),r=n.BookingModel.BookingLayer.getSailingsFaresObj(t,"Home"),u=i&&r;if(u=u&&i.ArrivalDateStr&&i.ArrivalTimeStr&&i.ArrivalDateStr.IsoDate,u=u&&r.DepartureDateStr&&r.DepartureTimeStr&&r.DepartureDateStr.IsoDate,u){if(i.ArrivalDateStr.IsoDate>r.DepartureDateStr.IsoDate)return!1;if(i.ArrivalDateStr.IsoDate===r.DepartureDateStr.IsoDate)return i.ArrivalTimeStr<r.DepartureTimeStr}return!0},validateTripsSelected:function(t,i){t=t||this.getSelectedTripType();var r=n.BookingModel.BookingLayer.getSailingsFaresObj(t,i);return r&&r.DepartureId&&!(r.DepartureId==="")&&!this.selectedDepartureSoldOut(r.DepartureId,i,t)},selectedDepartureSoldOut:function(t,i,r){var f=n.BookingModel.BookingLayer.getIsAmendment(),u;if(!f)return u=n.BookingModel.UiLayer.getDepartures(i,r),selectedUiDeparture=_.find(u,function(n){return n.DepartureId===t}),selectedUiDeparture&&selectedUiDeparture.PassengerCapacity===0},departuresSelected:function(){var t=t||this.getSelectedTripType();return this.validations.validateTripsSelected(t,"Out")?n.BookingModel.BookingLayer.attributes.OneWay||this.validations.validateTripsSelected(t,"Home")?!0:{Message:STENA.ErrorText.SailingsFares.DepartureHomeNotSelected,IsBusinessRuleFault:!0,Type:"DepartureNotSelected"}:{Message:STENA.ErrorText.SailingsFares.DepartureOutNotSelected,IsBusinessRuleFault:!0,Type:"DepartureNotSelected"}},outDepartureBeforeHomeDeparture:function(){var n=n||this.getTripType();return this.validations.validateOutBeforeReturn(n)?!0:{Message:STENA.ErrorText.SailingsFares.HomewardDepartBeforeArrival,IsBusinessRuleFault:!0,Type:"HomewardDepartBeforeArrival"}},isOfferCodeSecured:function(t){return n.BookingModel.UiLayer?n.BookingModel.UiLayer.isOfferCodeSecured(t):!1}}}(window.STENA=window.STENA||{},jQuery),function(n,t){n.formValidations={initValidation:function(i,r){r=r||{};this.__options=this.__options||[];this.__options.push(r);var f=this,o=r.scope?t("form").eq(0):t(i).find("form").not(".skip-validation"),e=[],u=_.extend({debug:!1,onkeyup:!1,onfocusout:function(n){var i=t(n),o=i.hasClass("invalid")||i.parent().hasClass("invalid"),u=i.data("scopeindex"),s=u?f.__options[u]:r;if(f.isValidatedOnce&&o&&!_.isEmpty(i.val()))f.validateForms(e,s);else return!1},onfocusin:!1,onsubmit:!1,errorClass:"invalid",invalidHandler:function(n,i){i.errorList.length>0&&_.each(i.errorList,function(n){t(n.element).hasClass("js-scoped-out")&&(i.errorList=_.without(i.errorList,n));(n.element.nodeName==="SELECT"||t(n.element).hasClass("checkbox"))&&t(n.element).parent().addClass("invalid")});i.successList.length>0&&_.each(i.successList,function(n){t(n).hasClass("js-scoped-out")&&(i.successList=_.without(i.successList,n));(n.nodeName==="SELECT"||t(n).hasClass("checkbox"))&&(t(n).parent().removeClass("invalid"),t(n).parent().addClass("valid"))})},errorPlacement:function(){return!1}},r.config||{});return this.mapLabels(o),_.extend(t.validator.messages,n.ErrorText.ClientValidation),_.each(o,function(n){var i=t(n),f=i.data("rules")||r.rules;i.length>0&&((r.rulesMap&&f||r.rules)&&(r.rules?u=_.extend(u,r.rules):_.has(r.rulesMap,f)&&(u=_.extend(u,r.rulesMap[f]))),e.push(i.validate(u)))}),{forms:e,options:r,validate:function(){return f.validateForms(e,r,u.debug)}}},mapLabels:function(n){for(var e=n.find("label"),r,u,i,f=0,o=e.length;f<o;f++)(r=t(e[f]),u=r.prop("for").replace(/\$/g,"\\$"),u)&&((input=t("#"+u),input.length===0||input[0].labelText)||(i=r.text(),i&&(i=i.replace("*","")),input[0].labelText=i))},validateForms:function(i,r,u){r=r||{};var o=this,f=[],e=!0;return _.each(i,function(n){var i=[],u;r.scope&&n.currentForm.length>0&&_.each(n.currentForm,function(n){var u=t(n),f;r.scope.find(n).length===0?i.push(u.addClass("js-scoped-out")):u.data("scopeindex")||(f=t.inArray(r,o.__options),f!==-1&&u.data("scopeindex",f))});_.each(_.keys(n.settings.rules||{}),function(t){var i=n.settings.rules[t];i&&i.customMessage&&(n.settings.customMessages=n.settings.customMessages||{},n.settings.customMessages[t]=_.clone(i),delete i.customMessage)});n.form();i.length>0&&_.each(i,function(n){n.removeClass("js-scoped-out")});n.valid()||(u=n.settings.customMessages,_.map(n.errorList,function(n){var t=u&&u[n.element.name],i=t&&t.customMessage;return i&&(n.element.labelText=Handlebars.helpers.getAppText.call(this,i)),n}),f.push({form:n,errorList:n.errorList,formHeader:t(n.currentForm).data("name")}),e=!1)}),n.$window.trigger("formvalidated",[f]),this.isValidatedOnce=!0,u&&console.log(f),e?!1:f},_classrules:{},addClassRules:function(n){n=n||this._classrules;t.validator.addClassRules(n)}}}(window.STENA=window.STENA||{},jQuery),function(n,t){n.ModelExtensions=n.ModelExtensions||{};n.ModelExtensions.sync={syncInterval:1e3,lastEvent:null,syncing:{},waiting:{},cancelledActions:[],syncModel:function(i,r){function e(n,t,i,r){return{deferred:n,updatesForThisRequest:t,optionsForThisRequest:i,self:r}}var u=this,o,f;return this.options=r||{},this.options.loader=this.options.loader?_utils.isJquery(this.options.loader):!1,this.options.master=this.options.master===!1?this.options.master:!0,this.options.loader=!this.options.loader&&n.$body.hasClass("loading")?n.$body:this.options.loader,this.syncInterval=this.options.syncInterval||this.syncInterval,i=u.cleanUpSyncModel(i),u.lastEvent=(new Date).getTime(),u.options.loader&&u.options.master&&(n.Wrapper.handleLoading(u.options.loader),u.options.loader=!1),u.isPriceUpdateRequest(i,u.options)&&(n.BookingModel.BookingLayer.trigger("spinStart:PriceSpecification"),u.options.PriceSpecificationSpinner=!0),u.hasRequestThePotentialToReturnShowcaseListData(i)&&n.BookingModel.BookingLayer.trigger("loading:ShowcaseList"),u.options.freezeUI&&(o=_.isObject(u.options.freezeUI)?u.options.freezeUI:{},n.Wrapper.freezeUI(o)),u.set("inSync",!1,{silent:!0,noTrigger:!0}),u.setValueInSessionStorage("inSync",!1),f=t.Deferred(),f.notify("init",u),u.options&&u.options.activeStep&&(i.ActiveStep=u.options.activeStep),u.options&&u.options.currentAction&&(i.CurrentAction=u.options.currentAction),u.options.timeStamp=(new Date).getTime(),u.waiting[i.CurrentAction]=u.options.timeStamp,this.options.forceRequest?this.syncCallBack(e(f,_.clone(i),_.clone(u.options),this)):_.delay(this.syncCallBack,this.syncInterval,e(f,_.clone(i),_.clone(u.options),this)),this.currentXHR={promise:f.promise(),currentAction:i.CurrentAction},f.promise()},cleanUpSyncModel:function(n){var t,e,i,r,o,u,s,f,h;if(n.BookingSteps){if(n.BookingSteps.SailingsFaresByTripType)for(t in n.BookingSteps.SailingsFaresByTripType)if(n.BookingSteps.SailingsFaresByTripType[t]&&n.BookingSteps.SailingsFaresByTripType[t].Legs)for(e in n.BookingSteps.SailingsFaresByTripType[t].Legs)if(i=n.BookingSteps.SailingsFaresByTripType[t].Legs[e].DepartureInfos,i)for(r=0;r<i.length;r++)i[r].DepInfoText="";if(n.BookingSteps.OnboardExtra)for(o in n.BookingSteps.OnboardExtra.Legs||[]){u=n.BookingSteps.OnboardExtra.Legs[o];for(s in u.OnboardExtrasGroups||[]){f=u.OnboardExtrasGroups[s];for(h in f.OnboardExtrasItems||[])f.OnboardExtrasItems[h].Media={}}}}return n},isPriceUpdateRequest:function(t,i){if(!t)return!1;var f=(i.preAction||t.CurrentAction||"").toUpperCase(),r=n.BookingModel.BookingLayer,u=r.getIsAnyLegSelected(),e=r.getTripType(),o=r.getSelectedTripType();switch(f){case"UPDATEDPRICE":return!0;case"DESTINATIONDEALSCHANGED":return!0;case"SELECTONBOARDEXTRA":return!0;case"PASSENGERSVEHICLESCHANGED":return u;case"ONEWAYORRETURN":return u&&o===e;case"SELECTCABIN":return!0;case"VALIDATEOFFERCODE":return u;default:return!1}},hasRequestThePotentialToReturnShowcaseListData:function(n){if(!n||n.CurrentAction==null)return!1;var t=n.CurrentAction.toUpperCase();switch(t){case"PRODUCTSELECTION":return!0;case"PASSENGERSVEHICLESCHANGED":return!0;default:return!1}},shouldCancelInitSailings:function(n){if(!n||n.CurrentAction==null)return!1;var t=n.CurrentAction.toUpperCase();switch(t){case"PREFERREDROUTE":return!0;case"PREFERREDDATE":return!0;case"PASSENGERSVEHICLESCHANGED":return!0;default:return!1}},syncCallBack:function(i){var r=i.self,o=i.deferred,f=i.updatesForThisRequest,u=i.optionsForThisRequest,e=r.attributes.ActiveStep;r.waiting[f.CurrentAction]===u.timeStamp&&(o.notify("buffering",r),r.syncing[f.CurrentAction]&&r.syncing[f.CurrentAction].abort(),r.syncing.InitSailings&&r.shouldCancelInitSailings(f)&&r.syncing.InitSailings.abort(),u.cancelAll&&(r.cancelledActions=[],_.each(r.syncing,function(n,t){r.cancelledActions.push(t);n.abort&&n.abort()})),u.loader&&n.Wrapper.handleLoading(u.loader),u.preAction&&(r.__cached={},r.__cached.options=t.extend(!0,{},u),r.__cached.updates=t.extend(!0,{},f),r.__cached.options.forceRequest=!0,f.CurrentAction=u.preAction),o.notify("syncing",r),u.itemToInject&&(f.ItemToInject=u.itemToInject),r.syncing[f.CurrentAction]=r.save(f,{wait:!1,avoidSet:!0,noTrigger:!0,silent:!0,beforeSend:function(t){var c;r.attributes.ActiveStep!==e&&typeof e!="undefined"&&e!==null&&e!==""&&(r.attributes.ActiveStep=e);t.setRequestHeader("X-HTTP-Method-Override","PUT");try{var u=n.BookingModel.BookingLayer,o=u.getSelectedTripType(!0),s=u.getActivePageForGA(u.getActivePageOrStep(f.ActiveStep),f.TripType),l="";_.isEmpty(o)||(o+="/");s!=="FindAndBook"&&(l=u.getGABookingStateStr()+"/");c=o+u.getGAUsageModeStr(f.CmsContext.UsageModeStr)+"/"+l+s+"-"+f.CurrentAction;t.setRequestHeader("AppDyn-Step-Action",s+"-"+f.CurrentAction);t.setRequestHeader("WebBook-Step-Action",c)}catch(v){t.setRequestHeader("AppDyn-Step-Action",f.ActiveStep+"-"+f.CurrentAction);t.setRequestHeader("WebBook-Step-Action",f.ActiveStep+"-"+f.CurrentAction)}if(n.BookingModel.BookingLayer.attributes.FetchSailingsAtLoad===!0&&utag_data){f.CurrentAction=="LoadLowFares"&&n.BookingModel.BookingLayer.setShouldFetchSailingsAtLoad(!1);var i=_.filter(_.keys(utag_data),function(n){return n.lastIndexOf("_qp")===0}),a=[],h=0;i&&_.isArray(i)&&i.length>0&&(i=i.sort(),_.each(i,function(){a.push(i[h]+"="+utag_data[i[h]]);h++}),t.setRequestHeader("Last-Query-Params",encodeURIComponent(a.join())))}},success:function(t,i){var f,e;o.notify("done",r);o.resolve(r);u.PriceSpecificationSpinner&&(n.BookingModel.BookingLayer.trigger("spinComplete:PriceSpecification"),u.PriceSpecificationSpinner=!1);r.success(t,i,u);i.BookingLayer&&(r.syncing[i.BookingLayer.CurrentAction]=!1,r.__cached&&r.__cached.options.preAction&&(r.__cached.options.preAction=!1,r.attributes.preAction=!1,r.attributes.CurrentAction=r.__cached.updates.CurrentAction,r.attributes.ActiveStep=r.__cached.updates.ActiveStep,r.syncModel(r.attributes,r.__cached.options)),u.postAction&&(_.isString(u.postAction)?r.setCurrentAction(u.postAction).syncModel(r.attributes):_.isObject(u.postAction)&&u.postAction.action&&(f=u.postAction.options||{},f.action==="lastCancelledAction"&&(e=r.cancelledActions,f.action=e&&e.length>0?_.last(_.without(e,i.BookingLayer.CurrentAction)):!1),f.action&&r.setCurrentAction(u.postAction.action).syncModel(r.attributes,f))))},error:function(n,t){r.error(n,t,u)},complete:function(t,i){r.complete(t,i,u);u.freezeUI&&!u.freezeUI.preserveFreezeUi&&n.Wrapper.unFreezeUI()}}))},functionMap:{"0":"handleBookingLayerResponse","1":"handleUiLayerResponse","2":"handleCompactBookingLayerResponse"},success:function(t,i,r){var u,e,f;if(this.saveObjectToSessionStorage("bookingLayerBeforeServerCall",t),u=this,e={"0":i.BookingLayer||null,"1":i.UiLayer||null},i.UiLayer&&i.UiLayer.HasValidationMessages&&i.UiLayer.ValidationMessages[0].Category=="ModelStateError")return n.BookingModel.BookingLayer.trigger("show:ModelStateError",null,{msg:i.UiLayer.ValidationMessages[0]}),!1;if(r=r||{},r.TraceBusinessValidations=i.TraceBusinessValidations,r.IsBusinessRuleFault=i.IsBusinessRuleFault,_.each(e,function(n,i){(n||!_.isEmpty(n))&&u[u.functionMap[i]](t,n,r)}),f=i.UiLayer&&!i.UiLayer.HasValidationMessages||!i.UiLayer?!1:i.UiLayer.ValidationMessages,(!this.options.preAction||f)&&this.resetLegsAction(),this.options.onSuccess)this.options.onSuccess(t,i,f)},error:function(t,i,r){if(i.status!==0&&(n.$window.trigger("loading:error"),r.onError))r.onError(t,i)},complete:function(t,i,r){if(i==="abort"){if(r.onAbort)r.onAbort(t,i);return!1}if(r.backgroundEvent||n.$window.trigger("loading:complete"),r.onComplete)r.onComplete(t,i)},preferencesChanged:function(n){var t=function(n){var t=0,i,r,u;if(!n||n.length===0)return t;for(i=0,u=n.length;i<u;i++)r=n.charCodeAt(i),t=(t<<5)-t+r|0;return t},i=""+localStorage.getItem("partyCompStorage")+localStorage.getItem("dateStorage")+localStorage.getItem("destinationPageId")+localStorage.getItem("routeStorage_"+localStorage.getItem("destinationPageId")),r=""+n.PartyCompStorageStr+n.DateStorageStr+n.CmsContext.DestinationPageId+n.RouteStorageStr,u=t(i),f=t(r);return u!==f},handleBookingLayerResponse:function(n,t,i){var u,r;t=_.omit(t,["ActiveStep","CurrentAction","ActivePage","ItemToInject"]);t.CmsContext=_.omit(t.CmsContext,["UseContractRate"]);this.preferencesChanged(t)?(this.saveAllStoragePropertiesToLocalStorage(t),Modernizr.localstorage&&(window.localStorage.removeItem("storedProductOut"),window.localStorage.removeItem("storedProductHome"),window.localStorage.removeItem("storedCabinsOut"),window.localStorage.removeItem("storedCabinsHome"),window.localStorage.removeItem("storedArrangementsOut"),window.localStorage.removeItem("storedArrangementsHome"),window.localStorage.removeItem("storedOnboardExtraOut"),window.localStorage.removeItem("storedOnboardExtraHome"))):Modernizr.localstorage&&(n.set({PreviousProductOut:window.localStorage.getItem("storedProductOut")},{silent:!0,noTrigger:!0}),n.set({PreviousProductHome:window.localStorage.getItem("storedProductHome")},{silent:!0,noTrigger:!0}),n.set({PreviousCabinsOut:JSON.parse(window.localStorage.getItem("storedCabinsOut"))},{silent:!0,noTrigger:!0}),n.set({PreviousCabinsHome:JSON.parse(window.localStorage.getItem("storedCabinsHome"))},{silent:!0,noTrigger:!0}),n.set({PreviousCabinsArrangementsOut:JSON.parse(window.localStorage.getItem("storedArrangementsOut"))},{silent:!0,noTrigger:!0}),n.set({PreviousCabinsArrangementsHome:JSON.parse(window.localStorage.getItem("storedArrangementsHome"))},{silent:!0,noTrigger:!0}),n.set({PreviousOnboardExtraOut:JSON.parse(window.localStorage.getItem("storedOnboardExtraOut"))},{silent:!0,noTrigger:!0}),n.set({PreviousOnboardExtraHome:JSON.parse(window.localStorage.getItem("storedOnboardExtraHome"))},{silent:!0,noTrigger:!0}));n.set({IsAuthenticated:t.IsAuthenticated},{silent:!0,noTrigger:!0});n.set({ReservationCode:t.ReservationCode},{silent:!0,noTrigger:!0});n.set({TripType:t.TripType},{silent:!0,noTrigger:!0});n.set({TripTypeWithPreloadedSailings:t.TripTypeWithPreloadedSailings},{silent:!0,noTrigger:!0});n.set({HiddenTripTypes:t.HiddenTripTypes},{silent:!0,noTrigger:!0});n.set({PreviousDepartureIdOut:t.PreviousDepartureIdOut},{silent:!0,noTrigger:!0});n.set({PreviousProductCodeOut:t.PreviousProductCodeOut},{silent:!0,noTrigger:!0});n.set({PreviousFerryCodeOut:t.PreviousFerryCodeOut},{silent:!0,noTrigger:!0});n.set({PreviousDepartureIdHome:t.PreviousDepartureIdHome},{silent:!0,noTrigger:!0});n.set({PreviousProductCodeHome:t.PreviousProductCodeHome},{silent:!0,noTrigger:!0});n.set({PreviousFerryCodeHome:t.PreviousFerryCodeHome},{silent:!0,noTrigger:!0});t.TraceList&&_.isObject(t.TraceList)&&!_.isEmpty(t.TraceList)&&(u=n.get("TraceList")||{},n.set({TraceList:_.extend(u,t.TraceList)},{silent:!0,noTrigger:!0}));this.saveObjectToSessionStorage("syncTimestamp",t.TimeStamp);this.handleLayer(n,t,!0,i);_.isEmpty(t.PartyCompStorageStr)?(r=localStorage.getItem("partyCompStorage"),r!=="undefined"&&r&&n.set({PartyCompStorageStr:r},{silent:!0,noTrigger:!0})):n.set({PartyCompStorageStr:t.PartyCompStorageStr},{silent:!0,noTrigger:!0})},handleUiLayerResponse:function(t,i,r){var f=this,u;n.BookingModel.UiLayer.set({HasValidationMessages:i.HasValidationMessages,StepsToUpdate:i.StepsToUpdate,ValidationMessages:i.ValidationMessages},{silent:!0,noTrigger:!0});i.ValidationRules&&n.BookingModel.UiLayer.set({ValidationRules:i.ValidationRules},{silent:!0,noTrigger:!0});i.HasValidationMessages?r.hasValidations&&(u=r.useCompleteValidationMessages?n.BookingModel.UiLayer.getCompleteValidationMessages():n.BookingModel.UiLayer.getValidationMessages(),r.hasValidations(u,i.ValidationMessages,i)):this.handleLayer(n.BookingModel.UiLayer,i,!0)},handleLayer:function(t,i,r,u){var y=i.StepsToUpdate,h={},e=[],o,p,w,f,a,c,v,s,l;r||t.set(i,{silent:!0,noTrigger:!0});y&&y.length>0&&(_.each(y,function(n){v=n.split(".");v.length===2?(s=v[0],l=v[1],o=i.BookingSteps[s]?"BookingSteps."+s+"."+l:s+"."+l,f=i.BookingSteps[s]?i.BookingSteps[s][l]:i[s][l]):(o=i.BookingSteps[n]?"BookingSteps."+n:n,f=i.BookingSteps[n]?i.BookingSteps[n]:i[n]);f&&f.RoutesToUpdate&&f.RoutesToUpdate.length>0&&_.each(f.RoutesToUpdate,function(t){c=n+":"+t;var i=f.Routes[t].ItemsToInject;i&&!_.isEmpty(i)?_.each(i,function(n){r&&(a=o+".Routes."+t+"."+n.ContainerProperty+"."+n.ItemIndex+"."+n.PropertyNameToReplace,h[a]=f.Routes[t][n.PropertyNameToInject]);e.push(c+":"+n.ContainerId)}):(r&&(w=o+".Routes."+t,h[w]=f.Routes[t]),e.push(c))});f&&f.LegsToUpdate&&f.LegsToUpdate.length>0&&_.each(f.LegsToUpdate,function(t){c=n+":"+t;var i=f.Legs[t].ItemsToInject;i&&!_.isEmpty(i)?_.each(i,function(n){r&&(a=o+".Legs."+t+"."+n.ContainerProperty+"."+n.ItemIndex+"."+n.PropertyNameToReplace,h[a]=f.Legs[t][n.PropertyNameToInject]);e.push(c+":"+n.ContainerId)}):(r&&(p=o+".Legs."+t,h[p]=f.Legs[t]),e.push(c))});f&&f.ShouldUpdateSelf&&(r&&_.each(f,function(n,t){t!=="Legs"&&(h[o+"."+t]=n)}),e.push(n))}),r&&t.set(h,{silent:!0,noTrigger:!0}));e.length>0&&this.triggerEvents(e,t);this.set("inSync",!0,{silent:!0,noTrigger:!0});(n.usingSessionStorage||n.useSessionStorageWithSession)&&(t.id==="BookingLayer"&&(u&&u.activeStepOnSuccess&&t.setActiveStep(u.activeStepOnSuccess),u&&u.shouldFetchSailingsAtLoad&&t.setShouldFetchSailingsAtLoad(u.shouldFetchSailingsAtLoad)),this.saveLayerToSessionStorage(t))},triggerEvents:function(n,t){t.id==="BookingLayer"&&t.attributes.CurrentAction!=="SearchSpecialOffers"&&t.trigger("change:booking");_.each(n,function(n){t.trigger("change:"+n)})}}}(window.STENA=window.STENA||{},jQuery),function(n,t){n.ModelExtensions=n.ModelExtensions||{};n.ModelExtensions.misc={resetDirection:function(t){n.direction=n.direction||!1;n.direction=t?t:!1},resetLegsAction:function(){this.set("LegsForCurrentAction",null,{silent:!0})},resetBookingSteps:function(n){var t={};return n=n||["BookingSteps.Cabins","BookingSteps.DestinationDeals","BookingSteps.OnboardExtra","BookingSteps.PassengerDetails","BookingSteps.SailingsFaresByTripType","BookingSteps.VehicleDetails"],_.each(n,function(n){t[n]=null}),this.set(t),this},getBookingSteps:function(){return this.get("BookingSteps")},getActiveStep:function(){return this.get("ActiveStep")},getCurrentAction:function(){return this.get("CurrentAction")},getIsOneWay:function(){return this.get("OneWay")},getActiveStepObj:function(n){var i=n||this.get("ActiveStep"),r,u;return/ByTripType$/.test(i)&&(i+="."+this.getSelectedTripType()),r=this.get("BookingSteps."+i),u=t.extend(!0,r,{OneWay:this.get("OneWay")}),u},getSelectedStepObj:function(n){var i=n||this.get("ActiveStep"),r,u;return/ByTripType$/.test(i)&&(i+="."+this.getSelectedTripType()),r=this.get("BookingSteps."+i),u=t.extend(!0,r,{OneWay:this.getIsOneWayForTripType(this.getSelectedTripType())}),u},getTotalPrice:function(){return this.get("PriceSpecification.TotalPrice.Text")},getTotalPriceNumeric:function(){return this.get("PriceSpecification.TotalPrice.Amount")},getDefaultTotalPrice:function(){return this.get("BookingContext.DefaultZeroPrice")},getCmsLanguageCode:function(){return this.get("BookingContext.CmsLanguageCode")},getCurrencyCode:function(){return this.get("BookingContext.CurrencyCode")},getIncludedFee:function(){var n=this.get("PriceSpecification.Fee");return n&&n.Text},getShouldFetchSailingsAtLoad:function(){return this.get("FetchSailingsAtLoad")},getInitialTabWithPreloadedSailings:function(){var t=this.get("TripTypeWithPreloadedSailings");if(t)switch(t){case n.tripTypeEnum.Efp:return"0";case n.tripTypeEnum.Daytrip:return"1";case n.tripTypeEnum.Cruise:return"2";case n.tripTypeEnum.SpecialOffer:return"3";case n.tripTypeEnum.Transfer:return"4";default:return null}return null},getCmsContext:function(){return this.get("CmsContext")},isOfferCodeAllowed:function(n){var t=this.get("CmsContext.ProductInfoByTripType");return t&&t[n]?t[n].IsOfferCodeAllowed:!0},getCmsOfferCode:function(){return this.get("CmsContext.OfferCode")},getUseContractRate:function(){return this.get("CmsContext.UseContractRate")},getCmsOfferCodeSecurityId:function(){return this.get("CmsContext.OfferCodeSecurityId")},getCmsOfferCodeIsValid:function(){return this.get("CmsContext.OfferCodeIsValid")},getModelValidations:function(i,r){var u=this.validateThis(i),e=[],o,f;return r||n.BookingModel.UiLayer.hasValidationMessages()&&(e=t.makeArray(n.BookingModel.UiLayer.getCompleteValidationMessages())),u=_.isArray(u)?u:[],u.length>0&&e.length>0?o="combined":e.length>0?o="server":u.length>0&&(o="client"),f={},f.validations=_.union(u,e),f.type=o,f.validations.length>0?f:!1},getIsAmendment:function(){return this.attributes.IsAmendment},getIsUpgrade:function(){return this.attributes.IsUpgrade},getIsProdEnvironment:function(){return this.attributes.IsProdEnvironment},getFerryName:function(n){var t=this.getSelectedTripType();return this.attributes.BookingSteps.SailingsFaresByTripType[t].Legs[n]&&this.attributes.BookingSteps.SailingsFaresByTripType[t].Legs[n].FerryName},getFerryImageUrl:function(n){var t=this.getSelectedTripType();return this.attributes.BookingSteps.SailingsFaresByTripType[t].Legs[n]&&this.attributes.BookingSteps.SailingsFaresByTripType[t].Legs[n].FerryCalloutImageUrl},setActiveStep:function(n){return this.set("ActiveStep",n,{silent:!0}),this},setShouldFetchSailingsAtLoad:function(t){return n.ModelExtensions.validations.getApprovedPassengers(this.getSelectedPassengers(),"Out")>0?this.set("FetchSailingsAtLoad",t,{silent:!0}):this.set("FetchSailingsAtLoad",!1,{silent:!0}),this},setCurrentAction:function(n,i){if(this.set("CurrentAction",n,{silent:!0}),i){if(this.get("OneWay")&&n!=="OneWayOrReturn")return this.set("LegsForCurrentAction",["Out"],{silent:!0}),this;if(this.get("OneWay")&&n==="OneWayOrReturn")return this.set("LegsForCurrentAction",["Home"],{silent:!0}),this;var r=this.get("LegsForCurrentAction");if(r&&r.length!==0){if(t.inArray(i,r)>-1)return!1;t.inArray(i,r)===-1&&(r.push(i),this.set("LegsForCurrentAction",r,{silent:!0}))}else this.set("LegsForCurrentAction",[i],{silent:!0})}return this},setStepAndCurrentAction:function(n,i,r){var e=this,f,u;return(n&&this.set("ActiveStep",n,{silent:!0}),i&&this.set("CurrentAction",i,{silent:!0}),this.get("OneWay")&&i!=="OneWayOrReturn")?(this.set("LegsForCurrentAction",["Out"],{silent:!0}),this):this.get("OneWay")&&i==="OneWayOrReturn"?(this.set("LegsForCurrentAction",["Home"],{silent:!0}),this):(f=!r||_.isArray(r)?r:[r],f&&(u=this.get("LegsForCurrentAction"),u&&u.length!==0?_.each(f,function(n){n&&t.inArray(n,u)===-1&&(u.push(n),e.set("LegsForCurrentAction",u,{silent:!0}))}):this.set("LegsForCurrentAction",f,{silent:!0})),this)},hasTripType:function(n){var t=this.get("RouteDateByTripType"),i;return!_.isEmpty(t)&&_.has(t,n)&&(i=t[n].Legs.Out,i.RouteCode&&i.FullDate)?!0:!1},prepareNewTripType:function(t,i){if(!t||(i=i==="FerryAccommodation"?"Efp":i||"Efp",this.prepareSelectedCustomers(t,i),this.hasTripType(t)))return!1;var s=_.clone(this.getRouteDateObj(i)),o=this.getRouteDatePath(t),e,r,f,u;return(this.set(o,s,{silent:!0}),e=this.getRouteDateObj(t),r=e.Legs.Out,t==="SpecialOffer"||t==="Transfer")?r&&!_.isEmpty(r.RouteCode):(_.isEmpty(e.Legs.Home)&&(this.set(o+".Legs.Home",_.clone(r),{silent:!0}),f=e.Legs.Home,f.LegName="Home",u=n.BookingModel.UiLayer.getOppositeRoute(r.RouteCode,t),u.RouteCode&&u.RouteCode!=null&&f.RouteCode!==""&&(f.RouteCode=u.RouteCode),u.RouteName&&u.RouteName!=null&&f.RouteName!==""&&(f.RouteName=u.RouteName)),r&&!_.isEmpty(r.RouteCode))},prepareSelectedCustomers:function(n,t){var u=this.get(this.path.PassengersVehiclesByTripType(t)+".Out.CustomerCategories"),i,r,f;u&&u.length!==0&&(i=_.clone(u),r=this.path.PassengersVehiclesByTripType(n)+".Out.CustomerCategories",this.set(r,i,{silent:!0}),this.getIsOneWay()||(f=this.get(this.path.PassengersVehiclesByTripType(t)+".Home.CustomerCategories"),i=_.clone(f),r=this.path.PassengersVehiclesByTripType(n)+".Home.CustomerCategories",this.set(r,i,{silent:!0})))},getGAUsageModeStr:function(n){var t="Priv";if(_.isEmpty(n))return t;switch(n){case"NotInitialized":return t;case"WebCustomer":return t;case"StaffMember":return"Staff";case"Anonymous":return t;case"Agent":return"Agent";case"OnlinePartner":return"Olp";default:return t}},getGABookingStateStr:function(){return n.isAmendment?"Amend":"New"},getActivePageForGA:function(n,t){var i="Sailings"+t;if(_.isEmpty(n))return i;switch(n){case"PassengersVehiclesByTripType":return"PassVeh";case"SailingsFaresByTripType":return i;case"Cabins":return"Cabins";case"OnboardExtra":return"Onboard";case"DestinationDeals":return"DestDeal";case"PassengerDetails":return"PassDet";case"PaymentDetails":return"PayDet";case"PayAndConfirm":return"PayDet";case"Confirmation":return"Confirm";default:return n}},getActivePageOrStep:function(t){return n.bookingPageName=="LoginPage"?n.bookingPageName:t||n.bookingPageName},isLoggedIn:function(){return this.get("IsAuthenticated")}}}(window.STENA=window.STENA||{},jQuery),function(n,t,i){n.ModelExtensions=n.ModelExtensions||{};n.ModelExtensions.passengers={normalizeCustomerCategories:function(){var n=this.getSelectedTripType(),i=this.get(this.path.PassengersVehiclesByTripType(n)+".Out.CustomerCategories"),t=[];_.each(i,function(n){t.push(_.clone(n))});this.set(this.path.PassengersVehiclesByTripType(n)+".Home.CustomerCategories",t,{silent:!0})},normalizeVehiclesAndTrailers:function(){var n=this.getSelectedTripType(),i=this.get(this.path.PassengersVehiclesByTripType(n)+".Out.SelectedVehicle"),t;this.set(this.path.PassengersVehiclesByTripType(n)+".Home.SelectedVehicle",i,{silent:!0});t=this.get(this.path.PassengersVehiclesByTripType(n)+".Out.SelectedTrailer");this.set(this.path.PassengersVehiclesByTripType(n)+".Home.SelectedTrailer",t,{silent:!0})},resetPassengers:function(){var r=this.getSelectedTripType(),t=this.path.PassengersVehiclesByTripType(r),i=[{AgeFrom:null,AgeTo:null,Code:null,GenericID:null,InfoLabel:null,Mandatory:!1,MaxNo:0,NamePlural:null,NameSingular:null,NoOf:0}],n={};n[t+".Out.CustomerCategories"]=i;n[t+".Home.CustomerCategories"]=i;this.set(n,{silent:!0})},resetVehicleAndTrailer:function(){var r=this.getSelectedTripType(),t=this.path.PassengersVehiclesByTripType(r),i={BookMultiple:!1,Description:"null",GeneralGenericID:"null",Type:"null"},n={};n[t+".Out.SelectedNoOfVehicle"]=0;n[t+".Home.SelectedNoOfVehicle"]=0;n[t+".Out.SelectedNoOfTrailer"]=0;n[t+".Home.SelectedNoOfTrailer"]=0;this.set(n,{silent:!0});this.setVehicle(i,!1,"Out");this.setVehicle(i,!1,"Home");this.setTrailer(null,"Out");this.setTrailer(null,"Home")},resetTrailer:function(){},getPassengerDetails:function(){return this.get("BookingSteps.PassengerDetails")},getSelectedPassengers:function(n){n=n||this.getSelectedTripType();var t=this.get(this.path.PassengersVehiclesByTripType(n)+".Out.CustomerCategories");return t?{Out:t,Home:this.get(this.path.PassengersVehiclesByTripType(n)+".Home.CustomerCategories")}:{Out:[],Home:[]}},getAmountOfPassengers:function(n){var i=this.getSelectedPassengers()[n],t=0;return _.each(i,function(n){parseInt(n.NoOf,10)>0&&!isNaN(n.NoOf)&&(t+=parseInt(n.NoOf,10))}),t},getPassengers:function(n){return n?this.get("BookingSteps.PassengerDetails.Legs."+n+".Guests"):{Out:this.get("BookingSteps.PassengerDetails.Legs.Out.Guests"),Home:this.get("BookingSteps.PassengerDetails.Legs.Home.Guests")}},getCabinsCanBeDistributed:function(n){var r=this,i=[],t=[];return _.each(n,function(n){i.push(r.get("BookingSteps.Cabins.Legs."+n+".Cabins"))}),_.each(i,function(n){n&&n.length>0&&t.push(_.reduce(_.pluck(n,"NoOf"),function(n,t){return n+t}))}),t.length>0&&_.max(t)>1},getPayingCustomer:function(){return this.get("BookingSteps.PassengerDetails.PayingCustomer")},getExtraMemberNotTravelling:function(){return this.get("BookingSteps.PassengerDetails.ExtraMemberNotTravelling")},getCustomerCategories:function(n){var i=this.getSelectedTripType(),t=this.path.PassengersVehiclesByTripType(i);return n?this.get(t+"."+n+".CustomerCategories"):{Out:this.get(t+".Out.CustomerCategories"),Home:this.get(t+".Home.CustomerCategories")}},getVehicle:function(n,t){t=t||this.getSelectedTripType();var i=this.path.PassengersVehiclesByTripType(t),r=this.get(i+"."+n+".SelectedVehicle");return{HasVehicle:this.getHasVehicle(n),SelectedVehicle:r,VehicleAmount:this.getVehicleAmount(n)}},getHasVehicle:function(n,t){t=t||this.getSelectedTripType();var r=this.path.PassengersVehiclesByTripType(t),i=this.get(r+"."+n+".SelectedVehicle");return!!(i&&i.Type!=="undefined"&&i.Type!==null&&i.Type.toLowerCase()!=="footpassengercode")},getVehicles:function(n){return this.get("BookingSteps.VehicleDetails.Legs."+n+".Vehicles")},getVehicleAmount:function(n){var t=this.getSelectedTripType(),i=this.path.PassengersVehiclesByTripType(t);return this.get(i+"."+n+".SelectedVehicle.NoOf")},getVehicleCode:function(n){var t=this.getSelectedTripType(),i=this.path.PassengersVehiclesByTripType(t);return this.get(i+"."+n+".SelectedVehicle.Type")},getTrailer:function(n,t){t=t||this.getSelectedTripType();var i=this.path.PassengersVehiclesByTripType(t);return{HasTrailer:this.getHasTrailer(n),SelectedTrailer:this.get(i+"."+n+".SelectedTrailer"),TrailerAmount:this.getTrailerAmount(n)}},getHasTrailer:function(n,t){t=t||this.getSelectedTripType();var r=this.path.PassengersVehiclesByTripType(t),i=this.get(r+"."+n+".SelectedTrailer");return!!(i&&i.GeneralGenericID!=="undefined"&&i.GeneralGenericID!==null)},getTrailerAmount:function(n){var t=this.getSelectedTripType(),i=this.path.PassengersVehiclesByTripType(t);return this.get(i+"."+n+".SelectedTrailer.NoOf")},getPassengerVehiclesDirection:function(n){var t=this.getSelectedTripType(),i=this.path.PassengersVehiclesByTripType(t);return this.get(i+"."+n)},getVehicleDetails:function(n){return n?this.get("BookingSteps.VehicleDetails.Legs."+n+".Vehicles"):{Out:this.get("BookingSteps.VehicleDetails.Legs.Out.Vehicles"),Home:this.get("BookingSteps.VehicleDetails.Legs.Home.Vehicles")}},getPetsDetails:function(){return this.get("BookingSteps.PassengerDetails.Pets")},getNoOfApprovedPassengers:function(n){var i=this.getSelectedTripType(),r=this.path.PassengersVehiclesByTripType(i),u=this.get(r+"."+n+".CustomerCategories"),t=0;return _.each(u,function(n){n.Code!="INFANT"&&n.Code!="CHILD"&&(t+=parseInt(n.NoOf))}),t},setPartySize:function(n){var t;return t=_.isString(n)?n=="true"?!0:!1:n,t||(this.normalizeCustomerCategories(),this.normalizeVehiclesAndTrailers()),this.resetDirection(),this.set(this.path.PassengersVehicles+"."+this.getSelectedTripType()+".IsDifferentPartySize",t,{silent:!0}),_.isObject(STENA.BookingModel.UiLayer.attributes.BookingSteps.PassengersVehiclesByTripType.SpecialOffer)&&this.set(this.path.PassengersVehicles+".SpecialOffer.IsDifferentPartySize",t,{silent:!0}),this.trigger("PassengersVehicles:DifferentPartySize"),this},setPassengers:function(t,i,r){if(!r||r==="Home"&&this.getIsOneWay())return!1;var u=this;return _.each(_.keys(STENA.BookingModel.UiLayer.attributes.BookingSteps.PassengersVehiclesByTripType),function(f){var s=u.path.PassengersVehiclesByTripType(f),h=n.BookingModel.UiLayer.getCustomerCategories(r),e,o;if(h){var l=h.slice(0),a=u.getSelectedPassengers(f)[r],c=!1;u.resetDirection(r);e=_.map(a,function(n){return n.Code&&n.Code===t&&(c=!0,n.NoOf=i),_.clone(n)});c||(o=_.find(l,function(n){return n.Code===t}),o&&(o.NoOf=i,e.push(o)));i==="0"&&(e=_.filter(e,function(n){return n.Code!==t}));u.isDifferentPartySize()?u.set(s+"."+r+".CustomerCategories",e,{silent:!0}):(u.set(s+".Out.CustomerCategories",e),u.set(s+".Home.CustomerCategories",e))}}),this.setPriorityBoardingAmount(),this.trigger("PassengersVehicles:PassengersVehiclesChanged"),this},setPayingCustomerDetail:function(n){this.resetDirection();this.set("BookingSteps.PassengerDetails.PayingCustomer."+n.id,n.value,{silent:!0});this.trigger("PassengerDetails:PayingCustomerDetailsChanged",{id:n.id,value:n.value})},setCreateOrUpdatePayingCustomerProfile:function(n){this.set("BookingSteps.PassengerDetails."+n.id,n.value,{silent:!0})},setPassengerDetail:function(n,t){var i,r;if(this.isDifferentPassengers()||this.isDifferentPartySize()){if(i=this.path.PassengerDetails+"."+n+".Guests",r=this.get(i+"."+t.index+"."+t.id),_.isEqual(r,t.value))return;this.resetDirection(n);this.set(i+"."+t.index+"."+t.id,t.value,{silent:!1})}else this.resetDirection(),i=this.path.PassengerDetails+".Out.Guests",r=this.get(i+"."+t.index+"."+t.id),_.isEqual(r,t.value)||this.set(i+"."+t.index+"."+t.id,t.value,{silent:!1}),this.attributes.OneWay||(i=this.path.PassengerDetails+".Home.Guests",r=this.get(i+"."+t.index+"."+t.id),_.isEqual(r,t.value)||this.set(i+"."+t.index+"."+t.id,t.value,{silent:!1}))},setVehicleDetails:function(n,t){var i;this.isDifferentPassengers()||this.isDifferentPartySize()?(i=this.path.VehicleDetails+"."+n+".Vehicles",this.resetDirection(n),this.set(i+"."+t.index+"."+t.id,t.value,{silent:!1})):(this.resetDirection(),i=this.path.VehicleDetails+".Out.Vehicles",this.set(i+"."+t.index+"."+t.id,t.value,{silent:!1}),i=this.path.VehicleDetails+".Home.Vehicles",this.set(i+"."+t.index+"."+t.id,t.value,{silent:!1}))},setPetsDetails:function(n){this.set("BookingSteps.PassengerDetails.Pets."+n.index+"."+n.id,n.value,{silent:!1})},setDifferentPassengers:function(n){var t;t=_.isString(n)?n=="true"?!0:!1:n;this.set("BookingSteps.PassengerDetails.DifferentGuestListOnHome",t);this.trigger("PassengerDetails:DifferentPassengers")},setVehicle:function(n,r,u,f){var e=this,h=this.getSelectedTripType(),l=_.omit(_.keys(this.get(this.path.PassengersVehicles)),h),c=this.getVehicle(u),a=c.SelectedVehicle&&c.SelectedVehicle.NoOf,o=t.extend(!0,{NoOf:a},n),v=o.Type,s=function(n,t){e.isDifferentPartySize()?e.set(n+"."+u+".SelectedVehicle",t,{silent:!0}):(e.set(n+".Out.SelectedVehicle",t,{silent:!0}),e.set(n+".Home.SelectedVehicle",t,{silent:!0}))};return s(this.path.PassengersVehiclesByTripType(h),o),_.each(l,function(n){var r=e.path.PassengersVehiclesByTripType(n),t=f&&f[n]&&f[n].NetVehiclesList||[],h=_.find(t,function(n){return n.Type===v}),u;h?s(r,o):(u=t.length===1?_.clone(t[0]):i,s(r,u))}),this.trigger("PassengersVehicles:PassengersVehiclesChanged"),this},setVehicleAmount:function(n,t,i){var r=this,u=_.keys(this.get(this.path.PassengersVehicles)),f=this.getVehicle(t),e=f.SelectedVehicle.Type;return _.each(u,function(u){var o=r.path.PassengersVehiclesByTripType(u),s=r.getVehicle(t,u),h=s&&s.SelectedVehicle||{},f;h.Type===e&&(f=h.BookMultiple?n:Math.min(n,1),i?r.isDifferentPartySize()?r.set(o+"."+t+".SelectedVehicle.NoOf",f,{silent:!0}):(r.set(o+".Out.SelectedVehicle.NoOf",f,{silent:!0}),r.set(o+".Home.SelectedVehicle.NoOf",f,{silent:!0})):r.isDifferentPartySize()?r.set(o+"."+t+".SelectedNoOfVehicle",f,{silent:!0}):(r.set(o+".Out.SelectedNoOfVehicle",f,{silent:!0}),r.set(o+".Home.SelectedNoOfVehicle",f,{silent:!0})))}),this.trigger("PassengersVehicles:PassengersVehiclesChanged"),this},setTrailer:function(n,r,u){var f=this,s=this.getSelectedTripType(),c=_.omit(_.keys(this.get(this.path.PassengersVehicles)),s),h=n&&n.Type,l=this.getVehicleCode(r),e=function(n,t){if(f.isDifferentPartySize())f.set(n+"."+r+".SelectedTrailer",t,{silent:!0});else{var i={};i[n+".Out.SelectedTrailer"]=t;i[n+".Home.SelectedTrailer"]=t;i.LegsForCurrentAction=["Out","Home"];f.set(i,{silent:!0})}},a=this.getTrailerAmount(r)||0,o=n?t.extend(!0,{NoOf:a},n):n;return e(this.path.PassengersVehiclesByTripType(s),o),_.each(c,function(n){var t=f.path.PassengersVehiclesByTripType(n),r=h&&u&&u[n]&&_.find(u[n].NetTrailersList,function(n){return n.Type===h&&n.LeadVehicleType===l});o===null||r?e(t,o):e(t,i)}),this.trigger("PassengersVehicles:PassengersVehiclesChanged"),this},setTrailerAmount:function(n,t,i){var r=this,f=_.keys(this.get(this.path.PassengersVehicles)),u=this.getTrailer(t),e=u.SelectedTrailer&&u.SelectedTrailer.Type,o=this.getVehicleCode(t);return _.each(f,function(u){var f=r.path.PassengersVehiclesByTripType(u),s=r.getTrailer(t,u),h=s&&s.SelectedTrailer||{};h.Type===e&&h.LeadVehicleType===o&&(i?r.isDifferentPartySize()?r.set(f+"."+t+".SelectedTrailer.NoOf",n,{silent:!0}):(r.set(f+".Out.SelectedTrailer.NoOf",n,{silent:!0}),r.set(f+".Home.SelectedTrailer.NoOf",n,{silent:!0})):r.isDifferentPartySize()?r.set(f+"."+t+".SelectedNoOfTrailer",n,{silent:!0}):(r.set(f+".Out.SelectedNoOfTrailer",n,{silent:!0}),r.set(f+".Home.SelectedNoOfTrailer",n,{silent:!0})))}),this.trigger("PassengersVehicles:PassengersVehiclesChanged"),this},setCabinForGuest:function(n,t){this.set("BookingSteps.PassengerDetails.Legs."+t+".Guests."+n.$index+".Cabin.Category",n.Cabin.Category,{silent:!0});this.set("BookingSteps.PassengerDetails.Legs."+t+".Guests."+n.$index+".Cabin.InstanceNo",n.Cabin.InstanceNo,{silent:!0})},triggerPassengerVehicleChanged:function(i){if(this.getActiveStep()!="FindAndBook"){var r=this;i=i||{};_utils.isBelowTabletResponsiveMode()&&(r.getAmountOfPassengers("Out")<1?t("#m_10_continue").parent().hide():t("#m_10_continue").parent().show());i.loader=n.$body.find(".m_total_price._03");i.onSuccess=function(n,t){t&&t.UiLayer&&t.UiLayer.RouteDateByTripType[r.attributes.TripType]?r.trigger("PassengersVehicles.PassengerVehiclesValidated",t.UiLayer.RouteDateByTripType[r.attributes.TripType].IsOfferCodeSecured):r.trigger("PassengersVehicles.PassengerVehiclesValidated")};this.setStepAndCurrentAction("PassengersVehiclesByTripType","PassengersVehiclesChanged").syncModel(this.attributes,i)}},setPriorityBoardingAmount:function(){var t=this,r="PRIOBOARD",i=t.getSailingsFaresObj();i&&_.each(i.Legs,function(i){var f=n.BookingModel.UiLayer.getOnboardExtras(i.LegName,r),u=t.getOnboardExtras(i.LegName),e,o;f&&u&&u.OnboardExtrasGroups&&u.OnboardExtrasGroups.length>0&&(e=_.flatten(_.pluck(_.flatten(_.pluck(f.OnboardExtrasHeaders,"OnboardExtrasGroups")),"OnboardExtrasItems")),o=_.flatten(_.pluck(u.OnboardExtrasGroups,"OnboardExtrasItems")),_.each(o,function(n){var r=_.find(e,function(t){return t.GenericId===n.GenericId});r&&(n.NoOf=_.reduce(_.pluck(_.filter(t.getCustomerCategories(i.LegName),function(n){return n.Code!=="INFANT"}),"NoOf"),function(n,t){return n+t},0))}))})},isDifferentPartySize:function(){var n=this.getSelectedTripType(),t=this.path.PassengersVehicles;return this.get(t+"."+n+".IsDifferentPartySize")},isDifferentPassengers:function(){return this.get("BookingSteps.PassengerDetails.DifferentGuestListOnHome")},isDiffentPartySizeInModel:function(){var f=this.getSelectedTripType(),n=this.path.PassengersVehiclesByTripType(f),t=this.get(n+".Out.CustomerCategories")||[],i=this.get(n+".Home.CustomerCategories")||[],r=[],u=[];return t.length!==i.length?!0:(_.each(t,function(n){r.push(n.Code,n.NoOf)}),_.each(i,function(n){u.push(n.Code,n.NoOf)}),_.difference(r,u).length>0)},isStaff:function(){return this.get("BookingSteps.PassengerDetails.PayingCustomer.StaffMember")},getIsDepartureTimePassed:function(n,t){return this.getSailingsFaresObj(t,n,"IsDepartureTimePassed")},hasMandatoryGuestList:function(n,t){return n?this.getSailingsFaresObj(t,n,"MandatoryGuestList"):{Out:this.getSailingsFaresObj(t,"Out","MandatoryGuestList"),Home:this.getSailingsFaresObj(t,"Home","MandatoryGuestList")}}}}(window.STENA=window.STENA||{},jQuery),function(n,t,i){n.ModelExtensions=n.ModelExtensions||{};n.ModelExtensions.sailings={getDeparture:function(n){return this.get(n+".DepartureSelection")},getRouteName:function(n){var t=this.get("ActiveStep");return this.get("BookingSteps."+t+"."+n+".RouteName")?this.get("BookingSteps."+t+"."+n+".RouteName"):this.getSailingsFaresObj(tripType,n,"RouteName")},getRouteCode:function(n,t){return t=t||this.getTripType(),this.getRouteDateObj(t,n,"RouteCode")},getRouteDate:function(n,t){return t=t||this.getTripType(),this.getRouteDateObj(t,n)||this.getRouteDateObj(t,n,"Legs")},getDepartureDate:function(n,t){return this.getRouteDateObj(t,n,"FullDate")},getDepartureIsoDate:function(n,t){var r=function(n){var t=/(\d{4})-(\d{2})-(\d{2})/.exec(n);return t?new Date(t[1],t[2]-1,t[3]):null},i=this.getRouteDateObj(t,n,"IsoDate");return i?r(i):new Date(0,1.1)},getDepartureProduct:function(n,t){return n?this.getSailingsFaresObj(t,n):{Out:this.getSailingsFaresObj(t,"Out"),Home:this.getSailingsFaresObj(t,"Home")}},getIsBothLegsSelected:function(n){var t=this.getSailingsFaresObj(n,"Out","Product"),i=this.getSailingsFaresObj(n,"Home","Product");return t&&!_.isEmpty(t.UniqueCellId)&&i&&!_.isEmpty(i.UniqueCellId)},getIsAnyLegSelected:function(n){var t=this.getSailingsFaresObj(n,"Out","Product"),i=this.getSailingsFaresObj(n,"Home","Product");return t&&!_.isEmpty(t.UniqueCellId)||i&&!_.isEmpty(i.UniqueCellId)},getIsLegSelected:function(n,t){var i=this.getSailingsFaresObj(n,t,"Product");return i&&!_.isEmpty(i.UniqueCellId)},getSelectedTripType:function(t){return this.getIsSelectedOutOrHome(n.tripTypeEnum.Efp)?n.tripTypeEnum.Efp:this.getIsSelectedOutOrHome(n.tripTypeEnum.Daytrip)?n.tripTypeEnum.Daytrip:this.getIsSelectedOutOrHome(n.tripTypeEnum.Cruise)?n.tripTypeEnum.Cruise:this.getIsSelectedOutOrHome(n.tripTypeEnum.FerryAccommodation)?n.tripTypeEnum.FerryAccommodation:this.getIsSelectedOutOrHome(n.tripTypeEnum.SpecialOffer)?n.tripTypeEnum.SpecialOffer:this.getIsSelectedOutOrHome(n.tripTypeEnum.Transfer)?n.tripTypeEnum.Transfer:t===!0?"":this.getTripType()},restoreTripTypeToSelected:function(){this.setTripType(this.getSelectedTripType());var n=this.getIsOneWayForTripType(this.getSelectedTripType());n&&this.setPartySize(!1);this.set("OneWay",n,{silent:!0})},restoreTripTypeToCurrentTab:function(n){this.setTripType(n);var t=this.getIsOneWayForTripType(n);t&&this.setPartySize(!1);this.set("OneWay",t,{silent:!0})},setTripType:function(n){this.set("TripType",n)},getIsSelectedOut:function(n){var t=this.getSailingsFaresObj(n,"Out","Product");return t&&!_.isEmpty(t.UniqueCellId)},getIsSelectedOutOrHome:function(n){var i=this.getSailingsFaresObj(n,"Out","Product"),t;return i&&!_.isEmpty(i.UniqueCellId)?!0:(t=this.getSailingsFaresObj(n,"Home","Product"),t&&!_.isEmpty(t.UniqueCellId))},getIsOneWayForTripType:function(n){return _.isObject(this.getSailingsFaresObj(n))&&this.getSailingsFaresObj(n).OneWay},getIsCruise:function(){return this.get("TripType")===n.tripTypeEnum.Cruise},getIsCruiseRoundTrip:function(){var t=this.getSailingsFaresObj(n.tripTypeEnum.Cruise);return this.getIsCruise()&&t&&t.IsRoundTrip},getIsCabinMandatory:function(n){var t=this.getDepartureProduct(n);return t&&t.Product&&t.Product.MandatoryCabin==="YES"},setAsOneWay:function(){return this.resetDirection(),this.setPartySize(!1),this.setOneWayForTripType(this.getTripType(),!0),this.set("OneWay",!0,{silent:!0}),this.trigger("FindAndBook:OnewayReturn"),this},setAsReturn:function(){return this.resetDirection(),this.setOneWayForTripType(this.getTripType(),!1),this.set("OneWay",!1,{silent:!0}),this.trigger("FindAndBook:OnewayReturn"),this},setDayMonthView:function(n,t,i){var r={};r[this.getRouteDatePath(t,i,"DayMonthView")]=n;this.set(r,{silent:!0})},setDepartureDate:function(n,i,r,u){var s=this,f=t.extend(!0,{},this.getRouteDate(i,u)),e=_utils.getDateObj(n),o=n.toString().split(" ");r=r||"PreferredDate";f.Day=e.day;f.FullDate=o[0]+" "+o[2]+" "+o[1]+" "+o[3];f.Month=e.month;f.Weekday=o[0];f.YearMonth=e.year+"-"+e.month;f.IsoDate=e.year+"-"+e.month+"-"+e.day;this.setCurrentAction(r,i);this.set(this.getRouteDatePath(u,i),f,{silent:!0});this.trigger(this.getActiveStep()+":"+r)},setRoute:function(n,t,i,r,u){r=r||"PreferredRoute";var f={};f[this.getRouteDatePath(u,i,"RouteName")]=t;f[this.getRouteDatePath(u,i,"RouteCode")]=n;this.set(f,{silent:!0});this.trigger(this.getActiveStep()+":"+r)},setOneWayForTripType:function(n,t){var i={};_.isObject(this.getSailingsFaresObj(n))&&(i[this.getSailingsFaresPath(n)+".OneWay"]=t,this.set(i,{silent:!0}))},setTransferDestination:function(t,r,u,f,e,o){var c;e=e||"PreferredRoute";c=2;u=="Out"&&(c=1);var h=n.BookingModel.UiLayer.getTransferDestination(o,t,r,c),s={},l=this.getIsOneWayForTripType(this.getSelectedTripType());h!==i&&(f==="ToFerry"&&(u==="Out"&&(s[this.getRouteDatePath(o,u,"RouteCode")]=h.FerryRouteCode,l||(s[this.getRouteDatePath(o,"Home","RouteCode")]=n.BookingModel.UiLayer.getOppositeRoute(h.FerryRouteCode,o).RouteCode)),u==="Home"&&(s[this.getRouteDatePath(o,u,"RouteCode")]=h.FerryRouteCode),s[this.getRouteDatePath(o,u,"TransferRouteCodeToFerry")]=t,s[this.getRouteDatePath(o,u,"DestinationDescriptionTextToFerry")]=h.DestinationDescriptionText,s[this.getRouteDatePath(o,u,"OpenTransferDepartureIdToFerry")]=h.OpenTransferDepartureId),f==="FromFerry"&&(s[this.getRouteDatePath(o,u,"TransferRouteCodeFromFerry")]=t,s[this.getRouteDatePath(o,u,"DestinationDescriptionTextFromFerry")]=h.DestinationDescriptionText,s[this.getRouteDatePath(o,u,"OpenTransferDepartureIdFromFerry")]=h.OpenTransferDepartureId));this.set(s,{silent:!0});this.setCurrentAction(e,u);this.trigger(this.getActiveStep()+":"+e)},setDepartureProduct:function(i,r,u,f){var s=u===n.tripTypeEnum.Daytrip||u===n.tripTypeEnum.Cruise||u===n.tripTypeEnum.Transfer&&!this.getIsOneWay()||u===n.tripTypeEnum.SpecialOffer&&!this.getIsOneWay(),c=r==="Out",e,o,h;s&&(c&&!f?(this.setPreviousDepartureIdAndProduct("Home",u),this.clearHomeLeg(u)):(e=this.get("LegsForCurrentAction")||[],t.inArray("Out",e)===-1&&(e.push("Out"),this.set("LegsForCurrentAction",e))));o=s&&r=="Out"?"HomewardSailings":"ProductSelection";h=s?"Home":r;this.setPreviousDepartureIdAndProduct(r,u);this.set(i,{silent:!0});this.resetDirection(h);this.setCurrentAction(o,h);e=this.get("LegsForCurrentAction")||[];o==="HomewardSailings"&&t.inArray("Out",e)>=0&&this.set("LegsForCurrentAction",["Home"]);this.removeDepartureProductsFromOtherTripTypes(u,"Out");this.removeDepartureProductsFromOtherTripTypes(u,"Home");this.trigger("SailingsFaresByTripType:"+o)},updateDepartureProduct:function(n){this.set(n,{silent:!0})},setPreviousDepartureIdAndProduct:function(n,t){var i=this.getSailingsFaresObj(t,n);i&&i.Product&&!_.isEmpty(i.Product.UniqueCellId)&&(this.set("PreviousDepartureId"+n,i.DepartureId,{silent:!0}),this.set("PreviousProductCode"+n,i.Product.Code,{silent:!0}),this.set("PreviousFerryCode"+n,i.FerryCode,{silent:!0}))},removeDepartureProductsFromOtherTripTypes:function(t,i){var r=this;_.each(_.values(n.tripTypeEnum),function(n){if(n!==t){var u=r.getSailingsFaresObj(n,i);u&&u.Product&&!_.isEmpty(u.Product.UniqueCellId)&&(r.set("PreviousDepartureId"+i,u.DepartureId,{silent:!0}),r.set("PreviousProductCode"+i,u.Product.Code,{silent:!0}),r.set("PreviousFerryCode"+i,u.FerryCode,{silent:!0}),r.set(r.getSailingsFaresPath(n,i,"Product"),{},{silent:!0}),r.set(r.getSailingsFaresPath(n,i,"DepartureDateStr"),{},{silent:!0}),r.trigger("RemoveDepartureProduct."+n+":"+i))}})},setLaterEarlierSailings:function(n,t,i){var r=this.getTripType(),e=i.getRouteDate(t,r),u={},f;return u[this.getRouteDatePath(r,t,"EarliestSearchDate")]=e.EarliestSearchDate,u[this.getRouteDatePath(r,t,"EarliestSearchTime")]=e.EarliestSearchTime,u[this.getRouteDatePath(r,t,"LatestSearchDate")]=e.LatestSearchDate,u[this.getRouteDatePath(r,t,"LatestSearchTime")]=e.LatestSearchTime,this.set(u,{silent:!0}),f=null,n&&(n==="earlier"?f="PreviousSailings":n==="later"&&(f="LaterSailings")),this.set("CurrentAction",f,{silent:!0}),this.set("LegsForCurrentAction",[t],{silent:!0}),this.trigger(this.getActiveStep()+":"+f),this},updateLaterEarlierSailingsDate:function(n,t,i){var r;n&&(n==="earlier"?r=i.getRouteDate(t).EarliestSearchDate:n==="later"&&(r=i.getRouteDate(t).LatestSearchDate),this.setDepartureDate(r,t,"PreferredDate"))},checkDepartureSelection:function(n){n=n||this.getTripType();var t=this.getSailingsFaresObj(n,"Out"),i=this.getSailingsFaresObj(n,"Home");return t&&i?!0:!1},clearHomeLeg:function(n){n=n||this.getTripType();this.unset(this.path.SailingsFares+"."+n+".Legs.Home")}}}(window.STENA=window.STENA||{},jQuery),function(n){n.ModelExtensions=n.ModelExtensions||{};n.ModelExtensions.products={getArrangements:function(){return this.get(this.path.DestinationDeals+".Arrangements")||[]},getCabins:function(n){return this.get(this.path.Cabins+"."+n+".Cabins")||[]},getSelectedCabin:function(n){return this.get(this.path.Cabins+"."+n+".CabinFoldedOut")},getOnboardExtras:function(n){return this.get(this.path.OnboardExtra+"."+n)||[]},getAllSpecifiedCabins:function(n){var i=this.getCabins(n),t=[];return _.each(i,function(n){t=_.union(t,n.SelectedCabinNumbers)}),t},isArrangementInBooking:function(n){var t=function(n,t){return t=t||"Id",function(i){return i[t]===n[t]}},f=this.getArrangements(),r=_.first(n.ArrangementSubtypes),e=_.first(r.ArrangementSubtypeScls),u=_(f).find(t(n)),i;return u&&(i=_(u.ArrangementSubtypes).find(t(r,"GenericId")),i)?_(i.ArrangementSubtypeScls).find(t(e)):!1},setArrangement:function(n){var t,e,o,s,h,c;if(n){var a=["GenericId","NoOf"],v=["GenericId","ArrangementSubtypeScls"],f=this.getArrangements(),l=_.chain(n.ArrangementSubtypes).first().pick(v).value(),i=_.chain(l.ArrangementSubtypeScls).first().pick(a).value(),u=function(n,t){return t=t||"Id",function(i){return i[t]===n[t]}},r=_(f).find(u(n));if(r)if(t=_(r.ArrangementSubtypes).find(u(l,"GenericId")),t)if(e=_(t.ArrangementSubtypeScls).find(u(i,"GenericId")),e)i.NoOf==="0"?(t.ArrangementSubtypeScls=_(t.ArrangementSubtypeScls).reject(u(e,"GenericId")),t.ArrangementSubtypeScls.length===0&&(r.ArrangementSubtypes=_(r.ArrangementSubtypes).reject(u(t,"GenericId"))),r.ArrangementSubtypes.length===0&&(f=_(f).reject(u(r)))):e.NoOf=i.NoOf;else{if(i.NoOf==="0")return;t.ArrangementSubtypeScls.push(i)}else{if(i.NoOf==="0")return;r.ArrangementSubtypes.push(l)}else{if(i.NoOf==="0")return;o=_(n).pick(["Id","Code","ProductElementId","ArrangementSubtypes"]);h=[];_.each(o.ArrangementSubtypes,function(n){s=_.pick(n,v);s.ArrangementSubtypeScls=[];c=[];_.each(n.ArrangementSubtypeScls,function(n){c.push(_.pick(n,a))});s.ArrangementSubtypeScls=c;h.push(s)});o.ArrangementSubtypes=h;f.push(o)}this.set(this.path.DestinationDeals+".Arrangements",f,{silent:!0});this.trigger("DestinationDeals:SelectArrangement")}},setCabins:function(n,t,i){var r=_.pick(n,["Description","GenericId","GeneralGenericId","SaleUnitDefinitionStr","Category","CategoryGroup","ReservationRuleStr","NoOf","DepartureFerryCabinVersion","PartOfPlus","Arrangements","NPrice","NoOfBerths"]),e=function(n,t){return t=t||"Id",function(i){return i[t]===n[t]}},u,f;if(this.resetDirection(t),r.Arrangements=[],u=this.getCabins(t),f=_(u).find(e(r,i)),f)r.NoOf==="0"?u=_(u).reject(e(r,i)):f.NoOf=r.NoOf;else{if(r.NoOf==="0")return;u.push(r)}this.storeCabinSelection(u,t);this.set(this.path.Cabins+"."+t+".Cabins",u,{silent:!0});this.trigger("Cabins:SelectCabin");this.trigger("Cabins:SelectCabin-"+n.GenericId,{noOf:n.NoOf})},setCabinArrangement:function(n,t){var e=function(n,t){return t=t||"Id",function(i){return i[t]===n[t]}},r,i,u,f;if(this.resetDirection(t),r=this.getCabins(t),i=_(r).find(function(t){return t.GenericId===n.CabinId}),i){if(u=_(i.Arrangements).find(e(n,"AstId")),f=i.Arrangements,u)n.NoOf==="0"?i.Arrangements=_(f).reject(e(n,"AstId")):u.NoOf=n.NoOf;else{if(n.NoOf==="0")return;f.push(_.pick(n,["AstId","AstGenericId","GeneralGenericId","Id","NoOf","Description","ReservationRuleStr","AddedBecauseIncluded","NPrice"]))}this.storeCabinArrangementSelection(i,i.Arrangements,t);this.set(this.path.Cabins+"."+t+".Cabins",r,{silent:!0});this.trigger("Cabins:SelectCabinArrangements")}},setOnboardExtraRoomArrangement:function(n,t){var r,u,i,f,e;this.resetDirection(t);r=this.getOnboardExtras(t);r.OnboardExtrasGroups||(this.attributes.BookingSteps.OnboardExtra.Legs[t]={LegName:t,OnboardExtrasGroups:[],ShouldUpdateSelf:!0},r=this.getOnboardExtras(t));u=_.find(r.OnboardExtrasGroups,this.match(n,"GenericId"));i=_.chain(n.OnboardExtrasItems).first().pick(["ArrId","ArrSequenceId","ReservationRuleStr","ArrDescription","PartOfPlus","GenericId","GeneralGenericId","AstId","Description","SaleUnitDefinitionStr","NoOf","AddedBecauseIncluded","NPrice","ArrangementCode","Code"]).value();i.AstGeneralCode=i.Code;f=_.pick(n,["CapacityUnitDefinitionStr","Description","Version","Category","Code","GenericId","ArrId","GroupType"]);f.OnboardExtrasItems=[i];u?(e=_.find(u.OnboardExtrasItems,function(n){return n.GenericId===i.GenericId}),e?i.NoOf==="0"?(u.OnboardExtrasItems=_.reject(u.OnboardExtrasItems,this.match(i,"GenericId")),u.OnboardExtrasItems.length===0&&(r.OnboardExtrasGroups=_.reject(r.OnboardExtrasGroups,this.match(n,"GenericId")))):e.NoOf=i.NoOf:i.NoOf!=="0"&&u.OnboardExtrasItems.push(i)):i.NoOf!=="0"&&r.OnboardExtrasGroups.push(f);this.storeOnboardExtraSelection(r.OnboardExtrasGroups,t);this.trigger("OnboardExtra:SelectArrangement")},setCabinForArrangements:function(n,t){var i=_.pick(n,["Description","GenericId","GeneralGenericId","SaleUnitDefinitionStr","Category","CategoryGroup","ReservationRuleStr","NoOf","DepartureFerryCabinVersion","PartOfPlus","NoOfBerths"]);this.resetDirection(t);this.set(this.path.Cabins+"."+t+".CabinFoldedOut",i,{silent:!0})},setCabinsForCruiseArrangements:function(n){var t=this,i=["Description","GenericId","GeneralGenericId","SaleUnitDefinitionStr","Category","CategoryGroup","ReservationRuleStr","NoOf","DepartureFerryCabinVersion","PartOfPlus","NoOfBerths"];n=_.map(n,function(n){return _.pick(n,i)});_.each(["Out","Home"],function(i){t.set(t.path.Cabins+"."+i+".CabinFoldedOut",n.shift(),{silent:!0})})},setCabinCategoryForMapData:function(n,t){this.set(this.path.Cabins+"."+t+".CabinMapCategory",n,{silent:!0})},setSelectedCabinNumbers:function(n,t,i,r){this.resetDirection(t);var f=this.getCabins(t),u=_(f).find(function(n){return n.GenericId===i});u&&(u.SelectedCabinNumbers=n,this.set(this.path.Cabins+"."+t+".Cabins",f,{silent:!0}),r||this.trigger("Cabins:SelectSpecificCabin-"+i,{noOf:u.NoOf}))},setUpSellingItem:function(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d){var nt="BookingSteps.PaymentDetails.UpSelling."+v+"."+y+".UpSellItems",tt={ID1:t,ID2:i,ID3:r,ID4:u,ID5:f,ID6:e,SaleUnitDefinition:o,ReservationRule:s,ExtendedInfo1:h,ExtendedInfo2:c,Title:l,Type:a,SloopType:v,LegName:y,Code:p,Version:w,Selected:b,ObjectData:k,BookingLayer:d},g=this.get(nt)||[];g.length===0&&this.set(nt,g);g.push(tt)},setOfferCode:function(n){this.set("CmsContext.OfferCode",n);this.trigger(this.getActiveStep()+":PreferredRouteDate")},setOfferCodeSecurityId:function(n){this.set("CmsContext.OfferCodeSecurityId",n)},setIsResponsive:function(n){this.set("CmsContext.IsResponsive",n)},match:function(n,t){return t=t||"Id",function(i){return i[t]===n[t]}},storeCabinSelection:function(n,t){var u,r,i;Modernizr.localstorage&&(u=window.localStorage.getItem("storedProduct"+t),u&&(n.length===0?(window.localStorage.removeItem("storedCabins"+t),window.localStorage.removeItem("storedArrangements"+t)):(r=_.map(n,function(n){return _.pick(n,["GenericId","NoOf"])}),window.localStorage.setItem("storedCabins"+t,JSON.stringify(r)),i=JSON.parse(window.localStorage.getItem("storedArrangements"+t)),i&&(i=_.filter(i,function(n){return _.find(r,function(t){return t.GenericId===n.CabinId})}),i.length===0?window.localStorage.removeItem("storedArrangements"+t):window.localStorage.setItem("storedArrangements"+t,JSON.stringify(i))))))},storeCabinArrangementSelection:function(n,t,i){var f,e,r,u;Modernizr.localstorage&&(f=JSON.parse(window.localStorage.getItem("storedCabins"+i)),e=_.find(f,function(t){return t.GenericId===n.GenericId}),e&&(r=_.map(t,function(n){return _.pick(n,["AstGenericId","NoOf"])}),_.each(r,function(t){t.CabinId=n.GenericId}),u=JSON.parse(window.localStorage.getItem("storedArrangements"+i)),u&&(r=_.union(_.filter(u,function(t){return t.CabinId!==n.GenericId}),r)),window.localStorage.setItem("storedArrangements"+i,JSON.stringify(r))))},storeOnboardExtraSelection:function(n,t){if(Modernizr.localstorage){var i=_.flatten(_.map(n,function(n){var t=_.map(n.OnboardExtrasItems,function(n){return _.pick(n,["GenericId","NoOf"])});return _.each(t,function(t){_.extend(t,{GrpGenericId:n.GenericId})}),t}));window.localStorage.setItem("storedOnboardExtra"+t,JSON.stringify(i))}}}}(window.STENA=window.STENA||{},jQuery),function(n){n.BookingLayerModel=n.MasterModel.extend({init:function(){var t=this;if(this.validations=n.ModelExtensions.validations,_.extend(this,n.ModelExtensions.sync),_.extend(this,n.ModelExtensions.misc),_.extend(this,n.ModelExtensions.passengers),_.extend(this,n.ModelExtensions.payment),_.extend(this,n.ModelExtensions.ancillary),_.extend(this,n.ModelExtensions.sailings),_.extend(this,n.ModelExtensions.products),_.extend(this,n.ModelExtensions.trackers),n.usingSessionStorage||n.useSessionStorageWithSession)this.on("update",function(){this.isUpdatingVersion||t.saveLayerToSessionStorage(this)});_.isFunction(this.setupPaymentEventListener)&&this.setupPaymentEventListener()},initSet:function(t){var i=this;this.commonSetup(t);this.set("LegsForCurrentAction",[]);n.doInitCallOnLoad===!0?this.syncModel(this.attributes,{syncInterval:200}):this.get("inSync")===!1?this.syncModel(this.attributes,{cancelAll:!0,onSuccess:function(){n.$body.removeClass("loading")}}):n.$body.removeClass("loading");this.bookingStepNames={};_.each(this.get("BookingSteps"),function(n,t){i.bookingStepNames[t]=!0});this.set("CmsContext.IsResponsive",_utils.isInPhoneResponsiveMode())},validateThis:function(n,t){var i=this,r=[];return n=_.isArray(n)?n:[n],_.each(n,function(n){var u=i.validations[n]?i.validations[n].apply(i,[t]):!0;(_.isObject(u)&&_.isString(u.Message)||_.isString(u)||u===!1)&&r.push(u)}),r.length>0?r:!0},getReservationCode:function(){return this.get("ReservationCode")},getPriceSpecification:function(){return this.get("PriceSpecification.PriceSpecificationItems")}})}(window.STENA=window.STENA||{},jQuery),function(n){n.userLayerModel=Backbone.Model.extend({urlGet:"/services/LoginService.ashx",urlPost:"/services/LoginService.ashx",url:"/services/LoginService.ashx",id:"userModel",init:function(){var n=this},save:function(n,t){return this.url=this.urlPost,Backbone.Model.prototype.save.call(this,n,t)},fetch:function(n){return this.url=this.urlGet,Backbone.Model.prototype.fetch.call(this,n)},getUserModel:function(n){var t=this;return t.url=t.urlGet,this.fetched?n.onSuccess&&n.onSuccess():this.fetch({success:function(){t.fetched=!0;n.onSuccess&&n.onSuccess()},error:function(){n.onError&&n.onError()}}),this},getValue:function(n,t){return t=this.get(n),t?this.get(n):"Key does not exist"},getCredentials:function(n,t){return n==!0?{GetForgotPasswordAgentId:this.get("GetForgotPasswordAgentId"),AgentPartId:this.get("AgentPartId"),LogOutReturnUrl:location.href}:t==!0?{GetForgotPasswordAgentUser:this.get("GetForgotPasswordAgentUser"),Email:this.get("Email"),LogOutReturnUrl:location.href}:{Email:this.get("Email"),Password:this.get("Password"),RememberMe:this.get("RememberMe"),BookingReference:this.get("BookingReference"),GetForgotPasswordEmail:this.get("GetForgotPasswordEmail"),BookingRefEmail:this.get("BookingRefEmail"),LogOutReturnUrl:location.href}},setValue:function(n,t){return _.isObject(n)?this.set(n,{silent:!0}):this.set(n,t,{silent:!0}),this},logout:function(){this.set("LoggedIn",!1,{silent:!0})},isLoggedIn:function(){return this.get("LoggedIn")}})}(window.STENA=window.STENA||{},jQuery),function(n){n.AmendmentDataModel=Backbone.Model.extend({initialize:function(n,t){var i=this,r,u,f;if(this.options=t||{},this.id=t.email?t.reservationCode+"&"+t.email:t.reservationCode,r=0,t.balancetopay&&(r=t.balancetopay),u="/book/amendment/AmendCancelInformation?reservationNo="+t.reservationCode+"&language="+t.language+"&balancetopay="+r,t.email||t.encryptedEmail?(f=t.encryptedEmail?"&encryptedEmail="+t.encryptedEmail:"&email="+encodeURIComponent(t.email),this.url=u+f,t.encryptedEmail?this.set("EncryptedEmail",t.encryptedEmail,{silent:!0}):this.set("Email",t.email,{silent:!0})):this.url=u,this.fetched){if(t.onSuccess)t.onSuccess(this)}else this.fetch({success:function(){if(i.fetched=!0,i.setURLs(),t.onSuccess)t.onSuccess(i)},error:function(){t.onError&&t.onError();i.set("ErrorMessage",i.fallbackMessage)}});return this},fallbackMessage:"Something went wrong. Please try again later!",getError:function(){return this.get("ErrorMessage")?_.pick(this.attributes,"ErrorMessage"):!1},getEmail:function(){return this.get("Email")},getBookingOptions:function(){return this.getError()?{HasError:!0}:_.pick(this.attributes,"CanAutoRefund","CanCancel","CanEdit","CanCheckIn","CanRefund","CanView","CanAutoRefundInfo","CanAutoRefundInfoCancel","CanPay")},getData:function(){return this.attributes},isCancelled:function(){return this.get("IsCancelled")},isCheckedIn:function(){return this.get("IsCheckedIn")},setURLs:function(){var n="/book/Amendment?SalesOwner="+this.options.salesOwner+"&ResCode="+this.options.reservationCode+"&lang="+this.options.language;return this.options.email?n=n+"&anonymousUserEmail="+this.options.email:this.options.encryptedEmail&&(n=n+"&uid="+this.options.encryptedEmail),n=n+"&activeStep=",this.set({SailingsFaresURL:n+"SailingsFaresByTripType",PassengersVehiclesURL:n+"PassengersVehicles",CabinsURL:n+"Cabins",OnboardExtraURL:n+"OnboardExtra",DestinationDealsURL:n+"DestinationDeals",PassengerDetailsURL:n+"PassengerDetails",PayAndConfirmURL:n+"PayAndConfirm",PayReservationURL:n+"PayReservation"},{silent:!0}),this},cancel:function(n){var t=this,i;return n=n||{},this._orginalUrl=this.url,i="/book/amendment/CancelReservation?reservationNo="+this.options.reservationCode+"&language="+this.options.language+"&anonymousLogin=true",this.url=this.options.email?i+"&email="+this.options.email:i,this.fetch({error:function(){t.set("ErrorMessage",t.fallbackMessage)},complete:function(){t.url=t._originalUrl;n.onComplete&&n.onComplete()}})},checkin:function(n){var t=this,i;return n=n||{},this._orginalUrl=this.url,i="/book/checkin?reservationNo="+this.options.reservationCode+"&language="+this.options.language+"&departureId="+n.departureId,this.url=i,this.fetch({error:function(){t.set("ErrorMessage",t.fallbackMessage)},complete:function(){t.url=t._originalUrl;n.onComplete&&n.onComplete()}})},sendEmail:function(n){var t=this,i;return n=n||{},this._orginalUrl=this.url,i="/book/amendment/SendEmail?reservationNo="+this.options.reservationCode+"&language="+this.options.language+"&email="+n.emailAddress,this.url=i,this.fetch({error:function(){t.set("ErrorMessage",t.fallbackMessage)},complete:function(){t.url=t._originalUrl;n.onComplete&&n.onComplete()}})}})}(window.STENA=window.STENA||{},jQuery),function(n){n.mapRouteLayerModel=Backbone.Model.extend({initialize:function(){}})}(window.STENA=window.STENA||{},jQuery),function(n){n.mapRouteLayerCollection=Backbone.Collection.extend({model:n.mapRouteLayerModel,url:"/services/RouteMapService.ashx",getMapRouteCollection:function(n){var t=this;return this.fetched?n.onSuccess&&n.onSuccess():this.fetch({success:function(){t.fetched=!0;n.onSuccess&&n.onSuccess()},error:function(){n.onError&&n.onError()}}),this}})}(window.STENA=window.STENA||{},jQuery),function(n){n.AmendmentDataCollection=Backbone.Collection.extend({addModel:function(t){var i=this.find(function(n){return t.email?n.id===t.reservationCode+"&"+t.email:n.id===t.reservationCode}),r,u;return i&&this.remove(i),r=t.onSuccess,u=_.extend(t,{onSuccess:function(n){r(n)}}),this.add(new n.AmendmentDataModel({},u)),i}})}(window.STENA=window.STENA||{},jQuery)