(function ($) {
    'use strict';

    function initMenu() {
        $('.nav_menu').on('click', function (event) {
            event.stopPropagation();
            $('.nav_list').addClass('open');
        });
        $('.nav_mask').on('click', function () {
            $('.nav_list').removeClass('open');
        });
        $('.nav_list').on('click', function (event) { event.stopPropagation(); });
        $(document).on('click', function () { $('.nav_list').removeClass('open'); });
        $('.abIdxMenu_Mbtn').on('click', function () {
            $(this).toggleClass('on');
            $('.abIdx_Menu ul').toggleClass('on').stop(true, true).slideToggle(160);
        });
        $('.cp_type .bd > ul > li > p span').on('click', function () {
            $(this).toggleClass('on').closest('p').next('div').stop(true, true).slideToggle(160);
        });
    }

    function initSliders() {
        if (!window.Swiper) { return; }
        if ($('#swiper1').length) {
            new Swiper('#swiper1', {
                loop: $('#swiper1 .swiper-slide').length > 1,
                autoplay: 5000,
                speed: 800,
                prevButton: '#swiper1 .swiper-button-prev',
                nextButton: '#swiper1 .swiper-button-next',
                pagination: '#swiper1 .swiper-pagination',
                paginationClickable: true
            });
        }
        if ($('#swiper2').length) {
            new Swiper('#swiper2', {
                loop: $('#swiper2 .swiper-slide').length > 1,
                autoplay: 4000,
                prevButton: '.abIdxTjPro_list > .swiper-button-prev',
                nextButton: '.abIdxTjPro_list > .swiper-button-next'
            });
        }
        if ($('.swiper-container04').length) {
            new Swiper('.swiper-container04', {
                slidesPerView: 3,
                spaceBetween: 20,
                centeredSlides: true,
                loop: $('.swiper-container04 .swiper-slide').length > 3,
                prevButton: '.NyAboutusHonor_List .swiper-button-prev',
                nextButton: '.NyAboutusHonor_List .swiper-button-next',
                breakpoints: { 767: { slidesPerView: 1 }, 1080: { slidesPerView: 3 } }
            });
        }
    }

    function initProductGallery() {
        var $main = $('.NyProDetail_Img .jqzoom img');
        $('#spec-list li').on('click', function () {
            $(this).addClass('on').siblings().removeClass('on');
            $main.attr('src', $(this).find('img').attr('src'));
        });
    }

    $(function () {
        initMenu();
        initSliders();
        initProductGallery();
    });
}(jQuery));
