function isOnScreen(elem) { var $elem = $(elem); var $window = $(window); var docViewTop = $window.scrollTop(); var docViewBottom = docViewTop + $window.height(); var elemTop = $elem.offset().top; var elemBottom = elemTop + $elem.height(); return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); } $(function () { var adres = window.location.href; var anchorID = adres.indexOf('?')+1; var anchor = adres.substring(anchorID); console.log(anchor); if ( anchorID > 0 && anchorID > -1 ) { var anchor = adres.substring(anchorID); $('html, body').delay( 100 ).animate({scrollTop: $('#'+anchor).offset().top - 50}, 'slow'); } $('.gallery').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.fancybox', loop: true }) $('.carousel-gallery').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.fancybox', loop: true }) $('.product-images').Chocolat({ imageSize : 'contain', fullScreen: false, imageSelector: '.choco', loop: true }) $('.tabs > ul li a').click(function(e){ e.preventDefault(); $('.tabs > ul li a').removeClass("active"); $(this).addClass("active"); _trg = $(this).attr("href"); $(".tab").removeClass("active"); $(_trg).addClass("active"); }); $(".acc-title").click(function(e){ $(this).parent().toggleClass("active"); }); $('#contactFormSend').on('submit', function(evt){ evt.preventDefault(); var k = [ 'name', 'question' ], good = true; $(this).find('[name]').removeClass('error'); $(this).find('p.ajaxInfo').hide(); /* if ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( $(this).find('[name="mail"]').val() ) == false ){ $(this).find('[name="mail"]').addClass('error'); good = false; } */ for ( var i = 0; i < k.length; i++ ){ var obj = $(this).find('[name="'+ k[i] +'"]'); if ( obj.val().length <= 1 ){ good = false; obj.addClass('error'); } } if ( good ){ $.post( $(this).attr('action'), $(this).serialize(), (function(response){ if (response.indexOf('false') === -1) { $(this).find('input, textarea').val(''); $(this).find('p.ajaxInfo.ok').show(); } else { $(this).find('p.ajaxInfo.error_send').show(); } }).bind(this)); } else { $(this).find('p.ajaxInfo.error').show(); } }); var startSlider = $('.start-slider').owlCarousel({ items: 1, autoplayHoverPause: false, autoplay: true, autoplayTimeout: 4000, animateIn: "fadeIn", animateOut: "fadeOut", loop: true, nav: false, dots: true, navText: ['',''] }).addClass("owl-carousel"); $('.slider-nav .nav-right').click(function() { startSlider.trigger('next.owl.carousel'); }) $('.slider-nav .nav-left').click(function() { startSlider.trigger('prev.owl.carousel'); }) $('.carousel-gallery .carousel').owlCarousel({ responsive: { 0: { items: 1 }, 700: { items: 3, margin: 10 }, 1000: { items: 4, margin:10 }, 1200: { items: 5, margin:20 } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 2000, dots: false, loop: true, thumbs: false }).addClass("owl-carousel"); $('.products-gallery .carousel').owlCarousel({ responsive: { 0: { items: 1 }, 700: { items: 3, margin: 10 }, 1000: { items: 4, margin:10, nav: true } }, autoplay: true, autoplayHoverPause: false, autoplayTimeout: 2000, nav: true, navText: ['‹','›'], loop: true }).addClass("owl-carousel"); $('.menucall').click(function(e){ e.preventDefault(); if($('header nav').hasClass("on")) { $('body > div').unbind("click"); $('header nav').removeClass("on"); } else { $('header nav').addClass("on"); $('body > div').on("click", function(ev){ $('header nav').removeClass("on"); $(this).unbind("click"); }); } }); $(window).scroll(function(e){ var _scroll = $(window).scrollTop(); if(_scroll > 100){ $('header').addClass("fixed"); } else { $('header').removeClass("fixed"); } if(_scroll > 150){ $('header').addClass("moved"); } else { $('header').removeClass("moved"); } if( $('.gfx-pallets').length > 0 ) { if( isOnScreen('.gfx-pallets') ) { $('.gfx-pallets').addClass("on"); } } }); });