var productId=0,productType=1,variantId=0,variantPrice=0,variantData=[],productTitle="",bundlePrice=0,setPrice=0,rrpPrice=0,savePrice=0,skipEngPrompt=!1,googleAnalyticsId="",centreDiscOverlay=null,optionGroupLogTimers=[],optionGroupItemPageSize=50,addToBasketModalEnabled=!1,nextDayCutoff=new Date,nextDayCountdownInterval=!1,nextDayCountdownTimer=!1,backInStockAlertData=null,canvas=null,canvasDefaultWidth=1e3,canvasDefaultHeight=1e3,canvasClipPathScale=.7,canvasClipPathWidth=0,canvasClipPathHeight=0,canvasClipPathX=0,canvasClipPathY=0;function updatePrice(){var e=parseInt($("#quantity").val());isNaN(e)&&(e=1),$("#totalPrice").html(asCurrency(bundlePrice*e)),$("#pDtl .pricing .prc span").html(asCurrency(bundlePrice)),savePrice>0?($("#pDtl .pricing .was .rrp").html(asCurrency(rrpPrice)),$("#pDtl .pricing .was .save").html(asCurrency(savePrice)),$("#pDtl .pricing .was").removeClass("hid")):$("#pDtl .pricing .was").addClass("hid")}function variantFilterRefresh(){variantId=0,variantData.forEach(function(e){e.avl=!0});var e=variantData.map(function(e){return{kId:e.kId,aId:0}}).filter(function(e,t,a){return a.map(function(e){return e.kId}).indexOf(e.kId)===t});$('.variants select, .variants .rbLst input[type="radio"]:checked').each(function(){var t=$(this).get(0),a="INPUT"==t.tagName?parseInt(t.parentElement.dataset.keyid):parseInt(t.dataset.keyid),r="INPUT"==t.tagName?parseInt(t.dataset.attrid):t.selectedIndex>0?parseInt(t.options[t.selectedIndex].value):0;r>0&&(e.filter(function(e){return e.kId==a})[0].aId=r,variantData.filter(function(e){return e.kId===a&&e.aId!=r}).forEach(function(e){variantData.filter(function(t){return t.pId===e.pId}).forEach(function(e){e.avl=!1})}))}),$('.variants select option, .variants .rbLst input[type="radio"]').each(function(){var t=$(this).get(0),a=parseInt(t.parentElement.dataset.keyid),r=variantData.map(function(e){return{kId:e.kId,aId:e.aId,pId:e.pId,price:e.price,rrp:e.rrp,save:e.save,avl:!0}});e.filter(function(e){return e.kId!=a&&e.aId>0}).forEach(function(e){r.filter(function(t){return t.kId===e.kId&&t.aId!=e.aId}).forEach(function(e){r.filter(function(t){return t.pId===e.pId}).forEach(function(e){e.avl=!1})})});var i="INPUT"==t.tagName?parseInt(t.dataset.attrid):parseInt(t.value);t.disabled=i>0&&0==r.filter(function(e){return e.aId==i&&e.avl}).length;var n=r.filter(function(e){return e.kId==a&&e.aId==i&&e.avl}).map(function(e){return{price:e.price,rrp:e.rrp,save:e.save}}).sort(function(e,t){return e.price<=t.price?-1:1}),o=parseFloat(n.length?n[0].price:0);if(t.checked&&(variantPrice>0&&(bundlePrice-=variantPrice,bundlePrice+=setPrice,variantPrice=0),o>0&&(bundlePrice-=setPrice,bundlePrice+=variantPrice=o,rrpPrice=parseFloat(n[0].rrp),savePrice=parseFloat(n[0].save))),n=r.filter(function(e){return e.kId==a&&e.avl}).map(function(e){return e.price}).filter(function(e,t,a){return a.map(function(e){return e}).indexOf(e)===t}),"INPUT"==t.tagName){var l=t.nextSibling.querySelector(".price");l&&(n.length>1&&o>0?(l.querySelector("b").innerHTML=asCurrency(o),l.classList.remove("hid")):l.classList.add("hid"))}else"OPTION"==t.tagName&&"0"!=t.value&&(n.length>1&&o>0?t.text=t.dataset.value+" ("+asCurrency(o)+")":t.text=t.dataset.value)});var t=variantData.filter(function(e){return e.avl}).map(function(e){return e.pId}).filter(function(e,t,a){return a.map(function(e){return e}).indexOf(e)===t});if(1==t.length&&(variantId=t[0]),variantId>0){document.getElementById("addToBasket").classList.remove("dis"),document.getElementById("addToBasket").disabled=!1,variantPrice>0&&(bundlePrice-=variantPrice,bundlePrice+=setPrice);var a=variantData.filter(function(e){return e.avl&&e.pId==variantId}).map(function(e){return{pId:e.pId,price:e.price,rrp:e.rrp,save:e.save}}).filter(function(e,t,a){return a.map(function(e){return e.pId}).indexOf(e.pId)===t})[0];(variantPrice=parseFloat(void 0!==a?a.price:0))>0&&(bundlePrice-=setPrice,bundlePrice+=variantPrice)}else document.getElementById("addToBasket").classList.add("dis"),document.getElementById("addToBasket").disabled=!0;updatePrice()}function changeEngravingType(e){$(".engravOpt, #alerts").hide();var t=$("#"+e.target.id),a=t.data("type"),r=parseFloat(t.data("unitprice")),i=""!=t.val()?t.val():0;if("Standard"==a){for(var n=$("#engraveItems").val().replace(/(^,)|(,$)/g,"").split(","),o=0,l=0;l2){var p=parseFloat(d[2]);if("Standard"==d[0]){for(n=$("#engraveItems").val().replace(/(^,)|(,$)/g,"").split(","),o=0,l=0;l-1?(a.val(a.val().replace(","+e+",",",")),bundlePrice-=t):(a.val(a.val()+e+","),bundlePrice+=t),updatePrice()}function toggleOptionGroupItem(e){var t=$(".optToggle",this),a=$(this).parents(".optGrp").first(),r=$(this),i=null!=t.parents(".optGrp").data("oneprice")?parseFloat(t.parents(".optGrp").data("oneprice")):null!=t.data("price")?parseFloat(t.data("price")):0;if(r.hasClass("selected"))r.removeClass("selected"),t.attr("value",i18n("add")),$('.pLst[data-groupset="'+a.data("groupset")+'"]').removeClass("hasSelection"),bundlePrice-=i;else{if($("#alerts",a).remove(),r.parents(".optGrp").hasClass("cdUpld")&&null==localStorageGet("customCentreDisc"))return void oById("cdUploadBtn").click();var n=r.siblings(".selected");if($('.optGrp[data-groupset="'+a.data("groupset")+'"]:not(#'+a.id+")").each(function(){0==n.length&&(n=$(".item.selected",$(this)))}),n.length){var o=$(".optToggle",n),l=null!=n.parents(".optGrp").data("oneprice")?parseFloat(n.parents(".optGrp").data("oneprice")):null!=o.data("price")?parseFloat(o.data("price")):0;bundlePrice-=l,n.removeClass("selected"),$('.pLst[data-groupset="'+a.data("groupset")+'"]').removeClass("hasSelection"),o.attr("value",i18n("add"))}r.addClass("selected"),t.attr("value",i18n("remove")),$('.pLst[data-groupset="'+a.data("groupset")+'"]').addClass("hasSelection"),bundlePrice+=i}if(a.hasClass("cdOvl")){var s=oQuery("#pDtl .altImg .item"),c=oQuery("#pDtl .mainImg .item"),d=r.hasClass("selected")&¢reDiscOverlay?"&overlay="+r.data("img")+";"+centreDiscOverlay.x+";"+centreDiscOverlay.y+";"+centreDiscOverlay.w+";"+centreDiscOverlay.h+";"+centreDiscOverlay.s+";"+centreDiscOverlay.m:"";if(s){(v=s.oQuery("img")).src=v.src.replace(/&overlay=[^&]+/,"")+d;var p=s.oQuery("source");p.srcset=p.srcset.replace(/&overlay=[^&]+/,"")+d}if(c){var u=c.oQuery("a"),v=u.oQuery("img");u.href=u.href.replace(/[\?&]overlay=[^&]+/,"")+d.replace(/^&/g,"?"),v.src=v.src.replace(/&overlay=[^&]+/,"")+d,c.oQueryAll("source").forEach(function(e){e.srcset=e.srcset.replace(/&overlay=[^&]+/,"")+d})}}updatePrice()}function addToBasket(e){if(3!=productType||0!=variantId){var t=$("#pDtl .engraveOptions").length>0,a=$("#engravingType"),r=t?a.val().split("|")[0]:"Standard",i={},n=!0;if($(".optGrp.required").each(function(){var e=$(this);if(!$('.pLst[data-groupset="'+e.data("groupset")+'"] .item').hasClass("selected")){$("html, body").animate({scrollTop:e.offset().top-("fixed"==$("#hdr").css("position")?$("#hdr").outerHeight():0)-(isDesktop?16:8)},0);var t=i18n("pleaseChooseAnOption")+" '"+e.data("title")+"' "+i18n("section");setTimeout(function(){modalAlert(i18n("forgetSomething"),t)},50),n=!1}}),n){if($(".jqFileUploadWrap .uploading").length)return e.preventDefault(),void alert(i18n("waitUntilAllFilesUploaded"));if(skipEngPrompt)skipEngPrompt=!1;else{var o=!1;switch(r){case"ArtworkUpload":case"DesignService":o=$('.engravOpt[data-optionid="'+a.val().split("|")[1]+'"] .jqFileUpload').get(0).files.length<1;break;case"ArtworkSend":break;case"Standard":if($("#pDtl .dtl .engraving, #pDtl .dtl .giftEngraving").length){for(var l=0,s=$('#pDtl .dtl .engraving textarea, #pDtl .dtl .engraving input[type="text"], #pDtl .dtl .giftEngraving input[type="text"], #pDtl .dtl .giftEngraving input[type="date"], #pDtl .dtl .giftEngraving textarea, #pDtl .dtl .giftEngraving select'),c=0;ci.width?(i.scaleToHeight(centreDiscOverlay.w*t),i.set({left:canvasClipPathX+(a.width*a.scaleX-i.width*i.scaleX)/2,top:canvasClipPathY})):(i.scaleToWidth(centreDiscOverlay.h*t),i.set({left:canvasClipPathX,top:canvasClipPathY+(a.height*a.scaleY-i.height*i.scaleY)/2})),i.clipPath=a,canvas.add(a),canvas.add(i),canvasClipPathWidth=a.width*t,canvasClipPathHeight=a.height*t,""!=centreDiscOverlay.m&&fabric.Image.fromURL(HTTPHost+centreDiscOverlay.m,function(e){e.width=canvasDefaultWidth,e.height=canvasDefaultHeight,e.originX="left",e.originY="top",e.scaleX=1,e.scaleY=1,e.perPixelTargetFind=!0,e.absolutePositioned=!0,e.selectable=!1,e.id="maskOverlay",e.scaleToHeight(canvasClipPathHeight).set({left:canvasClipPathX,top:canvasClipPathY}),canvas.add(e),canvas.bringToFront(e)}),canvas.setActiveObject(i),e.set({left:-centreDiscOverlay.x*t+canvasClipPathX,top:-centreDiscOverlay.y*t+canvasClipPathY}).scale(t),canvas.backgroundImage=e;var n=document.createElement("img");n.src=HTTPHost+"/Img/Cross.svg",fabric.Object.prototype.controls.deleteControl=new fabric.Control({x:.5,y:-.5,offsetY:-20,offsetX:20,cursorStyle:"pointer",mouseUpHandler:function(e,t){var a=t.target,r=a.canvas;r.remove(a),r.requestRenderAll(),oQuery("#fileUpload_Files .remove").click(),oQuery("#centreDiscUpload").classList.remove("hasFile"),oQueryAll("#centreDiscUpload .error").forEach(function(e){e.remove()})},render:function(e,t,a,r,i){var o=this.cornerSize;e.save(),e.translate(t,a),e.rotate(fabric.util.degreesToRadians(i.angle)),e.drawImage(n,-o/2,-o/2,o,o),e.restore()},cornerSize:24})},r.src=a,window.uplCntrTimer=setInterval(function(){canvasClipPathWidth>0&&canvasClipPathHeight>0&&(clearInterval(window.uplCntrTimer),canvasFitToPageSize(),oQuery("#centreDiscUpload .canvasWrapper").classList.toggle("processing"))},250)})}}function canvasFitToPageSize(){if(oById("centreDiscUpload")&&canvasClipPathWidth>0&&canvasClipPathHeight>0){canvas.setWidth(canvasDefaultWidth),canvas.setHeight(canvasDefaultHeight);var e=oQuery("#centreDiscUpload").offsetWidth,t=oQuery("#modalContent").offsetHeight-oQuery(".info").offsetHeight-32,a=Math.min(e/(canvasClipPathWidth/canvasClipPathScale),t/(canvasClipPathHeight/canvasClipPathScale));canvas.setZoom(a>1?1:a);var r=e/2-canvasDefaultWidth*a/2;canvas.viewportTransform[4]=r,canvas.renderAll(),canvas.calcOffset()}}function centreDiscSave(){canvas.backgroundImage=null,""!=centreDiscOverlay.m&&canvas.getObjects().forEach(function(e){"maskOverlay"===e.id&&canvas.remove(e)}),canvas.setZoom(1),canvas.viewportTransform[4]=0;var e={dataURL:canvas.toDataURL({width:canvasClipPathWidth+4,height:canvasClipPathHeight+4,top:canvasClipPathY-2,left:canvasClipPathX-2,format:"png"}),saveLocation:"CustomerArtwork"};oQueryAll("#centreDiscUpload .error").forEach(function(e){e.remove()}),$.ajax({url:FolderRoot+"Handlers/FileSave.ashx",type:"POST",cache:!1,data:e,success:function(e){if(null!=e.data.filePath){localStorageRemove("customCentreDisc"),localStorageSet("customCentreDisc",e.data.filePath),oQueryAll(".optGrp.cdOvl .item.selected .optToggle").forEach(function(e){e.click()});var t=oQuery(".cdUpld");t.classList.add("hasFile");var a=t.oQuery(".item");a.removeAttribute("data-img"),a.oQuery("img").removeAttribute("src"),a.dataset.img=localStorageGet("customCentreDisc"),$(".item",t).data("img",localStorageGet("customCentreDisc")),a.oQuery("img").setAttribute("src",FolderRoot+localStorageGet("customCentreDisc")+"?w=180&h=180"),a.oQuery(".optToggle").click(),oQ("#cdUploadClear").addEventListener("click",centreDiscClear),oQ("#cdUploadClear").classList.remove("hid"),modalHide()}else{oQuery("#centreDiscUpload").classList.add("saveErr");var r=oQuery("#fileUpload_Wrap"),i=document.createElement("div");i.classList.add("error"),i.innerHTML="undefined"!=typeof i18n?i18n("fileUploadError"):"Sorry but we couldn't upload the file you selected. Please try again.",r.parentElement.appendChild(i)}},error:function(e){oQuery("#centreDiscUpload").classList.add("saveErr");var t=oQuery("#fileUpload_Wrap"),a=document.createElement("div");a.classList.add("error"),a.innerHTML="undefined"!=typeof i18n?i18n("fileUploadError"):"Sorry but we couldn't upload the file you selected. Please try again.",t.parentElement.appendChild(a)}})}function centreDiscClear(){localStorageRemove("customCentreDisc"),oQueryAll(".optGrp.cdOvl .item.selected .optToggle").forEach(function(e){e.click()}),loadOptionGroup(oQ(".optGrp.cdUpld").attributes["data-groupid"].value),oQ("#cdUploadClear").classList.add("hid")}function doTracking(){"undefined"!=typeof ga&&(ga("create",googleAnalyticsId),ga("send",{hitType:"event",eventCategory:"Product Page",eventAction:"Add to Basket",eventLabel:productTitle,eventValue:null,nonInteraction:!0})),"undefined"!=typeof fbq&&fbq("track","AddToCart",{value:($("#quantity").val()*bundlePrice).toFixed(2),currency:CurrencyCode})}function pDtlResize(){window.matchMedia&&window.matchMedia("(max-width: 749px)").matches?$("#pDtlAttr, #pDtlFullDesc2, #pDtlRvws").addClass("collapsable"):$("#pDtlAttr, #pDtlFullDesc2, #pDtlRvws").removeClass("collapsable"),window.canvasResizeTimer&&(clearTimeout(window.canvasResizeTimer),window.canvasResizeTimer=null),window.canvasResizeTimer=setTimeout(canvasFitToPageSize,250)}function loadOptionGroup(e,t){var a=FolderRoot+"Handlers/Product/OptionGroups.ashx?pid="+productId+"&gid="+e+"&limit="+optionGroupItemPageSize,r=$("#optGrp"+e+" input.search");if(r.length){var i=r.val();""!=i&&(a+="&text="+i)}var n=$("#optGrp"+e+" select.category");if(n.length){var o=n.val();null!=o&&""!=o&&(a+="&cid="+o)}var l=$("article.selected",$("#optGrp"+e));l.length?a+="&selected="+$(".optToggle",l).data("productid"):t>0&&(a+="&default="+t),$.ajax({url:a,type:"GET",cache:!0,success:function(e){var a=e.data.optionGroup.groupId,r=$("#optGrp"+a);if(e.data.optionGroup.isCentreDiscOverlay&&r.addClass("cdOvl"),e.data.optionGroup.allowUpload&&r.addClass("cdUpld"),e.data.optionGroup.isRequired&&r.addClass("required").data("title",e.data.optionGroup.title),e.data.optionGroup.onePrice>-1&&r.attr("data-oneprice",e.data.optionGroup.onePrice),e.data.optionGroupItems.filter(e=>e.moqValue>0).length>0&&(1==e.data.optionGroupItems.map(e=>e.moqValue).distinct().length?(e.data.optionGroup.moqValue=e.data.optionGroupItems.map(e=>e.moqValue)[0],e.data.optionGroup.showMOQValue=!0):e.data.optionGroup.showMOQ=!0),e.data.optionGroupItems.filter(e=>e.setupFeeType>0).length>0)if(1==e.data.optionGroupItems.map(e=>`${e.setupFeeType}_${e.setupFeeValue}_${e.setupFeeThreshold}`).distinct().length){var i=e.data.optionGroupItems.filter(e=>e.setupFeeType>0)[0];1==i.setupFeeType?(e.data.optionGroup.showSetupFee1=!0,e.data.optionGroup.setupFeeValue=asCurrency(i.setupFeeValue)):2==i.setupFeeType?(e.data.optionGroup.showSetupFee2=!0,e.data.optionGroup.setupFeeValue=asCurrency(i.setupFeeValue),e.data.optionGroup.setupFeeThreshold=i.setupFeeThreshold):e.data.optionGroup.showSetupFee3=!0}else e.data.optionGroup.showSetupFee3=!0;renderTemplate("Product/OptionGroup",e.data,function(i){if(0==$("p.hdr",r).length){if(r.html($(i)),e.data.optionGroup.allowUpload){if(null!=localStorageGet("customCentreDisc")){var n=oQ(".cdUpld");n.classList.add("hasFile");var o=n.oQ(".item");o.dataset.img=localStorageGet("customCentreDisc"),$(".item",n).data("img",localStorageGet("customCentreDisc")),o.oQ("img").setAttribute("src",FolderRoot+localStorageGet("customCentreDisc")+"?w=180&h=180"),oQ("#cdUploadClear").addEventListener("click",centreDiscClear),oQ("#cdUploadClear").classList.remove("hid")}else oQ("#cdUploadClear").classList.add("hid");oQ("#cdUploadBtn").addEventListener("click",centreDiscUpload)}$(".filter .action",r).on("click",function(e){e.preventDefault(),loadOptionGroup(a)}),$(".filter .search",r).on("keyup",function(e){e.preventDefault(),$(".filter .category",r).val(""),loadOptionGroup(a),null!=optionGroupLogTimers[a]&&clearTimeout(optionGroupLogTimers[a]),optionGroupLogTimers[a]=setTimeout(function(){logOptionGroupSearch(a)},500)}),$(".filter .category",r).on("change",function(e){$(".filter .search",r).val(""),loadOptionGroup(a)})}else $(".items",r).html($(i).filter(".items").html()),$(".count b",r).html(e.data.optionGroup.itemCount),0==e.data.optionGroup.itemCount?0==$("#noItems",r).length&&renderTemplate("Alert",{error:{message:i18n("couldntFindAnythingThatMatched")}},function(e){$("
").attr("id","noItems").addClass("mBox").html(e).insertBefore($(".items",r))}):$("#noItems",r).remove();$(".item",r).on("click",toggleOptionGroupItem),$(".pLst",r).carouselH({pageSize:4,stepSize:4,autoStepSize:!1,responsive:[{breakpoint:860,settings:{pageSize:4,stepSize:4}},{breakpoint:750,settings:{pageSize:4,stepSize:4}},{breakpoint:580,settings:{pageSize:6,stepSize:6}},{breakpoint:480,settings:{pageSize:5,stepSize:5}}]}).on("scroll",function(t){var a=$(this).get(0).carouselH;!a.loadMoreTimer&&e.data.optionGroup.itemCount>a.itemCount&&a.activeIndex>=a.itemCount-optionGroupItemPageSize/2&&(a.loadMoreTimer=setTimeout(function(){loadOptionGroupProducts(e.data.optionGroup.groupId,a.itemCount)},1e3))}),t>0&&$("input.optToggle[data-productid="+t+"]",r).click()})}})}function loadOptionGroupProducts(e,t){var a=FolderRoot+"Handlers/Product/OptionGroups.ashx?pid="+productId+"&gid="+e+"&itemsonly=1&limit="+optionGroupItemPageSize+"&offset="+t,r=$("#optGrp"+e+" input.search");if(r.length){var i=r.val();""!=i&&(a+="&text="+i)}var n=$("#optGrp"+e+" select.category");if(n.length){var o=n.val();null!=o&&""!=o&&(a+="&cid="+o)}$.ajax({url:a,type:"GET",cache:!0,success:function(t){var a=$("#optGrp"+e);renderTemplate("Product/OptionGroupProducts",t.data,function(e){$(".pLst",a).append(e).get(0).carouselH.reinit(),$(".item",a).off("click").on("click",toggleOptionGroupItem),$(".pLst",a).get(0).carouselH.loadMoreTimer=null})}})}function logOptionGroupSearch(e){var t=$("#optGrp"+e+" input.search");if(t.length){var a=t.val();""!=a&&$.ajax({url:FolderRoot+"Handlers/Product/OptionGroups.ashx?pid="+productId+"&gid="+e+"&text="+a+"&log=1",type:"GET",cache:!0})}}function engPromptInit(){$("#engPrompt a.skip").click(function(){modalHide(),skipEngPrompt=!0,setTimeout(function(){$("#addToBasket").get(0).click()},300)}),$("#engPrompt a.cta").click(function(){modalHide()})}function addedToBasketInit(){$("#modal.addedToBsk .btns #continue").on("click",function(){modalHide()}),$("#modal.addedToBsk .btns #basket").on("click",function(){window.location.href=FolderRoot+PAGEPATH.BASKET}),$("#modal.addedToBsk .carousel .pLst").carouselH({pageSize:2,stepSize:2,autoStepSize:!1,responsive:[{breakpoint:550,settings:{pageSize:4,stepSize:4}},{breakpoint:480,settings:{pageSize:3,stepSize:3}}]})}function lightbox(e){if(!window.matchMedia||window.matchMedia("(min-width: 750px)").matches){var t=oQuery("#lightbox .carousel");t.innerHTML="",oQueryAll("#pDtl .mainImg .item a").forEach(function(e,a){t.innerHTML+='
  • -1?"&":"?")+'w=968&h=968" />
  • '}),modalShow(oById("lightbox").innerHTML,1e3,1e3,"lightbox"),$("#modal.lightbox .carousel").carouselH({pageSize:1,stepSize:1,autoStepSize:!1,showDots:!0,startIndex:e});var a=oQuery("#modal.lightbox .carousel");window.addEventListener("keydown",function(e){switch(e.keyCode){case 37:a.carouselH.scrollTo(-1);break;case 39:a.carouselH.scrollTo(1)}})}}function imgMainLazyLoadAll(){setTimeout(function(){oQueryAll("#pDtl .mainImg source[data-lazy-src], #pDtl .mainImg img[data-lazy-src]").forEach(function(e){"SOURCE"==e.tagName?e.srcset=e.dataset.lazySrc:e.src=e.dataset.lazySrc})},10),oQuery("#pDtl .mainImg .clip").removeEventListener("scroll",imgMainLazyLoadAll)}function nextDayBannerCountdown(){var e=(nextDayCutoff-new Date)/1e3;if(e<=1)nextDayBannerLoad();else{var t=Math.floor(e/86400),a=Math.floor((e-86400*t)/3600),r=Math.floor((e-86400*t-3600*a)/60),i=Math.floor(e-86400*t-3600*a-60*r),n=window.matchMedia&&window.matchMedia("(min-width: 500px)").matches;$(".orderWithin .countdown .hour b").html(n?("00"+a).slice(-2):a),0==a?$(".orderWithin .countdown .hour").addClass("zero"):$(".orderWithin .countdown .hour").removeClass("zero"),1==a?$(".orderWithin .countdown .hour").addClass("single"):$(".orderWithin .countdown .hour").removeClass("single"),$(".orderWithin .countdown .min b").html(n?("00"+r).slice(-2):r),0==r?$(".orderWithin .countdown .min").addClass("zero"):$(".orderWithin .countdown .min").removeClass("zero"),1==r?$(".orderWithin .countdown .min").addClass("single"):$(".orderWithin .countdown .min").removeClass("single"),$(".orderWithin .countdown .sec b").html(n?("00"+i).slice(-2):i),1==i?$(".orderWithin .countdown .sec").addClass("single"):$(".orderWithin .countdown .sec").removeClass("single")}}function nextDayBannerLoad(){clearInterval(nextDayCountdownInterval),clearTimeout(nextDayCountdownTimer);var e=FolderRoot+"Handlers/Product/NextDayLoad.ashx?pid="+productId;$.ajax({url:e,type:"GET",cache:!1,success:function(e){null!=e.data.nextDayDelivery?(e.data.nextDayDelivery.showCountdown=e.data.nextDayDelivery.isBeforeCutOff&&(new Date(e.data.nextDayDelivery.orderBefore)-new Date)/1e3/60/60<24,renderTemplate("Product/NextDayPanel",e.data.nextDayDelivery,function(t){$(".buyNowNDD").html($(t)).removeClass("hid"),e.data.nextDayDelivery.showCountdown&&(nextDayCutoff=new Date(e.data.nextDayDelivery.orderBefore),nextDayBannerCountdown(),nextDayCountdownInterval=setInterval(nextDayBannerCountdown,1e3))})):$(".buyNowNDD").addClass("hid")}})}function pDtlInit(){updatePrice(),3==productType&&(variantFilterRefresh(),$(".variants select").on("change",variantFilterRefresh),$('.variants .rbLst input[type="radio"]').on("click",variantFilterRefresh)),$("textarea.engraveMsg").jqEngraveLimiter(),$('input[type="text"].giftMsg, textarea.giftMsg').jqTextLimiter({countSpaces:countSpacesInPersonalisation});var e=oById("addToBasket");e&&e.addEventListener("click",addToBasket);var t=oById("backInStockAlertBtn");t&&t.addEventListener("click",backInStockAlert),backInStockAlertData&&"cancel"==backInStockAlertData.action&&backInStockAlert(null,"cancel"),$("#pDtl .dtl").jqCatchEnter({target:"#addToBasket"}),$('.engraveOptions input[name="rbEngravOpt"]').on("click",changeEngravingType);var a=oQuery(".img360 a");a&&a.addEventListener("click",function(e){e.preventDefault(),modalFrame(HTTPHost+"/360ImageViewer.aspx?prefix="+this.dataset.imageset+"&w=1000&h=1000",1e3,1e3)}),$("#pDtl .mainImg ul").carouselH({pageSize:1,stepSize:1,autoStepSize:!1,showDots:!0,responsive:[{breakpoint:1e3,settings:{showDots:!1}}]}).on("scroll",function(e){var t=e.detail.activeIndex||0,a=$('#pDtl .altImg ul a[data-index="'+t+'"]');$("#pDtl .altImg ul a").removeClass("active"),a.length&&$(a[0]).addClass("active");var r=$("#pDtl .altImg ul.alt").get(0);r&&r.carouselH&&r.carouselH.setActiveIndex(t)});var r=$("#pDtl .altImg ul.alt");$(".item",r).length>5&&(r.addClass("carousel"),r.carouselH({pageSize:4,stepSize:1,autoStepSize:!1,vertical:!0})),oQueryAll("#pDtl .mainImg .item a").forEach(function(e,t){e.addEventListener("click",function(e){e.preventDefault(),lightbox(t)})}),oQueryAll("#pDtl .altImg .item a").forEach(function(e){e.addEventListener("click",function(e){oQuery("#pDtl .mainImg ul.carousel").carouselH.setActiveIndex(this.dataset.index)})});var i=$("#centreOverlay");i.length>0&&(centreDiscOverlay={x:i.data("x"),y:i.data("y"),w:i.data("w"),h:i.data("h"),s:i.data("s"),m:i.data("m")}),$('#pDtlOpts .opts .item input[type="checkbox"]').on("click",function(e){toggleBundleItem(parseInt($(this).attr("data-productid")),parseFloat($(this).attr("data-unitprice")))}),$("#quantity").on("keyup mouseup blur",function(e){"blur"==e.type&&isNaN(parseInt($("#quantity").val()))?$("#quantity").val("1"):$("#quantity").attr("maxlength")&&$("#quantity").val().length>$("#quantity").attr("maxlength")&&$("#quantity").val("9999999999".substring(0,$("#quantity").attr("maxlength"))),updatePrice()}),$("#pDtlGroupAlt .pLst").carouselH({pageSize:3,stepSize:3,autoStepSize:!1,responsive:[{breakpoint:1e3,settings:{pageSize:5,stepSize:5}},{breakpoint:860,settings:{pageSize:4,stepSize:4}},{breakpoint:750,settings:{pageSize:3,stepSize:3}},{breakpoint:640,settings:{pageSize:5,stepSize:5}},{breakpoint:480,settings:{pageSize:4,stepSize:4}}]}),$("#pDtlLsts .pLst, #pDtlTSRec .pLst").carouselH({pageSize:3,stepSize:3,autoStepSize:!1,responsive:[{breakpoint:860,settings:{pageSize:6,stepSize:6}},{breakpoint:640,settings:{pageSize:5,stepSize:5}},{breakpoint:480,settings:{pageSize:4,stepSize:4}}]}),$("#pDtlOpts .optGrp").each(function(){loadOptionGroup($(this).data("groupid"),$(this).data("defaultproduct"))}),window.matchMedia&&window.matchMedia("(max-width: 749px)").matches?$("#pDtlAttr, #pDtlFullDesc2, #pDtlRvws").addClass("collapsable"):$("#pDtlAttr, #pDtlFullDesc2, #pDtlRvws").removeClass("collapsable"),$(".engraveOptions .help").on("click",function(e){modalFrame(this.href,800,600),e.preventDefault()}),oQuery("#pDtl .mainImg .clip").addEventListener("scroll",imgMainLazyLoadAll),window.addEventListener("resize",pDtlResize),window.addEventListener("pageshow",nextDayBannerLoad),window.addEventListener("focus",nextDayBannerLoad),dataLayer.push({event:"productDetail",ecommerce:{detail:{products:[{id:productId,name:productTitle,price:bundlePrice}]}}}),dataLayer.push({event:"view_item",ecommerce:{items:[{item_name:productTitle,item_id:productId,price:bundlePrice,quantity:"1"}]}})}document.addEventListener("DOMContentLoaded",function(){try{pDtlSetVars()}catch(e){return void console.log(e)}jqDefer(pDtlInit)});