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 recaptchaCallback() {
$('.g-recaptcha').addClass('confirmed');
}
$(function () {
$('.search-call').click(function(e){
e.preventDefault();
$('.search-widget').toggleClass("on");
});
$('.menucall').click(function(e){
e.preventDefault();
$('.menu').toggleClass("on");
});
$('#rodoagree .toggle').click(function() {
$(this).hide(100);
$(this).parent().animate({height: '200px'},400,function() {
$(this).css({height: '100%'});
});
});
$('.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 = [ 'mail', 'question' ],
good = true;
$(this).find('.form__item').each(function() {
$(this).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"]').parents('.form__item').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.parents('.form__item').addClass('error');
}
}
if ( $('.g-recaptcha').hasClass('confirmed') ) {
$('.recaptcha_error').hide(300).addClass('hide');
good = true;
} else {
$('.g-recaptcha').addClass('error');
$('.recaptcha_error').show(300).removeClass('hide');
good = false;
}
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();
}
});
$('.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");
$('.start-slider .owl-dots').removeClass("disabled");
$('.start-slider .owl-nav').removeClass("disabled");
$('.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({
autoplayHoverPause: true,
autoplay: true,
autoplayTimeout: 3000,
animateIn: "slideInRight",
animateOut: "slideOutLeft",
responsive: {
0: {
items: 1,
margin: 15
},
600: {
items: 3,
margin:20
},
1000: {
items: 4,
margin:40
}
},
loop: true,
nav: true,
navText: ['',''],
dots: false
}).addClass("owl-carousel");
});