//Basics functions for Landing Page
jQuery(document).ready(function () {
    
                jQuery('section#intro a.cta.buy_online').click(function () {
    // alert('passe');
    jQuery('html, body').animate({
        scrollTop: jQuery('section#section-3').offset().top - 94
    }, 500);

});

    /*############# DO NOT REMOVE #############*/

    $('#g6 #section-5 .inner .wrapper-accordion .item').on('mouseenter', function () {
        $('#g6 #section-5 .inner .wrapper-accordion .item').removeClass('active');
        $('#g6 #section-5 .inner .wrapper-accordion .item .reduced').show();
        $('#g6 #section-5 .inner .wrapper-accordion .item .deployed').hide();
        $(this).addClass('active');
        $(this).find('.reduced').hide();
        $(this).find('.deployed').show();
    });

    $('#section-6 a').on('click', function () {
        $('#section-7').show('fast');
        // CAROUSEL SECTION 7
        setTimeout(function () {
            $('#section-7 .slider-table').slick({
                slidesToShow: 4,
                slidesToScroll: 1,
                dots: false,
                arrows: false,

            });
        }, 200);
    });

    /*MODALS*/
    jQuery('.modal-btn').click(function () {
        var scroll = jQuery(window).scrollTop();
        var dataModal = jQuery(this).attr('data-modal');
        jQuery('.modals[data-modal=' + dataModal + ']').css('top', scroll + 60);
        jQuery('.modal-bg, .modals[data-modal=' + dataModal + ']').addClass('show');
    });

    jQuery('.close-modal, .modal-bg, #modals-container > div button, .close').click(function () {
        jQuery('.modal-bg, .modals, modal').removeClass('show');
    });

    /*VIDÉOS*/
    jQuery('.video-btn').click(function () {
        var vidID = jQuery(this).attr('data-videoID');
        var vidTitle = jQuery(this).attr('data-videoTitle');
        jQuery('.modal-video .video-title').append(vidTitle);
        jQuery('.modal-video iframe').attr('src', 'https://www.youtube.com/embed/' + vidID + '?rel=0&autoplay=1');
        jQuery('.modal-video, .video-bg').addClass('show');
    });

    jQuery('.modal-video .close-modal, .video-bg').click(function () {
        jQuery('.modal-video, .video-bg').removeClass('show');
        jQuery('.modal-video .video-title').html('');
        jQuery('.modal-video iframe').attr('src', '');
    });

    /*##########################*/


    // INITIALISATION CAROUSEL

    $('#section-8 .inner').slick({
        slidesToShow: 1,
        slidesToScroll: 1,
        dots: false,
        autoplay: true,
        autoplaySpeed: 5000,
        arrows: true,
        prevArrow: "<span class='slick-prev arrow slick-arrow prev'><img src='https://www.tefal.com/medias/g6-section-8-arrow-left.png?context=bWFzdGVyfHJvb3R8ODA3fGltYWdlL3BuZ3xoZGMvaGJiLzEzOTIwMzc2MzU2ODk0LnBuZ3xjMTQ4MmNjYmZkMWQ4ZDE0MTAzNjk1NzAyN2YxZjU3MDRlY2EwN2QzNTBhYjhkMWQzMzkzZGNlNzE1NzE4YjVl'></span>",
        nextArrow: "<span class='slick-next arrow slick-arrow next'><img src='https://www.tefal.com/medias/g6-section-8-arrow-right.png?context=bWFzdGVyfHJvb3R8Nzk5fGltYWdlL3BuZ3xoMzIvaDg3LzEzOTIwMzc2NDU1MTk4LnBuZ3xkOGQ1ZDM5Y2E3MzU2ZWFiYjA4NTRiN2NkZDA1YzdjZDgzMDdiMWJkNWU1ODBhMWRkMGUxZjFhNDM2YTUxODA1'></span>",
    });



    // FIN CAROUSEL

    //FIN DOCUMENT READY
});

//FIXED NAV
var navTop = jQuery('.sticky-container[role=nav]').offset().top;
jQuery(window).on('scroll', function () {
    if (jQuery(window).scrollTop() + 50 >= navTop) {
        jQuery('nav.sticky').addClass('stick');
    } else {
        jQuery('nav.sticky').removeClass('stick');
    }
});

jQuery('nav.sticky button, nav.sticky a').click(function () {
    // alert('passe');
    var data = jQuery(this).attr('data-section');
    jQuery('html, body').animate({
        scrollTop: jQuery('section[data-section=' + data + ']').offset().top - 90
    }, 500);

});

/*WAYPOINTS*/
jQuery('.section').each(function () {
    var data = jQuery(this).attr('data-section');
    var waypoints = jQuery('section[data-section=' + data + ']').waypoint(function (up) {
        jQuery('nav.sticky button').removeClass('current');
        jQuery('nav.sticky button[data-section=' + data + ']').addClass('current');
        console.log(data);
    })
});

jQuery('.section').each(function () {
    var data = jQuery(this).attr('data-section');
    var waypoints = jQuery('section[data-section=' + data + ']').waypoint(function (down) {
        jQuery('nav.sticky button').removeClass('current');
        jQuery('nav.sticky button[data-section=' + data + ']').addClass('current');
    }, {
        offset: 175
    })
});
