var X_IT = 'it'; var X_EN = 'en'; var X_ES = 'es'; var X_DE = 'de'; var X_FR = 'fr'; var X_RU = 'ru'; var X_C2 = 'c2'; var isMultilingua = 1; var LANG_CURRENT = 'it'; var blnStandalone = ( window.navigator.standalone ); $(function() { productDetailGallery(4000); menuSliding(); utils(); }); function fPreloadImmagine( pstrImg ) { var oImmagine = new Image(); oImmagine.src = pstrImg; } function fLoading( pintAction ) { if ( pintAction > 0 ) { $('#oLoadingTop').css('left', (($(document).width()/2)-22)+'px'); $('#oLoadingTop .lt-bg').css('margin-top', (getScrollTop() + (($(window).height()/2)-22))+'px'); $('#oLoading, #oLoadingTop').css('height', $(document).height()+'px').removeClass('hide'); } else $('#oLoading, #oLoadingTop').addClass('hide'); } function getScrollTop() { if(typeof pageYOffset!= 'undefined') { return pageYOffset; //most browsers } else { var B= document.body; //IE 'quirks' var D= document.documentElement; //IE with doctype D= (D.clientHeight)? D: B; return D.scrollTop; } } function menuSliding() { $('.dropdown').on('show.bs.dropdown', function(e) { if ( $(window).width() > 750 ) $(this).find('.dropdown-menu').first().stop(true, true).slideDown(); else $(this).find('.dropdown-menu').first().stop(true, true).show(); }); $('.dropdown').on('hide.bs.dropdown', function(e) { if ( $(window).width() > 750 ) $(this).find('.dropdown-menu').first().stop(true, true).slideUp(); else $(this).find('.dropdown-menu').first().stop(true, true).hide(); }); } function pictureZoom() {} function utils() { /* click on the box activates the radio */ $('#checkout').on('click', '.box.shipping-method, .box.payment-method', function(e) { var radio = $(this).find(':radio'); radio.prop('checked', true); }); /* click on the box activates the link in it */ $('.box.clickable').on('click', function(e) { window.location = $(this).find('a').attr('href'); }); /* external links in new window */ $('.external').on('click', function(e) { e.preventDefault(); window.open($(this).attr("href")); }); /* animated scrolling */ $('.scroll-to, .scroll-to-top').click(function(event) { var full_url = this.href; var parts = full_url.split("#"); if (parts.length > 1) { scrollTo(full_url); event.preventDefault(); } }); function scrollTo(full_url) { var parts = full_url.split("#"); var trgt = parts[1]; var target_offset = $("#" + trgt).offset(); var target_top = target_offset.top - 100; if (target_top < 0) { target_top = 0; } $('html, body').animate({scrollTop: target_top}, 1000); } } function productDetailGallery(confDetailSwitch) { $('.thumb:first').addClass('active'); $(".thumb").click(function(e) { switchImage($(this)); e.preventDefault(); }); function autoSwitch() { var nextThumb = $('.thumb.active').closest('div').next('div').find('.thumb'); if (nextThumb.length == 0) { nextThumb = $('.thumb:first'); } switchImage(nextThumb); } function switchImage(thumb) { $('.thumb').removeClass('active'); var bigUrl = thumb.attr('href'); var medUrl = thumb.data('imagem'); var imageID = thumb.data('imid'); $('#mainImage_Loader').css( 'height', $('#mainImage').height() + 'px' ); $('#mainImage_Loader').removeClass('hide'); $('#mainImage').addClass('hide'); //console.log("image "+bigUrl); //alert("image "+bigUrl); var img = new Image(); img.onload = function () { //alert("image is loaded "+bigUrl); if ( $('#mode').length > 0 ) { thumb.addClass('active'); $('#mainImage_titolo').html( thumb.attr('title') ); $('.mimage-box').addClass('hide'); $('#mimage-box-'+imageID).removeClass('hide'); if ( ! $('#mimage-box-'+imageID+' img').length ) { var strHTML = '' + thumb.attr('title') + ''; $('#mainImage #mimage-box-'+imageID+' a picture').append(strHTML); setTimeout(() => { $('#mainImage').removeClass('hide'); $('#mainImage_Loader').addClass('hide'); }, 200); } else { $('#mainImage').removeClass('hide'); $('#mainImage_Loader').addClass('hide'); } } else { thumb.addClass('active'); $('#source_webp,#source_jpg').remove(); $('#mainImage img').attr('src', medUrl); $('#mainImage a').attr('href', bigUrl); $('#mainImage a').attr('title', thumb.attr('title')); $('#mainImage_titolo').html( thumb.attr('title') ); if ( blnStandalone ) $(".fancybox").click(function(){ return false; }); else $(".fancybox").fancybox(); setTimeout(() => { $('#mainImage').removeClass('hide'); $('#mainImage_Loader').addClass('hide'); }, 200); } } img.src = bigUrl; } } $.fn.alignElementsSameHeight = function() { $('.same-height-row').each(function() { var maxHeight = 0; var children = $(this).find('.same-height'); children.height('auto'); if ($(window).width() > 768) { children.each(function() { if ($(this).innerHeight() > maxHeight) { maxHeight = $(this).innerHeight(); } }); children.innerHeight(maxHeight); } maxHeight = 0; children = $(this).find('.same-height-always'); children.height('auto'); children.each(function() { if ($(this).innerHeight() > maxHeight) { maxHeight = $(this).innerHeight(); } }); children.innerHeight(maxHeight); }); } $(window).load(function() { windowWidth = $(window).width(); $(this).alignElementsSameHeight(); pictureZoom(); }); $(window).resize(function() { windowWidth = $(window).width(); newWindowWidth = $(window).width(); if (windowWidth !== newWindowWidth) { setTimeout(function() { $(this).alignElementsSameHeight(); //fullScreenContainer(); pictureZoom(); }, 100); windowWidth = newWindowWidth; } }); Number.prototype.formatMoney = function(c, d, t){ var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); };