var Watchfinder=Watchfinder||{};Watchfinder.LocateStore=function(){function r(){if($(".locations",n).length>0){var t=document.getElementsByClassName("locations")[0].offsetWidth-document.getElementsByClassName("locations")[0].clientWidth;t==0?$("html").addClass("hidden-scrollbar"):$("html").removeClass("hidden-scrollbar")}}function e(){if(navigator.geolocation)var n=navigator.geolocation.getCurrentPosition(s,h);else window.location.href="/locations/list"}function o(t,i){$(".map",n).attr("src")!==t&&($(".map",n).addClass("fade-out"),setTimeout(function(){$(".map",n).attr("src",t)},500),setTimeout(function(){$(".map",n).removeClass("fade-out")},1e3));$("#EnquiryType",f).val(i)}function s(n){window.location.href="/locations/geolocate?lat="+n.coords.latitude+"&lng="+n.coords.longitude}function h(n){$(".btn-locate",t).removeClass("disabled active-submit").addClass("failed-submit");switch(n.code){case n.PERMISSION_DENIED:wfHelpers.translate("Site.PermissionDenied",function(n){$(".geo-notify",t).html(n).show()});break;case n.POSITION_UNAVAILABLE:wfHelpers.translate("Locations.Error.Unavailable",function(n){$(".geo-notify",t).html(n).show()});break;case n.TIMEOUT:wfHelpers.translate("Locations.Error.Timeout",function(n){$(".geo-notify",t).html(n).show()});break;case n.UNKNOWN_ERROR:wfHelpers.translate("Locations.Error.Failed",function(n){$(".geo-notify",t).html(n).show()})}}function c(n){var t=n.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function l(n){var t=n.accelerationIncludingGravity.x,r=n.accelerationIncludingGravity.y,f=n.accelerationIncludingGravity.z;t=i(t);r=i(r);f=i(f);var h=$(".locations-container-bkg"),e=$(window).width(),c=$(window).height(),o=e/(100/u(t,1))/10,l=o>100?100:o,s=c/(100/u(r,1))/20,a=s>100?100:s;e<=767&&$(h).css({"background-position":"calc(50% - "+l+"px) calc(50% - "+a+"px)"})}function i(n){var t=n;return Math.round(t*10)/10}function u(n,t){var r=0;return r=t?(n+10)*5:(n+10)/20,i(r)}var t="#locations_locate",n="#locations_list",f="#modal_locations-message";$(window).on("load",function(){r()});matchMedia("(min-width:768px)").matches&&modules.collapse.select($(".boutique_item:eq(0) > .btn-collapse"));window.addEventListener("devicemotion",l,!0);$(t).on("submit",".search-address",function(){$(this).valid()?($(this).find('button[type="submit"]').addClass("disabled active-submit"),dataLayer.push({"locate-a-store-search-term":$("input[name=Postcode]").val()})):$(".btn-locate").removeClass("disabled active-submit")});$(t).on("click",".btn-locate",function(){$(this).addClass("disabled active-submit");e()});$(n).on("click","[data-accordion=boutiques]",function(){var i=$(this).data("iframe"),r=$(this).data("enqtype");o(i,r);var u=$(this),n=u.parent().attr("id"),t=setInterval(function(){matchMedia("(min-width:768px)").matches?$("#"+n+" .collapse-visible").length>0&&(c(document.getElementById(n))||document.getElementById(n).scrollIntoView({behavior:"smooth",block:"end"}),clearInterval(t)):$("#"+n+" .collapse-visible").length>0&&($("html, body").animate({scrollTop:$("#"+n).offset().top-20},"slow"),clearInterval(t))},100)});$(n).on("click","[data-action=get-all-regions]",function(t){t.preventDefault();var i=$(".boutique_item .collapse-visible + .chevron",n),u=$(".boutique_item .collapse-visible + .chevron + .chevron-shadow",n),f=$(".international-locations-target",n);i.css({right:0});u.css({right:"20px"});$.ajax({context:this,url:"/locations/list/all?listOnly=true",method:"GET",success:function(n){$(this).parent().slideUp(function(){f.append($(n).find(".locations > *"));f.slideDown(400,function(){r();i.removeAttr("style");u.removeAttr("style")})})}})})}()