/**
 * Created by jxw
 * 2019-06-17
 */


$(".top .menuicon").click(function(){
    $(this).toggleClass('show');
    if($(this).hasClass('show'))
        $(".top .menu").slideDown(300)
    else
        $(".top .menu").slideUp(200)
})

$(function(){
    if(IEVersion()>-1&&IEVersion()<9){
        alert("IE版本过低，请使用ie9以上版本或其他浏览器极速版本");
    }
    var ww=$(window).width();
    if(ww>1000){
        new WOW().init();
        // 导航二级栏目展开
        $(".menu a").each(function(index, el) {
            $(this).hover(function() {
                if(index>0&&index<4){
                    $(".navaboutsec").eq(index-1).stop().slideDown().siblings('.navaboutsec').slideUp();
                    $(".secnavback").show();
                    $(this).addClass('s').siblings().removeClass('s');
                }else{
                    $(".navaboutsec").slideUp();
                    $(".secnavback").hide();
                    $(this).siblings().removeClass('s');
                }
            });
        });
        $(".secnavback").hover(function() {
            $(".menu a").removeClass('s');
            $(".navaboutsec").slideUp();
            $(this).hide();
        });
    }
    if(ww<1000){
        $(".nylocbg .nynav a").width((100/$(".nylocbg .nynav a").length)-1+"%");
        $(".bottom h1").click(function(event) {
            $(this).toggleClass('active');
            if($(this).parent().find('ul').css('display') == 'none')
                $(this).parent().find('ul').slideDown(300);
            else
                $(this).parent().find('ul').slideUp(200);
        });
    }
    //产品导航二级栏目去掉最后一条 |
    $(".small.pronavlink").each(function(index, el) {
        $(this).text($(this).text().substring(0,$(this).text().length-2))
    });
    // 搜索框展开
    $(".topsreach").click(function(event) {
        if($(".topssdivbg").is(":hidden")){
            $(this).find('span').addClass('glyphicon-remove');
            $(".topssdivbg").stop().slideDown();
        }else{
            $(this).find('span').removeClass('glyphicon-remove');
            $(".topssdivbg").stop().slideUp();
        }
    });
    //搜索点击
    $(".topssdiv .input-group-btn .dropdown-menu li").click(function(event) {
        $(this).parent().parent().find('.btn-default').html($(this).text()+' <span class="caret"></span>');
        $("#ColumnID").val($(this).data('columnid'));
    });
    $("#form1 .ssbtncilck").click(function(event) {
        $("form[name='form1']").submit();
    });

    // 产品列表页多页签
    $(".prolistdiv").each(function(index, el) {
        $(this).find('.prolist .protit a:eq(0)').addClass('s');
    });
    $(".protit a").click(function(event) {
        var index=$(this).index();
        var liwidth=$(this).parent().parent().find('.protabli').width();
        $(this).addClass('s').siblings().removeClass('s');
        $(this).parent().parent().find('.protab .protabul').animate({"margin-left": "-"+index*liwidth}, 500)
    });
    $(".prolistmore").each(function(index, el) {
        var liheight=Math.ceil($(this).parent().find('a').length/3)*28;
        if(ww<1000)
            liheight=$(this).parent().find('a').length*28;
        if(liheight<=165)
            $(this).hide();
        else{
            $(this).click(function(event) {
                if($(this).hasClass("glyphicon-remove")){
                    $(this).removeClass('glyphicon-remove');
                    $(this).parent().animate({height: 165}, 500);
                }else{
                    // var liheight=Math.ceil($(this).parent().find('a').length/3)*28;
                    $(this).addClass('glyphicon-remove');
                    $(this).parent().animate({height: liheight}, 500);

                }

            });
        }
    });

    //联系我们地图
    if($(".lxwmmapdiv").length>0){
        var map = new BMap.Map("bdmap");    // 创建Map实例
        map.centerAndZoom(new BMap.Point(120.598054,28.096222), 15);  // 初始化地图,设置中心点坐标和地图级别
        var pt = new BMap.Point(120.598054,28.096222);
        var myIcon = new BMap.Icon("assets/images/icon-5.png", new BMap.Size(32,40));
        var marker2 = new BMap.Marker(pt,{icon:myIcon});  // 创建标注
        map.addOverlay(marker2);
    }

    //招聘表单提交
    $(".jobbtn a.success").click(function(event) {
        var JobUpTime=$.cookie('JobUpTime');
        if(JobUpTime=="0"){
            alert("您刚刚提交过简历，请等待10分钟之后再提交！");
            return false;
        }
        var JobName=$(".JobName").val();
        var UpName=$(".UpName").val();
        var Sex=$(".Sex").val();
        var MingZu=$(".MingZu").val();
        var Hyzt=$(".Hyzt").val();
        var JiGuan=$(".JiGuan").val();
        var Hksz=$(".Hksz").val();
        var Csrq=$(".Csrq").val();
        var Sfzh=$(".Sfzh").val();
        var Zzmb=$(".Zzmb").val();
        var Zgxl=$(".Zgxl").val();
        var Zy=$(".Zy").val();
        var Yqdy=$(".Yqdy").val();
        var Lxdh=$(".Lxdh").val();
        var Dz=$(".Dz").val();
        var Dzyx=$(".Dzyx").val();
        var Yb=$(".Yb").val();
        var Jyjl=$(".Jyjl").val();
        var Gznr=$(".Gznr").val();
        var Zwpj=$(".Zwpj").val();
        if(JobName==""){
            alert("招聘岗位必须选择");
            $(".JobName").focus();
            return false;
        }
        $(".Mustfill").each(function(index, el) {
            if($(this).val()==""){
                alert("带*号为必填项，有必填项未填");
                $(this).focus();
                return false;
            }
        });
        $.ajax({
            url: '/Common/ExtChange.aspx?ExtGroupIdentify=jobfrom&action=Insert',
            type: 'POST',
            dataType: 'json',
            data: {JobName: JobName,UpName: UpName,Sex: Sex,MingZu: MingZu,Hyzt: Hyzt,JiGuan: JiGuan,Hksz: Hksz,Csrq: Csrq,Sfzh: Sfzh,Zzmb: Zzmb,Zgxl: Zgxl,Zy: Zy,Yqdy: Yqdy,Lxdh: Lxdh,Dz: Dz,Dzyx: Dzyx,Yb: Yb,Jyjl: Jyjl,Gznr: Gznr,Zwpj:Zwpj},
        })
        .done(function(data) {
            if(data.value="1"){
                alert("您的简历已提交成功，我们会尽快联系您！");
                var now = new Date();
                now.setTime(now.getTime() + 10 * 60 * 1000);
                $.cookie('JobUpTime', '0', { expires: now, path: "/", domain: window.DomainName });
            }else{
                alert("参数有误");
            }
        })
    });
    //招聘表单重置
    $(".jobbtn a.warning").click(function(event) {
        $(".jobUp input.form-control").val("");
        $(".jobUp textarea.form-control").val("");
    });


})

//首页脚本
$(function(){
    var hnheight=[];
    $(".index-row-2 .homenewsdiv").each(function(index, el) {
        hnheight.push($(this).find('h2').height());
    });
    $(".index-row-2 .homenewsdiv h2").height(Math.max.apply(null, hnheight));
    var swiperHome = new Swiper('.pcbanner', {
        paginationClickable: true,
        spaceBetween: 0,
        centeredSlides: true,
        autoplay : 5000,
        pagination: '.pcbanner .swiper-pagination',
    });
    var swiperHome2 = new Swiper('.wapbanner', {
        paginationClickable: true,
        spaceBetween: 0,
        centeredSlides: true,
        autoplay : 5000,
        pagination: '.wapbanner .swiper-pagination',
    });
    var swiperPro = new Swiper('.homepro', {
        slidesPerView: 4,
        paginationClickable: true,
        spaceBetween: 30,
        nextButton: '.index-row-3 .swiper-button-next',
        prevButton: '.index-row-3 .swiper-button-prev',
        breakpoints: {
            1024: {
                slidesPerView: 2,
                spaceBetween: 10
            },
        }
    });
})

// 判断ie版本
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浏览器
    }
}


//内页导航定位
if($('.pageban').length > 0){
    $('.pageban a').click(function(){
        var tag = $(this).attr("rel");
        if(tag && tag != '')
            $("html ,body").animate({scrollTop : $('.'+tag).offset().top },1000,"easeInOutQuint");
    })
}


//视频播放
$('.aboutvideoclick').click(function(event) {
    videoInit($(this).attr('data-value'))
});
function videoInit(url){
    if($('.maskBg').length == 0 &&$('.videoShow').length == 0){
        $('body').append("<div class='maskBg'></div><div class='videoShow' id='player'></div>");
        var player = new Clappr.Player({
            autoPlay:true,
            width:'100%',
            height:'100%',
            source: url,
            Loop:true,
            parentId: "#player"
        });

        $('.maskBg').animate({opacity: 1},400);
        $('.videoShow').animate({opacity: 1,top:'50%'},600,"easeInOutQuint",function(){

            $('.maskBg').click(function(event) {
                $('.maskBg').remove();
                $('.videoShow').remove();
            });
        });
    }
}


