$(document).ready(function() {
    //cookie测试
    if (document.cookie.indexOf("user=new") == -1) {
        //cookie时间2小时
        var t = new Date(new Date() * 1 + 2 * 60 * 60 * 1000);
        document.cookie = "user=new; expires=" + t.toGMTString();
    } else {
        $(".section").eq(1).addClass('active');
    }
    //首页背景轮播
    $('.xhy-bgcar1 ul li').simpleSwitch({
        playTime: 4000
    });
    $('#fullpage').fullpage({
        scrollOverflow: true,
        scrollingSpeed: 1200,
        afterLoad: function(anchorLink, index) {
            if (index == 1) {
                $('.xhy-c').removeClass('fadeInTop animated')
                $('.xhy-atip').addClass('fadeInLeft animated')
                $('.xhy-search').addClass('fadeInRight animated')
                $('.ba0').addClass('fadeInLeft1 animated')
                $('.ba1').addClass('fadeInLeft1 animated')
                $('.ba2').addClass('fadeInOpacity animated1')
                $('.ba3').addClass('fadeInRight1 animated')
                $('.ba4').addClass('fadeInRight1 animated')
            }
        },
        onLeave: function(index, direction) {
            if (index == '1') {
                $('.xhy-atip').removeClass('fadeInLeft animated')
                $('.xhy-search').removeClass('fadeInRight animated')
                $('.ba0').removeClass('fadeInLeft1 animated')
                $('.ba1').removeClass('fadeInLeft1 animated')
                $('.ba2').removeClass('fadeInOpacity animated1')
                $('.ba3').removeClass('fadeInRight1 animated')
                $('.ba4').removeClass('fadeInRight1 animated')
                $('.xhy-c').addClass('fadeInTop animated')
            }
        }
    })

})

window.onload = function() {
    //设置动态高度 $(window).height()
    $('.xhy-c').css('marginTop', $(window).height() - 700 + 'px');
    //首页动画效果
    function toggleBox() {
        $('.index-top-btn').click(function(e) {
            e.stopPropagation()
            $('.index-menu').slideToggle()
            $(document).click(function(e) {
                if (e.target.className == 'index-menu-bg') return
                if ($('.index-menu').css('display') === 'block') {
                    $('.index-menu').slideUp()
                }
            })
        })
        $('.index-menu .close').click(function(e) {
            $('.index-menu').slideUp()
        })
    }
    toggleBox()

    $('.index-float-btn').click(function(e) {
        e.stopPropagation()
        $('.index-menu').slideToggle()
        $(document).click(function() {
            if ($('.index-menu').css('display') === 'block') {
                $('.index-menu').slideUp()
            }
        })
    })

    $('.index-tit .tit').mouseenter(function() {
        var index = $(this).parent().children('.index-tit .tit').index(this);
        $(this).parent().siblings('.index-tab').children('.index-item').eq(index).show().siblings('.index-item').hide();
        $(this).addClass('cur');
        $(this).siblings().removeClass('cur');
    });


    $('.index-newspic li').simpleSwitch({
        num: '.index-picpg li',
        className: 'cur',
        text: '.index-pictt li',
        playTime: 4000
    });

    //首页背景图轮播
    $('.index-newspic2 li').simpleSwitch({
        num: '.index-newspic2 li',
        className: 'cur',
        playTime: 8000
    });

    jQuery('.tab-list-bool li').tabPanelFun({
        cur: 'cur',
        tabContent: '.tab-group',
        tabItem: '.tab-item',
        pra: true,
        pradom: '.tab-parent'
    });

    jQuery('.mid_con_tab ul li').tabPanelFun({
        cur: 'cur',
        tabContent: '.mid_con_tab_con',
        tabItem: '.mid_ctc_con',
        pra: true,
        pradom: '.mid_con_tab'
    });

    jQuery('.index-zw-tit .tit').tabPanelFun({
        cur: 'cur',
        tabContent: '.index-zw-tab',
        tabItem: '.index-zw-item'
    });

    jQuery('.index-zw-tit2 .tit').tabPanelFun({
        cur: 'cur',
        tabContent: '.index-zw-tab2',
        tabItem: '.index-zw-item'
    });

    jQuery('.index-more-img').bannerRollLR({
        len: 3,
        moveTime: 3000,
        prev: '.index-more-left',
        next: '.index-more-right'
    });

    $('.index-headline-item').simpleSwitch({
        playTime: 5000,
        type: 'top',
        autoPlay: true 
    })
    //首页头条轮播
    $('.index-headline-item').mouseenter(function(){
        var xx= $(this);
        $('.index-headline-item').simpleSwitch({
            playTime: 5000,
            type: 'top',
            autoPlay: false 
        })
    })
}