/* ------------------------------------------------------- PLAN / DESIGN / BUILD / INSTALL AUTO LOOP ------------------------------------------------------- */function initTurnkeyProcess(component) { if (!component || component.dataset.jkTkReady === "true") return;var steps = Array.prototype.slice.call( component.querySelectorAll(".jk-tk-step") );var images = Array.prototype.slice.call( component.querySelectorAll(".jk-tk-shot") );if (!steps.length || !images.length) return;component.dataset.jkTkReady = "true";var currentIndex = 0; var timer = null; var intervalTime = 4000; var restartDelay = 700;function getStepIndex(element, fallbackIndex) { var value = element.getAttribute("data-step");if (value === null || value === "") { return fallbackIndex; }value = Number(value);return Number.isNaN(value) ? fallbackIndex : value; }function activate(index) { index = Number(index);if (Number.isNaN(index)) return;currentIndex = index;steps.forEach(function (step, position) { var stepIndex = getStepIndex(step, position); var active = stepIndex === index;step.classList.toggle("is-active", active); step.setAttribute("aria-selected", active ? "true" : "false");/* Restart active progress animation if one is defined in CSS. */ var progress = step.querySelector(".jk-tk-progress");if (progress && active) { progress.style.animation = "none"; void progress.offsetWidth; progress.style.animation = ""; } });images.forEach(function (image, position) { var imageIndex = getStepIndex(image, position); var active = imageIndex === index;image.classList.toggle("is-active", active); image.setAttribute("aria-hidden", active ? "false" : "true"); }); }function getOrderedIndexes() { return steps.map(function (step, position) { return getStepIndex(step, position); }); }function showNext() { var indexes = getOrderedIndexes(); var currentPosition = indexes.indexOf(currentIndex); var nextPosition = currentPosition < 0 ? 0 : (currentPosition + 1) % indexes.length;activate(indexes[nextPosition]); }function stopAutoLoop() { if (timer) { window.clearInterval(timer); timer = null; } }function startAutoLoop() { stopAutoLoop();timer = window.setInterval(function () { if (!document.hidden) { showNext(); } }, intervalTime); }steps.forEach(function (step, position) { var index = getStepIndex(step, position);step.addEventListener("mouseenter", function () { stopAutoLoop(); activate(index); });step.addEventListener("focus", function () { stopAutoLoop(); activate(index); });step.addEventListener("click", function () { stopAutoLoop(); activate(index); }); });component.addEventListener("mouseenter", stopAutoLoop);component.addEventListener("mouseleave", function () { stopAutoLoop();window.setTimeout(function () { if (!component.matches(":hover")) { startAutoLoop(); } }, restartDelay); });component.addEventListener("focusout", function (event) { if (!component.contains(event.relatedTarget)) { startAutoLoop(); } });document.addEventListener("visibilitychange", function () { if (document.hidden) { stopAutoLoop(); } else { startAutoLoop(); } });var initiallyActive = steps.find(function (step) { return step.classList.contains("is-active"); });activate( initiallyActive ? getStepIndex( initiallyActive, steps.indexOf(initiallyActive) ) : getStepIndex(steps[0], 0) );startAutoLoop(); }/* ------------------------------------------------------- INDUSTRIES HOVER IMAGE SWITCHER ------------------------------------------------------- */function findIndustryRoot(panel) { var parent = panel.parentElement;while (parent && parent !== document.documentElement) { if ( parent.querySelector(".jki-item") && parent.querySelector(".jki-panel") ) { return parent; }parent = parent.parentElement; }return document; }function initIndustryPanel(panel) { if (!panel || panel.dataset.jkiReady === "true") return;var root = findIndustryRoot(panel);var items = Array.prototype.slice.call( root.querySelectorAll(".jki-item") );var images = Array.prototype.slice.call( panel.querySelectorAll(".jki-image") );var caption = panel.querySelector(".jki-caption"); var captionTitle = caption ? caption.querySelector("strong") : null;var captionText = caption ? caption.querySelector("span") : null;if (!items.length || !images.length) return;panel.dataset.jkiReady = "true";function getItemIndex(item, fallbackIndex) { var value = item.getAttribute("data-index");if (value === null || value === "") { value = item.getAttribute("data-image-index"); }if (value === null || value === "") { return fallbackIndex; }value = Number(value);return Number.isNaN(value) ? fallbackIndex : value; }function getImageIndex(image, fallbackIndex) { var value = image.getAttribute("data-image-index");if (value === null || value === "") { value = image.getAttribute("data-index"); }if (value === null || value === "") { return fallbackIndex; }value = Number(value);return Number.isNaN(value) ? fallbackIndex : value; }function activate(index) { index = Number(index);if (Number.isNaN(index)) return;var selectedItem = null;items.forEach(function (item, position) { var active = getItemIndex(item, position) === index;item.classList.toggle("is-active", active); item.setAttribute( "aria-current", active ? "true" : "false" );if (active) { selectedItem = item; } });images.forEach(function (image, position) { var active = getImageIndex(image, position) === index;image.classList.toggle("is-active", active); image.setAttribute( "aria-hidden", active ? "false" : "true" ); });if (selectedItem && captionTitle) { var itemTitle = selectedItem.getAttribute("data-title");if (!itemTitle) { var titleElement = selectedItem.querySelector( ".jki-item-title, b, strong, h3, h4" );itemTitle = titleElement ? titleElement.textContent.trim() : ""; }if (itemTitle) { captionTitle.textContent = itemTitle; } }if (selectedItem && captionText) { var itemCaption = selectedItem.getAttribute("data-caption");if (itemCaption) { captionText.textContent = itemCaption; } } }items.forEach(function (item, position) { var index = getItemIndex(item, position);item.addEventListener("mouseenter", function () { activate(index); });item.addEventListener("pointerenter", function (event) { if (event.pointerType !== "touch") { activate(index); } });item.addEventListener("focus", function () { activate(index); });item.addEventListener("click", function (event) { var href = item.getAttribute("href");if ( item.tagName === "A" && (!href || href === "#") ) { event.preventDefault(); }activate(index); }); });var initiallyActive = items.find(function (item) { return item.classList.contains("is-active"); });activate( initiallyActive ? getItemIndex( initiallyActive, items.indexOf(initiallyActive) ) : getItemIndex(items[0], 0) ); }/* ------------------------------------------------------- INITIALISATION ------------------------------------------------------- */function initialiseEverything() { document .querySelectorAll(".jk-tk-component") .forEach(initTurnkeyProcess);document .querySelectorAll(".jki-panel") .forEach(initIndustryPanel); }function initialiseSliders() { initContinuousSlider( ".smooth-feel .flickity-slider", "rtl", 0.3 );initContinuousSlider( ".smooth-feel-ltr .flickity-slider", "ltr", 0.3 ); }function start() { initialiseEverything();window.setTimeout(initialiseSliders, 600);new MutationObserver(function () { initialiseEverything(); }).observe(document.documentElement, { childList: true, subtree: true }); }if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", start); } else { start(); } })();