/* Block 0: Variables Block 1: AJAX Block 2: Mobile Menu Block 3: Form fields checking Block 4: Lazy loading Block 5: Product lists Block 6: Product filters Block 7: Product detail Block 8 Photoviewer Block 9: Slideout div from top Block 10: Photozoomer Block 11: Shopping cart Block 12: Webshop popup (used in checkout for delivery services) Block 13: Chat window interface Block Y: General functions Block Z: mouse, keyboard and touch events */ /*-------------------------------- Block 0: Variables -------------------------------*/ var vw = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); var vh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); var curPos = (window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0); var uparrow = null; var mainSaved = false; var smallscreen = false; /*-------------------------------- Block 1: AJAX -------------------------------*/ // AJAX Load function al(obj) { main.style.minHeight = main.offsetHeight + 'px'; if (obj.href) { ar(obj.href + (obj.href.indexOf('?') != -1 ? '&' : '?') + 'a=1' + (typeof design !== 'undefined' ? '&design=' + design : ''), main, false, true, true, false, true); } else { ar(obj.action + (obj.action.indexOf('?') != -1 ? '&' : '?') + 'a=1' + (typeof design !== 'undefined' ? '&design=' + design : ''), main, false, true, true, obj, true); } // Close mobile menu if (typeof mnav !== 'undefined' && mnav.classList.contains('active')) { mNav(); } return false; // do not follow a href } // AJAX request var loadReady = true; function ar(url, div, append, script, loader, postdata, scroll = false) { // Save main if (!mainSaved && typeof main !== 'undefined' && main) { history.pushState({page:main.innerHTML}, '', window.location.pathname); mainSaved = true; } var q = new XMLHttpRequest(); var r = ''; if (typeof div == 'string') { div = document.getElementById(div) ? document.getElementById(div) : false; } if (!append && div && loader) { div.innerHTML = '
'; } q.onreadystatechange = function() { if (q.readyState == 4 && q.status == 200 && div) { if (script) { r = parseScript(q.responseText); loadReady = true; if (document.getElementById('ewloading')) { document.getElementById('ewloading').style.display = 'none'; } } else { r = q.responseText; } if (append) { div.innerHTML += r; } else { div.innerHTML = r; if (scroll) { // Do not scroll down if too close curPos = (window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0); //console.log(div.offsetTop + ', ' + curPos + ', ' + vh + ': ' + (div.offsetTop - curPos) + ' > ' + (vh / 2)); if (curPos > div.offsetTop || (div.offsetTop - curPos) > (vh / 2)) { setTimeout(function() { div.scrollIntoView({ behavior: 'smooth'}); }, 100); } } } if (script) { execScripts(); } } } if (postdata) { q.open('POST', url, true); if (typeof postdata === 'object' && postdata.nodeName.toLowerCase() === 'form') { q.send(new FormData(postdata)); } else { q.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); q.send(postdata); } } else { q.open('GET', url, true); q.send(); } } // AJAX request function parseScript(_source) { var source = _source; scripts = new Array(); // Strip out tags while (source.indexOf(' -1) { var s = source.indexOf('", e); //