var myApp=angular.module("rmApp",["ngAnimate","ngCookies","ngRoute","services","GBCHDirective","rmCommerceController","rmCheckout","rmTransactionHistory","rmSearchController","rmLoginController","rmAccountStatementController","rmCustomerServiceController","rmSIPPSSASAdminController","rmHistoricMetalPriceChartController","rmRegistrationController","rmFooterSignUp","rmCategoryListing","rmMessagesModal","cookieController","breakpointApp","responsiveUtilities","slickCarousel","rmPasswordStrength","rmSovereignCertificateSignUp","rmPasswordChangeController","rmChangeLoginDetailsController","rmContactPreferencesController","rmArticleListingController","gbchSearchCoinModule","rmRmgController"]),services,rmDirectivesApp,rmCommerceController,rmCheckout,searchController,rmCategoryListingController,rmgController,rmCookieController,loginController,rmAccountStatementController,registrationController,contactPreferencesController,rmMessagesController,rmFooterSignUpController,rmSovereignCertificateSignUpController,passwordChangeController,breakpointApp,responsiveUtility,rmTransactionHistory,rmArticleListing,rmHistoricMetalPriceChartController,rmCustomerServiceController,rmSIPPSSASAdminController,changeLoginDetailsController;myApp.run(["$http",function(n){var t=angular.element('input[name="__RequestVerificationToken"]')[0];t&&(n.defaults.headers.common["X-XSRF-Token"]=t.value);n.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}]);myApp.factory("httpRequestInterceptor",function(){return{responseError:function(n){var t=n.data.match("<title>(.*?)<\/title>");t!==null&&t.length>0}}});myApp.config(["$httpProvider",function(n){n.interceptors.push("httpRequestInterceptor")}]);services=angular.module("services",[]);services.factory("myService",["$http",function(n){return this.commerceController=null,{setCommerceCtrl:function(n){this.commerceController=n},getCommerceCtrl:function(){return this.commerceController},getFeed:function(t){var i=t.indexOf("?")===-1?"?":"&";return t=t+i+"noCache="+(new Date).getTime(),n.get(t).then(function(n){return n}).catch(function(){})},postData:function(t,i){var r=t.indexOf("?")===-1?"?":"&";return t=t+r+"noCache="+(new Date).getTime(),n.post(t,i).then(function(n){return n}).catch(function(){})},deleteData:function(t,i){var r=t.indexOf("?")===-1?"?":"&";return t=t+r+"noCache="+(new Date).getTime(),n.delete(t,i).then(function(n){return n}).catch(function(){})}}}]);services.factory("addressServices",["myService","$http",function(){var n={CapturePlusCallback:function(){},CapturePlusError:function(){},CapturePlusStartTyping:function(){}};return window.CapturePlusCallback=function(t,i){n.CapturePlusCallback(t,i)},window.CapturePlusStartTyping=function(t,i){n.CapturePlusStartTyping(t,i)},window.CapturePlusError=function(t,i){n.CapturePlusError(t,i)},n}]);services.factory("$localStorage",["$window",function(n){return{store:function(t,i){n.localStorage[t]=i},get:function(t,i){return n.localStorage[t]==null?null:n.localStorage[t]||i},storeObject:function(t,i){n.localStorage[t]=JSON.stringify(i)},getObject:function(t,i){return n.localStorage[t]==null?null:JSON.parse(n.localStorage[t]||i)}}}]);services.factory("errorHandler",["myService",function(){return{displayError:function(n,t,i,r,u,f){t.errorHandler.title=i;t.errorHandler.content=r;t.errorHandler.action=u;t.errorHandler.target=f;t.errorHandler.showTarget=f!=null&&f.length>0;switch(n){case 1:$("#rmMessagesModal").modal("show");break;case 2:$("#rmMessagesAlert").toggle("show")}switch(u){}},action:function(n,t){n&&t?n(t):t&&(window.location=t);$("#rmMessagesModal").modal("hide");return}}}]);services.factory("compareServices",["myService","$cookies",function(n,t){return{addToCompare:function(n){t.put("comparedProducts",n,{path:"/"})}}}]);services.filter("removeSpaces",[function(){return function(n){return angular.isString(n)?n.replace(/[\s]/g,""):n}}]);services.filter("makeSlug",[function(){return function(n){return angular.isString(n)?n.replace(/[\s]/g,"-"):n}}]);services.filter("titleCase",function(){return function(n){return n=n||"",n.replace(/\w\S*/g,function(n){return n.charAt(0).toUpperCase()+n.substr(1).toLowerCase()})}});services.filter("showStatus",function(){return function(n){switch(n){case 1:status="In Stock";break;case 2:status="Awaiting stock";break;case 3:status="Sourced to order";break;case 4:status="Limited Stock";break;case 5:status="Pre-order";break;case 6:status="No Longer Available";break;case 7:status="Sold out";break;default:status=""}return status}});services.filter("stockClass",function(){return function(n){switch(n){case 1:status="text-success";break;case 2:status="text-info";break;case 3:status="text-success";break;case 4:status="text-gold";break;case 5:status="text-gold";break;case 6:status="text-danger";break;case 7:status="text-danger";break;default:status=""}return status}}),function(){var n=function(){var n={CapturePlusCallback:function(){},CapturePlusError:function(){},CapturePlusStartTyping:function(){}};return window.CapturePlusCallback=function(t,i){n.CapturePlusCallback(t,i)},window.CapturePlusStartTyping=function(t,i){n.CapturePlusStartTyping(t,i)},window.CapturePlusError=function(t,i){n.CapturePlusError(t,i)},n};services.factory("pcAnywhereSvc",n)}();rmDirectivesApp=angular.module("rmDirectives",["services"]);rmDirectivesApp.directive("capitalize",function(){return{require:"ngModel",link:function(n,t,i,r){var u=function(n){var i,u;return n==undefined&&(n=""),i=n.trim().toUpperCase(),i!==n&&(u=t[0].selectionStart,r.$setViewValue(i),r.$render(),t[0].selectionStart=u,t[0].selectionEnd=u),i};r.$parsers.push(u);u(n[i.ngModel])}}});rmDirectivesApp.directive("postcodeValidator",["myService",function(n){var t;return{restrict:"A",require:"ngModel",scope:{postcodeValidator:"=",postcodeDisable:"="},link:function(i,r,u,f){function h(){f.$setViewValue("");f.$render()}function c(){f.$setViewValue("");f.$render()}function o(){h();s("")}function l(){}function s(n){$(r).attr("PlaceHolder",n)}function e(n){var u=!0,r,f;return i.postcodeDisable||(t?(r=t[i.postcodeValidator],r?(s(r.ShadowText),l(),r.SinglePostcode?c(r.PostcodePattern):n?(f=new RegExp(r.PostcodePattern,"i"),u=f.test(n)):u=!1):o()):o()),i.$parent.$parent.manualAddressPostcodeIsValid=u,n}function a(){n.getFeed("/mvcApi/postcodeValidator/Get").then(function(n){t=n.data;e(i[u.ngModel])})}f.$parsers.push(e);a();i.$watch("postcodeValidator",function(n,t){n!==t&&i.$parent.manualAddress&&e(i[u.ngModel])},!0);i.$watch("postcodeDisable",function(n,t){setTimeout(function(){n!==t&&i.$parent.manualAddress&&e(i[u.ngModel])},1e3)},!0)}}}]);rmDirectivesApp.directive("phonecharacter",function(){return{require:"ngModel",link:function(n,t,i,r){function u(n){if(n){var t=n.replace(/[^0-9)(+ -]/g,"").replace(/  +/g," ");return t!==n&&(r.$setViewValue(t),r.$render()),t}return undefined}r.$parsers.push(u)}}});rmDirectivesApp.directive("validateEmail",function(){var n=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return{require:"ngModel",link:function(t,i,r,u){u&&u.$validators.email&&(u.$validators.email=function(t){return u.$isEmpty(t)||(t=t.toLowerCase()),u.$isEmpty(t)||n.test(t)})}}});rmDirectivesApp.directive("floatingNumberOnly",function(){return{require:"ngModel",link:function(n,t,i,r){r.$parsers.push(function(n){var e=new RegExp("(^[0-9]{1,9})+(.[0-9]{1,4})?$","g"),f,t,o,u,i;return n==""?"":(f=/^[.]*$/,f.test(n))?(r.$setViewValue(""),r.$render(),""):(t=n.replace(/[^0-9.]/g,""),t!=n&&(r.$setViewValue(t),r.$render()),i=t.length,(o=e.test(t))?(u=t.split(".").length-1,u==0&&i>9&&(t=t.slice(0,i-1),r.$setViewValue(t),r.$render())):(u=t.split(".").length-1,i>0&&u>1&&(t=t.slice(0,i-1)),t.slice(t.indexOf(".")+1).length>4&&(t=t.slice(0,i-1)),r.$setViewValue(t),r.$render()),t)})}}});rmDirectivesApp.directive("inputNumberOnly",function(){return{require:"ngModel",link:function(n,t,i,r){r.$parsers.push(function(n){var i=new RegExp("(^[0-9]{1,9})?$","g"),t;return n==""?"":i.test(n)?(t=n.replace(/[^0-9]/g,""),t!=n&&(r.$setViewValue(t),r.$render()),t):(r.$setViewValue(""),r.$render(),"")})}}});rmDirectivesApp.directive("autoFocus",function(){return{restrict:"AE",replace:!1,scope:{},link:function(n,t,i){i.$observe("autoFocus",function(n){n==="true"&&setTimeout(function(){t.focus()},0)})}}});rmDirectivesApp.directive("compile",["$compile",function(n){return function(t,i,r){t.$watch(function(n){return n.$eval(r.compile)},function(r){i.html(r);n(i.contents())(t)})}}]);angular.module("GBCHDirective",[]).directive("ngEnter",function(){return{restrict:"A",link:function(n,t,i){t.bind("keypress",function(t){t.which===13&&(n.$apply(function(){n.$eval(i.ngEnter)}),t.preventDefault())})}}});rmCommerceController=angular.module("rmCommerceController",["services","ngCookies"]);rmCommerceController.factory("debounce",["$timeout","$q",function(n,t){return function(i,r,u){var f,e=t.defer();return function(){var o=this,s=arguments,h=function(){f=null;u||(e.resolve(i.apply(o,s)),e=t.defer())},c=u&&!f;return f&&n.cancel(f),f=n(h,r),c&&(e.resolve(i.apply(o,s)),e=t.defer()),e.promise}}}]);rmCommerceController.controller("rmCommerceController",["$scope","myService","errorHandler","$timeout","debounce",function(n,t,i,r,u){var e=this,f=n,s,o,h;e.validation=[];e.defaultShipment=[];e.deliveryBullionShipment=[];e.vaultBullionShipment=[];e.hasItemDeliveredToSpecifiedAddress=!1;e.hasItemDeliveredToInvestmentAddress=!1;e.hasItemToBeStored=!1;f.onlyNumbers=/^\d+$/;f.numberRegex=/^[1-9]\d*$/;f.changedItem=null;f.errorHandler=[];f.basketLoaded=!1;f.ageRestricted=!1;f.subTotalExVat="";f.unitPrice="";e.getShipmentForMixedBasket=function(){e.defaultShipment=e.shipments&&Array.isArray(e.shipments)?e.shipments.filter(function(n){return n.ShipmentUniqueId=="Default-1"}):[];e.deliveryBullionShipment=e.shipments&&Array.isArray(e.shipments)?e.shipments.filter(function(n){return n.ShipmentUniqueId=="BullionCart-Delivered"}):[];e.vaultBullionShipment=e.shipments&&Array.isArray(e.shipments)?e.shipments.filter(function(n){return n.ShipmentUniqueId=="BullionCart-Vaulted"}):[];e.hasItemDeliveredToSpecifiedAddress=e.defaultShipment&&e.defaultShipment.some(function(n){return n.CartItems&&n.CartItems.length>0});e.hasItemDeliveredToInvestmentAddress=e.deliveryBullionShipment&&e.deliveryBullionShipment.some(function(n){return n.CartItems&&n.CartItems.length>0});e.hasItemToBeStored=e.vaultBullionShipment&&e.vaultBullionShipment.some(function(n){return n.CartItems&&n.CartItems.length>0})};f.getBasketSummary=function(){f.basketLoaded||f.getBasket()};e.basketItemCount=-1;f.getBasketItemCount=function(){t.getFeed("/mvcapi/cart/GetCount").then(function(n){e.basketItemCount=n.data})};f.getBasket=function(){t.getFeed("/mvcapi/cart/Get").then(function(t){e.basket=t.data;e.shipments=e.basket.Shipments;e.getShipmentForMixedBasket();e.validation=e.basket.Validation;e.promotions=e.basket.Promotions;e.consumerPromotions=e.basket.ConsumerPromotions;e.bullionPromotions=e.basket.BullionPromotions;f.checkGiftingSessionTimeout(e.shipments);f.items=$(e.shipments).map(function(){return this.CartItems});f.basketLoaded=!0;n.someAgeRestricted();e.basketItemCount=t.data.ItemCount});f.onCountDown&&(f.coundowntimer=f.totalSeconds,f.countDown())};f.checkGiftingSessionTimeout=function(n){var r,t,u,i;if(typeof PrintzwareModal!="undefined"&&n!=undefined)for(r=0;r<n.length;r++)if(t=n[r],t.CartItems!=null&&t.CartItems!=undefined)for(u=0;u<t.CartItems.length;u++)i=t.CartItems[u],i.HasbeenPersonalised&&(i.isGiftingSesstionTimeout=!1,PrintzwareModal.isSessionTimeout(i.UniqueId)&&(i.isGiftingSesstionTimeout=!0))};f.getBasketAndSyncWithPamp=function(){t.getFeed("/mvcapi/cart/GetAndSyncWithPamp").then(function(t){console.log("sync with pamp: "+t.data.ValidForPayment);e.basket=t.data.Cart;e.shipments=e.basket.Shipments;e.getShipmentForMixedBasket();e.validation=e.basket.Validation;e.promotions=e.basket.Promotions;e.consumerPromotions=e.basket.ConsumerPromotions;e.bullionPromotions=e.basket.BullionPromotions;f.items=$(e.shipments).map(function(){return this.CartItems});f.basketLoaded=!0;n.someAgeRestricted();f.onCheckSyncWithPamp(t.data.IsSyncWithPampError,t.data.IsNotEnoughMoney,t.data.ValidForPayment);f.onCountDown&&!t.data.ShowInsufficientFunds&&(f.coundowntimer=f.totalSeconds,f.countDown())})};f.someAgeRestricted=function(){e.shipments&&e.shipments[0]&&e.shipments[0].CartItems&&(n.ageRestricted=e.shipments[0].CartItems.some(function(n){return n.IsAgeRestricted===!0}))};f.validateMarket=function(n){t.postData("/mvcapi/cart/ValidateForCountryCode?countryCode="+n).then(function(n){e.validation=n.data.Validation})};f.getUpdatedBasket=function(){t.getFeed("/mvcapi/cart/GetMini").then(function(n){e.basket.Total=n.data.Total;e.basket.TotalDiscount=n.data.TotalDiscount;e.basket.TotalDelivery=n.data.TotalDelivery;e.basket.SubTotal=n.data.SubTotal;e.basket.TotalWithoutRecuring=n.data.TotalWithoutRecuring;e.basket.ItemCount=n.data.ItemCount;e.basketItemCount=e.basket.ItemCount;e.basket.Modified=n.data.Modified;e.basket.Promotions=n.data.Promotions;e.basket.Shipments=n.data.Shipments;e.basket.RetailDeliveryTotal=n.data.RetailDeliveryTotal;e.basket.RetailDeliveryTotalWithoutDiscount=n.data.RetailDeliveryTotalWithoutDiscount;e.basket.RetailSubTotal=n.data.RetailSubTotal;e.basket.RetailDiscount=n.data.RetailDiscount;e.basket.RetailTotal=n.data.RetailTotal;e.basket.ConsumerSavedAmount=n.data.ConsumerSavedAmount;e.basket.ConsumerPromotions=n.data.ConsumerPromotions;e.basket.TotalInvestmentDelivery=n.data.TotalInvestmentDelivery;e.basket.InvestmentSubTotal=n.data.InvestmentSubTotal;e.basket.InvestmentTotal=n.data.InvestmentTotal;e.basket.InvestmentVat=n.data.InvestmentVat;e.basket.InvestmentVatWithoutDeliveryFee=n.data.InvestmentVatWithoutDeliveryFee;e.basket.BullionPromotions=n.data.BullionPromotions;e.basket.FullBasketTotalWithoutDeliveryFeeVat=n.data.FullBasketTotalWithoutDeliveryFeeVat;e.basket.FullBasketSubTotal=n.data.FullBasketSubTotal;e.basket.FullBasketTotal=n.data.FullBasketTotal;t.setCommerceCtrl(e);f.items=$(e.shipments).map(function(){return this.CartItems});e.basketSummary={Modified:e.basket.Modified};e.promotions=e.basket.Promotions;e.consumerPromotions=e.basket.ConsumerPromotions;e.bullionPromotions=e.basket.BullionPromotions;var i=n.data.Shipments;$.each(i,function(n,t){var r=$.grep(e.shipments,function(n){return n.ShipmentUniqueId===t.ShipmentUniqueId&&n.ShipmentId===t.ShipmentId}),i=r.length>0?r[0]:undefined;if(i){if(i.ShippingMethods=t.ShippingMethods,i.ShippingMethodId=t.ShippingMethodId,i.EstimatedStorageCost=t.EstimatedStorageCost,i.CartItems.length!=t.CartItems.length)return f.getBasket(),!1;$.each(i.CartItems,function(n,i){var r=t.CartItems[n];if(r==null)return f.getBasket(),!1;i.Code===r.Code&&i.UniqueId===r.UniqueId&&(i.DiscountedPrice=r.DiscountedPrice,i.Quantity=r.Quantity,i.Subscribed=r.Subscribed,i.PlacedPrice=r.PlacedPrice,i.StockSummary=r.StockSummary,i.DiscountedUnitPrice=r.DiscountedUnitPrice,i.RecurrenceType=r.RecurrenceType,i.BullionCartItem&&r.BullionCartItem&&(i.BullionCartItem.PricePerUnitString=r.BullionCartItem.PricePerUnitString))})}})})};f.$watch("items",function(n,t){s&&r.cancel(s);var i=[];$.each(n,function(n,r){t!==window.undefined&&t[n]!==window.undefined&&t[n].Code===r.Code&&t[n].Quantity!==r.Quantity&&(r.BullionCartItem&&r.BullionCartItem.IsSignatureVariant||i.push(r))});i.length>0&&(f.changedItem=i[0],s=r(f.sendQuantityUpdate,300))},!0);f.isValidToAdd=function(n){return!f.quantityToAdd||isNaN(f.quantityToAdd)?!1:(f.quantityToAdd=Math.round(f.quantityToAdd,0),f.quantityToAdd!==1&&(f.quantityToAdd>n.MaxQuantity||f.quantityToAdd<n.MinQuantity))?!1:!0};e.buildAddBasketParams=function(n,t){var i={code:n,quantity:f.quantityToAdd};return t&&(i.investmentAmount=t),$.param(i)};f.isHighLightQuantityBreak=function(n,t,i){return i&&f.quantityToAdd<=0?!0:t!=-1?f.quantityToAdd>=n&&f.quantityToAdd<t:f.quantityToAdd>=n};f.addToBasket=function(n,r,u){if($("#item_"+n.id).data("added")!==!0){var s=e.buildAddBasketParams(n.id,u),o="/mvcapi/cart/AddToCart?"+s;window.PWOrderId&&window.PWImageUrl&&(o=o+"&PWOrderId="+window.PWOrderId+"&PWImageUrl="+window.PWImageUrl);t.postData(o).then(function(t){if(t.data.Success){if(r!==window.undefined&&!!r){window.location=r;return}$("#item_"+n.id).text(t.data.Message).data("added",!0).attr("disabled",!0)}else i.displayError(1,f,t.data.Title,t.data.Message,null,null);f.getBasket()})}};f.quickCheckout=function(n,r,u){if($("#item_buynow_"+n.id).data("added")!==!0){var o=e.buildAddBasketParams(n.id,u);t.postData("/mvcapi/cart/BuyNow?"+o).then(function(t){if(t.data.Success){if(r!==window.undefined){window.location=r;return}$("#item_buynow_"+n.id).text(t.data.Message).data("added",!0)}else i.displayError(1,f,t.data.Title,t.data.Message,null,null)})}};f.changeSubscription=function(n){t.postData("/mvcapi/cart/UpdateItemSubscription?code="+n.Code+"&subscribe="+!n.Subscribed).then(function(n){n.data.Success||i.displayError(1,f,n.data.Title,n.data.Message,null,null);f.getUpdatedBasket()})};f.removeFromBasket=function(n,r,u){var e="",o="shipment="+n,s="&code="+r;e=o+s;u&&(e+="&PWOrderId="+u);t.postData("/mvcapi/cart/RemoveFromCart?"+e).then(function(n){n.data.Success||i.displayError(1,f,n.data.Title,n.data.Message,null,null);f.getBasket();f.checkBalance()})};f.updateQuantity=function(n,t){n.Quantity+=t};f.minQuantityAllow=1;f.maxQuantityAllow=999;f.timeToUpdateChange=1e3;f.currencySymbol=currencySymbol;f.quantityBreaks=typeof quantityBreaks!="undefined"?quantityBreaks:null;const c=u(function(t,i){if(quantityBreaks&&quantityBreaks.length>0){quantityBreaks=quantityBreaks.sort(function(n,t){return t.quantity-n.quantity});var u=quantityBreaks.filter(function(n){return n.quantity<=i}),r=u[0]||null;n.subTotalExVat=r?f.formatCurrency(r.price*i,",",".",f.currencySymbol):f.formatCurrency(n.singleUnitPrice*i,",",".",f.currencySymbol);n.unitPrice=r?f.formatCurrency(r.price,",",".",f.currencySymbol):f.formatCurrency(n.singleUnitPrice,",",".",f.currencySymbol)}else n.subTotalExVat=f.formatCurrency(n.singleUnitPrice*i,",",".",f.currencySymbol),n.unitPrice=f.formatCurrency(n.singleUnitPrice,",",".",f.currencySymbol)},f.timeToUpdateChange,!1);f.setupQuantity=function(n,t){n&&(f.minQuantityAllow=n);t&&(f.maxQuantityAllow=t)};f.updateBullionQuantity=function(t,i){if(i){if(n.numberRegex.test(i)){var r=parseInt(i);f.quantityToAdd=isNaN(r)?f.minQuantityAllow:r>f.maxQuantityAllow?f.maxQuantityAllow:r<f.minQuantityAllow?f.minQuantityAllow:r}else n.quantityToAdd=f.minQuantityAllow;c(t,f.quantityToAdd)}};f.formatCurrency=function(n,t,i,r){return n=n||0,t=t||",",i=i||".",r=r||"$",Number(n).toFixed(2).toString().split(/[-.]/).reverse().reduceRight(function(n,r,u){return u==2?"-"+n:u==1?n+r.replace(/(\d)(?=(\d{3})+$)/g,"$1"+t):n+i+r},r)};f.sendQuantityUpdate=function(){var r=f.changedItem,u="",e="shipment="+r.ShipmentId,o="&code="+r.Code,s="&quantity="+r.Quantity;u=e+o+s;r.UniqueId&&(u+="&PWOrderId="+r.UniqueId);t.postData("/mvcapi/cart/UpdateItemQuantity?"+u).then(function(n){f.changedItem=null;n.data.Success||i.displayError(1,f,n.data.Title,n.data.Message,null,null);f.getUpdatedBasket();f.checkBalance()});n.$broadcast("updateQuantity",{someProp:""})};f.quantityToAdd=1;f.basketSubtotal=0;e.basket={Total:0,Shipments:[],ItemCount:0};f.getBasketItemCount();e.couponCode="";f.addCoupon=function(n){e.couponCode!==""&&e.couponCode!==window.undefined&&t.postData("/mvcapi/cart/ApplyCoupon?couponCode="+e.couponCode+"&isBuynow="+(typeof n!="undefined"?n:!1)).then(function(t){t.data.Success?(e.couponCode="",n?e.onGetQuickcheckoutPromotions():f.getBasket()):i.displayError(1,f,t.data.Title,t.data.Message,null,null)})};e.quickCheckoutPromotions=[];e.onGetQuickcheckoutPromotions=function(){t.postData("/mvcApi/QuickCheckout/GetPromotions").then(function(n){e.quickCheckoutPromotions=n.data.Promotions})};f.removeCoupon=function(n,r){n!==""&&t.postData("/mvcapi/cart/RemoveCoupon?couponCode="+n+"&isBuynow="+(typeof r!="undefined"?r:!1)).then(function(n){n.data.Success||i.displayError(1,f,n.data.Title,n.data.Message,null,null);r?e.onGetQuickcheckoutPromotions():f.getBasket()})};f.changeShipment=function(n){n!==""&&t.postData("/mvcapi/cart/ChangeShipment?code="+n).then(function(n){n.data.Success||i.displayError(1,f,n.data.Title,n.data.Message,null,null);f.getBasket()})};f.beginEditInvestmentValue=function(n){if(n!==""){var t="#invest_input_"+n;$(t).find(".invest-amount1").hide();$(t).find(".invest-edit-btn").hide();$(t).find(".input1").show();$(t).find(".invest-save-btn").removeClass("hidden")}};f.editInvestmentValue=function(n){var u,r,o;n!==""&&((u="#invest_input_"+n,r=$(u).find(".invest-input").val(),isNaN(parseFloat(r)))||(o=e.buildAddBasketParams(n,parseFloat(r)),t.postData("/mvcapi/cart/AddToCart?"+o).then(function(n){n.data.Success?f.getBasket():i.displayError(1,f,n.data.Title,n.data.Message,null,null)})))};f.getUnitPrice=function(n){return n.BullionCartItem?n.BullionCartItem.PricePerUnitString:n.DiscountedUnitPrice!==""?n.DiscountedUnitPrice:n.PlacedPrice};f.getSubTotal=function(){return e.basket.FullBasketSubTotal};f.getTotalDiscount=function(){return e.basket.TotalDiscount};f.showTotalDiscount=function(){return!(e.basket.TotalDiscount===window.undefined||e.basket.TotalDiscount!=null&&e.basket.TotalDiscount.length===5&&e.basket.TotalDiscount.substr(-4)==="0.00")};f.getDeliveryTotal=function(){return e.basket.TotalDelivery};f.getTotalWithoutDeliveryFeeVat=function(){return e.basket.FullBasketTotalWithoutDeliveryFeeVat};f.getTotal=function(){return e.basket.FullBasketTotal};f.getBasketQty=function(){return e.basketItemCount};f.checkMultipleDelivery=function(){if(f.items===window.undefined)return!1;if(f.getBasketQty()>1){var n=$(f.items).map(function(){if(this.IsGift)return this});return n.length>0}return!1};f.basketLoading=function(){return!f.basketLoaded&&f.getBasketQty()<0};f.getTotalWithoutRecuring=function(){return e.basket.TotalWithoutRecuring};f.basketSubtotal=f.getSubTotal();f.basketDeliveryCharge=4.99;f.basketSavings=0;f.compare={items:[]};f.compare.limit=3;o=f.compare.items;f.toggleCompare=function(n,t,i){t.inCompare!=!0&&f.compare.items.length<f.compare.limit?f.addToCompare(n,t):t.inCompare==!0&&f.removeFromCompare(n,t);r(function(){calculatePopoverPosition(i.target)})};f.addToCompare=function(n,t){o.indexOf(t)===-1&&(o.push(t),t.inCompare=!0)};f.removeFromCompare=function(n,t){if(o){var i=o.indexOf(t);o.splice(i,1);t.inCompare=!1}};f.hovering=!1;h=null;f.toggleHover=function(t,i){t===!0?r(function(){r.cancel(h);n.hovering=!n.hovering;calculatePopoverPosition(i.target)},500):h=r(function(){n.hovering=!n.hovering;$(".comparePopover").css({bottom:-9999,left:-9999}).removeClass("open")},700)};f.loginUser=function(n){n.preventDefault();f.userLoggedIn=!0};f.logoutUser=function(n){n.preventDefault();f.userLoggedIn=!1};f.getRetailDeliveryTotal=function(){return e.basket.RetailDeliveryTotalWithoutDiscount};f.getRetailSubTotal=function(){return e.basket.RetailSubTotal};f.showRetailTotalDiscount=function(){return!(!e.basket.ConsumerSavedAmount||e.basket.ConsumerSavedAmount!=null&&e.basket.ConsumerSavedAmount.length===5&&e.basket.ConsumerSavedAmount.substr(-4)==="0.00")};f.showInvestmentTotalDiscount=function(){return!(!e.basket.BullionSavedAmount||e.basket.BullionSavedAmount!=null&&e.basket.BullionSavedAmount.length===5&&e.basket.BullionSavedAmount.substr(-4)==="0.00")};f.getRetailDiscount=function(){return e.basket.RetailDiscount};f.getRetailSubTotal=function(){return e.basket.RetailSubTotal};f.getRetailTotal=function(){return e.basket.RetailTotal};f.getInvestmentSubTotal=function(){return e.basket.InvestmentSubTotal};f.getBullionSavedAmount=function(){return e.basket.BullionSavedAmount};f.getConsumerSavedAmount=function(){return e.basket.ConsumerSavedAmount};f.getInvestmentTotal=function(){return e.basket.InvestmentTotal};f.getInvestmentVat=function(){return e.basket.InvestmentVat};f.getInvestmentVatWithoutDeliveryFeeVat=function(){return e.basket.InvestmentVatWithoutDeliveryFee};f.getInvestmentDeliveryTotal=function(){return e.basket.TotalInvestmentDelivery};f.getInvestmentDelivery=function(){return e.deliveryBullionShipment!=null&&e.deliveryBullionShipment[0].ShippingMethods!=null?e.deliveryBullionShipment[0].ShippingMethods.length>0?e.deliveryBullionShipment[0].ShippingMethods[0].DeliverCost:"":e.basket.TotalDelivery};f.getEstimatedStorageFee=function(){return e.vaultBullionShipment!=null&&e.vaultBullionShipment[0].EstimatedStorageCost!=null?e.vaultBullionShipment[0].EstimatedStorageCost:null};f.intervalCountDown=undefined;f.onCountDown=!1;f.coundowntimer=180;f.totalSeconds=180;f.countDown=function(t,i){i||(f.intervalCountDown&&clearInterval(f.intervalCountDown),t!=undefined&&t!==""&&!isNaN(t)&&t>0&&(f.coundowntimer=t,f.totalSeconds=t),f.intervalCountDown=setInterval(function(){n.coundowntimer--;n.$apply();n.coundowntimer<=0&&(clearInterval(n.intervalCountDown),n.onCountDown=!0,n.getBasketAndSyncWithPamp())},1e3))};f.validForPayment;f.isSyncWithPampError;f.isNotEnoughMoney;f.onCheckSyncWithPamp=function(n,t,i){f.closeSyncPampErrorPopup();f.validForPayment=i;f.isSyncWithPampError=n;f.isNotEnoughMoney=t;(n||t)&&f.showSyncPampErrorPopup(n,t);i?$("#payment-btn").removeAttr("disabled"):$("#payment-btn").attr("disabled",!0)};f.showSyncPampErrorPopup=function(n,t){$("body").append('<div class="modal-backdrop fade in"><\/div>');n?$("#pamp-sync-error").removeClass("hidden"):$("#pamp-sync-error").addClass("hidden");t?$("#pamp-not-enough-money").removeClass("hidden"):$("#pamp-not-enough-money").addClass("hidden");$("#syncWithPampError").show().addClass("in")};f.closeSyncPampErrorPopup=function(){$("#syncWithPampError").hide().removeClass("in");$(".modal-backdrop").remove()};f.onSubmitCheckout=function(n){if(f.validForPayment==!1){f.onCheckSyncWithPamp(f.isSyncWithPampError,f.isNotEnoughMoney,f.validForPayment);return n.preventDefault(),!1}return clearInterval(f.intervalCountDown),!0};f.showAddFund=!1;f.accountBalance="";f.checkBalance=function(){t.getFeed("/mvcapi/cart/CheckBalance").then(function(n){n.data&&(f.accountBalance=n.data.Balance,f.showAddFund=n.data.ShowInsufficientFunds)})}}]);rmCheckout=angular.module("rmCheckout",["services","rmDirectives"]);rmCheckout.controller("rmCheckoutController",["$scope","$http","$window","$location","$anchorScroll","myService","pcAnywhereSvc","errorHandler","$timeout",function(n,t,i,r,u,f,e,o){function c(n){var i=new Date(n.replace(/(\d{2})-(\d{2})-(\d{4})/,"$2/$1/$3")),t=new Date(i),r=("0"+t.getMonth()).slice(-2),u=("0"+t.getDate()).slice(-2),f=t.getFullYear();return new Date(f,r,u)}var h=this,s=n;s.NameOnCardPattern="[A-Z '-]*";h.byEmail=!1;h.byPost=!1;h.byTelephone=!1;h.usedForDeliveryAddress=!1;h.rmAddresses={addresses:[]};h.rmAddressNicknames={nicknames:[]};s.rmCreditCards=[];s.$watch("rmCreditCards",function(n){h.shouldShowCardOptions=s.isAmexCardAvailable||n&&n.length>0;h.shouldShowCardOptions||(s.updateJs("newCard"),s.SelectedCard="newCard")});s.isAmexCardAvailable=!1;s.$watch("isAmexCardAvailable",function(n){h.shouldShowCardOptions=n||s.rmCreditCards&&s.rmCreditCards.length>0;h.shouldShowCardOptions||(s.updateJs("newCard"),s.SelectedCard="newCard")});s.$watch("selectedAddress",function(n,t){s.rmAddInfo.sameAsDelivery||n===t||h.initMasterCard(s.countryCodesJsArray)});s.SetSameAsDelivery=function(n){if(s.rmAddInfo.sameAsDelivery){if(!n)return;n=JSON.parse(n);s.selectedAddress={BillingDefault:!0,Line1:n.Line1,Line2:n.Line2,City:n.City,PostalCode:n.PostalCode,CountryCode:n.CountryCode,CountryRegion:{Region:n.CountryRegion&&n.CountryRegion.Region}}}else s.selectedAddress={AddressId:"",Line1:"",Line2:"",City:"",PostalCode:"",CountryName:"",CountryCode:"",CountryRegion:{Region:""}}};s.initPCAJS=function(){$.getScript(pcaJsUrl)};h.shouldShowCardOptions=!0;s.CountryCode="";s.$watch("CountryCode",function(n,t){s.shippingMethodId.length===36&&n!==t&&h.updateDelivery(s.shippingMethodId)});s.Title="Mr";s.rmDeliveryOptions={options:[]};s.sameAsDelivery=!0;s.rmAddInfo.sameAsDelivery=!0;s.showAmexCcvMessage=!1;s.paymentType="card";s.customerType="existing";s.deliveryCountry="United Kingdom";s.billingCountry="United Kingdom";s.enterNewCard=!1;s.acceptTC=!1;s.isBilling=!1;s.currentAddressId="";s.countryCodesJsArray="";s.Telephone="";s.MobilePhone="";s.shippingMethodId="";s.$watch("shippingMethodId",function(n){n.length===36&&h.updateDelivery(n)});s.hasSelectedAddress=!1;s.selectedAddress={AddressId:"",Line1:"",Line2:"",City:"",PostalCode:"",CountryName:"",CountryCode:"",CountryRegion:{Region:""}};s.manualAddress=!1;s.manualAddressPostcodeIsValid=!1;s.SelectedCard="";s.confirmOver16YearsOld=!1;s.init=function(n,t,i){s.currentAddressId=n<=0?"new":n;h.usedForDeliveryAddress=t;s.sameAsDelivery=i;s.rmAddInfo.sameAsDelivery=s.sameAsDelivery};h.initMasterCard=function(n){f.getFeed("/mvcapi/creditcards/get").then(function(n){s.rmCreditCards=n.data});s.countryCodesJsArray=n;n&&s.selectedAddress&&s.selectedAddress.CountryCode!==""&&(s.isAmexCardAvailable=n.indexOf(s.selectedAddress.CountryCode)!==-1)};h.setSelectedAddresses=function(n,t,i,r,u,f){s.selectedAddress={BillingDefault:!0,Line1:n,Line2:t,City:i,PostalCode:u,CountryCode:f,CountryRegion:{Region:r}}};h.getAddresses=function(){f.getFeed("/mvcapi/addresses/get").then(function(n){var i,t;for(h.rmAddresses=n.data,i=!1,t=0;t<h.rmAddresses.length;t++)if(h.rmAddresses[t].AddressId===s.currentAddressId&&(s.addressOption=t.toString(),s.selectedAddress=h.rmAddresses[t],i=!0,h.usedForDeliveryAddress&&s.validateAddressMarket()),f.getFeed("/mvcapi/addresses/getNicknames").then(function(n){h.rmAddressNicknames=n.data}),i===!0)return;h.rmAddresses.length===0&&(s.addressOption="new",s.AddressNickname="Registered")})};h.addressEnterManuallyClick=function(){s.manualAddress=!0;s.selectedAddress={AddressId:"",Line1:"",Line2:"",City:"",PostalCode:"",CountryName:"",CountryCode:"",CountryRegion:{Region:""}};s.selectedAddress.CountryCode="GBR";s.selectedAddress.AddressId="new";h.usedForDeliveryAddress&&h.getDeliveryOptions()};h.addressCancelManuallyClick=function(){s.manualAddress=!1;s.selectedAddress={AddressId:"",Line1:"",Line2:"",City:"",PostalCode:"",CountryName:"",CountryCode:"",CountryRegion:{Region:""}};s.shippingMethodId="";s.rmDeliveryOptions={options:[]};s.SetPcaPredictObject("")};s.setupAddress=function(n,t,i,r,u,f,e,o){s.AddressLine1=n;s.AddressLine2=t;s.AddressLine5=i;s.Town=r;s.Postcode=u;s.Telephone=e;s.MobilePhone=o;f&&(s.CountryCode=f);n&&u&&(h.setSelectedAddresses(n,t,r,i,u,f),s.hasSelectedAddress=!0)};s.changePaymentType=function(n){s.paymentType===n&&s.updateJs(s.SelectedCard)};e.CapturePlusCallback=function(n,t){var r=t.Line1===""?t.Neighbourhood:t.Line1,i=t.Line2;t.Line3!=undefined&&t.Line3!==""&&(i=i+", "+t.Line3);t.Line4!=undefined&&t.Line4!==""&&(i=i+", "+t.Line4);t.Company!=undefined&&t.Company!==""&&(r=t.Company+", "+r,t.Company="");s.AddressLine1=r;s.AddressLine2=i;s.AddressLine3=t.Line3;s.AddressLine4=t.Line4;s.AddressLine5=t.ProvinceName;s.Town=t.City;s.Postcode=t.PostalCode;s.CountryCode=t.CountryIso3;typeof emitter!="undefined"&&emitter.emit("event:address-fetched",{address:t});s.selectedAddress={AddressId:"new",Line1:r,Line2:i,City:t.City,CountryRegion:{Region:t.ProvinceName},PostalCode:t.PostalCode,CountryName:t.CountryName,CountryCode:t.CountryIso3};s.hasSelectedAddress=!0;s.newAddress=!1;h.usedForDeliveryAddress&&s.validateAddressMarket();s.$apply()};s.validateAddressMarket=function(){s.selectedAddress.CountryCode.length===3&&h.usedForDeliveryAddress?(s.$parent.validateMarket(s.selectedAddress.CountryCode),h.getDeliveryOptions()):s.rmDeliveryOptions=[]};s.GetPcaPredictObject=function(){return s.pcaPredict?s.pcaPredict:s.rmAddInfo.pcaPredict};s.SetPcaPredictObject=function(n){s.pcaPredict?s.pcaPredict=n:s.rmAddInfo.pcaPredict=n};s.getAddresses=function(){s.GetPcaPredictObject().length>1?(h.pcSuggestions=h.suggestions,$("#pcaResults").addClass("open")):$("#pcaResults").removeClass("open")};s.previouslySelectedCard=null;s.updateJs=function(n){if(s.previouslySelectedCard===n){typeof LoadSessionJs!="undefined"&&LoadSessionJs(amex);return}s.previouslySelectedCard=n;switch(n){case"newCard":s.enterNewCard=!0;s.showAmexCcvMessage=!1;amex=!1;break;case"newAmexCard":s.enterNewCard=!0;s.showAmexCcvMessage=!0;amex=!0;break;default:amex=!1;s.enterNewCard=!1;s.showAmexCcvMessage=!1}s.SelectedCard=n;typeof LoadSessionJs!="undefined"&&LoadSessionJs(amex)};s.initialiseEditPersonalDetails=function(n,t,i,r,u,f,e,o,h,c,l,a,v,y,p,w,b){s.Title=n;s.FirstName=t;s.LastName=i;s.DobDay=r;s.DobMonth=u;s.DobYear=f;s.Email=e;s.Telephone=o;s.AddressLine1=h;s.AddressLine2=c;s.Town=l;s.AddressLine5=a;s.Postcode=v;s.CountryCode=y;s.MiddleName=p;s.SecondLastName=w;s.Gender=b;s.hasSelectedAddress=!0};s.updatePersonalDetails=function(){s.formData={};s.formData.__RequestVerificationToken=$("#editPersonalDetails input[name=__RequestVerificationToken]").val();s.formData.Title=s.Title;s.formData.FirstName=s.FirstName;s.formData.LastName=s.LastName;s.formData.DateOfBirthDay=s.DobDay;s.formData.DateOfBirthMonth=s.DobMonth;s.formData.DateOfBirthYear=s.DobYear;s.formData.Email=s.Email;s.formData.Telephone=s.Telephone;s.formData.Password=s.Password;s.formData.MiddleName=s.MiddleName;s.formData.SecondLastName=s.SecondLastName;s.formData.Gender=s.Gender;s.formData.PrimaryAddress={};s.Company!=undefined&&s.Company!==""&&(s.AddressLine1=s.Company+", "+s.AddressLine1,s.Company="");s.formData.PrimaryAddress.Line1=s.AddressLine1;s.formData.PrimaryAddress.Line2=s.AddressLine2;s.formData.PrimaryAddress.City=s.Town;s.formData.PrimaryAddress.CountryRegion={};s.formData.PrimaryAddress.CountryRegion.Region=s.AddressLine5;s.formData.PrimaryAddress.PostalCode=s.Postcode;s.formData.PrimaryAddress.CountryCode=s.CountryCode;t({method:"POST",url:"/MvcApi/EditPersonalDetails",data:$.param(s.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){var t=n.data;s.hasEditFeedback=!0;s.hasEditFeedbackError=!1;s.hasEditFeedbackSuccess=!1;t.success?(s.hasEditFeedbackSuccess=!0,s.erroredFields=[],i.location.reload()):(s.hasEditFeedbackError=!0,s.messages=t.messages,s.erroredFields=t.erroredFields,s.dobError=t.dobError,s.emailError=t.emailError)})};s.checkDelivery=function(){return(s.$parent.rmCommerce.validation===window.undefined||s.$parent.rmCommerce.validation.length===0)&&s.checkoutForm.$invalid===!1&&!s.manualAddress||s.manualAddress&&s.manualAddressPostcodeIsValid?!0:!1};h.getDeliveryOptions=function(){if(h.usedForDeliveryAddress){if(s.selectedAddress.CountryCode.length!==3){if(s.CountryCode.length!==3)return;s.selectedAddress.CountryCode=s.CountryCode}f.postData("/mvcapi/delivery/get",{countryCode:s.selectedAddress.CountryCode}).then(function(n){s.rmDeliveryOptions=n.data;s.rmDeliveryOptions.length>0&&(s.shippingMethodId=s.rmDeliveryOptions[0].Id)})}};n.$on("updateQuantity",function(){h.getDeliveryOptions()});h.updateDelivery=function(n){f.postData("/mvcapi/delivery/update",{shippingMethodId:n}).then(function(){s.$parent.getUpdatedBasket()})};s.hasEditFeedback=!1;s.erroredFields=[];s.accPayOrderNumber="";s.accPayErrorMessage="";s.postPayment=function(){var n={MastercardSessionId:s.mastercardSessionId,Amount:s.paymentAmount,CurrencyCode:s.currencyCode,IsAmex:s.showAmexCcvMessage,NameOnCard:s.nameOnCard,TokenisedCardNumber:s.token,SaveCard:s.SaveCard,SelectedCard:s.SelectedCard,PaymentMethodId:$("#paymentMethodId").val()};f.postData("/mvcapi/accountpayment/post",n).then(function(n){n.data.Card3DsHtmlContent!=null&&n.data.Card3DsHtmlContent!==""?($(document).find("#paymentDiv").length||$("body").append("<div id='paymentDiv'><\/div>"),$("#paymentDiv").html(n.data.Card3DsHtmlContent),window.document.echoForm.submit()):n.data.PaymentSuccessful?s.accPayOrderNumber=n.data.OrderNumber:s.accPayErrorMessage=n.data.Message},function(n){s.accPayErrorMessage=n})};s.fund={returnUrl:"",paymentAmount:"",nameOnCard:"",cardNumber:"",expiryMonth:"",expiryYear:"",securityCode:"",paymentSessionId:"",paymentMethodId:"",saveCard:"",selectedCard:"",mastercard:"",orderNumberPrefix:""};s.inprogessPayment=!1;s.isPaymentSuccess=!1;s.addFund=function(n,t){if(!(s.fund.paymentAmount<=0)){s.inprogessPayment=!0;s.fund.paymentSessionId=s.mastercardSessionId;s.fund.selectedCard=s.SelectedCard;s.fund.returnUrl=t;var i=s.fund;f.postData("/mvcApi/AccountPayment/addFund",i).then(function(i){s.inprogessPayment=!1;i.data.Card3DsHtmlContent!=null&&i.data.Card3DsHtmlContent!==""?($(document).find("#paymentDiv").length||$("body").append("<div id='paymentDiv'><\/div>"),$("#paymentDiv").html(i.data.Card3DsHtmlContent),window.document.echoForm.submit()):i.data.PaymentSuccessful?(s.accPayOrderNumber=i.data.OrderNumber,t!=undefined&&t!=null&&t!=""?window.location.href=t:n!=undefined&&n!=null&&n!=""&&$(n).click(),s.isPaymentSuccess=!0,s.updateBalanceInHeader()):s.accPayErrorMessage=i.data.Message},function(n){s.accPayErrorMessage=n;s.inprogessPayment=!1})}};s.isCall=!1;s.amlCheck=function(n,t,i){s.isCall=n.currentTarget.getAttribute("data-is-call")=="true";s.inprogessPayment=!0;f.postData("/mvcapi/aml/check",{paymentAmount:s.fund.paymentAmount}).then(function(n){if(s.inprogessPayment=!1,!n.data.ReapplyKyc&&(n.data.ReapplyKyc||n.data.Continue))if(t&&t.apply(s,i),s.isCall)s.addFund(i[0],i[1]);else{var r=s.checkoutForm;r.$$element[0].submit()}else s.kycReapplication=n.data,s.kycReapplication.UserDateOfBirth=c(n.data.UserDateOfBirth),$("#rmKycReapplicationModal").modal("show")},function(n){s.accPayErrorMessage=n;s.inprogessPayment=!1})};s.reapplyKyc=function(n,t){var i=s.$parent.kycReapplication;f.postData("/mvcapi/kyc/reapply",i).then(function(i){if(i.data.Continue)if($("#rmKycReapplicationModal").modal("hide"),s.$parent.isCall)s.$parent.addFund(n,t);else{var r=s.$parent.checkoutForm;r.$$element[0].submit()}s.kycReapplication.Message=i.data.Message},function(n){s.kycReapplication.Message=n})};s.updatePaymentStatus=function(n){n&&(!n.Message||(s.accPayErrorMessage=n.Message))};s.updateBalanceInHeader=function(){t({method:"POST",url:"/mvcApi/GetBalance",headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){$(".wallet-balance-amount").html(n.data.balance);!isNaN(n.data.balanceAmount)&&parseFloat(n.data.balanceAmount)>=0?$(".wallet-balance-amount").removeClass("text-danger"):$(".wallet-balance-amount").addClass("text-danger")})};h.showOptionsOutPopup=function(){$("body").append('<div class="modal-backdrop fade in"><\/div>');$("#optionsOutModal").show().addClass("in")};h.closeOptionsOutPopup=function(){$("#optionsOutModal").hide().removeClass("in");$(".modal-backdrop").remove();$("#payNowButton").prop("disabled",!1)};s.CheckoutButtonClicked=!1;s.checkForm=function(n,t,i,r,u){if(s.CanContinue(n,t)&&r.$valid)if(s.acceptTC&&(i=="true"||s.confirmOver16YearsOld)){if((i!="true"||u=="true")&&!h.byEmail&&!h.byPost&&!h.byTelephone){h.showOptionsOutPopup();return}s.proceedWithOrder(n,t)}else s.acceptTC||$(".acceptterms").removeClass("hidden"),i!="false"||s.confirmOver16YearsOld||$(".confirmOver16").removeClass("hidden"),$("#payNowButton").prop("disabled",!1);else $("#payNowButton").prop("disabled",!1)};s.CanContinue=function(n){if(s.paymentType===n){if($("#nameOnCard").val()&&$("#nameOnCard").val().length===0&&s.enterNewCard)return $(".carddetails").removeClass("hidden"),s.checkoutForm.nameOnCard.$touched=!0,$("#payNowButton").prop("disabled",!1),!1;if($("#paymentSessionId").val().length>0)return!0;if($("#checkoutForm input[name=SelectedCard]:checked").length===1){if($("#checkoutForm input[name=SelectedCard]:checked").val().indexOf("new")===-1)return!0;$(".carddetails").removeClass("hidden")}else $(".carddetails").removeClass("hidden")}else return!0;return $("#payNowButton").prop("disabled",!1),!1};s.proceedWithOrder=function(){s.CheckoutButtonClicked||(s.CheckoutButtonClicked=!0,$("#checkoutForm").submit())};s.checkFormRmg=function(){if(!s.acceptTC){$(".acceptterms").removeClass("hidden");return}if(s.selectedAddress.Line1.length===0){$(".addressdetails").removeClass("hidden");return}if($("#nameOnCard").val().length===0&&s.enterNewCard){$(".carddetails").removeClass("hidden");return}$("#paymentSessionId").val().length>0?$("#checkoutForm").submit():$(".carddetails").removeClass("hidden")};s.setupAddEditAddress=function(n,t,i,r,u,f,e,o,h,c){s.showSuccessMessage=!1;s.showFailureMessage=!1;s.AddressId=n;s.AddressNickname=t;s.FirstName=i;s.LastName=r;s.AddressLine1=u;s.AddressLine2=f;s.AddressLine5=o;s.Town=e;s.Postcode=h;(c===null||c==="")&&(c="GBR");s.CountryCode=c;(h!=null&&h!=""||u!=null&&u!="")&&(s.hasSelectedAddress=!0)};s.addUpdateAddress=function(n){s.erroredFields=[];s.formData={};s.formData.Address={};s.formData.Address.CountryRegion={};s.formData.Address.AddressId=s.AddressId;s.formData.Address.Name=s.AddressNickname;s.formData.Address.FirstName=s.FirstName;s.formData.Address.LastName=s.LastName;s.formData.Address.Line1=s.AddressLine1;s.formData.Address.Line2=s.AddressLine2;s.formData.Address.CountryRegion.Region=s.AddressLine5;s.formData.Address.City=s.Town;s.formData.Address.PostalCode=s.Postcode;s.formData.Address.CountryCode=s.CountryCode;s.formData.__RequestVerificationToken=$("#AddEditAddress input[name=__RequestVerificationToken]").val();t({method:"POST",url:"/mvcApi/AddUpdateAddress",data:$.param(s.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){t.data.success?(s.showSuccessMessage=!0,s.erroredFields=t.data.erroredFields,s.AddressId=t.data.addressId,n.length>0&&i.location.assign(n)):(s.showSuccessMessage=!1,s.erroredFields=t.data.erroredFields)}).catch(function(n){alert(n.data.match("<title>(.*?)<\/title>")[1])})};s.checkNickname=function(n){s.checkoutForm.AddressNickname.$setValidity("duplicate",!0);for(var t=0;t<h.rmAddressNicknames.length;t++)if(h.rmAddressNicknames[t].toLowerCase()===n.toLowerCase()){s.checkoutForm.AddressNickname.$setValidity("duplicate",!1);return}};s.makeCurrentAddress=function(n){if(n===null||n==="new"){s.selectedAddress={AddressId:"new",Line1:"",Line2:"",City:"",PostalCode:"",CountryName:"",CountryCode:""};s.rmDeliveryOptions={options:[]};return}s.selectedAddress=Engine.isInt(n)?h.rmAddresses[n]:n;$("#pcaResults").removeClass("open")};s.checkPostCodeFormat=function(n){var r,t,i;n==="GBR"&&(r=typeof s.selectedAddress.PostalCode=="undefined"?s.Postcode:s.selectedAddress.PostalCode,typeof r!="undefined"&&r.trim()!==""&&(t=r.replace(" ",""),i=t.length-3,i>1&&(typeof s.selectedAddress.PostalCode!="undefined"&&(s.selectedAddress.PostalCode=t.slice(0,i)+" "+t.slice(i)),typeof s.Postcode!="undefined"&&(s.Postcode=t.slice(0,i)+" "+t.slice(i)))))};$("#pcaResults").on("click",function(){$("#pcaResults").removeClass("open")});s.removeCard=function(n){o.displayError(1,s,"Are you sure?","Remove this card.",s.removeConfirmed,n)};s.removeConfirmed=function(n){f.postData("/mvcapi/creditcards/delete?token="+n).then(function(n){s.rmCreditCards=n.data});$("#rmMessagesModal").modal("hide")};s.initNumber=function(n){return n&&!isNaN(parseFloat(n))&&parseFloat(n)||0}}]).controller("rmAddressControllerNewUser","myService","errorHandler",function(n){n.savedCardList=[];n.customerType="new"}).controller("rmPaymentPage",["$scope",function(n){n.showPromoCode=!0}]);searchController=angular.module("rmSearchController",["services"]);searchController.controller("rmSearchBar",["$scope","$timeout","myService","$http","$templateCache",function(n,t,i,r,u){var s=this,o,f,e;n.method="GET";o="";f=!1;s.getSearch=function(){f||o===n.searchTerm||(f=!0,o=n.searchTerm,n.code=null,n.response=null,n.searchTerm.length<3?(f=!1,n.models={Suggestions:[],RelatedArticles:[]}):r({method:n.method,url:"/mvcApi/GetSuggestions?searchTerm="+n.searchTerm,cache:u}).then(function(t){t.status===200&&(n.models=t.data);f=!1}))};n.doSearch=function(){isBreakpoint("xs")||isBreakpoint("sm")||(n.searchTerm.length>=3?(e&&t.cancel(e),e=t(s.getSearch,500)):e&&t.cancel(e))};n.clearSearch=function(){n.searchTerm=""};$("#navSectionSearch").on("headerSection:closed",function(){n.clearSearch()})}]);angular.module("gbchSearchCoinModule",["services","ngAnimate","slickCarousel","ngSanitize","GBCHDirective"]).run(["$anchorScroll",function(n){n.yOffset=80}]).filter("getIndexById",function(){return function(n,t){for(var i=0,r=n.length;i<r;i++)if(+n[i].id==+t)return i;return null}}).filter("getLetterObject",function(){return function(n,t,i,r){for(var c,o,u,f,s=[],e=0;e<t.length;e++){var h=0,l=0,o=t[e].variants;if(e!=i||r)for(u=0;u<n.length;u++)f=o.map(function(n){return n.letter}).indexOf(n[u].toUpperCase()),f>=0&&(h+=o[f].price.amount);else for(u=0;u<n.length;u++)n[u]===" "?s.push({letter:" ",defaultImageUrl:"",price:null}):(f=o.map(function(n){return n.letter}).indexOf(n[u].toUpperCase()),f>=0?(s.push(o[f]),h+=o[f].price.amount):s.push({letter:n[u].toUpperCase(),defaultImageUrl:"",price:{amount:0}}));if(t[e].subCategories.length>0){for(c=t[e].subCategories[0].variants,u=0;u<n.length;u++)f=c.map(function(n){return n.letter}).indexOf(n[u].toUpperCase()),f>=0&&(l+=c[f].price.amount);if(t[e].subCategories[0].price=l-h,o=t[e].subCategories[0].variants,!!r)for(u=0;u<n.length;u++)n[u]===" "?s.push({letter:" ",defaultImageUrl:"",price:null}):(f=o.map(function(n){return n.letter}).indexOf(n[u].toUpperCase()),f>=0?s.push(o[f]):s.push({letter:n[u].toUpperCase(),defaultImageUrl:"",price:{amount:0}}))}t[e].price=h}return{coins:s,categories:t}}}).controller("gbchSearchCoin",["$anchorScroll","$location","$window","$scope","$timeout","$http","$templateCache","$sce","$filter","errorHandler","myService",function(n,t,i,r,u,f,e,o,s,h){var c=this;c.isFirstTimeFocus=!0;c.isRequesting=!1;c.moduleSetting=GBCH_SETTING;c.currencySymbol="£";c.title=!c.moduleSetting.step1Title?"Choose your Coins":c.moduleSetting.step1Title;c.description=!c.moduleSetting.step1Description?"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do elusmod tempor":c.moduleSetting.step1Description;c.quicktip=!c.moduleSetting.step1InputTeaserText?"Enter Name or text (Max. 50 characters)":c.moduleSetting.step1InputTeaserText;c.cta_primary=!c.moduleSetting.step1CTAPrimary?"Choose Metal and Finish":c.moduleSetting.step1CTAPrimary;c.cta_secondary=!c.moduleSetting.step1CTASecondary?"I want all 26 coins A-Z":c.moduleSetting.step1CTASecondary;c.step1NoCoinInputError=!c.moduleSetting.step1NoCoinInputError?"No coin(s) have been selected":c.moduleSetting.step1NoCoinInputError;c.step2Title=!c.moduleSetting.step2Title?"Pick your coin metal":c.moduleSetting.step2Title;c.step2ButtonText=!c.moduleSetting.step2ButtonText?"Select":c.moduleSetting.step2ButtonText;c.step3Title=!c.moduleSetting.step3Title?"Packaging and Gift Options":c.moduleSetting.step3Title;c.step3UpgradeText=!c.moduleSetting.step3UpgradeText?"Upgrade Now":c.moduleSetting.step3UpgradeText;c.step3DowngradeText=!c.moduleSetting.step3DowngradeText?"Downgrade Now":c.moduleSetting.step3DowngradeText;c.step3AddToBasketText=!c.moduleSetting.step3AddToBasketText?"Add items to Basket":c.moduleSetting.step3AddToBasketText;c.step3TotalText=!c.moduleSetting.step3TotalText?"Total:":c.moduleSetting.step3TotalText;c.step3AddToBasketError=!c.moduleSetting.step3AddToBasketError?"Your session is timeout":c.moduleSetting.step3AddToBasketError;c.addBasketSuccessfulText=!c.moduleSetting.step4Title?"Your items have been added to your basket":c.moduleSetting.step4Title;c.step4Description=!c.moduleSetting.step4Description?"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do elusmod tempor":c.moduleSetting.step4Description;c.step4PrimaryCTA=!c.moduleSetting.step4PrimaryCTA?"Go to Basket":c.moduleSetting.step4PrimaryCTA;c.step4SecondaryCTA=!c.moduleSetting.step4SecondaryCTA?"Start Again":c.moduleSetting.step4SecondaryCTA;c.step4SummaryTitle=!c.moduleSetting.step4SummaryTitle?"Summary":c.moduleSetting.step4SummaryTitle;c.step4ItemsText=!c.moduleSetting.step4ItemsText?"Items":c.moduleSetting.step4ItemsText;c.step4QtyText=!c.moduleSetting.step4QtyText?"Qty":c.moduleSetting.step4QtyText;c.step4PriceText=!c.moduleSetting.step4PriceText?"Price":c.moduleSetting.step4PriceText;c.maximumSearchString=50;c.remainSearchString=50;c.tfSearchCoinValueTemp="";c.tfSearchCoinValue="Coin Hunt";c.tfSearchCoinValueDisplay="";c.tfSearchCoinValueDisplayWord=[];c.errorMessageTpl="Sorry - ### is not part of the collection";!c.moduleSetting.step1InputError||(c.errorMessageTpl=c.moduleSetting.step1InputError);c.errorMessage="";c.step=1;c.activeCategory=null;c.totalPrice=0;c.slickConfig={infinite:!1,dots:!1,slidesToShow:4,slidesToScroll:4,responsive:[{breakpoint:1280,settings:{slidesToShow:3,slidesToScroll:3}},{breakpoint:768,settings:{slidesToShow:1,slidesToScroll:1}}],enabled:!0};c.categories=CATEGORY_INFO==null?[]:CATEGORY_INFO.subCategories;c.packagingOptions=undefined;c.giftOptions=[];c.summaryBasket=[];c.trustAsHtml=function(n){return o.trustAsHtml(n)};r.$watch("ctrl.tfSearchCoinValueDisplay",function(){var n,i,t;for(c.tfSearchCoinValueDisplayWord=[],n=0,i=[],c.tfSearchCoinValueDisplayWord[n]=[],t=0;t<c.tfSearchCoinValueDisplay.length;t++)t==c.tfSearchCoinValueDisplay.length-1&&c.tfSearchCoinValueDisplayWord[n].push(i),c.tfSearchCoinValueDisplay[t].letter===" "?(c.tfSearchCoinValueDisplayWord[n].push(i),n=n+1,i=[],c.tfSearchCoinValueDisplayWord[n]=[]):i.push(c.tfSearchCoinValueDisplay[t])});c.focusSearchField=function(){c.isFirstTimeFocus&&(c.isFirstTimeFocus=!1,c.tfSearchCoinValueTemp="",c.tfSearchCoinValue="",c.tfSearchCoinValueDisplay="",c.searchCoins())};c.getAllCoins=function(){for(var t=[],n="A".charCodeAt(0),i="Z".charCodeAt(0);n<=i;)t.push(String.fromCharCode(n)),++n;c.tfSearchCoinValue=t.join("");c.searchCoins()};c.searchCoins=function(){var t,n,r,i;c.remainSearchString=c.maximumSearchString-c.tfSearchCoinValue.replace(/[^a-zA-Z]/gi,"").length;c.remainSearchString<0&&(t=c.tfSearchCoinValue.length-c.tfSearchCoinValueTemp.length,c.remainSearchString=0,t>1&&(t=c.tfSearchCoinValue.replace(/[^a-zA-Z]/gi,"").length-c.maximumSearchString),c.tfSearchCoinValue=c.tfSearchCoinValue.substr(0,c.tfSearchCoinValue.length-t));n=c.tfSearchCoinValue.replace(/[^a-zA-Z ]/gi,"").replace(/\s\s+/g," ");r=c.getDifferenceTwoString(n,c.tfSearchCoinValue.replace(/\s\s+/g," "));c.errorMessage=r.length>0?c.errorMessageTpl.replace("###",r.split("").join(", ")):"";i=null;i=c.activeCategory==null?s("getLetterObject")(n,c.categories,0,!1):c.packagingOptions!==undefined&&c.packagingOptions.isUpgrade?s("getLetterObject")(n,c.categories,c.activeCategory,!0):s("getLetterObject")(n,c.categories,c.activeCategory,!1);c.tfSearchCoinValueDisplay=i.coins;c.categories=i.categories;c.tfSearchCoinValueTemp=c.tfSearchCoinValue;c.activeCategory!=null&&(c.resetBasketTemp(),c.resetCategory(c.activeCategory,!1));c.step>3&&(c.step=3)};c.getDifferenceTwoString=function(n,t){for(var r=0,i=0,u="";i<t.length;)n[r]!=t[i]||r==n.length?u+=t[i]:r++,i++;return u};c.showCategory=function(){c.categories.length>0&&c.tfSearchCoinValue.replace(/[^a-zA-Z]/gi,"")!==""?(c.step=2,c.gotoAnchor()):c.categories.length==0?h.displayError(1,r,"Basket Warning","The category is empty",null,null):h.displayError(1,r,"Basket Warning",c.step1NoCoinInputError,null,null)};c.viewMore=function(){};c.selectCategory=function(n){c.activeCategory!=n&&(c.activeCategory=n,c.step=3,c.gotoAnchor(),c.resetBasketTemp(),c.resetCategory(n,!0))};c.resetBasketTemp=function(){c.summaryBasket=[];var n=c.tfSearchCoinValue.toUpperCase().replace(/[^a-zA-Z]/gi,"").split(""),t={id:c.categories[c.activeCategory].id,name:c.categories[c.activeCategory].displayName+"<div>("+n.join(",")+")<\/div>",quantity:n.length,price:c.categories[c.activeCategory].price};c.summaryBasket.push(t);c.totalPrice=c.packagingOptions!=undefined&&c.packagingOptions.isUpgrade?parseFloat(c.categories[c.activeCategory].price)+parseFloat(c.packagingOptions.price):parseFloat(c.categories[c.activeCategory].price)};c.resetCategory=function(n,t){if(c.categories[n].subCategories.length>0){var i=!1;c.packagingOptions!==undefined&&(i=c.packagingOptions.isUpgrade);c.packagingOptions=c.categories[n].subCategories[0];c.packagingOptions.isUpgrade=i}else c.packagingOptions=undefined;t&&c.updateCoinImage();c.getRelatedVariantAPI(c.categories[n].id);c.totalPrice=c.packagingOptions!=undefined&&c.packagingOptions.isUpgrade?parseFloat(c.categories[n].price)+parseFloat(c.packagingOptions.price):parseFloat(c.categories[n].price)};c.updateCoinImage=function(){var n=c.tfSearchCoinValue.replace(/[^a-zA-Z ]/gi,"").replace(/\s\s+/g," "),t=null;t=c.packagingOptions!=undefined&&c.packagingOptions.isUpgrade?s("getLetterObject")(n,c.categories,c.activeCategory,!0):s("getLetterObject")(n,c.categories,c.activeCategory,!1);c.tfSearchCoinValueDisplay=t.coins};c.upgradePackage=function(){c.resetBasketTemp();var n=c.tfSearchCoinValue.toUpperCase().replace(/[^a-zA-Z]/gi,"").split("");c.packagingOptions.isUpgrade?(c.totalPrice=c.totalPrice-parseFloat(c.packagingOptions.price),c.summaryBasket[0]={id:c.categories[c.activeCategory].id,name:c.categories[c.activeCategory].displayName+"<div>("+n.join(",")+")<\/div>",quantity:n.length,price:c.categories[c.activeCategory].price},c.getRelatedVariantAPI(c.categories[c.activeCategory].id)):(c.totalPrice=c.totalPrice+parseFloat(c.packagingOptions.price),c.summaryBasket[0]={id:c.packagingOptions.id,name:c.packagingOptions.displayName+"<div>("+n.join(",")+")<\/div>",quantity:n.length,price:c.categories[c.activeCategory].price+c.packagingOptions.price},c.getRelatedVariantAPI(c.packagingOptions.id));c.packagingOptions.isUpgrade=!c.packagingOptions.isUpgrade;c.updateCoinImage()};c.minusVolume=function(n){var t;n.quantity>0?(n.quantity=n.quantity-1,c.totalPrice=c.totalPrice-parseFloat(n.price.amount),t=s("getIndexById")(c.summaryBasket,n.id),!t||(c.summaryBasket[t].quantity=n.quantity,c.summaryBasket[t].price=n.price.amount*n.quantity)):(t=s("getIndexById")(c.summaryBasket,n.id),c.summaryBasket.splice(t,1))};c.plusVolume=function(n){if(n.quantity<n.maxQuantity){n.quantity=n.quantity+1;c.totalPrice=c.totalPrice+parseFloat(n.price.amount);var t=s("getIndexById")(c.summaryBasket,n.id);t?(c.summaryBasket[t].quantity=n.quantity,c.summaryBasket[t].price=n.price.amount*n.quantity):c.summaryBasket.push({id:n.id,code:n.code,name:n.displayName,quantity:n.quantity,price:n.price.amount*n.quantity})}};c.updateRelatedVariantQuantity=function(n,t){var i=s("getIndexById")(c.summaryBasket,n.id);i?(c.summaryBasket[i].quantity=n.quantity,c.summaryBasket[i].price=n.price.amount*n.quantity):c.summaryBasket.push({id:n.id,code:n.code,name:n.displayName,quantity:n.quantity,price:n.price.amount*n.quantity});c.totalPrice=parseFloat(t)<parseFloat(n.quantity)?c.totalPrice+parseFloat(n.price.amount):c.totalPrice-parseFloat(n.price.amount);n.quantity<1&&c.summaryBasket.splice(i,1)};c.addItemToBasket=function(){c.step=4;c.packagingOptions===undefined||c.step===4?(c.slickConfig.responsive[1].settings.slidesToShow=2,c.slickConfig.responsive[1].settings.slidesToShow=2):(c.slickConfig.responsive[1].settings.slidesToShow=1,c.slickConfig.responsive[1].settings.slidesToShow=1)};c.restart=function(){c.tfSearchCoinValueTemp="";c.tfSearchCoinValue="Coin Hunt";c.tfSearchCoinValueDisplay="";c.errorMessage="";c.isFirstTimeFocus=!0;c.activeCategory=null;c.totalPrice=0;c.categories=CATEGORY_INFO==null?[]:CATEGORY_INFO.subCategories;c.packagingOptions=undefined;c.giftOptions=[];c.summaryBasket=[];c.step=1;c.gotoAnchor();c.searchCoins()};c.saveToBasket=function(){var t=[],i,u,n;for(c.isRequesting=!0,n=0;n<c.tfSearchCoinValueDisplay.length;n++)c.tfSearchCoinValueDisplay[n].letter!==" "&&(t[c.tfSearchCoinValueDisplay[n].letter]===undefined?t[c.tfSearchCoinValueDisplay[n].letter]={code:c.tfSearchCoinValueDisplay[n].code,quantity:1}:t[c.tfSearchCoinValueDisplay[n].letter].quantity++);if(Object.keys(t).length>0){i="";for(u in t)i=i+t[u].code+"#"+t[u].quantity+";";for(n=1;n<c.summaryBasket.length;n++)i=i+c.summaryBasket[n].code+"#"+c.summaryBasket[n].quantity+";";f({method:"POST",url:"/mvcApi/cart/AddBundleToCart",params:{codeAndQuantity:i},headers:{"Content-Type":"application/json"}}).then(function(n){c.isRequesting=!1;n.data.Success||h.displayError(1,r,n.data.Title,n.data.Message,null,null);c.step=5;r.$parent.getUpdatedBasket();c.gotoAnchor()}).catch(function(n){c.isRequesting=!1;n.status&&(n.status==403?h.displayError(1,r,"Error",c.step3AddToBasketError,null,null):h.displayError(1,r,"Error","Something wrong. Please try again.",null,null))})}else c.isRequesting=!1,h.displayError(1,r,"Basket Warning",c.step1NoCoinInputError,null,null)};c.getRelatedVariantAPI=function(n){var t=c.tfSearchCoinValue.replace(/[^a-zA-Z]/gi,"");t!==""?f({method:"GET",url:(window.location.pathname[window.location.pathname.length-1]==="/"?window.location.pathname:window.location.pathname+"/")+"GetRelatedVariants",params:{id:n,query:c.tfSearchCoinValue.replace(/[^a-zA-Z]/gi,"")},headers:{"Content-Type":"application/json"}}).then(function(n){c.giftOptions=n.data;c.giftOptions.forEach(function(n){n.quantity=0});c.step=3.5;c.packagingOptions===undefined||c.step===4?(c.slickConfig.responsive[1].settings.slidesToShow=2,c.slickConfig.responsive[1].settings.slidesToShow=2):(c.slickConfig.responsive[1].settings.slidesToShow=1,c.slickConfig.responsive[1].settings.slidesToShow=1);u(function(){c.step=3},500)}):u(function(){c.step=3.5},500)};c.gotoAnchor=function(){var r="gbch-search-container-step-"+c.step;c.step===1?$("html, body").animate({scrollTop:0},"fast"):t.hash()!==r?Math.round(c.step)===3?setTimeout(function(){i.animateScroll("#gbch-search-container-step-"+Math.round(c.step))},1e3):setTimeout(function(){i.animateScroll("#gbch-search-container-step-"+Math.round(c.step))},400):n()};angular.element(i).bind("resize",function(){c.packagingOptions===undefined||c.step===4?(c.slickConfig.responsive[1].settings.slidesToShow=2,c.slickConfig.responsive[1].settings.slidesToShow=2):(c.slickConfig.responsive[1].settings.slidesToShow=1,c.slickConfig.responsive[1].settings.slidesToShow=1);r.$digest()});c.searchCoins()}]).run(["$http",function(n){var t=angular.element('input[name="__RequestVerificationToken"]')[0];t&&(n.defaults.headers.common["X-XSRF-Token"]=t.value)}]);rmCategoryListingController=angular.module("rmCategoryListing",["services","ngCookies"]);rmCategoryListingController.controller("rmCategoryListing",["$scope","myservice",function(n,t){var i=this,o=n;i.getProducts=function(){t.getFeed("/Static/data/catalogue.json").then(function(n){i.products=n.data;i.items=i.products.items;i.filters=i.products.facets})};i.products={items:[]};i.getProducts();var r=$(".slickDirective").data("slides-lg")||4,u=$(".slickDirective").data("slides-md")||4,f=$(".slickDirective").data("slides-sm")||3,e=$(".slickDirective").data("slides-xs")||2;o.variantCarouselConfig={infinite:!0,arrows:!0,dots:!0,speed:1e3,autoplay:!1,fade:!1,slidesToScroll:e,pauseOnFocus:!0,slidesToShow:e,mobileFirst:!0,responsive:[{breakpoint:767,settings:{slidesToShow:f,slidesToScroll:f}},{breakpoint:991,settings:{slidesToShow:u,slidesToScroll:u}},,{breakpoint:1199,settings:{slidesToShow:r,slidesToScroll:r}}]}}]).controller("rmRecentlyViewed",["$scope","myService",function(n,t){var i=this,r=n;n.init=function(n){r.getRVProducts(n)};r.getRVProducts=function(n){t.getFeed("/mvcApi/recentlyViewed/Get?currentVariant="+n).then(function(n){i.products=n.data;i.items=i.products.items;i.filters=i.products.facets})};i.products={items:[]};r.removeFromRV=function(n){t.postData("/mvcApi/recentlyViewed?product="+n.Code).then(function(){var t=i.products.indexOf(n);i.products.splice(t,1)})}}]).controller("productDetailController",["$scope","myService",function(n,t){var i=this,r=n;i.getRVProducts=function(){t.getFeed("/Static/data/productDetail.json").then(function(n){i.product=n.data})};i.product={};i.getRVProducts()}]).controller("rmFeefo",["$scope","$http","myService",function(n,t,i){var u=this,r=n,f;r.Limit=10;r.maxRating=5;r.plusHalf=!1;r.remainder=0;r.variantCode="";f=n.Limit;r.init=function(n){r.GetFeefoSummaryRatings(n)};n.init=function(n,t){r.getFeefoReviews(n,t)};r.reviews=[];r.getMoreReviews=function(t){n.Limit=n.Limit+10;r.getFeefoReviews(t,n.Limit)};r.getFeefoReviews=function(t,f){i.getFeed("/mvcApi/Feefo/Get?variantCode="+t+"&limit="+f).then(function(t){var f,i,e;if(t.data!==""&&t.status===200){for(u.product=t.data,f=t.data.ReviewData,r.roundRatingNum=Math.floor(t.data.StarRating),r.roundRating=Engine.getNumber(r.roundRatingNum),r.reviewCount=Math.floor(t.data.CountOfReviews),Engine.isInt(t.data.StarRating)||(r.plusHalf=!0),r.roundRatingNum<r.maxRating&&(r.remainder=r.maxRating-r.roundRatingNum),r.plusHalf===!0&&(r.remainder=r.remainder-1),r.remainder=Engine.getNumber(r.remainder),i=0;i<f.length;i++)n.reviews.push(f[i]);e=t.data.CountOfFeedbacks>n.reviews.length;e||$("#reviewsLoadMoreButton").remove()}})};r.GetFeefoSummaryRatings=function(n){i.getFeed("/mvcApi/Feefo/GetSummary?variantCode="+n).then(function(n){n.data!==""&&n.status===200&&(u.product=n.data,r.roundRatingNum=Math.floor(n.data.StarRating),r.roundRating=Engine.getNumber(r.roundRatingNum),r.reviewCount=Math.floor(n.data.CountOfReviews),Engine.isInt(n.data.StarRating)||(r.plusHalf=!0),r.roundRatingNum<r.maxRating&&(r.remainder=r.maxRating-r.roundRatingNum),r.plusHalf==!0&&(r.remainder=r.remainder-1),r.remainder=Engine.getNumber(r.remainder))})}}]).controller("rmComparePage",["$scope","myService",function(n,t){var i=this,r=n;i.getCompare=function(){t.getFeed("/Static/data/comparedItems.json").then(function(n){i.products=n.data;i.items=i.products.items;i.facets=i.products.facets})};i.products={items:[]};i.getCompare();r.removeFromCompare=function(n){i.items.splice(n,1)}}]);rmgController=angular.module("rmRmgController",["services"]);rmgController.controller("rmRmg",["$scope","$http","$window","myService",function(n,t,i,r){var u=n;u.rmgWallet="";u.rmgAmount="";u.rmgMin=0;u.rmgMax=100;u.rmgWalletIdMin=10;u.rmgWalletIdMax=20;u.init=function(n,t,i,r,f,e){u.rmgMin=n;u.rmgMax=t;u.rmgWalletIdMin=i;u.rmgWalletIdMax=r;u.rmgWallet=f;e>0&&(u.rmgAmount=e)};u.amountIsValid=function(n){return(u.rmgBuyForm.Amount.$setValidity("range",!1),isNaN(n))?!1:(u.rmgAmount=(Math.round(n*100)/100).toFixed(2),u.rmgAmount>=u.rmgMin&&u.rmgAmount<=u.rmgMax)?(u.rmgBuyForm.Amount.$setValidity("range",!0),!0):!1};u.walletIsValid=function(n){u.rmgBuyForm.WalletId.$setValidity("range",!1);u.rmgWallet=n;u.rmgWallet.length>=u.rmgWalletIdMin&&u.rmgWallet.length<=u.rmgWalletIdMax&&u.rmgBuyForm.WalletId.$setValidity("range",!0)};u.showRmgAmoutUpdate=function(){$(".rmgUpdate").toggle()};u.updateRmgAmount=function(){u.amountIsValid(u.rmgAmount)&&r.postData("/mvcapi/rmg/getcharges?amount="+u.rmgAmount+"&walletid="+u.rmgWallet).then(function(n){$(".summaryCharges").text("£"+n.data.PremiumAmount.toFixed(2));$(".summaryAmount").text("£"+n.data.Amount.toFixed(2));$(".summaryTotal").text("£"+n.data.Total.toFixed(2));$("#rmgAmount").val(n.data.Amount.toFixed(2));$(".rmgUpdate").toggle()})}}]);rmCookieController=angular.module("cookieController",["ngCookies","ngRoute"]);rmCookieController.controller("cookieController",["$scope","$cookies","$window",function(n,t){var i=n;i.cookiePolicy=t.get("cookiePolicy");i.setCookie=function(){var n=new Date;n.setFullYear(n.getFullYear()+2);t.put("cookiePolicy",!0,{path:"/",expires:n});$("#cookiePolicyContainer").addClass("accepted")};i.removeCookie=function(){t.remove("cookiePolicy",{path:"/"})}}]);loginController=angular.module("rmLoginController",["services","rmDirectives"]);loginController.controller("rmLogin",["$scope","$http","$cookies","$window","myService",function(n,t,i,r,u){n.userLoggedIn=!1;n.hasError=!1;n.email="";n.password="";n.checkoutEmail="";n.checkoutPassword="";n.showTwoStepAuthentication=!1;n.showCheckOutTwoStepAuthentication=!1;n.securityQuestion="";n.checkoutSecurityQuestion="";n.validActivationCode=!1;n.activationCustomerCode="";n.activationPostcode="";n.resetSent=!1;n.resetPasswordError="";n.showPasswordResetConfirmation=!1;n.enhancedMessage="";n.user={user:{FirstName:"",LastName:"",Email:""}};n.setupLogin=function(t,i,r,u){n.userLoggedIn=u;n.user={user:{FirstName:t,LastName:i,Email:r}}};n.resetPassword=function(i,r,u){n.formData={};n.formData.Email=n.resetEmail;n.formData.Recaptcha=u?$('#recaptchaForgotPasswordOnCheckoutPageDiv textarea[name="g-recaptcha-response"]').val():$('#forgottenPW-header textarea[name="g-recaptcha-response"]').val();n.resetSent=!1;n.resetPasswordError="";t({method:"POST",url:"/mvcApi/Reset",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){t.data.success?(n.resetSent=!0,$(i).click(),$(r).click(),n.showPasswordResetConfirmation=!0):(n.resetPasswordError=t.data.errors?t.data.errors:"An error occurred while processing request. Please try again",window.forgotPasswordRecaptcha&&grecaptcha.reset(forgotPasswordRecaptcha))})};n.login=function(){n.showSuccessMsg=!1;n.formData={};n.formData.Email=n.getEmail();n.formData.Password=n.getPassword();n.formData.SecurityAnswer=n.securityAnswer;onSubmitForm($("#login-header"));n.showTwoStepAuthentication&&onSubmitForm($("#login-securityQuestion"));t({method:"POST",url:"/mvcApi/Login",data:n.formData}).then(function(t){var i=t.data;i.Success?(n.hasError=!1,i.LoginViewModel?(n.showTwoStepAuthentication=!0,n.securityQuestion=i.LoginViewModel.SecurityQuestion):i.Message?(n.showSuccessMsg=!0,n.loginMessage=i.Message):i.EnhancedMessage?(n.showSuccessMsg=!0,n.enhancedMessage=i.EnhancedMessage):r.location.href=i.ReturnUrl):(n.hasError=!0,i.Message?n.loginMessage=i.Message:i.EnhancedMessage&&(n.enhancedMessage=i.EnhancedMessage));onClearSubmitForm($("#login-header"));n.showTwoStepAuthentication&&onClearSubmitForm($("#login-securityQuestion"))})};n.checkoutLogin=function(){n.formData={};n.formData.Email=n.getEmail();n.formData.Password=n.getPassword();n.formData.SecurityAnswer=n.checkoutSecurityAnswer;t({method:"POST",url:"/mvcApi/Login",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){var i=t.data;i.Success?(n.hasError=!1,i.LoginViewModel?(n.checkoutSecurityQuestion=i.LoginViewModel.SecurityQuestion,n.showCheckOutTwoStepAuthentication=!0):i.ReturnUrl!==window.undefined?r.location.href=i.ReturnUrl:(n.hasError=!0,i.Message?n.loginMessage=i.Message:i.EnhancedMessage&&(n.enhancedMessage=i.EnhancedMessage))):(n.hasError=!0,i.Message?n.loginMessage=i.Message:i.EnhancedMessage&&(n.enhancedMessage=i.EnhancedMessage))})};n.logout=function(n){n?onSubmitForm($("#logout-header")):onSubmitForm($("#btn-logout"));u.postData("mvcApi/Logout").then(function(n){i.remove("User",{path:"/"});onClearSubmitForm($("#btn-logout"));onClearSubmitForm($("#logout-header"));r.location.href=n.data.url})};n.checkForPostback=function(){n.activationCustomerCode!=null&&n.activationCustomerCode.length>0&&(n.validActivationCode=!0)};n.getPassword=function(){var n=$("#loginUsrPW1-header").val();return n===window.undefined?n=$("#loginUsrPW1-main").val():n.length===0&&(n=$("#loginUsrPW1-main").val()),n};n.getEmail=function(){var n=$("#loginEmail1-header").val();return n===window.undefined?n=$("#loginEmail1-main").val():n.length===0&&(n=$("#loginEmail1-main").val()),n};n.rqUsername="";n.requestSent=!1;n.requestUsername=function(i,r,u){n.formData={};n.formData.Email=n.rqUsername;n.requestSent=!1;n.formData.Recaptcha=u?$('#recaptchaForgotPasswordOnCheckoutPageDiv textarea[name="g-recaptcha-response"]').val():$('#forgottenUN-header textarea[name="g-recaptcha-response"]').val();t({method:"POST",url:"/mvcApi/RequestUsername",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){t.data.success?(n.requestSent=!0,$(i).click(),$(r).click(),n.rqUsername="",window.forgotUserNameOrPasswordRecaptcha&&grecaptcha.reset(forgotUserNameOrPasswordRecaptcha),n.resetPasswordError=""):(n.resetPasswordError=t.data.errors?t.data.errors:"Unable to request username or password",window.forgotUserNameOrPasswordRecaptcha&&grecaptcha.reset(forgotUserNameOrPasswordRecaptcha))})};n.Balance="";n.getBalanceInHeader=function(){t({method:"POST",url:"/mvcApi/GetBalance",headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){n.Balance=t.data.balance})}}]);rmAccountStatementController=angular.module("rmAccountStatementController",["services"]);rmAccountStatementController.controller("rmAccountStatement",["$scope","$http","myService",function(n,t){n.hasStatamentData=!1;n.selectedStatement="select";n.currentStatement="select";n.getStatementData=function(){n.hasStatamentData=!1;n.currentStatement===n.selectedStatement||n.selectedStatement==="select"?n.hasStatamentData=!1:(n.formData={},n.formData.StatementId=n.selectedStatement,n.currentStatement=n.selectedStatement,t({method:"POST",url:"/mvcApi/GetStatement",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){n.statement=t.data.statement;n.hasStatementData=!0}))}}]);registrationController=angular.module("rmRegistrationController",["services"]);registrationController.controller("rmRegistration",["$scope","$http","$cookies","$window",function(n,t,i,r){n.regError=!1;n.AttemptRegistration=function(){n.formData={};n.formData.EmailAddress=n.registerEmail;n.formData.FirstName=n.registerFirstName;n.formData.LastName=n.registerLastName;t({method:"POST",url:"/mvcApi/Register",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(t){t.data.Success?(n.regError=!1,r.location.href=t.data.RegistrationUrl):n.regError=!0})};n.IsExistingEmail=!0;n.EmailAddress="";n.IsExistingEmail=function(t){if(t==="True"){n.IsExistingEmail=!0;return}n.IsExistingEmail=!1};n.CheckExistingEmail=function(i){i&&t({method:"POST",url:"/BullionRegistrationPage/CheckExistingEmail",params:{email:n.EmailAddress},headers:{"Content-Type":"application/json"}}).then(function(t){n.IsExistingEmail=t.data})};n.UsernameValid=!0;n.Username="";n.ValidateUserName=function(i,r){i&&t({method:"POST",url:"/BullionRegistrationPage/ValidateUsername",params:{username:r},headers:{"Content-Type":"application/json"}}).then(function(t){n.UsernameValid=t.data})}}]);contactPreferencesController=angular.module("rmContactPreferencesController",["services"]);contactPreferencesController.controller("rmContactPreferences",["$scope","$http",function(n,t){n.ShowSuccessMessage=!1;n.byEmail=!1;n.byPhone=!1;n.byPost=!1;n.setupPreferences=function(t,i,r){n.byEmail=t;n.byPhone=i;n.byPost=r};n.updatePreferences=function(){n.formData={};n.formData.__RequestVerificationToken=$("#changePreferences input[name=__RequestVerificationToken]").val();n.formData.ByEmail=n.byEmail;n.formData.ByPhone=n.byPhone;n.formData.ByPost=n.byPost;t({method:"POST",url:"/mvcApi/UpdateContactPreferences",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(){n.showSuccessMessage=!0})};n.updateEmailContactPreference=function(){n.formData={};n.formData.__RequestVerificationToken=$("input[name=__RequestVerificationToken]").val();n.formData.ByEmail=n.byEmail;t({method:"POST",url:"/mvcApi/updateEmailContactPreference",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(){n.showSuccessMessage=!0})};n.updateTelephoneContactPreference=function(){n.formData={};n.formData.__RequestVerificationToken=$("input[name=__RequestVerificationToken]").val();n.formData.ByPhone=n.byPhone;t({method:"POST",url:"/mvcApi/updateTelephoneContactPreference",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(){n.showSuccessMessage=!0})};n.updatePostalContactPreference=function(){n.formData={};n.formData.__RequestVerificationToken=$("input[name=__RequestVerificationToken]").val();n.formData.ByPost=n.byPost;t({method:"POST",url:"/mvcApi/updatePostalContactPreference",data:$.param(n.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(){n.showSuccessMessage=!0})}}]);rmMessagesController=angular.module("rmMessagesModal",["services"]);rmMessagesController.controller("rmMessagesModal",["$scope","errorHandler",function(n,t){var r=this,i=n;i.action=function(n,i){t.action(n,i)}}]);rmFooterSignUpController=angular.module("rmFooterSignUp",[]);rmFooterSignUpController.controller("rmFooterSignUp",["$scope","$http",function(n,t){var i=n;i.emailFormat=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;i.formData={};i.formData.__RequestVerificationToken=$("#newsletterSignUp input[name=__RequestVerificationToken]").val();i.resetValidation=function(){$(".newsleter-validation").addClass("hidden")};i.submit=function(){t({method:"POST",url:"/Newsletter/SignUp",data:$.param(i.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){var t=n.data;i.resetValidation();t.success?($(".success-message").removeClass("hidden"),$("#newsletter").collapse("hide"),$("#newsletterExpand").hide(),i.Message=""):(i.Message=t.message,$(".newsleter-validation").removeClass("hidden"))})}}]);rmSovereignCertificateSignUpController=angular.module("rmSovereignCertificateSignUp",[]);rmSovereignCertificateSignUpController.controller("rmSovereignCertificateSignUp",["$scope","$http",function(n,t){n.emailFormat=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;n.certificateSignUpFormData={};n.certificateSignUpFormData.__RequestVerificationToken=$("#soverignCertificateSignUp input[name=__RequestVerificationToken]").val();n.submit=function(){$(".certificate-success").addClass("hidden");$(".certificate-error").addClass("hidden");t({method:"POST",url:"/Certificate/CertificateSignUp",data:$.param(n.certificateSignUpFormData),headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}}).then(function(t){var i=t.data;i.success?($(".certificate-success").removeClass("hidden"),n.Message=""):(n.Message=i.message,$(".certificate-error").removeClass("hidden"))})}}]);passwordChangeController=angular.module("rmPasswordChangeController",["services"]);passwordChangeController.controller("rmPasswordChange",["$scope","$http",function(n,t){var r=this,i=n;i.hasSuccess=!1;i.hasFailure=!1;n.updateUserPassword=function(n){n&&(i.formData={},i.formData.__RequestVerificationToken=$("#changePasswordForm input[name=__RequestVerificationToken]").val(),i.formData.Password=i.originalPassword,i.formData.NewPassword=i.confirmPassword,t({method:"POST",url:"/mvcApi/ChangePassword",data:$.param(i.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){n.data.success?(i.hasSuccess=!0,i.hasFailure=!1):(i.hasSuccess=!1,i.hasFailure=!0)}))}}]);angular.module("slickCarousel",[]).constant("slickCarouselConfig",{method:{},event:{}}).directive("slick",["$timeout","slickCarouselConfig",function(n,t){var i,r;return i=["slickGoTo","slickNext","slickPrev","slickPause","slickPlay","slickAdd","slickRemove","slickFilter","slickUnfilter","unslick"],r=["afterChange","beforeChange","breakpoint","destroy","edge","init","reInit","setPosition","swipe","lazyLoaded","lazyLoadError"],{scope:{settings:"=",enabled:"@",accessibility:"@",adaptiveHeight:"@",autoplay:"@",autoplaySpeed:"@",arrows:"@",asNavFor:"@",appendArrows:"@",prevArrow:"@",nextArrow:"@",centerMode:"@",centerPadding:"@",cssEase:"@",customPaging:"&",dots:"@",draggable:"@",fade:"@",focusOnSelect:"@",easing:"@",edgeFriction:"@",infinite:"@",initialSlide:"@",lazyLoad:"@",mobileFirst:"@",pauseOnHover:"@",pauseOnDotsHover:"@",respondTo:"@",responsive:"=?",rows:"@",slide:"@",slidesPerRow:"@",slidesToShow:"@",slidesToScroll:"@",speed:"@",swipe:"@",swipeToSlide:"@",touchMove:"@",touchThreshold:"@",useCSS:"@",variableWidth:"@",vertical:"@",verticalSwiping:"@",rtl:"@"},restrict:"AE",link:function(r,u,f){angular.element(u).css("display","none");var e,h,o,c,l,s;h=function(){e=angular.extend(angular.copy(t),{enabled:r.enabled!=="false",accessibility:r.accessibility!=="false",adaptiveHeight:r.adaptiveHeight==="true",autoplay:r.autoplay==="true",autoplaySpeed:r.autoplaySpeed!=null?parseInt(r.autoplaySpeed,10):3e3,arrows:r.arrows!=="false",asNavFor:r.asNavFor?r.asNavFor:void 0,appendArrows:r.appendArrows?angular.element(r.appendArrows):angular.element(u),prevArrow:r.prevArrow?angular.element(r.prevArrow):void 0,nextArrow:r.nextArrow?angular.element(r.nextArrow):void 0,centerMode:r.centerMode==="true",centerPadding:r.centerPadding||"50px",cssEase:r.cssEase||"ease",customPaging:f.customPaging?function(n,t){return r.customPaging({slick:n,index:t})}:void 0,dots:r.dots==="true",draggable:r.draggable!=="false",fade:r.fade==="true",focusOnSelect:r.focusOnSelect==="true",easing:r.easing||"linear",edgeFriction:r.edgeFriction||.15,infinite:r.infinite!=="false",initialSlide:parseInt(r.initialSlide)||0,lazyLoad:r.lazyLoad||"ondemand",mobileFirst:r.mobileFirst==="true",pauseOnHover:r.pauseOnHover!=="false",pauseOnDotsHover:r.pauseOnDotsHover==="true",respondTo:r.respondTo!=null?r.respondTo:"window",responsive:r.responsive||void 0,rows:r.rows!=null?parseInt(r.rows,10):1,slide:r.slide||"",slidesPerRow:r.slidesPerRow!=null?parseInt(r.slidesPerRow,10):1,slidesToShow:r.slidesToShow!=null?parseInt(r.slidesToShow,10):1,slidesToScroll:r.slidesToScroll!=null?parseInt(r.slidesToScroll,10):1,speed:r.speed!=null?parseInt(r.speed,10):300,swipe:r.swipe!=="false",swipeToSlide:r.swipeToSlide==="true",touchMove:r.touchMove!=="false",touchThreshold:r.touchThreshold?parseInt(r.touchThreshold,10):5,useCSS:r.useCSS!=="false",variableWidth:r.variableWidth==="true",vertical:r.vertical==="true",verticalSwiping:r.verticalSwiping==="true",rtl:r.rtl==="true"},r.settings)};o=function(){var n=angular.element(u);return n.hasClass("slick-initialized")&&(n.remove("slick-list"),n.slick("unslick")),n};c=function(){h();var t=angular.element(u);if(angular.element(u).hasClass("slick-initialized")){if(e.enabled)return t.slick("getSlick");o()}else{if(!e.enabled)return;t.on("init",function(n,t){return typeof e.event.init!="undefined"&&e.event.init(n,t),typeof s!="undefined"?t.slideHandler(s):void 0});n(function(){angular.element(u).css("display","block");t.not(".slick-initialized").slick(e)})}r.internalControl=e.method||{};i.forEach(function(n){r.internalControl[n]=function(){var i;i=Array.prototype.slice.call(arguments);i.unshift(n);t.slick.apply(u,i)}});t.on("afterChange",function(t,i,u){s=u;typeof e.event.afterChange!="undefined"&&n(function(){r.$apply(function(){e.event.afterChange(t,i,u)})})});t.on("beforeChange",function(t,i,u,f){typeof e.event.beforeChange!="undefined"&&n(function(){n(function(){r.$apply(function(){e.event.beforeChange(t,i,u,f)})})})});t.on("reInit",function(t,i){typeof e.event.reInit!="undefined"&&n(function(){r.$apply(function(){e.event.reInit(t,i)})})});if(typeof e.event.breakpoint!="undefined")t.on("breakpoint",function(t,i,u){n(function(){r.$apply(function(){e.event.breakpoint(t,i,u)})})});if(typeof e.event.destroy!="undefined")t.on("destroy",function(t,i){n(function(){r.$apply(function(){e.event.destroy(t,i)})})});if(typeof e.event.edge!="undefined")t.on("edge",function(t,i,u){n(function(){r.$apply(function(){e.event.edge(t,i,u)})})});if(typeof e.event.setPosition!="undefined")t.on("setPosition",function(t,i){n(function(){r.$apply(function(){e.event.setPosition(t,i)})})});if(typeof e.event.swipe!="undefined")t.on("swipe",function(t,i,u){n(function(){r.$apply(function(){e.event.swipe(t,i,u)})})});if(typeof e.event.lazyLoaded!="undefined")t.on("lazyLoaded",function(t,i,u,f){n(function(){r.$apply(function(){e.event.lazyLoaded(t,i,u,f)})})});if(typeof e.event.lazyLoadError!="undefined")t.on("lazyLoadError",function(t,i,u,f){n(function(){r.$apply(function(){e.event.lazyLoadError(t,i,u,f)})})})};l=function(){o();c()};u.one("$destroy",function(){o()});return r.$watch("settings",function(n){if(n!==null)return l()},!0)}}}]);breakpointApp=angular.module("breakpointApp",[]);breakpointApp.directive("breakpoint",["$window","$rootScope",function(n,t){return{restrict:"A",link:function(i,r,u){function o(n){t.$broadcast("breakpointChange",i.breakpoint,n)}function s(){i.breakpoint.windowSize=n.innerWidth;i.$$phase||i.$apply()}function h(n){var t=f[Object.keys(f)[0]];for(var u in f)u<n&&(t=f[u]),r.removeClass(f[u]);r.addClass(t);i.breakpoint.class=t;i.$$phase||i.$apply()}i.breakpoint={"class":"",windowSize:n.innerWidth};var f=i.$eval(u.breakpoint),e=!0;angular.element(n).bind("resize",s);i.$watch("breakpoint.windowSize",function(n){h(n)});i.$watch("breakpoint.class",function(n,t){(n!=t||e)&&(o(t),e=!1)})}}}]),function(){"use strict";var n=function(){return{require:"ngModel",scope:{otherModelValue:"=compareTo"},link:function(n,t,i,r){r.$validators.compareTo=function(t){return t==n.otherModelValue};n.$watch("otherModelValue",function(){r.$validate()})}}};myApp.directive("compareTo",n)}();rmDirectivesApp.directive("pagination",["$animate","$compile",function(){return{restrict:"AE",replace:!1,scope:{options:"=",totalItems:"=",currentPage:"=",firstText:"@",previousText:"@",nextText:"@",lastText:"@",ngDisabled:"="},bindToController:{options:"=",totalItems:"=",currentPage:"=",firstText:"@",previousText:"@",nextText:"@",lastText:"@",ngDisabled:"="},controllerAs:"pagination",templateUrl:function(n,t){return t.templateUrl||"/Static/trm/js/app/templates/pagination/pagination.html"},controller:["$http","$scope","$rootScope","$element","$attrs",function(n,t,i,r){function o(n,t,i){return{number:n,text:t,active:i}}function h(n,i){var v,p,w,b,k,d,g,nt;t.currentPage=n;e._currentPage=t.currentPage;var h=[],f=1,r=i,y=angular.isDefined(u)&&u<i;for(y&&(c?(f=Math.max(n-Math.floor(u/2),1),r=f+u-1,r>i&&(r=i,f=r-u+1)):(f=(Math.ceil(n/u)-1)*u+1,r=Math.min(f+u-1,i))),v=f;v<=r;v++)p=o(v,a(v),v===n),h.push(p);return y&&u>0&&(!c||l||s)&&(f>1&&((!s||f>3)&&(w=o(f-1,"...",!1),h.unshift(w)),s&&(f===3&&(b=o(2,"2",!1),h.unshift(b)),k=o(1,"1",!1),h.unshift(k))),r<i&&((!s||r<i-2)&&(d=o(r+1,"...",!1),h.push(d)),s&&(r===i-2&&(g=o(i-1,i-1,!1),h.push(g)),nt=o(i,i,!1),h.push(nt)))),t.totalPages=r,h}var e;var f=t.options||{maxSize:5,rotate:!0,boundaryLinkNumbers:!0,forceEllipses:!1,boundaryLinks:!0,directionLinks:!0,itemsPerPage:5},u=f.maxSize||5,c=f.rotate||!0,s=f.boundaryLinkNumbers||!0,l=f.forceEllipses||!1,a=angular.isDefined(r.pageLabel)?function(n){return t.$parent.$eval(r.pageLabel,{$page:n})}:angular.identity;t.boundaryLinks=f.boundaryLinks||!0;t.directionLinks=f.directionLinks||!0;e=this;t.pages=[];t.currentPage=1;e._currentPage=t.currentPage;t.itemsPerPage=f.itemsPerPage;e.$onInit=function(){t.totalPages=t.calculateTotalPages();t.pages=h(1,t.totalPages)};t.selectPage=function(n){n!=e._currentPage&&(t.$emit("PageChanged",{pageIndex:n}),t.pages=h(n,t.totalPages))};t.noPrevious=function(){return t.currentPage===1};t.noNext=function(){return t.currentPage===t.totalPages};t.$watch("currentPage",function(n,i){i!=n&&(t.totalPages=t.calculateTotalPages(),t.pages=h(n,t.totalPages))});t.$watch("totalItems",function(n,i){i!=n&&(t.totalPages=t.calculateTotalPages(),t.pages=h(e._currentPage,t.totalPages))});t.$watch("options",function(n,i){i!=n&&(t.totalPages=t.calculateTotalPages(),t.pages=h(e._currentPage,t.totalPages))});t.calculateTotalPages=function(){var n=this.itemsPerPage<1?1:Math.ceil(this.totalItems/this.itemsPerPage);return Math.max(n||0,1)}}],link:{post:function(){}}}}]);responsiveUtility=angular.module("responsiveUtilities",[]);responsiveUtility.directive("filterclasses",function(){function n(n){function i(){isBreakpoint("xs")||isBreakpoint("sm")?(t.headingClass="collapsed",t.sectionClass=" "):t.$index<=2?(t.headingClass=" ",t.sectionClass="in"):(t.headingClass="collapsed",t.sectionClass=" ")}var t=n;t.$watch("$index",function(){i();t.$on("breakpointChange",function(){i()})})}return{link:n,restrict:"A"}});responsiveUtility.directive("rvdirective",function(){function n(n){function i(){isBreakpoint("xs")&&(t.displayBreak=2,t.displayLimit=6);isBreakpoint("sm")&&(t.displayBreak=4,t.displayLimit=8);(isBreakpoint("md")||isBreakpoint("lg"))&&(t.displayBreak=6,t.displayLimit=6);t.hiddenItems=t.displayLimit-t.displayBreak}var t=n;i();t.$on("breakpointChange",function(){i()})}return{link:n,restrict:"A"}});responsiveUtility.directive("relatedprodsdirective",function(){function n(n){function i(){t.rpLimit=isBreakpoint("xs")?2:3}var t=n;i();t.$on("breakpointChange",function(){i()})}return{link:n,restrict:"A"}});responsiveUtility.directive("variantinfocollapse",function(){function n(n){function i(){t.showClass=isBreakpoint("xs")?" ":"in"}var t=n;i();t.$on("breakpointChange",function(){i()})}return{link:n,restrict:"A"}}),function(){angular.module("rmPasswordStrength",[]).controller("FormController",["$scope",function(){}]).filter("passwordCount",[function(){return function(n,t){return n=angular.isString(n)?n:"",t=isFinite(t)?t:7,n&&(n.length>t?t+"+":n.length)}}]).factory("zxcvbn",[function(){return{score:function(){var n=zxcvbn.apply(null,arguments);return n&&n.score}}}]).directive("okPassword",["zxcvbn",function(n){return{restrict:"AC",require:"ngModel",link:function(t,i,r,u){i.on("blur change keydown",function(){t.$evalAsync(function(t){var r=t.password=i.val(),f=n.score(r);if(t.passwordStrength=r?r.length>7&&n.score(r)||0:null,!r){u.$setValidity("okPassword",null);return}u.$setValidity("okPassword",t.passwordStrength>=2)})})}}}])}();rmTransactionHistory=angular.module("rmTransactionHistory",["services","rmDirectives"]);rmTransactionHistory.controller("rmTransactionHistoryController",["$scope","myService","errorHandler",function(n,t){var r=this,i=n;i.isFetchedData=!1;i.fetchedView="";i.pageSize=pageSize||5;i.currentPage=1;i.filterKey="";i.totalItems=totalItems||0;i.options={maxSize:5,rotate:!0,boundaryLinkNumbers:!0,forceEllipses:!1,boundaryLinks:!0,directionLinks:!0,itemsPerPage:i.pageSize};r.$onInit=function(){};n.$on("PageChanged",function(t,r){n.currentPage=r.pageIndex;i.onFilter()});i.onFilter=function(n){n&&(i.currentPage=1);t.getFeed("mvcApi/TransactionHistory/Filter?transactionType="+i.filterKey+"&pageSize="+i.pageSize+"&pageNumber="+i.currentPage).then(function(n){n.data&&(i.isFetchedData=!0,i.fetchedView=n.data.View,i.totalItems=n.data.TotalItems,i.currentPage=n.data.PageNumber)})}}]);rmArticleListing=angular.module("rmArticleListingController",["services"]);rmArticleListing.controller("rmArticleListing",["$scope","$element",function(n,t){var i=n;i.currentPage=1;i.url="";i.moreToLoad=!1;i.loadMore={ContentReference:1,Page:1,ResultsPerPage:1};i.init=function(n,t,r,u,f){i.loadMore.ContentReference=n;i.loadMore.ResultsPerPage=t;i.url=r;i.TotalArticles=u;i.moreToLoad=f};i.loadMoreArticles=function(){return i.loadMore.Page=i.loadMore.Page+1,$.post(i.url,i.loadMore,function(n){$(".articleBlockGridView",t).append(n.articles)}),i.loadMore.Page*i.loadMore.ResultsPerPage>=i.TotalArticles&&(i.moreToLoad=!1),!1}}]);rmHistoricMetalPriceChartController=angular.module("rmHistoricMetalPriceChartController",["services"]);rmHistoricMetalPriceChartController.controller("rmHistoricMetalPriceChart",["$scope","$http","$location","myService",function(n,t,i){function f(){var n=e();r.chartOptions={legend:{position:"none"},chartArea:{top:10,width:"100%",height:"80%"},hAxis:{gridlines:{count:r.vAxisGridLines},format:n},vAxis:{format:u()+"#,###.00",gridlines:{count:r.hAxisGridLines},textPosition:"in"},titlePosition:"in",axisTitlesPosition:"in",fontName:"corpid_c4_regular"}}function e(){switch(r.period){case"Today":case"Live":return"HH:mm:ss";default:return"dd/MM/yyyy"}}function u(){switch(r.currency){case"gbp":return"£";case"eur":return"€";default:return"$"}}function o(n){var t,o;f();google.charts.load("current",{packages:["corechart"]});t=new google.visualization.DataTable;t.addColumn("datetime","point");t.addColumn("number","");var u=[],e=[],i=new Date(1900,1,1);$.each(n,function(n,t){var r=new Date(parseInt(t.Time.substr(6)));u.push([r,t.Value]);(r.getFullYear()!==i.getFullYear()||r.getMonth()!==i.getMonth()||r.getDate()!==i.getDate())&&(e.push(r),i=r)});r.period==="Week"&&(r.chartOptions.hAxis.ticks=e);t.addRows(u);o=new google.visualization.LineChart(document.getElementById(r.chartId));o.draw(t,r.chartOptions)}var r=this;r.isLoading=!0;r.chartId="";r.period="Live";r.commodity="xau";r.currency="eur";r.vAxisGridLines=6;r.hAxisGridLines=6;r.refreshFrequently=3e3;r.summary={};r.lastUpdatedTime={};r.chartOptions={legend:{position:"none"},chartArea:{top:10,width:"100%",height:"80%"},hAxis:{gridlines:{count:r.vAxisGridLines}},vAxis:{format:u()+"#,###.00",prefix:"XXX",gridlines:{count:r.hAxisGridLines},textPosition:"in"},titlePosition:"in",axisTitlesPosition:"in",fontName:"corpid_c4_regular"};setTimeout(function(){window.addEventListener("load",function(){r.changeChartView(r.period,r.currency,r.commodity,!0)})},1e3);r.intervalLive;r.changeChartView=function(n,t,i,u){clearInterval(r.intervalLive);n==="Live"?(r.drawChart(n,t,i,u),r.intervalLive=setInterval(function(){r.drawChart(n,t,i,!0)},r.refreshFrequently)):(clearInterval(r.intervalLive),r.drawChart(n,t,i,u))};r.drawChart=function(n,u,f,e){r.period=n;r.currency=u;r.commodity=f;r.isLoading=!0;t({method:"GET",url:"/mvcApi/MetalPrice/GetChartData?period="+r.period+"&currency="+r.currency+"&commodity="+r.commodity}).then(function(n){var t=n.data;setTimeout(function(){o(t.chartData)},1e3);r.summary=t.summary;r.lastUpdatedTime=t.chartData[t.chartData.length-1].StringTime;r.isLoading=!1;e||i.search("period="+r.period+"&currency="+r.currency+"&commodity="+r.commodity)})};r.initData=function(n,t,u){i.$$search&&i.$$search.period?(r.period=i.$$search.period,r.currency=i.$$search.currency,r.commodity=i.$$search.commodity):(r.period=n,r.currency=u,r.commodity=t)}}]);rmCustomerServiceController=angular.module("rmCustomerServiceController",["services"]);rmCustomerServiceController.controller("rmCustomerService",["$scope","$http","myService","$window",function(n,t,i,r){var u=this;u.searchText="";u.isLoading=!1;u.userList=[];u.currentPage=1;u.pageSize=30;u.totalItems=0;u.noResults=!1;u.sortOrder="";u.sortAsc=!0;u.sortType="";u.pagingOptions={maxSize:5,rotate:!0,boundaryLinkNumbers:!0,forceEllipses:!1,boundaryLinks:!0,directionLinks:!0,itemsPerPage:u.pageSize};n.hasStatamentData=!1;n.selectedStatement="select";n.currentStatement="select";n.$on("PageChanged",function(n,t){u.goToPage(t.pageIndex)});u.searchUsers=function(){this.isLoading=!0;var n=u.sortOrder?"&sortOrder="+u.sortOrder:"",i=u.sortType?"&sortType="+u.sortType:"";u.pagingOptions.itemsPerPage=u.pageSize;t({method:"GET",url:"/mvcApi/customerservice/searchcontacts?keyword="+u.searchText+n+i+"&page="+u.currentPage+"&pagesize="+u.pageSize}).then(function(n){u.userList=n.data.list;u.totalItems=n.data.totalPages*u.pageSize;u.noResults=u.userList.length===0;u.isLoading=!1})};u.onSearchUsers=function(){u.currentPage=1;u.sortOrder="AccountStatus";u.sortType="Desc";u.sortAsc=!1;u.searchUsers()};u.goToPage=function(n){u.currentPage=n;u.searchUsers()};u.onSorting=function(n){u.currentPage=1;u.sortAsc=u.sortOrder===n?!u.sortAsc:!0;u.sortOrder=n;u.sortType=u.sortAsc?"Asc":"Desc";u.searchUsers()};u.onImpersonate=function(i){i&&(n.formData={},n.formData.userName=i,t({method:"POST",data:$.param(n.formData),url:"/mvcApi/customerservice/impersonate",headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){n.data.success&&(r.location.href=n.data.redirectUrl)}))}}]);rmSIPPSSASAdminController=angular.module("rmSIPPSSASAdminController",["services"]);rmSIPPSSASAdminController.controller("rmSIPPSSASAdmin",["$scope","$http","myService","$window",function(n,t,i,r){var u=this;u.searchText="";u.isLoading=!1;u.userList=[];u.pagers=[];u.currentPage=1;u.pageSize=30;u.totalItems=0;u.totalPages=1;u.onSearch=!1;u.pagingOptions={maxSize:5,rotate:!0,boundaryLinkNumbers:!0,forceEllipses:!1,boundaryLinks:!0,directionLinks:!0,itemsPerPage:u.pageSize};n.hasStatamentData=!1;n.selectedStatement="select";n.currentStatement="select";n.$on("PageChanged",function(n,t){u.goToPage(t.pageIndex)});u.searchUsers=function(){u.pagingOptions.itemsPerPage=u.pageSize;this.isLoading=!0;t({method:"GET",url:"/mvcApi/sippssasadmin/searchcontacts?keyword="+u.searchText+"&page="+u.currentPage}).then(function(n){var t=n.data;u.userList=t.list;u.totalPages=t.totalPages;u.totalItems=t.totalPages*u.pageSize;u.isLoading=!1})};u.impersonateUser=function(i){i&&(n.formData={},n.formData.userEmail=i,t({method:"POST",data:$.param(n.formData),url:"/mvcApi/sippssasadmin/Impersonate",headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){n.data.success&&(r.location.href=n.data.redirectUrl)}))};u.onSearchUsers=function(){u.currentPage=1;u.onSearch=!0;u.searchUsers()};u.goToPage=function(n){u.currentPage=n;u.searchUsers()}}]);changeLoginDetailsController=angular.module("rmChangeLoginDetailsController",["services"]);changeLoginDetailsController.controller("rmChangeLoginDetails",["$scope","$http","$window",function(n,t,i){var u=this,r=n;r.hasSuccess=!1;r.hasFailure=!1;r.securityQuestions=null;r.userName=null;r.confirmPassword="";r.password="";r.securityAnswer="";r.confirmSecurityAnswer="";n.init=function(){r.securityQuestionSelected="";r.password="";r.formData={};r.formData.__RequestVerificationToken=$("#changeLoginDetailsForm input[name=__RequestVerificationToken]").val();t({method:"POST",url:"/mvcApi/GetSecurityQuestions",data:$.param(r.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){n.data.listSecurityQuestion?(r.securityQuestions=n.data.listSecurityQuestion,r.userName=n.data.userName):i.location.href=n.data.RegistrationUrl})};n.updateUserPassword=function(n){if(onSubmitForm("#change-login-detail"),n.$invalid){onClearSubmitForm("#change-login-detail");return}if(r.formData={},r.formData.__RequestVerificationToken=$("#changeLoginDetailsForm input[name=__RequestVerificationToken]").val(),r.formData.SecurityQuestion=r.securityQuestionSelected,r.formData.SecurityAnswer=r.securityAnswer,r.formData.Password=r.originalPassword,r.formData.NewPassword=r.password,r.formData.Password===r.formData.NewPassword){onClearSubmitForm("#change-login-detail");return}t({method:"POST",url:"/mvcApi/ChangeLoginDetails",data:$.param(r.formData),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){onClearSubmitForm("#change-login-detail");n.data.success?(r.hasSuccess=!0,r.hasFailure=!1,window.location.href=redirectTo):(r.hasSuccess=!1,r.hasFailure=!0)})}}])