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 () { if ( $(window).width() < 767 ) { $('video').remove(); $('.item.movie').addClass('errorbg'); } $(window).load(function(){ if ( window.location.pathname == '/' ) { var video = document.getElementById("main-video"); var playing = false; setTimeout(function() { video.play(); }, 1500); if( video ) { video.addEventListener("play", function() { if(!playing) { setInterval(function() { video.currentTime = 0; }, (video.duration * 1000)-20); playing = true; } }); } } }); $('.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(); } }); if ( !$('.start-slider').hasClass('one-slide') ) { var startSlider = $('.start-slider').owlCarousel({ items: 1, autoplayHoverPause: false, autoplay: true, autoplayTimeout: 4000, animateIn: "fadeIn", animateOut: "fadeOut", dots: true, loop: true, nav: false, navText: ['',''] }).addClass("owl-carousel owl-theme"); } else { var startSlider = $('.start-slider').owlCarousel({ items: 1, autoplayHoverPause: false, autoplay: false, autoplayTimeout: 99000, animateIn: "fadeIn", animateOut: "fadeOut", dots: false, mouseDrag: false, touchDrag: false, pullDrag: false, freeDrag: false, loop: false, nav: false, navText: ['',''] }).addClass("owl-carousel owl-theme"); } $('.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"); }); } }); if ( $('.section-with-picture.producent').hasClass('producent') ) { $('body').addClass('producent'); } //btn fix mobile if ( $(window).width() <= 767 ) { $('.typical-content a.button').each(function() { $('
').insertBefore($(this)); $(this).appendTo($(this).prev()); }); } $(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"); } } }); });