function extractProductMicrodata(){const e=document.querySelector('[itemtype="http://schema.org/Product"]');if(!e)return null;let t={};return["name","sku","description","image","brand","price","url"].forEach((a=>{const r=e.querySelector(`[itemprop="${a}"]`);r&&(t[a]=r.getAttribute("content")||r.innerText)})),t}async function postProductMicrodata(){showAlert("fa-pulse fa-spinner","Processing","Please wait...","#FFFFFF",!1);let e=extractProductMicrodata();if(!e)return void console.warn("No product microdata found!");let t=document.getElementById("txtQty").value;e.qty=t;let a=document.getElementById("printing");a&&"Yes"==a.value&&(e.printing="Y");try{const a=0==selectsWithDataExtra.length?"/basket/add":"/basket/add-multiple",o=0==selectsWithDataExtra.length?e:{items:[e]};for(var r of selectsWithDataExtra)""!==r.value&&o.items.push({sku:r.value,qty:t});const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),i=await n.json();showAlert("icon-ok-circled",CONST_PRODUCT_ADD_TITLE,CONST_PRODUCT_ADDED+" "+e.name+" "+CONST_PRODUCT_ADDED_APPEND,"#FFFFFF",!1),setBasket({Qty:i.totalQty,Cost:i.totalPrice})}catch(e){console.error("Error posting product data:",e)}}function qty_increase(){var e=parseInt(document.getElementById("txtQty").value,10);e=isNaN(e)?1:e,e++,document.getElementById("txtQty").value=qty_check(e),updatePrice()}function qty_decrease(){var e=parseInt(document.getElementById("txtQty").value,10);e=isNaN(e)?1:e,e--,document.getElementById("txtQty").value=qty_check(e),updatePrice()}function qty_check(e){var t=isNaN(e)?1:e;return t>999?t=999:t<1&&(t=1),t}function qty_update(){var e=parseInt(document.getElementById("txtQty").value,10);document.getElementById("txtQty").value=qty_check(e),updatePrice()}function updatePrice(){var e=document.querySelector('[itemprop="price"]').content,t=parseInt(document.getElementById("txtQty").value,10),a=e*t;for(var r of selectsWithDataExtra)if(""!==r.value){let e=r.options[r.selectedIndex];e&&e.hasAttribute("data-extra-price")&&(a+=e.getAttribute("data-extra-price")*t)}document.getElementById("price").innerHTML=localizeCost(a)}var getFinalPrice=function(e,t){return Number((e*((100-t)/100)).toFixed(2))};const selectsWithDataExtra=document.querySelectorAll("[data-extra] select");document.addEventListener("DOMContentLoaded",(()=>{document.querySelectorAll("[data-basket-add]").forEach((e=>{e.addEventListener("click",postProductMicrodata)})),selectsWithDataExtra.forEach((e=>{e.addEventListener("click",updatePrice)}))}));var prod_gallery_images,prod_isMobile=window.innerWidth<=980,prod_gal_selector=document.querySelector(".prod_gal_selector"),galleryCont=document.getElementById("galleryCont"),videoCont=document.getElementById("videoCont"),galleryModel=function(e){this.media=void 0!==e.ImagePath?"Image":"Video";var t=e.ImagePath;t&&"/"!==t.charAt(0)&&(t="/"+t),this.source=t||e.VideoLink,this.orderID=e.ImageOrder||e.VideoOrder,this.caption=e.Caption},gallery=[];if(void 0!==window.__gallery)for(var i in window.__gallery)gallery.push(new galleryModel(window.__gallery[i]));if(void 0!==window.__videos)for(var i in window.__videos)gallery.push(new galleryModel(window.__videos[i]));function createGallery(){galleryCont.innerHTML="",videoCont.innerHTML="",gallery.forEach((function(e,t){var a=e.caption||document.querySelector("h1").textContent+" Gallery image "+(t+1);if("Image"===e.media)(r=document.createElement("div")).className="gal_img",(o=document.createElement("img")).src=cdn.getSRC(e.source,{w:60,h:60}),o.setAttribute("data-position",t),o.setAttribute("caption",a),o.setAttribute("title",a),o.classList.add("animated","fadeIn"),r.appendChild(o),galleryCont.appendChild(r);else if("Video"===e.media){var r,o;(r=document.createElement("div")).className="gal_img",(o=document.createElement("img")).src="https://i.ytimg.com/vi/"+e.source+"/hqdefault.jpg",o.setAttribute("data-position",t),o.setAttribute("caption",a),o.setAttribute("title",a),o.setAttribute("media",e.media),o.setAttribute("yt",e.source),o.setAttribute("loading","lazy"),o.classList.add("animated","fadeIn"),r.appendChild(o),videoCont.appendChild(r)}})),prod_gallery_images=document.querySelectorAll(".prod_gal_selector .gal_img");for(let e=0;e=gallery.length&&(e=0);try{if(void 0===e)return;var a=document.body.classList.contains("overlay_gal");t||void 0===prod_current||a||prod_expand(),prod_current=e;var r=prod_last;prod_last=e;var o=document.getElementById("prod_gallery_main");o.innerHTML="";var n=prod_gallery_images[e].querySelector("img"),i=n.getAttribute("src").replace("?w=60&h=60",""),d=n.getAttribute("media"),l=n.getAttribute("yt");if("Video"==d)o.innerHTML='
',setTimeout(yt_light,0),prod_isMobile||setTimeout((function(){document.querySelector(".prod_gal_container .youtube-player").firstChild.click()}),1e3);else{var c=new Image;c.src=i+(a?"?w=1500&h=1500":"?w=400&h=400"),c.alt=n.alt,c.title=n.title,c.classList.add("zoom"),o.innerHTML='',c.onload=function(){o.innerHTML="",r!==e&&c.classList.add("fadeIn","animated"),a&&c.classList.add("zoomlg","animated","fadeIn"),o.appendChild(c)}}}catch(e){}}function prod_expand(){document.body.classList.add("overlay_gal"),prod_setImage(prod_current,!1)}function prod_despand(){document.body.classList.remove("overlay_gal")}function init_md_gal(){document.querySelector(".expand").addEventListener("click",(function(){prod_expand()})),document.querySelector(".despand").addEventListener("click",(function(){prod_despand()})),document.querySelector(".gal-reverse").addEventListener("click",(function(){prod_deltaImage(-1)})),document.querySelector(".gal-next").addEventListener("click",(function(){prod_deltaImage(1)})),document.querySelectorAll("img.alt").forEach((e=>{e.addEventListener("mouseleave",(function(e){e.target.setAttribute("src",e.target.getAttribute("data-orig"))})),e.addEventListener("mouseover",(function(e){e.target.setAttribute("src",e.target.getAttribute("data-alt"))}))}))}document.addEventListener("DOMContentLoaded",(function(){init_md_gal()}));