(function($) {
    $(document).ready(function() {

        if ($('.onglets-paiement').length > 0) {
          $('.onglets-paiement form').on('submit', function() {
            $('.webform-previous.form-submit').hide();
          })
        }

        // disable mousewheel on a input number field when in focus
        // (to prevent Cromium browsers change the value when scrolling)
        $('form').on('focus', 'input[type=number]', function(e) {
            $(this).on('mousewheel.disableScroll', function(e) {
                e.preventDefault();
            });
        });
        $('form').on('blur', 'input[type=number]', function(e) {
            $(this).off('mousewheel.disableScroll');
        });

        // var offres = $('.offres-supplementaires .view-content');
        // var btn_offres = $('.btn_more_abo button');
        // var btn_offres_text = $('.btn_more_abo_txt');

        // function offres_supplementaires() {
        //     offres.addClass('is-slider');
        //     offres.slick({
        //         infinite: false,
        //         responsive: [
        //             {
        //                 breakpoint: 991,
        //                 settings: {
        //                     slidesToShow: 2
        //                 }
        //             },
        //             {
        //                 breakpoint: 540,
        //                 settings: {
        //                     slidesToShow: 1
        //                 }
        //             }
        //         ]
        //     });
        // }

        // function offresShow() {
        //     offres.addClass('is-visible');
        //     $(this).addClass('btn_active');
        //     btn_offres_text.html(
        //         btn_offres_text.html().replace('plus', 'moins')
        //     );
        //     btn_offres_text.html(
        //         btn_offres_text.html().replace('Meer', 'Minder')
        //     );

        //     // if (window.matchMedia('(max-width: 991px)').matches) {
        //     //     offres_supplementaires();
        //     // }

        //     btn_offres.one('click', offresHide);
        // }

        // function offresHide() {
        //     offres.removeClass('is-visible');
        //     $(this).removeClass('btn_active');
        //     btn_offres_text.html(
        //         btn_offres_text.html().replace('moins', 'plus')
        //     );
        //     btn_offres_text.html(
        //         btn_offres_text.html().replace('Minder', 'Meer')
        //     );

        //     // if (offres.hasClass('is-slider')) {
        //     //     offres.slick('unslick');
        //     // }

        //     btn_offres.one('click', offresShow);
        // }

        // btn_offres.one('click', offresShow);

        //afficher/masquer bloc contact en mobile
        // $('.box_call_center .cm-call').click(function() {
        //     $('.box_call_center .cm-box').slideToggle();
        // });

        //carousel
        // $('.cm-mod-carousel .field-name-field-mod-texte .field-items').slick({
        //     slidesToShow: 1,
        //     responsive: [
        //         {
        //             breakpoint: 991,
        //             settings: {
        //                 centerMode: true,
        //                 centerPadding: '0',
        //                 slidesToShow: 1
        //             }
        //         }
        //     ]
        // });

        // $(
        //     '.cm-mod-carousel .field-name-field-mod-image .field-items, .slider-content .view-content'
        // ).slick({
        //     centerMode: true,
        //     centerPadding: '15%',
        //     slidesToShow: 1,
        //     responsive: [
        //         {
        //             breakpoint: 1199,
        //             settings: {
        //                 centerMode: false,
        //                 centerPadding: '0',
        //                 slidesToShow: 1
        //             }
        //         }
        //     ]
        // });

        // $('.box-promos .view-content').slick({
        //     dots: true,
        //     arrows: false,
        //     autoplay: true,
        //     autoplaySpeed: 5000,
        //     responsive: [
        //         {
        //             breakpoint: 992,
        //             settings: {
        //                 slidesToShow: 2
        //             }
        //         },
        //         {
        //             breakpoint: 540,
        //             settings: {
        //                 slidesToShow: 1
        //             }
        //         }
        //     ]
        // });

        // if (window.matchMedia('(max-width: 991px)').matches) {
        //     //menu carousel
        //     $('#cm-menu-formule ul').horizonSwiper({
        //         item: 'li'
        //     });
        // }

        // $(window).on('resize', function() {
        //     if (
        //         window.matchMedia('(max-width: 991px)').matches &&
        //         !offres.hasClass('slick-slider') &&
        //         offres.hasClass('is-visible')
        //     ) {
        //         offres_supplementaires();
        //     } else if (
        //         window.matchMedia('(min-width: 992px)').matches &&
        //         offres.hasClass('is-slider')
        //     ) {
        //         offres.slick('unslick');
        //     }
        // });

        //FAQ
        var faq = $('.faq-qa-header, .faq-header');

        faq.click(function(e) {
            e.preventDefault();
            if ($(this).hasClass('.faq-qa-header')) {
                $(this).toggleClass('is-open');
            } else {
                $(this)
                    .parent()
                    .toggleClass('is-open');
            }
        });

        //form style material design
        //$.material.init()
    });
})(jQuery);
