

$(".coc-3").ready(function () {
    var s = 0;
    var l = 40;
    var end = 1200;
    var w = $("#honnor .hd ul li").width();
    $("#honnor .hd ul li").each(function (i, e) {
        s += $(e).width();
    })
    $("#honnor .hd ul").width(s);
    jQuery("#honnor").slide({
        mainCell: ".bd ul",
        titCell: ".hd ul li",
        effect: "leftLoop",
        trigger: "click",
        autoPlay: true,
        interTime: 4000,
        delayTime: 1500,
        vis: 1,
        startFun: function (i, c) {
            if (c - 7 < i) {
                l = w * (c - 7) + 40;
            } else if (c - 7 > i) {
                l = w * i;
            } else if (i == 0) {
                l = 40;
            }

            $("#honnor .hd ul").css("left", -l);
        }
    })
})



$(".pc_slideshow").ready(function () {
    $(".pc_slideshow .pc_slideshow_context").css("margin-top", "-" + parseInt($(".pc_slideshow .pc_slideshow_context").height() / 2) + "px");
    $(".pc_slideshow").slide({
        mainCell: ".bd",
        titCell: ".hd",
        effect: "fold",
        autoPage: "<span></span>",
        trigger: "click",
        autoPlay: true,
        interTime: 7000,
        delayTime: 1200
    })
})



$(".programme_slide").ready(function () {
    $(" .programme_slide").slide({
        mainCell: ".bd",
        titCell: ".hd span",
        effect: "fold",
        trigger: "click",
        autoPlay: true,
        interTime: 7000,
        delayTime: 1200
    })

})


$(".case_slide").ready(function () {
    $(".case_slide").slide({
        mainCell: ".bd",
        titCell: ".hd div",
        effect: "fold",
        trigger: "click",
        autoPlay: true,
        interTime: 3000,
        delayTime: 1000
    })
})


$(".header").ready(function () {
    // 二级
    $(".pc_column .pc_column_one").on("mouseenter", function (e) {
    
        $(".pc_column .pc_column_one").not(this).children(".pc_column_two").stop().hide(0);
       
        if ($(this).children(".pc_column_two").length > 0) {
           $(this).children(".pc_column_two").stop().slideDown(300);
        } else
          $(this).children(".pc_column_two").stop().slideUp(100);
    })
    
    $(".pc_column .pc_column_one").on("mouseleave", function (e) {
        e.stopPropagation();
        $(this).children(".pc_column_two").stop().slideUp(100);
    })

// 三级
     $(".pc_column .pc_column_two li").on("mouseenter", function () {
    //   $(".pc_column .pc_column_two li ").not(this).children(".pc_column_three").stop().hide(0);
 
        if ($(this).children(".pc_column_three").length > 0) {
           $(this).children(".pc_column_three").show(200);
        } else
        $(this).children(".pc_column_three").stop().hide(200);
    })
    $(".pc_column .pc_column_two li").on("mouseleave", function () {
          $(this).children(".pc_column_three").stop().hide(300);
    })
})

$("#newCenter").ready(function(){
    $("#newCenter .index_news").on("mouseenter",function(){
            $(this).width("550px");
            $("#newCenter .index_news").not(this).width("400px")
        
    })
    $("#newCenter .index_news").on("mouseleave",function(){
        $("#newCenter .index_news").width("450px");
    })
})


$(function () {

    $("#searchbtn").off("click").on('click', function () {
        if (!$(this).hasClass("on")) {
            $(".search-area").slideDown();
            $(this).removeClass("on").addClass("on");
            $(document).scroll(function () {
                $(".search-area").slideUp();
                $("#searchbtn").removeClass("on");
            })
        } else {
            $(".search-area").slideUp();
            $(this).removeClass("on");
        }
    })

    $("#schbtn").on('click', function () {
        if ($("#keywords").val() == '') {
            layer.msg("请输入搜索关键字");
            $("#keywords").focus();
            return false;
        }
        $("#schform").submit();
    })
})

function gotoPage() {
    var page = $("#page").val();
    if (page == '') {
        layer.msg("请输入页数！", {
            icon: 2
        });
        $("#page").focus();
        return false;
    }
    window.location.href = $("#goto_page").attr("data-url") + '-' + page + '.html';
}

function getjob() {
    joinsid = $(this).attr("data-id");
    $.ajax({
        url: "do-9.html",
        type: "POST",
        data: {
            id: joinsid
        },
        dataType: "html",
        success: function (data) {
            var dt = JSON.parse(data);
            var d = dt.data;
            $("#joinstitle").text(d.title);
            $("#joinscontent").html(d.content);
            $("#inputtile").val(d.title);
            if (dt.code == 1) {
                layer.open({
                    type: 1,
                    title: false,
                    closeBtn: false,
                    shade: .8,
                    shadeClose: false,
                    area: ['1200px', '850px'],
                    content: $("#joinsform"),
                    end: function () {
                        $("#joinsform").hide();
                    }
                })
            } else {
                layer.msg(d.msg, {
                    icon: 2
                })
            }
        }
    })
}

function loadjob() {
    var btn = $(this);
    $.ajax({
        url: "do-10.html",
        type: 'POST',
        data: {
            cid: 15,
            limit: 8,
            tnum: 15,
            limitstart: $(".interior_recruitment-information-table tr").length - 1
        },
        async: false,
        success: function (data) {
            var da = JSON.parse(data);
            var option = '';
            if (da.flag == 200 || da.flag == 210) {
                d = da.data;
                btn.text("正在加载...");
                setTimeout(function () {
                    for (var i = 0; i < d.length; i++) {
                        option = '<tr><td>' + d[i].newtitle + '</td><td>' + d[i].source + '</td><td>' + d[i].guest + '</td><td>' + d[i].writer + '</td><td>' + d[i].newtime + '</td><td>' + d[i].newontime + '</td><td class="btn" data-title="' + d[i].title + '" data-id="' + d[i].id + '">网上应聘</td></tr>';
                        $(".interior_recruitment-information-table table").append(option);
                    }
                    if (da.flag == 210) {
                        btn.html("没有更多了");
                    }
                    else {
                        $(".interior_recruitment-information .more").one('click', loadjob);
                        btn.html("点击加载更多+");
                    }
                    $(".interior_recruitment-information td.btn").unbind();
                    $(".interior_recruitment-information td.btn").on("click", getjob);
                }, 1500);

            } else if (da.flag == 220) {
                btn.html("正在加载...");
                setTimeout(function () {
                    btn.html("没有更多了");
                    $(".interior_recruitment-information td.btn").unbind();
                    $(".interior_recruitment-information td.btn").on("click", getjob);
                }, 1200);
            }

        }
    })
}

$(".interior_recruitment-information").ready(function () {
    $(".interior_recruitment-information td.btn").on("click", getjob);
    $(".img_pop .closebtn").on('click', function () {
        $("#joinsform").hide();
    })
})


$(".interior_recruitment-information").ready(function () {
    $(".interior_recruitment-information .more").one('click', loadjob)
})

$(".pc_footer-plug-in").ready(function () {

    $("#rtel").on('mouseenter', function () {
        layer.tips('<div class="qrcode">' + $(this).attr("data-tel") + '</div>', this, {
            tips: [4, '#2d66a5'],
            time: 0
        })
    });
    $("#rtel").on("mouseleave", function () {
        layer.close(layer.index)
    });
    $("#rwx").on('mouseenter', function () {
        layer.tips('<div class="qrcode"><img class="qrcode" src="' + $(this).attr("data-img") + '"/></div>', this, {
            tips: [4, '#2d66a5'],
            time: 0,
            skin: "wxqrcode"
        })
    });
    $("#rwx").on("mouseleave", function () {
        layer.close(layer.index)
    });
})

$(function () {
    $(".msgformbtn").on('click', function () {
        $("#msgform #formtitle").text($(this).attr("data-tit"));
        $("#msgform #formtitle1").text($(this).attr("data-tit1") + "：");
        $("#msgform #formtitle1").siblings("textarea").attr("placeholder", "请填写" + $(this).attr("data-tit1"));
        $("#msgform #mtype").val($(this).attr("data-type"));
        layer.open({
            type: 1,
            title: false,
            closeBtn: false,
            shade: .8,
            shadeClose: false,
            area: ['1090px', '530px'],
            content: $("#msgform"),
            end: function () {
                $("#msgform").hide();
            }
        })

    })


    // 首页fullpage

    $("#fullpage").ready(function () {
        $('#fullpage').fullpage({
            //Navigation
            menu: false, //绑定菜单，设定的相关属性与anchors的值对应后，菜单可以控制滚动，默认为false。
            // anchors: ['firstPage', 'secondPage'], //anchors定义锚链接，默认为[]
            lockAnchors: false, //是否锁定锚链接，默认为false,设为true后链接地址不会改变
            navigation: true, //是否显示导航，默认为false
            navigationPosition: 'right', //导航小圆点的位置
            navigationTooltips: ['介绍', '关于雅达', '解决方案', '行业应用', '新闻中心', '快速导航'], //导航小圆点的提示
            showActiveTooltip: false, //是否显示当前页面的tooltip信息
            slidesNavigation: true, //是否显示横向幻灯片的导航，默认为false
            slidesNavPosition: 'bottom', //横向导航的位置，默认为bottom，可以设置为top或bottom
            //Scrolling
            css3: true, //是否使用CSS3 transforms来实现滚动效果，默认为true
            scrollingSpeed: 1000, //设置滚动速度，单位毫秒，默认700
            autoScrolling: true, //是否使用插件的滚动方式，默认为true,若为false则会出现浏览器自带滚动条
            fitToSection: true, //设置是否自适应整个窗口的空间，默认值：true
            scrollBar: false, //是否包含滚动条，默认为false,若为true浏览器自带滚动条出现
            easing: 'easeInOutCubic', //定义页面section滚动的动画方式，若修改此项需引入jquery.easing插件
            easingcss3: 'ease', //定义页面section滚动的过渡效果，若修改此项需引入第三方插件
            loopBottom: false, //滚动到最低部后是否连续滚动到顶部，默认为false
            loopTop: false, //滚动到最顶部后是否连续滚动到底部，默认为false
            // loopHorizontal: true, //横向slide幻灯片是否循环滚动，默认为true
            continuousVertical: false, //是否循环滚动，不兼容loopTop和loopBottom选项
            // normalScrollElements: '#baidumap', //避免自动滚动，滚动时的一些元素，例如百度地图
            scrollOverflow: false, //内容超过满屏后是否显示滚动条，true则显示滚动条，若需滚动查看内容还需要jquery.slimscroll插件的配合
            touchSensitivity: 15, //在移动设备中滑动页面的敏感性，默认为5最高100，越大越难滑动
            normalScrollElementTouchThreshold: 5,
            //Accessibility
            keyboardScrolling: true, //是否可以使用键盘方向键导航，默认为true
            animateAnchor: true, //锚链接是否可以控制滚动动画，默认为true,若为false则锚链接定位失效
            recordHistory: true, //是否记录历史，默认为true,浏览器的前进后退可导航。若autoScrolling:false,那么这个属性将被关闭
            //Design
            controlArrows: true, //定义是否通过箭头来控制slide,默认true
            verticalCentered: false, //定义每一页的内容是否垂直居中，默认true
            resize: false, //字体是否随窗口缩放而缩放，默认false
            sectionsColor: [], //为每个section设置background-color属性
            paddingTop: '100px', //设置每一个section顶部的padding,默认为0
            paddingBottom: '0', //设置每一个section底部的padding,默认为0
            // fixedElements: '', //固定元素，默认为null,需要配置一个jquery选择器，在页面滚动时，fixElements设置的元素不滚动
            responsiveWidth: 0,
            responsiveHeight: 0,
            //Custom selectors
            sectionSelector: '.section', //section选择器。默认为.section
            slideSelector: '.slide', //slide选择器，默认为.slide
            //events
            onLeave: function (index, nextIndex, direction) {
                switch (nextIndex) {
                    case 1:
                        if ($('#about_title-en').hasClass('a-fadeinR')) {
                            $('#about_title-en').removeClass('a-fadeinR')
                        }

                        if ($('#about_title-ch').hasClass('a-fadeinL')) {
                            $('#about_title-ch').removeClass('a-fadeinL')
                        }

                        if ($('#about_context').hasClass('a-fadeinB')) {
                            $('#about_context').removeClass('a-fadeinB')
                        }

                        if ($('#about_us-padding-btn').hasClass('a-fadein')) {
                            $('#about_us-padding-btn').removeClass('a-fadein')
                        }
                        break;
                    case 2:
                        if ($('#programme_content-title').hasClass('a-bounceinT')) {
                            $('#programme_content-title').removeClass('a-bounceinT')
                        }

                        if ($('#programme_content-text').hasClass('a-bounceinB')) {
                            $('#programme_content-text').removeClass('a-bounceinB')
                        }

                        if ($('#programme_point').hasClass('a-bounce')) {
                            $('#programme_point').removeClass('a-bounce')
                        }

                        if ($('.programme_slide .hd').hasClass('a-rotatein')) {
                            $('.programme_slide .hd').removeClass('a-rotatein')
                        }
                        break;
                    case 3:
                        if ($('.case_slide .hd').hasClass('a-flip')) {
                            $('.case_slide .hd').removeClass('a-flip')
                        }

                        if ($('#case_friendship').hasClass('a-rotateinRB')) {
                            $('#case_friendship').removeClass('a-rotateinRB')
                        }
                        break;
                    case 4:
                        if ($('#newCenter .index_news .news_title').hasClass('a-fadeinB')) {
                            $('#newCenter .index_news .news_title').removeClass('a-fadeinB')
                        }

                        if ($('#newCenter .index_news.el0').hasClass('a-rotateinLT')) {
                            $('#newCenter .index_news.el0').removeClass('a-rotateinLT')
                        }

                        if ($('#newCenter .index_news.el1').hasClass('a-flipin a-flipinY')) {
                            $('#newCenter .index_news.el1').removeClass('a-flipin a-flipinY')
                        }

                        if ($('#newCenter .index_news.el2').hasClass('a-rotateinRT')) {
                            $('#newCenter .index_news.el2').removeClass('a-rotateinRT')
                        }
                        break;

                }
            },
            afterLoad: function (anchorLink, index) {
                switch (index) {
                    case 1:

                        if (!$('#about_title-en').hasClass('a-fadeinR')) {
                            $('#about_title-en').addClass('a-fadeinR')
                        }

                        if (!$('#about_title-ch').hasClass('a-fadeinL')) {
                            $('#about_title-ch').addClass('a-fadeinL')
                        }

                        if (!$('#about_context').hasClass('a-fadeinB')) {
                            $('#about_context').addClass('a-fadeinB')
                        }

                        if (!$('#about_us-padding-btn').hasClass('a-fadein')) {
                            $('#about_us-padding-btn').addClass('a-fadein')
                        }
                        break;
                    case 2:
                        if (!$('#programme_content-title').hasClass('a-bounceinT')) {
                            $('#programme_content-title').addClass('a-bounceinT')
                        }

                        if (!$('#programme_content-text').hasClass('a-bounceinB')) {
                            $('#programme_content-text').addClass('a-bounceinB')
                        }

                        if (!$('#programme_point').hasClass('a-bounce')) {
                            $('#programme_point').addClass('a-bounce')
                        }

                        if (!$('.programme_slide .hd').hasClass('a-rotatein')) {
                            $('.programme_slide .hd').addClass('a-rotatein')
                        }
                        break;
                    case 3:
                        if (!$('.case_slide .hd').hasClass('a-flip')) {
                            $('.case_slide .hd').addClass('a-flip')
                        }

                        if (!$('#case_friendship').hasClass('a-rotateinRB')) {
                            $('#case_friendship').addClass('a-rotateinRB')
                        }
                        break;
                    case 4:
                        if (!$('#newCenter .index_news .news_title').hasClass('a-fadeinB')) {
                             $('#newCenter .index_news .news_title').addClass('a-fadeinB')
                        }

                        if (!$('#newCenter .index_news.el0').hasClass('a-rotateinLT')) {
                             $('#newCenter .index_news.el0').addClass('a-rotateinLT')
                        }

                        if (!$('#newCenter .index_news.el1').hasClass('a-flipin a-flipinY')) {
                             $('#newCenter .index_news.el1').addClass('a-flipin a-flipinY')
                        }

                        if (!$('#newCenter .index_news.el2').hasClass('a-rotateinRT')) {
                             $('#newCenter .index_news.el2').addClass('a-rotateinRT')
                        }
                        break;

                }
            },
            afterRender: function () { },
            afterResize: function () { },
            afterSlideLoad: function (anchorLink, index, slideAnchor, slideIndex) { },
            onSlideLeave: function (anchorLink, index, slideIndex, direction, nextSlideIndex) { }
        });
    })

    // 跳转首页最后一个页面的padding
    $("#fullpage .section.last .bg").css("padding-top", parseInt($(window).height() - $(".pc_footer").height() - $(".pc_consultancy").height() - 100) + "px");
    $(window).resize(function () {
        $("#fullpage .section.last .bg").css("padding-top", parseInt($(window).height() - $(".pc_footer").height() - $(".pc_consultancy").height() - 100) + "px");
    })

    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    if (scrollTop == 0) {
        $("#slideshow-anchor").addClass('on').siblings().removeClass('on');
    }

    $(window).scroll(function () {

        if ($(window).scrollTop() > 300) {
            $(".pc_footer-plug-in .return_top").slideDown(800);
        } else {
            $(".pc_footer-plug-in .return_top").slideUp(800);
        }
    });

    $(".pc_interior-nav p").each(function () {
        if ($(this).hasClass('on')) {
            $(this).siblings().removeClass('on');
        }
    });

    $(".pc_interior-nav p").on('click', function () {
        $(this).addClass('on').siblings().removeClass('on');
    });



})

function IEVersion() {
    var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串  
    var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器  
    var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器  
    var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
    if (isIE) {
        var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
        reIE.test(userAgent);
        var fIEVersion = parseFloat(RegExp["$1"]);
        if (fIEVersion == 7) {
            return 7;
        } else if (fIEVersion == 8) {
            return 8;
        } else if (fIEVersion == 9) {
            return 9;
        } else if (fIEVersion == 10) {
            return 10;
        } else {
            return 6;//IE版本<=7
        }
    } else if (isEdge) {
        return 'edge';//edge
    } else if (isIE11) {
        return 11; //IE11  
    } else {
        return -1;//不是ie浏览器
    }
}

$(function () {
    if (IEVersion() > 0 && IEVersion() < 10) {
        $("form input,form textarea").each(function () {
            if ($(this).attr("placeholder") != undefined && $(this).attr("placeholder") != '') {
                $(this).val($(this).attr("placeholder"));
                $(this).blur(function () {
                    if ($(this).val() == "")
                        $(this).val($(this).attr("placeholder"));
                })
                $(this).focus(function () {
                    if ($(this).val() == $(this).attr("placeholder"))
                        $(this).val("");
                })
            }
        })
    }
    if (IEVersion() < 0 || (IEVersion() > 0 && IEVersion() > 8)) {
        if (document.getElementById('mydiv')) {
            var config = {
                vx: 4,
                vy: 4,
                height: 3,
                width: 3,
                count: 100,
                color: "255, 255, 255",
                stroke: "255,255,255",
                dist: 6000,
                e_dist: 20000,
                max_conn: 10
            }
            CanvasParticle(config);
        }
    }
})

