$(document).ready(function(){
    subnav();
    headerChild();
    subNav3();
    teamSwiper();
    jiagouSwiper();
    historySwiper();
    touziTab();
    socialSwiper();
    inforTab();
    csrZhaopin();
    csrSwiper();
    baseSwiper();
    socialSwiper2();
    vsIndexSwiper();
    newPresenceSwiper();
    resultSwiper();
    contactMap();
    socialTab();
    djSwiper();
    ztNews();
    report();


    if($("#fullpage").length > 0){

    }else{
        $(".goTop a").click(function(){
            $('body,html').animate({scrollTop:0},200);
            return false;
        });
    }


    $(".newMedia-more-btn").find("a").click(function(){
        if(!$(this).hasClass("on")){
            $(this).addClass("on");
            $(this).html("收起");
            $(".newMedia-more-con").slideDown(200);
        }else{
            $(this).removeClass("on");
            $(this).html("展开更多");
            $(".newMedia-more-con").slideUp(200);
        }
    })

    $(".fabulous a").click(function(){
        if(!$(this).hasClass("on")){
            $(this).addClass("on");
        }else{
            $(this).removeClass("on");
        }
    })

    $(".video-fabulous a").click(function(){
        if(!$(this).hasClass("on")){
            $(this).addClass("on");
        }else{
            $(this).removeClass("on");
        }
    })




});

$(window).resize(function(){

    subnav();

});

function headerChild(){

}



function subnav(){

    var _length = $(".sub-nav ul li").length;
    $(".sub-nav ul li").width(100/_length+'%');

}

function teamSwiper(){
    if($(".team-swiper-t").length > 0){

        var swiper1 = new Swiper ('.team-swiperItem-1 .swiper-container', {
            paginationClickable :true,
            calculateHeight : true,
            autoHeight: true,
            autoplayDisableOnInteraction : false,
            loop : false,
        })
        $('.team-swiperItem-1 .arrow-left').on('click', function(e){
            e.preventDefault()
            swiper1.swipePrev()
        })
        $('.team-swiperItem-1 .arrow-right').on('click', function(e){
            e.preventDefault()
            swiper1.swipeNext()
        })
        $(".boss-wrap .team-boss-item").click(function(){
            var _length = $(this).parents(".boss-wrap");
            swiper1.swipeTo(_length.index())
        })

        var swiper2 = new Swiper ('.team-swiperItem-2 .swiper-container', {
            paginationClickable :true,
            calculateHeight : true,
            autoHeight: true,
            slidesPerView : 4,
            autoplayDisableOnInteraction : false,
            loop : true,
        })
        $('.team-swiperItem-2 .arrow-left').on('click', function(e){
            e.preventDefault()
            swiper2.swipePrev()
        })
        $('.team-swiperItem-2 .arrow-right').on('click', function(e){
            e.preventDefault()
            swiper2.swipeNext()
        })


        // var temeName;
        // $(".team-swiperItem").each(function(e){
        //     var _child = $(this).find(".team-container");
        //     temeName = "s-con-"+e;
        //     nextBtn = "s-next-"+e;
        //     prevBtn = "s-prev-"+e;
        //     pageBtn = "s-page-"+e;
        //     _child.addClass(temeName);
        //     _child.siblings(".s-next").addClass(nextBtn);
        //     _child.siblings(".s-prev").addClass(prevBtn);
        //     _child.siblings(".s-page").addClass(pageBtn);
        //     var swiper = new Swiper('.'+temeName,{
        //         calculateHeight : true,
        //         loop:true,
        //         grabCursor: true,
        //         paginationClickable: true
        //     })
        //     $('.s-prev-'+e).on('click', function(e){
        //         e.preventDefault()
        //         swiper.swipePrev()
        //     })
        //     $('.s-next-'+e).on('click', function(e){
        //         e.preventDefault()
        //         swiper.swipeNext()
        //     })
        // })

    }
}

function subNav3(){
    $(".t-tab-list ul li").click(function(){
        $(this).addClass('on').siblings().removeClass("on");
        $(".t-tab-con .t-tab-con-item").eq($(this).index()).addClass("active").siblings().removeClass("active");
    })

    $(".t-tab-con .t-tab-con-item").each(function(){
        var _childList = $(this).find(".tz-img-list");
        var _childList2 = $(this).find(".tz-qy-list-item");
        var _more = $(this).find(".tz-img-more");
        _childList.find(".tz-img-item:gt(15)").hide();
        _childList2.find("li:gt(15)").hide();
        if(_childList.find(".tz-img-item").length >= 17){
            _childList.siblings(_more).show();
        }else{
            _childList.siblings(_more).hide();
        }
        if(_childList2.find("li").length >= 17){
            _childList2.siblings(_more).show();
        }else{
            _childList2.siblings(_more).hide();
        }
        _more.find("a").click(function(){
            if(!$(this).hasClass("on")){
                $(this).addClass("on");
                $(this).html('收起');
                _childList.find(".tz-img-item:gt(15)").slideDown(200);
                _childList2.find("li:gt(15)").slideDown(200);
            }else{
                $(this).removeClass("on");
                $(this).html('展开更多');
                _childList.find(".tz-img-item:gt(15)").slideUp(200);
                _childList2.find("li:gt(15)").slideUp(200);
            }

        })

    })
}

function jiagouSwiper(){
    if($(".cy-swiper").length > 0){
        var CName;
        $(".cy-tab-swiper-item").each(function(e){
            var _child = $(this).find(".jg-container");
            CName = "jg-con-"+e;
            nextBtn = "jg-next-"+e;
            prevBtn = "jg-prev-"+e;
            pageBtn = "jg-page-"+e;
            _child.addClass(CName);
            _child.siblings(".jg-next").addClass(nextBtn);
            _child.siblings(".jg-prev").addClass(prevBtn);
            _child.siblings(".jg-page").addClass(pageBtn);

            var _length = _child.find(".swiper-slide").length;
            if(_length > 3){
                _child.siblings(".arrow-left").show();
                _child.siblings(".arrow-right").show();
                var swiper = new Swiper('.'+CName,{
                    // pagination: '.'+pageBtn,
                    // prevButton: '.'+prevBtn,
                    // nextButton:'.'+nextBtn,
                    slidesPerView : 3,
                    calculateHeight : true,
                    autoplay : 5000,
                    loop:true,
                    grabCursor: true,
                    autoplayDisableOnInteraction : false,
                    paginationClickable: true
                })
            }else{
                _child.siblings(".arrow-left").hide();
                _child.siblings(".arrow-right").hide();
                var swiper = new Swiper('.'+CName,{
                    // pagination: '.'+pageBtn,
                    // prevButton: '.'+prevBtn,
                    // nextButton:'.'+nextBtn,
                    slidesPerView : 3,
                    calculateHeight : true,
                    // autoplay : 5000,
                    // loop:true,
                    grabCursor: true,
                    autoplayDisableOnInteraction : false,
                    paginationClickable: true
                })
            }



            $('.jg-prev-'+e).on('click', function(e){
                e.preventDefault()
                swiper.swipePrev()
            })
            $('.jg-next-'+e).on('click', function(e){
                e.preventDefault()
                swiper.swipeNext()
            })

        })

        $(".cy-tit-link a").click(function(){
            $(this).addClass("on").siblings().removeClass("on");
            $(this).parents().siblings(".cy-tit-txt").find(".cy-tit-txt-item").eq($(this).index()).addClass("on").siblings().removeClass("on");
            $(".cy-tab-swiper").find(".cy-tab-swiper-item").eq($(this).index()).addClass("on").siblings().removeClass("on");
        })


    }
}

function historySwiper(){

    if($(".history").length > 0){

        var viewSwiper = new Swiper('.view .swiper-container', {
            calculateHeight : true,
            autoHeight: true,
            loop : false,
            onSlideChangeStart: function() {
                updateNavPosition()
            }
        })

        $('.view .arrow-left,.preview .arrow-left').on('click', function(e) {
            e.preventDefault()
            if (viewSwiper.activeIndex == 0) {
                viewSwiper.swipeTo(viewSwiper.slides.length - 1, 1000);
                return
            }
            viewSwiper.swipePrev()
        })
        $('.view .arrow-right,.preview .arrow-right').on('click', function(e) {
            e.preventDefault()
            if (viewSwiper.activeIndex == viewSwiper.slides.length - 1) {
                viewSwiper.swipeTo(0, 1000);
                return
            }
            viewSwiper.swipeNext()
        })

        var previewSwiper = new Swiper('.preview .swiper-container', {
            visibilityFullFit: true,
            slidesPerView: 'auto',
            calculateHeight : true,
            autoHeight: true,
            onlyExternal: true,
            loop : false,
            onSlideClick: function() {
                viewSwiper.swipeTo(previewSwiper.clickedSlideIndex)
            }
        })

        $(".history-swiper2 .swiper-slide").each(function(){
            var _child = $(this).find(".years-txt");
            var _moreBtn = $(this).find(".years-item-more");
            _child.find(".years-txt-item:gt(1)").hide();
            if(_child.find(".years-txt-item").length > 2){
                _moreBtn.show();
            }else{
                _moreBtn.hide();
            }
            _moreBtn.find("a").click(function(){
                if(!$(this).hasClass("on")){
                    $(this).addClass("on");
                    $(this).html('收起');
                    _child.find(".years-txt-item:gt(1)").slideDown(200);
                }else{
                    $(this).removeClass("on");
                    $(this).html('展开更多');
                    _child.find(".years-txt-item:gt(1)").slideUp(200);
                }
            })

        })

        function updateNavPosition() {
            $('.preview .active-nav').removeClass('active-nav')
            var activeNav = $('.preview .swiper-slide').eq(viewSwiper.activeIndex).addClass('active-nav')
            if (!activeNav.hasClass('swiper-slide-visible')) {
                if (activeNav.index() > previewSwiper.activeIndex) {
                    var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1
                    previewSwiper.swipeTo(activeNav.index() - thumbsPerNav)
                } else {
                    previewSwiper.swipeTo(activeNav.index())
                }
            }
        }

    }

}

function touziTab(){
    $(".Company-data-tit ul li").click(function(){
        $(this).addClass("on").siblings().removeClass("on");
        $(".Company-data-con .Company-data-item").eq($(this).index()).addClass("active").siblings().removeClass("active");
    })
}

function socialSwiper(){
    if($(".new-media-swiper").length > 0){
        var swiper = new Swiper ('.new-media-swiper .swiper-container', {
            paginationClickable :true,
            autoHeight: true,
            calculateHeight : true,
            autoplayDisableOnInteraction : false,
            loop : false,
            onSlideChangeStart: function(swiper){
                $(".new-swiper-btn ul li").eq(swiper.activeIndex).addClass("on").siblings().removeClass("on");
                // alert(swiper.activeIndex);
            }
        })
        $(".new-swiper-btn ul li").hover(function(){
            $(this).addClass("on").siblings().removeClass("on");
            swiper.swipeTo($(this).index());
        })
    }
}

function inforTab(){
    $(".infor-tab ul li").click(function(){
        $(this).addClass("on").siblings().removeClass("on");
        $(".infor-list .infor-list-item").eq($(this).index()).addClass("show").siblings().removeClass("show");
    })
}

function csrZhaopin(){
    $(".csr-moreBtn a").click(function(){
        $(this).toggleClass("on");
        $(".csr-list").slideToggle(200);
    })

    $(".csr-list-item .csr-tit").click(function(){
        $(this).parents(".csr-list-item").toggleClass("on");
        $(this).siblings(".csr-open").slideToggle(200);
    })

    $(".zpDetails a").click(function(){
        $(this).toggleClass("on");
        $(".zpDetails-txt").slideToggle(200);
    })
}

function csrSwiper(){
    if($(".csr-linian").length > 0){
        var csrName;

        $(".csr-linian-item").each(function(e){
            var _child = $(this).find(".csr-container");
            csrName = "csr-con-"+e;
            nextBtn = "csr-next-"+e;
            prevBtn = "csr-prev-"+e;
            pageBtn = "csr-page-"+e;
            _child.addClass(csrName);
            _child.siblings(".csr-next").addClass(nextBtn);
            _child.siblings(".csr-prev").addClass(prevBtn);
            _child.siblings(".csr-page").addClass(pageBtn);
            var swiper = new Swiper('.'+csrName,{
                // pagination: '.'+pageBtn,
                // prevButton: '.'+prevBtn,
                // nextButton:'.'+nextBtn,
                calculateHeight : true,
                loop:true,
                grabCursor: true,
                paginationClickable: true
            })
            $('.csr-prev-'+e).on('click', function(e){
                e.preventDefault()
                swiper.swipePrev()
            })
            $('.csr-next-'+e).on('click', function(e){
                e.preventDefault()
                swiper.swipeNext()
            })
        })

    }
}

function baseSwiper(){
    if($(".base-swiper").length > 0){
        var swiper = new Swiper ('.base-swiper .swiper-container', {
            // prevButton: '.base-swiper .swiper-button-prev',
            // nextButton: '.base-swiper .swiper-button-next',
            paginationClickable :true,
            calculateHeight : true,
            autoHeight: true,
            slidesPerView : 3,
            autoplayDisableOnInteraction : false,
            loop : true,
        })
        $('.base-swiper .arrow-left').on('click', function(e){
            e.preventDefault()
            swiper.swipePrev()
        })
        $('.base-swiper .arrow-right').on('click', function(e){
            e.preventDefault()
            swiper.swipeNext()
        })
    }
}

function socialSwiper2(){
    if($(".social-swiper").length > 0){
        var swiper = new Swiper ('.social-swiper .swiper-container', {
            // prevButton: '.social-swiper .swiper-button-prev',
            // nextButton: '.social-swiper .swiper-button-next',
            paginationClickable :true,
            autoHeight: true,
            calculateHeight : true,
            slidesPerView : 3,
            spaceBetween:20,
            autoplayDisableOnInteraction : false,
            loop : true,
        })
        $('.social-swiper .arrow-left').on('click', function(e){
            e.preventDefault()
            swiper.swipePrev()
        })
        $('.social-swiper .arrow-right').on('click', function(e){
            e.preventDefault()
            swiper.swipeNext()
        })
    }
}

function vsIndexSwiper(){
    if($(".vs-tj-swiper").length > 0){
        var swiper = new Swiper ('.vs-tj-swiper .swiper-container', {
            pagination: '.vs-tj-swiper .pagination',
            paginationClickable :true,
            autoHeight: true,
            calculateHeight : true,
            spaceBetween:20,
            autoplay:5000,
            autoplayDisableOnInteraction : false,
            loop : true,
        })
    }
}

function newPresenceSwiper(){
    if($(".new-presence-swiper").length > 0){
        var swiper = new Swiper ('.new-presence-swiper .swiper-container', {
            // prevButton: '.new-presence-swiper .swiper-button-prev',
            // nextButton: '.new-presence-swiper .swiper-button-next',
            paginationClickable :true,
            slidesPerView : 4,
            autoHeight: true,
            calculateHeight : true,
            spaceBetween:20,
            autoplayDisableOnInteraction : false,
            loop : true,
        })
        $('.new-presence-swiper .arrow-left').on('click', function(e){
            e.preventDefault()
            swiper.swipePrev()
        })
        $('.new-presence-swiper .arrow-right').on('click', function(e){
            e.preventDefault()
            swiper.swipeNext()
        })
    }
}


function resultSwiper(){
    if($(".result-years").length > 0){
        var swiper = new Swiper ('.result-years .swiper-container', {
            // prevButton: '.new-presence-swiper .swiper-button-prev',
            // nextButton: '.new-presence-swiper .swiper-button-next',
            paginationClickable :true,
            slidesPerView : 4,
            autoHeight: true,
            calculateHeight : true,
            autoplayDisableOnInteraction : false,
            loop : false,
        })
    }
}


function contactMap(){
    if($("#map").length > 0){
        // 百度地图API功能
        var map = new BMap.Map("map");
        var point = new BMap.Point(116.364061,39.934551);
        map.centerAndZoom(point, 18);
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
        marker.setAnimation(BMAP_ANIMATION_BOUNCE);
    }
}


function socialTab(){

    $(".social-link li").click(function(){
        $(this).addClass("on").siblings().removeClass("on");
        $(".social-list .social-item").eq($(this).index()).addClass("show").siblings().removeClass("show");
    })

}

function djSwiper(){
    if($(".dj-special-swiper").length > 0){
        var swiper = new Swiper ('.dj-special-swiper .swiper-container', {
            // prevButton: '.dj-special-swiper .swiper-button-prev',
            // nextButton: '.dj-special-swiper .swiper-button-next',
            paginationClickable :true,
            slidesPerView : 3,
            autoHeight: true,
            calculateHeight : true,
            spaceBetween:20,
            autoplay:5000,
            autoplayDisableOnInteraction : false,
            loop : true,
        })
        $('.dj-special-swiper .arrow-left').on('click', function(e){
            e.preventDefault()
            swiper.swipePrev()
        })
        $('.dj-special-swiper .arrow-right').on('click', function(e){
            e.preventDefault()
            swiper.swipeNext()
        })

        $(".dj-special-more").find("a").click(function(){
            if(!$(this).hasClass("on")){
                $(this).addClass("on");
                $(this).html("收起");
                $(".dj-special-swiper").css({'height':'auto','overflow':'inherit'});
                $(".dj-special-swiper").slideDown(200);
            }else{
                $(this).removeClass("on");
                $(this).html("展开更多");
                $(".dj-special-swiper").css({'height':'0','overflow':'hidden'});
                $(".dj-special-swiper").slideDown(200);
            }

        })
    }
}

function ztNews(){
    $(".new-zt-more").find("a").click(function(){
        if(!$(this).hasClass("on")){
            $(this).addClass("on");
            $(this).html("收起");
            $(".new-presence-swiper").css({'height':'auto','overflow':'inherit'});
            $(".new-presence-swiper").slideDown(200);
        }else{
            $(this).removeClass("on");
            $(this).html("展开更多");
            $(".new-presence-swiper").css({'height':'0','overflow':'hidden'});
            $(".new-presence-swiper").slideDown(200);
        }
    })
}

function report(){

   // $(".report-btn .btn").click(function(){
   //     var _href= $(this).attr("data-href");
   //     var _val = $(".label").find("input:radio[name='agree']:checked").val();
   //     if(_val == null){
   //         console.log("no")
   //         return false;
   //     }else{
   //         console.log("yes")
  //          window.location.href = _href;
   //     }
   // })

    $(".lawsList-item>a").click(function(){
        $(this).parent().toggleClass("on");
        $(this).siblings(".laws-slide").slideToggle(200);
    })

}


