function setLoading(n){n?$("#loading-indicator").removeClass("hidden"):$("#loading-indicator").addClass("hidden")}function showDynamicStoreSearch(n){n&&(showSearchElements(),comboSearch(""),getLocation())}function showSearchElements(){$("#customer-suburb, .customer-suburb").focus();var n=$("#customer-suburb, .customer-suburb")[0];n.value="";comboSearch("");$("#customer-suburb, .customer-suburb").unbind("keyup");$("#customer-suburb, .customer-suburb").on("keyup",function(){comboSearch($(this).val(),$(this).hasClass("local-store-offers-customer-suburb"))})}function comboSearch(n,t){n=n.trim();n.length<3?(clearTimeout(timer),setLoading(!1),$(".combo-search-results").children().fadeOut(function(){$(this).remove()}),$(".combo-search-results").addClass("hidden"),previousSearch="",previousNumbers="NONE"):n!==previousSearch&&(setLoading(!0),getStoresWithDelay(n,findStore,updateComboResults,t),previousSearch=n)}function findStore(n){return filter(storeList,function(t){return t.Number.toString()===n})[0]}function setTimeoutValue(n){timeout=n}function getStoresWithDelay(n,t,i,r){timeout>0?(timer&&clearTimeout(timer),timer=setTimeout(function(){getStores(n,t,i,r)},timeout)):getStores(n,t,i,r)}function getStores(n,t,i,r){var u=parseInt(maxStores),f;u||(u=null);f="/dynamicstoresearchapi/getlimitedstores/"+u+"/"+encodeURIComponent(n);(countryCode=="BE"||countryCode=="LU")&&(f="/"+window.location.pathname.split("/")[1]+"/dynamicstoresearchapi/getlimitedstores/"+u+"/"+encodeURIComponent(n));setLoading(!0);$.ajax({type:"GET",url:f,success:function(n){setLoading(!1);storeNumbers="";n.Data.length>0?(storeList=n.Data,$.each(storeList,function(n,t){storeNumbers+=t.StoreNo})):storeList=[{Number:"NO_MATCH"}]},complete:function(){i&&i(r)}})}function updateComboResults(n){var t=$("#local-store-special-offers .combo-search-results"),i;n||(t=$(".combo-search-results").not("#local-store-special-offers .combo-search-results"));storeNumbers!==previousNumbers&&(t.empty(),t.removeClass("hidden"),storeNumbers?$.each(storeList,function(n,r){var u,f;switch(countryCode){case"AU":case"NZ":case"NL":case"BE":case"DE":case"DK":case"SG":u=dominosLabel+" "+r.Name;f=r.Address.StreetName+"<br>"+r.Address.PostalCode+" "+r.Address.Suburb;break;case"FR":case"LU":u=dominosLabel+" "+r.Name;f=r.Address.StreetName+", <br>"+r.Address.Suburb+" "+r.Address.State+" "+r.Address.PostalCode;break;default:u=r.FullName;f=""}i=$("<li data-storenumber='"+r.StoreNo+"'><a class= 'store-result dynamicStoreSearchbtn' data-menuCode='"+menuCode+"'data-country= '"+countryCode+"'data-storeno='"+r.StoreNo+"'data-name='"+r.Name.replace(/'/g,"&#39;")+"'data-state='"+r.Address.State+"'data-onlineordering='"+(r.OrderingMethods.Online?"true":"false")+"'data-postalcode='"+r.Address.PostalCode+"'data-storeurl ='"+r.Properties.storeUrl+"'data-offersurl ='"+r.Properties.offersUrl+"'onclick='setCookieAndReloadStoreMenu(this);'><div class='resultStoreNameOuterDiv'><div class='resultStoreNameDiv'>"+u+"<\/div><p class='storeAddress'>"+f+"<\/p><span class='selectBtn'>"+selectBtnLabel+"<\/span><\/div><\/a><\/li>");t.append(i);i.fadeIn()}):t.append($('<li><div class="noResultFoundDiv">'+noResultFoundMsg+"<\/div><\/li>")).fadeIn());setLoading(!1);previousNumbers=storeNumbers}function setCookieAndReloadStoreMenu(n){var t={countryCode:$(n).data("country"),storeNo:$(n).data("storeno"),name:$(n).data("name"),state:$(n).data("state"),onlineOrdering:$(n).data("onlineordering"),postalcode:$(n).data("postalcode")};return setCookieAndReloadStoreMenuFromJson(t),reloadOnSamePage==="true"?location.reload():window.location.href=onClickOfStoreGoToStoreDetails==="true"?$(n).data("storeurl"):onClickOfStoreGoToOffersPage==="true"?$(n).data("offersurl"):$(n).data("offersurl"),!1}function setCookieAndReloadStoreMenuFromJson(n){var t=new Date,i=t.getTime();i+=36e5;t.setTime(i);document.cookie="preferredStore="+encodeURI(JSON.stringify(n))+"; expires="+t.toUTCString()+"; path=/";document.cookie="StoreNo="+n.storeNo+"; expires="+t.toUTCString()+"; path=/"}function initLocation(){if(setLoading(!0),navigator.geolocation){var n={enableHighAccuracy:!0,timeout:1e4,maximumAge:0};navigator.geolocation.getCurrentPosition(i,t,n);function i(n){var i=`/GetStoreLocale?lon=${n.coords.longitude}&lat=${n.coords.latitude}`;fetch(i).then(function(n){return n.ok?n.json():null}).then(function(n){n!==null&&getStores(n,null,updateDefaultStore)}).catch(t)}function t(){setLoading(!1)}}else setStoreDetails()}function setStoreDetails(){showDynamicStoreSearch(!0)}function getLocation(){var n,t;if(setLoading(!0),n=$("#customer-suburb, .customer-suburb")[0],n.value="",navigator.geolocation){t={enableHighAccuracy:!0,timeout:5e3,maximumAge:0};navigator.geolocation.getCurrentPosition(r,i,t);function r(t){var r=`/GetStoreLocale?lon=${t.coords.longitude}&lat=${t.coords.latitude}`;fetch(r).then(function(n){return n.ok?n.json():null}).then(function(t){t!==null&&(n.value=t,comboSearch(n.value))}).catch(i)}function i(){setLoading(!1)}}}function showHideLocalOffersStoreFinder(n){n?($(".localStoreFinderV1Section").removeClass("hidden"),$("#local-store-special-offers .change-local-store").hide(),$("#local-store-special-offers .cancel-local-store-finder").show(),$("#local-store-special-offers .loading-indicator").addClass("hidden")):($(".localStoreFinderV1Section").addClass("hidden"),$("#local-store-special-offers .change-local-store").show(),$("#local-store-special-offers .cancel-local-store-finder").hide(),$("#local-store-special-offers .customer-suburb").val(""),comboSearch(""))}function showHideLocalStoreFinder(n){n?($("#storeFinderV1Section").removeClass("hidden"),$("#change-local-store").hide(),$("#cancel-local-store-finder").show(),$("#loading-indicator").addClass("hidden")):($("#storeFinderV1Section").addClass("hidden"),$("#change-local-store").show(),$("#cancel-local-store-finder").hide(),$("#customer-suburb, .customer-suburb").val(""),comboSearch(""))}var previousNumbers,previousSearch,storeList=[],timeout,timer,storeNumbers;$(document).ready(function(){setLoading(!1);showSearchElements();typeof PageBackgroundImageDesktop!="undefined"&&typeof PageBackgroundImageMobile!="undefined"&&($(window).width()>768?$(".gridArticle").css("background-image","url("+PageBackgroundImageDesktop+")"):$(".gridArticle").css("background-image","url("+PageBackgroundImageMobile+")"))})