$(function(){
    var tooltip = $('[data-toggle="tooltip"]');
    if(!isNull(tooltip)){
        tooltip.tooltip(); 
    }
    //banner图片计数器
    var bannerImgNum=$(".banner .carousel-inner .item").length;
    if(bannerImgNum > 0){
        var bannerOlNum='<li data-target="#myCarousel" data-slide-to="0" class="active"></li>';
        for(var i = 1; i < bannerImgNum; i++){
            bannerOlNum +='<li data-target="#myCarousel" data-slide-to="'+i+'"></li>';
        }
        $(".banner .carousel-indicators").empty().append(bannerOlNum);
    }
    //导航选中高亮
    var currentPage = $("#pageViewId").val();
    if(typeof(currentPage) != 'undefined'){
        //$(".nav-inner>li[type='"+currentPage+"']").addClass("active").siblings("li").removeClass("active");
        //$(".nav-inner li ol li[type='"+currentPage+"']").parents("li").addClass("active").siblings("li").removeClass("active");
        var navLi=$(".header-nav ul>li");
        for(var i=0;i<navLi.length;i++){
            //navLi.eq(i).find("ol li").attr("type")==currentPage || navLi.eq(i).attr("type")=="qikanzaixian"
        	var hasLi=false;
        	if(navLi.eq(i).find("ol li").length>0){
                var navLi2=navLi.eq(i).find("ol li");
                for (var j = 0; j<navLi2.length;j++) {
                   if(navLi2.eq(j).attr("type")==currentPage){
                        navLi2.eq(j).parents("li").addClass("active").siblings("li").removeClass("active");
                        hasLi=true;
                    } 
                }
                if (hasLi==false)
                {
                	 if(navLi.eq(i).attr("type")==currentPage){
                         navLi.eq(i).addClass("active").siblings("li").removeClass("active");
                     }
                }
            }
            else{
                if(navLi.eq(i).attr("type")==currentPage){
                    navLi.eq(i).addClass("active").siblings("li").removeClass("active");
                }
            }
        }
    }
    //期刊列表中去掉最后一条文章的下border
    //$(".articleListBox").find(".article-list:last-child").css("border",0);
    //首页文章列表tab切换
    $(".tab-ul li").click(function(){
        var tabUlLiIndenx=$(this).index();
        $(".tab-ol li").eq(tabUlLiIndenx).addClass("active").siblings().removeClass("active");
    })
    //文章中图
//    var mySwiper = $('.swiper-container').swiper({
//        loop:true,
//        grabCursor: true,
//        paginationClickable: true
//    });
    $('.arrow-left').on('click', function(e) {
        e.preventDefault()
        var swiper = $(this).siblings('.swiper-container').data('swiper');
        swiper.swipePrev();
        var obj = swiper.imagesToLoad[swiper.activeIndex];
        var srcPath = obj.src;
        if (srcPath == "" || srcPath == undefined) {
            $(obj).attr("src", $(obj).attr("srcl"));
        }
    });
    $('.arrow-right').on('click', function(e) {
        e.preventDefault()
        var swiper = $(this).siblings('.swiper-container').data('swiper');
        swiper.swipeNext();
        var obj = swiper.imagesToLoad[swiper.activeIndex];
        var srcPath = obj.src;
        if (srcPath == "" || srcPath == undefined) {
            $(obj).attr("src", $(obj).attr("srcl"));
        }
    });
    
    //显示方式切换
    $(".widthimg").click(function(){
        $(this).addClass("current").siblings().removeClass("current");
        $(".articleListBox.active").find(".device").addClass("active");
        $(".articleListBox.active").find(".morenstyle").css({"display":"none"});
    })
    $(".widthtext").click(function(){
        $(this).addClass("current").siblings().removeClass("current");
        $(".articleListBox.active").find(".device").removeClass("active");
        $(".articleListBox.active").find(".morenstyle").css({"display":"none"});
    })
    $(".widthabs").click(function(){
        $(this).addClass("current").siblings().removeClass("current");
        $(".articleListBox.active").find(".device").addClass("active");
        $(".articleListBox.active").find(".morenstyle").css({"display":"block"});
    })

    //全选与反选
    $(".checkAll").click(function() {
        $('input[name="journalArticleCheck"]').prop("checked",this.checked);
    });
    var $journalArticleCheck = $("input[name='journalArticleCheck']");
    $journalArticleCheck.click(function(){
        $(".checkAll").prop("checked",$journalArticleCheck.length == $("input[name='journalArticleCheck']:checked").length ? true : false);
    });
    var pageType = getUrlParam("pageType");
    var currentPage = $("#pageViewId").val();
    //导出
    $("#export").click(function(){
        var articleIds ="";
        var exportCheckObj = $("input[name='journalArticleCheck']:checked");
        var size = exportCheckObj.size();
        if (size == 0) {
            if($("#language").val()=="en"){
                alert("Please select at least one article!");
                return false;
            }else{
                alert("请至少选择一篇文章！");
                return false;
            }
        }else{
            $.each(exportCheckObj,function(i,e){
                var articleId = $(e).attr("checkArticleId");
                if(size-1== i){
                    articleIds +=articleId
                }else{
                    articleIds +=articleId+",";
                }
            })
            //alert(articleId);
            $("#exportArticleId").attr("article_id",articleIds);
        }
    });

    //引用本文
    $("#ReferencePaper").click(function(){
    	var showAlert = "";
    	var pageType = "";
    	if($("#language").val()=="en"){
    		showAlert = "Please select at least one article!";
    		pageType = "en";
        }else{
        	showAlert = "请至少选择一篇文章！";
        	pageType = "cn";
        }
        if ($("input[name='journalArticleCheck']:checked").size() == 0) {
            if($("#language").val()=="en"){
                alert(showAlert);
                return false;
            }else{
                alert(showAlert);
                return false;
            }
        }else{
            var html = "";
            var articleIds = "";
            $.each($("input[name='journalArticleCheck']:checked"),function(i,e){
//                var contenObj = $(e).parents(".article-list-left").siblings().clone();
//                html += $(contenObj).find(".citation").show().prop('outerHTML');
                var articleId = $(e).attr("checkArticleId");
                var size = $("input[name='journalArticleCheck']:checked").size();
                if(size-1== i){
                    articleIds +=articleId
                }else{
                    articleIds +=articleId+",";
                }
            })
            if(!isNull(articleIds)){
            	$.ajax({
    	    		type:'post',
    	    		url:local_host +"article/getCitationStr",
    	    		data:{'ids':articleIds,
    					'fileType':1,
    					'pageType':pageType},
    	    		success:function(dataMap){
    						var citation = "";
    						if(pageType == "cn"){
    							citation = dataMap.citationCn.split("****");
    						}else{
    							citation = dataMap.citationEn.split("****");
    						}
    						for(var i=0;i<citation.length;i++){
    							html += '<div style="display: block;" class="citation">'+citation[i]+'</div>';
    						}
    						$("#copyReference").html(html);
    						MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
    	    		}
    			})
            }
            
        }
    });


    //栏目定位
    $('.column').mouseover(function () {
        $('.column-list').stop().slideDown();
    }).mouseout(function () {
        $('.column-list').stop().slideUp();
    })

    $('.column-ul li a').on("click", function () {
        var columnid = $(this).attr('href');
        $("html,body").animate({
            scrollTop: $(columnid).offset().top - 10 + "px"
        }, {
            duration: 500,
            easing: "swing"
        });
        $('.column-list').stop().hide();
    })

    $(".achiveBox .panel-collapse").eq(0).addClass("in");

    //高级检索结果页
    $(".clearText").click(function(){
        var inputText=$(this).siblings().val();
        //alert(inputText);
        if(inputText != " "){
            $(this).siblings().val("");
        }
    })

    $("#clearText").click(function(){
        $(".inputText input").val("");
    })

    //检索结果页聚类添加滚动条
    $(".soutongji div,#copyReference").niceScroll({
        cursorcolor:"#054d8c",
        cursoropacitymax:1,
        touchbehavior:false,
        cursorwidth:"5px",
        cursorborder:"0",
        cursorborderradius:"5px"
    });

    //检索条件点击关闭当前条件
    $(".condition-p span i").click(function(){
        $(this).parent("span").hide();
    })

    /**回到顶部**/
    $(window).scroll(function(){
        var backScrollTop=$(window).scrollTop();
        var windowHeight=$(window).height();
        if(backScrollTop>=windowHeight/2){
            $(".bottom-fixed").fadeIn(500);
        }else{
            $(".bottom-fixed").fadeOut(500);
        }
    })
    $(".bottom-fixed").click(function(){
        $("html,body").animate({scrollTop:0},500);
    })

    //搜索结果页tab栏切换
    $(".resultTab li").click(function(){
        $(this).addClass("active").siblings().removeClass("active");
    })

    //搜索结果页中全文中参考文献上标不显示参考文献
    $(".div_show_none .xref a").attr({"href":"javascript:void(0)"});
    $(".div_show_none a[ref-type='bibr']").attr({"href":"javascript:void(0)"});

   
    
    //留言板点击关闭
    $(".messageClose").click(function(){
		$(".monitor").hide();
		$(".messageBoardWrap").hide();
	})
	
	
	
	
	 //20190513版本过刊
	  $(".guokan-tab li").click(function(){
			$(this).addClass("curr").siblings().removeClass("curr");
			_index =$(this).index();
			$(".guokan-con .guokan-con-tab").eq(_index).addClass("active").siblings().removeClass("active");
			if(_index ==1){
				$(".guokan-con .guokan-dl").each(function(){
		            $(this).find("dd").css({"width":Math.floor($(this).width()/$(this).find("dd").length-2),"margin-left":"1px","margin-right":"1px"});
		        });
			}
	  })
	  var yearTab=$(".guokan-dlyear.dlyear-tab dl");
	  var tempYear = $(".guokan-dl dd.active a").text().trim();
	    for(var i=0;i<yearTab.length;i++) {
			if(yearTab.eq(i).attr("id")== tempYear){
				yearTab.eq(i).show().siblings().hide();
			}
		}
    
	  $(".guokan-dlwrap .guokan-dl dd").click(function(){
	    	var yearA=$(this).find("a").text().trim();
	    	//var yearTab=$(".guokan-dlyear.dlyear-tab dl");
	    	if(yearA==""){
				return;
			}
	    	yearTab.hide();
	    	$(this).addClass("active").siblings().removeClass("active");
	        $(this).addClass("active").parents(".guokan-dl").siblings(".guokan-dl").find("dd").removeClass("active");
	    	for(var i=0;i<yearTab.length;i++) {
	    		if(yearTab.eq(i).attr("id")==yearA){
	    			yearTab.eq(i).show().siblings().hide();
	    		}
	    	}
	        
	    });
})
/*window.onload = function(){
	var $hei = $(".guokan-con .guokan-pic li a img").height();
	$(".guokan-con .guokan-pic li a img").css("height",$hei);
}*/
$(window).load(function() {
	var $hei = $(".guokan-con .guokan-pic li a img").height();
	$(".guokan-con .guokan-pic li a img").css("height",$hei);
});
//相关期刊展开功能
function showMore(obj){
    var moreDiv = $(obj).parent(".archiveList");
    var openStatus = moreDiv.hasClass("current");
    if(openStatus){
        $(obj).find("span").addClass("icon-sanjiao1");
        $(obj).find("span").removeClass("icon-sanjiao");
        moreDiv.removeClass("current");
    }else{
        $(obj).find("span").removeClass("icon-sanjiao1");
        $(obj).find("span").addClass("icon-sanjiao");
        moreDiv.addClass("current");
    }
}

/**
 * 文章弹出引用信息到文件
 * e：object，当前对象
 * */
function referenceText(citation){
    $("#copyReference").empty();
    var context = "<p>"+citation+"</p>";
    $("#copyReference").html(context);
}

//弹出模态框复制功能
function copywz() {
    var ReferenceHtml = document.getElementById('copyReference').innerHTML;
    var noLabel = ReferenceHtml.replace(/<.+?>/gim,'');
    document.getElementById("biao1").value = noLabel;
    //alert($("#copyReference").text());
    document.getElementById("biao1").value = $("#copyReference").text();
    var wz = document.getElementById("biao1");
    wz.select(); // 选择对象
    //trim(wz.value)
    document.execCommand("Copy"); // 执行浏览器复制命令
    var currentPage = $("#pageViewId").val();
    var pageType = getUrlParam("pageType");
    if (!isNull(pageType) && "en" == pageType || currentPage=='Home' || currentPage == 'archivearticle' ) {
        alert("copy citation success");
    }
    else alert("复制成功");
}

//单个导出
function setExportData(articleId){
    $("#exportArticleId").attr("article_id",articleId);
}

/**
 * 加载期列表
 * @return
 */
function loadAllIssuelist(){
    var ajaxArg={
        url: local_host +"article/getAllJournalCatalogList",
        returnFun:loadIssuelist
    };
    ajaxPost(ajaxArg);
}
/**
 * 加载检索联动的年期
 * @return
 */
function loadIssuelist(data){
    /**select框值**/
    if(!isNull(data)){
        $("#s1").empty();
        var i = 0;
        for (var key in data){
            i = i +1;
            var issues = data[key];
            $("#s1").append("<option value="+key+">"+key+"年第"+issues[0].volume+"卷</option>");
            if(i == 1){
                $("#s2").empty();
                $.each(issues,function(j,e){
                    $("#s2").append("<option value="+e.issue+">第"+e.issue+"期</option>");

                })
            }
        }

        $("#s1").change(function(){
            var yearCurrent = $("#s1").val();
            for (var key in data){
                var issues = data[key];
                if(key == yearCurrent){
                    $("#s2").empty();
                    $.each(issues,function(j,e){
                        $("#s2").append("<option value="+e.issue+">第"+e.issue+"期</option>");
                    })
                }
            }
        })
    }
}

/*选择期后跳转到过刊页面 */
function selectIssue(obj){
    $(".left_search").attr("action",($(obj).val()));
}


$(function(){
	$(".fl-layout .article-list:last").css({"border-bottom":"none"});
	
    /*pc导航*/
    $(".header-nav ul > li").on("mouseenter",function () {
        if($(this).children().hasClass("data-show")) {
            $(this).children("a").addClass("active");
            $(this).find(".data-show").stop().slideDown(200);
        }
    });
    $(".header-nav ul > li").on("mouseleave",function () {
        if($(this).children().hasClass("data-show")) {
            $(this).children("a").removeClass("active");
            $(this).find(".data-show").stop().slideUp(200);
        }
    });
    /*导航结束*/
    //$(".tab-ul-index li:last").css({"margin":0,"float":"right"});

    /*响应式手机js*/
//	底部top按钮，点击返回顶部
    $(document).on('touchend','.toTop',function(){
        $('body,html').animate({scrollTop:0},300);
    })
    $('.navList').click(function(){
        if($('.smallUl').css('display')=='none'){
            $('.smallUl').slideDown();
            $(this).find('.span1').css({"transform":"rotate(-45deg)","margin-top":10});
            $(this).find(".span2").css({"opacity":0});
            $(this).find('.span3').css({"transform":"rotate(45deg)","margin-top":-21});
        }else{
            $('.smallUl').slideUp();
            $(this).find('.span1').css({"transform":"rotate(0deg)","margin-top":0});
            $(this).find(".span2").css({"opacity":1});
            $(this).find('.span3').css({"transform":"rotate(0deg)","margin-top":0});
        }
        if($(".search-app-wrap").css("display")=="block"){
        	$(".search-app-wrap").hide(0);
        	$(".search-app").removeClass("active");
        }
    });
    
    $(".search-app").click(function () {
        if($(".search-app-wrap").css("display")=="none"){
            $(".search-app-wrap").stop().slideDown(200);
            $(this).addClass("active");
        }else{
            $(".search-app-wrap").stop().slideUp(200);
            $(this).removeClass("active");
        }
        if($(".smallUl").css("display")=="block"){
        	$(".smallUl").hide(0);
        	$(".navList").find('.span1').css({"transform":"rotate(0deg)","margin-top":0});
        	$(".navList").find(".span2").css({"opacity":1});
        	$(".navList").find('.span3').css({"transform":"rotate(0deg)","margin-top":0});
        }
    });
    
    
    
    $(".smallUl>li").click(function () {
        if($(this).find(".data-show").css("display")=="none") {
            $(this).find("a span").addClass("active");
            $(this).siblings().find("a span").removeClass("active");
            $(this).find(".data-show").slideDown(200);
            $(this).siblings().find(".data-show").slideUp(200);
        }else {
            $(this).find(".data-show").slideUp(200);
            $(this).find("a span").removeClass("active");
        }
    });
    for(var i=0;i<$(".smallUl>li").length;i++){
        if($(".smallUl>li").eq(i).find("li").length>0){
            $(".smallUl>li").eq(i).children("a").append('<span><img src="'+local_host+'style/web/images/public/selet-arrow_app.png"></span>');
        }
    }
    _flag = true;
    function run() {
        //$(".phone-nav .text").css({"width":parseInt($(".phone-nav .container").width()-$(".navList").width()-$(".phone-nav .sub").width()-$(".phone-nav .en").width()-30)});
    	if($(window).width()<=1200){
            $(".header .navList span").last().css({"margin":0,"border":"none"});
            $(".smallUl").css({"top":$(".phone-nav").outerHeight()});
            $(".tab-ul-index").css({"width":$(".tab-ul-index li").length*$(".tab-ul-index li").outerWidth(true)});
            $(".item-div .tab-box").css({"overflow-x":"auto","overflow-y":"hidden"});
        }else{
            $(".tab-ul-index").css({"width":"100%"});
            $(".item-div .tab-box").css({"overflow-x":"inherit","overflow-y":"inherit"});
        }
        $(".advance-search-bot").css({"min-height":$(window).height()-$(".header").height()-$(".footer").height()-$(".phone-nav").height()-100});
        $(".main>.container").css({"min-height":$(window).height()-$(".footer").height()-$(".phone-nav").height()});
        $(".archcon .tab-ul").each(function(){
            $(this).find("dd").css({"width":Math.floor($(this).width()/$(this).find("dd").length-2),"margin-left":"1px","margin-right":"1px"});
        });
        
        if(window.innerWidth<=991){
            var left=$(".second-level-l").prop("outerHTML");
            $(".second-level-r").prev(".second-level-l").hide();
            $(".second-level-r").next().append(left);
            $(".second-level-r").next("div").show();
            setTimeout(function(){
                $(".search_year").change(function(){
					var yearId = $(this).val();
				    $(this).parent().siblings(".form-group").find("."+yearId).show().siblings().hide();
				    //给Action赋值
				    $(this).parents(".left_search").attr("action",$(this).parent().siblings(".form-group").find("."+yearId).val());
                })
            },200)
            if($(".second-level-r").next().find(".second-level-l").length>1){
                $(".second-level-r").next().append(left);
                $(".second-level-r").next().find(".second-level-l").eq(0).show().siblings().remove();
            }
            if($("div[class *= orders-]").length > 0 && $(".main-index").length >0){
            	if($(".main-phone").length == 0){
            		$(".main .container").prepend("<div class='main-phone'></div>");
            		var temparr = [];
	            	$("div[class *= orders-]").each(function(i,e){
	            		$index =  $(e).attr("class").indexOf("orders-");
	            		temparr.push($(e).attr("class").substring($index+7,$index+9));
	            	})
	            	temparr = temparr.sort(function (a, b) {
	                    return a - b;
	                });
	            	var mainPhone = $(".main-phone");
	            	for (var i=0;i<temparr.length;i++){
			            mainPhone.append($('.orders-' + temparr[i]).prop("outerHTML"))
			        }
	            	//_flag = false;
	            	
	            	if($('.carousel').length > 0){
		            	 var $carousels = $('.carousel');
		            	    var startX,endX;
		            	    var offset = 50;
		            	    $carousels.on('touchstart',function (e) {
		            	        startX = e.originalEvent.touches[0].clientX;
		            	    });
		            	    $carousels.on('touchmove',function (e) {
		            	        endX = e.originalEvent.touches[0].clientX;
		            	    });
		            	    $carousels.on('touchend',function (e) {
		            	        var distance = Math.abs(startX - endX);
		            	        if (distance > offset){
		            	            $(this).carousel(startX >endX ? 'next':'prev');
		            	        }
		            	    })	            		
	            	}

            	}
            	
            	$(".main-phone").show();
            	$(".main-left,.main-right,.main-mid").hide();
            }
            
            
        }else{
        	if($("div[class *= orders-]").length > 0){
         	 	$(".main-left,.main-right,.main-mid").show();
         	 	$(".main-phone").remove();
         	 }
            $(".second-level-r").prev(".second-level-l").show();
            $(".second-level-r").next("div").hide();
            $(".search_year").change(function(){
				var yearId = $(this).val();
			    $(this).parent().siblings(".form-group").find("."+yearId).show().siblings().hide();
			    //给Action赋值
			    $(this).parents(".left_search").attr("action",$(this).parent().siblings(".form-group").find("."+yearId).val());
            })
        }
        /*search*/
        if($(window).width()<=767){
          if($(".inputText.paddingLeftNone").siblings(".form-control-1-box").find("select").css("display")=="none"){
          	$(".search-wrap .inputText.paddingLeftNone").css({"width":"100%","margin":"0"});
          }else{
        	  $(".search-wrap .inputText.paddingLeftNone").css({"width":"71%","margin":"0 0 0 2%"});
          }
        }else{
        	if($(".inputText.paddingLeftNone").siblings(".form-control-1-box").find("select").css("display")=="none"){
        		$(".search-wrap .inputText.paddingLeftNone").css({"width":"482px","margin":"0 30px 0 0"});
        	}else{
        		$(".search-wrap .inputText.paddingLeftNone").css({"width":"365px","margin":"0 30px 0 0"});
        	}
        }

    }
	function detectZoom (){
	  var ratio = 0,
		screen = window.screen,
		ua = navigator.userAgent.toLowerCase();
	  
	   if (window.devicePixelRatio !== undefined) {
		  ratio = window.devicePixelRatio;
	  }
	  else if (~ua.indexOf('msie')) {
		if (screen.deviceXDPI && screen.logicalXDPI) {
		  ratio = screen.deviceXDPI / screen.logicalXDPI;
		}
	  }
	  else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
		ratio = window.outerWidth / window.innerWidth;
	  }
		
	   if (ratio){
		ratio = Math.round(ratio * 100);
	  }
		
	   return ratio;
	   
	};
    $(window).load(function () {
        run();
    });
    $(window).resize(function () {
        run();
        if(detectZoom() != 100){
			 run();
		}
    });
    
    var topArr=[];
    for(var i=0;i<$(".phone-htmlContent .navTitle").length;i++){
        topArr.push($(".phone-htmlContent .navTitle").eq(i).offset().top);
    }
    // 手机右下角目录高度
        $(".article-menu-bot").css({"height":$(window).height()-$(".article-menu>h3").height()});
        	$(".article-btn").click(function(){
		        if($(".article-menu").css("z-index")=="-1"){
		            $(".article-menu").addClass("ac1");
		            var wrapper = document.querySelector('.article-menu-bot');
        			/*var scroll = new BScroll(wrapper,{
        				click:true
        			});*/
		        }else{
		            $(".article-menu").removeClass("ac1");
		        }
		    });
        	
    
    // 手机上到全文第一条显示右下角目录
    if($("#htmlContent2>.full-text").length > 0){
        $(window).scroll(function(){
            var htmlT=$("#htmlContent2>.full-text").offset().top;
            if($(window).scrollTop()>=htmlT){
                $(".article-btn").addClass("ac");
            }else{
                $(".article-btn").removeClass("ac");
            }
        })
    }

//    全文中点击标题展开相应标题内容
    $(document).on('click','.main figcaption','.phone-htmlContent .navTitle',function(e){
        var _this = $(this);
        if(_this.hasClass('grayBgColor')){
            _this.removeClass('grayBgColor').parent().removeClass('grayBorder');
            _this.next().hide();
        }else{
            _this.addClass('grayBgColor').parent().addClass('grayBorder');
            _this.next().show();
        }
    });
    $(".open-articleEn").click(function(){
    	if($(this).next(".articleEn").css("display")=="none"){
    		$(this).next(".articleEn").slideDown(200);
    		$(this).find("span").addClass("icon-jian").removeClass("icon-jia");
    	}else{
    		$(this).next(".articleEn").slideUp(200);
    		$(this).find("span").addClass("icon-jia").removeClass("icon-jian");
    	}
    })
// 移动端滑动
    if($(".mescroll").length>0){
        var wrapper = document.querySelector('.mescroll');
        var scroll = new BScroll(wrapper);
    }

})



/*优先发表和当期srcl图片切换*/
$(function(){
	$(".weixin").click(function(){
		shareTools("weixin",$(this));
		if($(this).parent().siblings(".weixinBox").css("display")=="none"){
			$(this).parent().siblings(".weixinBox").show();
		}
	});
	$(".kongjian").click(function(){
		shareTools("qzone",$(this));
	});
	$(".xinlang").click(function(){
		shareTools("sina",$(this));
	});
	
    // 优发表图片第一张图片懒加载
    function scrollImg() {
        var aImg=$("#lan .article-list .curtu .picList");
        var len = aImg.length;
        var n = 0;//存储图片加载到的位置，避免每次都从第一张图片开始遍历
        var seeHeight = document.documentElement.clientHeight;//可见区域高度
        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
        for (var i = n; i < len; i++) {
            var prioTop=$("#lan .article-list").find(".curtu").eq(i).offset().top;
            //console.log(prioTop)
            if (prioTop < seeHeight + scrollTop) {
            	if($("#lan .article-list").find(".curtu").eq(i).find(".picList li:first img").attr("src") == undefined){
	            	if(typeof($("#lan .article-list .curtu .picList li").eq(i).find("a img").attr("srcl"))!="undefined"){
	            		$("#lan .article-list").find(".curtu").eq(i).find(".picList li:first img").attr({"src":$("#lan .article-list").find(".curtu").eq(i).find(".picList li:first a img").attr("srcl")});
	            	}else{
	            		$("#lan .article-list").find(".curtu").eq(i).find(".picList li:first img").attr({"src":$("#lan .article-list").find(".curtu").eq(i).find(".picList li:first a").attr("href")});
	            	}
            	}
                n = i + 1;
            }
        }
    }
    if($(window).width()>768 || (!isNull($('#isShowImg').val()) && $('#isShowImg').val() == '1')){
    	scrollImg();
    }else{
    	$('.curtu').hide();
    }
    $(window).scroll(function () {
    	if($(window).width()>768 || (!isNull($('#isShowImg').val()) && $('#isShowImg').val() == '1')){
    		scrollImg();
    	}
    });
    /*当期或者优先发表图片先不加载,点击后再加载第一张*/
    $(".tab-ul li.current_").click(function(){
    	var index=$(this).index();
    	var articleList=$("#myTabContent .tab-pane").eq(index).find(".article-list");
    	for(var i=0;i<articleList.length;i++){
    		if(articleList.eq(i).find(".picList li:first a img").attr("src")==undefined){
    			articleList.eq(i).find(".picList li:first a img").attr({"src":articleList.eq(i).find(".picList li:first a img").attr("srcl")});
    		}
    	}
    });
    // 如果只有一张图片就不显示左右箭头
    $(".article-list").each(function(){
        if($(this).find(".picList li").length<=1){
            $(this).find(".picPrev,.picNext").hide();
        }
    });

    function pic(){
        if($(window).width()>=1200){
            $(".picList").each(function () {
                var _li=$(this).find("li");
                $(this).css({"width":_li.length*_li.width()});
                $(this).find("li").eq(0).addClass("active");
            });
            $(".picNext").click(function(){
                var index=$(this).siblings(".picList").find("li.active").index();
                var length=$(this).siblings(".picList").find("li").length;
                if(index >= 0 && index < length-1) {
                    ++index;
                    $(this).siblings(".picList").find("li").eq(index).addClass("active").siblings("li").removeClass("active");
                    if(typeof($(this).siblings(".picList").find("li").eq(index).find("a img").attr("srcl"))!="undefined"){
                        var aNhref=$(this).siblings(".picList").find("li").eq(index).find("a img").attr("srcl");
                        $(this).siblings(".picList").find("li").eq(index).find("a img").attr({"src":aNhref});
                    }else{
                        var aNhref=$(this).siblings(".picList").find("li").eq(index).find("a").attr("href");
                        $(this).siblings(".picList").find("li").eq(index).find("a img").attr({"src":aNhref});
                    }
                }else if(index==length-1){
                    var index=0;
                    $(this).siblings(".picList").find("li").eq(index).stop(true,true).addClass("active").siblings("li").removeClass("active");
                }
            });
            $(".picPrev").click(function(){
                var index=$(this).siblings(".picList").find("li.active").index();
                var length=$(this).siblings(".picList").find("li").length;
                if(index >= 0 && index <= length-1) {
                    --index;
                    $(this).siblings(".picList").find("li").eq(index).addClass("active").siblings("li").removeClass("active");
                    if(typeof($(this).siblings(".picList").find("li").eq(index).find("a img").attr("srcl"))!="undefined"){
                        var aNhref=$(this).siblings(".picList").find("li").eq(index).find("a img").attr("srcl");
                        $(this).siblings(".picList").find("li").eq(index).find("a img").attr({"src":aNhref});
                    }else{
                        var aNhref=$(this).siblings(".picList").find("li").eq(index).find("a").attr("href");
                        $(this).siblings(".picList").find("li").eq(index).find("a img").attr({"src":aNhref});
                    }
                }else if(index==0){
                    $(this).siblings(".picList").find("li").eq(length-1).addClass("active").siblings("li").removeClass("active");
                }
            });
        }else{
            $(".picList").css({"width":"100%"});
            $(".article-list").each(function(){
                $(this).find(".curtu-show .picList li").each(function(){
                	$(this).find("a").removeClass("group3 cboxElement");
                    $(this).find("a img").attr({"src":$(this).find("a").attr("href")});
                });
                
            })
            if($(".picList").length>0){
                $('.picList').owlCarousel({
                    items:1,
                    itemsDesktop:[1170,1],
                    itemsDesktopSmall : [992,1],
                    itemsTablet: [768,1],
                    itemsTabletSmall:[450,1],
                    itemsMobile : [360,1],
                    navigation: true,
                    navigationText: ["",""],
                    autoPlay:false,
                    rewindSpeed:300
                });
            }
        }
    }
    $(window).load(function(){
    	if($(window).width()>768 || (!isNull($('#isShowImg').val()) && $('#isShowImg').val() == '1')){
    		pic();
        }
    });
    $(window).resize(function(){
    	if($(window).width()>768 || (!isNull($('#isShowImg').val()) && $('#isShowImg').val() == '1')){
    		pic();
        }
    });


    $(".article-list").each(function(){
        var h=$(this).find(".article-list-title a").css("line-height");
        $(this).find(".article-list-left").css({"height":h});
        $(this).find(".article-list-left").children().addClass("allCenter");
        $(this).find(".article-list-left").children("span").css({"height":h,"line-height":h})
    });
   /////////过刊页选中问题及各种切换
    //新过刊页js(中文)
    var lindex = 0,
        _index = 0,
        tempyearlist = 0,
        tempyearblock = 0,
        columimg = $('.columimg'),
        columlist = $('.columlist'),
        yearlistclick,
        yearblockclick;
    if(!sessionStorage.getItem('index')) {
		sessionStorage['index'] = -1;
	}
    if(!sessionStorage.getItem('method')) {
		sessionStorage['method'] = 0;
	}
    var his = window.history.length;
    $(".arc-listit dd").click(function() {
        _index = $(this).index(".arc-listit dd");
        tempyearlist = $(this).attr("temp");
        yearlistclick = $(".archcon.archcon-new dl dd a:contains('"+tempyearlist+"')").parent("dd");
        sessionStorage['index'] = tempyearlist;
        yearlistclick.addClass("active").siblings().removeClass("active");
        yearlistclick.addClass("active").parents(".tab-ul").siblings(".tab-ul").find("dd").removeClass("active");
        //$(".ever-year,.tab-content.tab-images>div,.tab-content.tab-images>ul").hide();
    	for(var i=0;i<$(".archcon-new .tab-pane").length;i++) {
    		if($(".archcon-new .tab-pane").eq(i).attr("id")== tempyearlist){
    			$(".archcon-new .tab-pane").eq(i).show().siblings().hide();
    		}
    	}
        $(this).addClass("active").siblings().removeClass("active");
        initColumn(columimg, columlist);
        if(lindex == 0) {
            columimg.show().find('.archimg').hide().eq(_index).show();
        } else {
            columlist.show().find('.ar-list').hide().eq(_index).show();
        }
    })
    //图文，列表显示切换
    $(".arcmethod li").click(function() {
    	sessionStorage['method'] = $(this).index();
        $(this).addClass("active").siblings().removeClass("active");
        lindex = $(this).index(".arcmethod li");
        initColumn(columimg, columlist);
        var _index = $(".arc-listit dd.active").index();
        if(lindex == 0) {
        	$(".conarch .archcon").eq(lindex).show().siblings(".conarch .archcon").hide()
            columimg.show().find('.archimg').hide().eq(_index-1).show();
        } else if(lindex == 1) {
        	$(".conarch .archcon").eq(lindex -1).show().siblings(".conarch .archcon").hide()
            columlist.show().find('.ar-list').hide().eq(_index-1).show();
        }else{
        	initColumn(columimg, columlist);
        	$(".conarch .archcon").eq(lindex -1).show().siblings(".conarch .archcon").hide()
        	$(".archcon .tab-ul").each(function(){
                $(this).find("dd").css({"width":Math.floor($(this).width()/$(this).find("dd").length-2),"margin-left":"1px","margin-right":"1px"});
            });
        }
    });
    
    $(".archcon.archcon-new dl dd").click(function(event){
    	var yearA=$(this).find("a").text().trim();
    	if(yearA==""){
			return;
    	}
        
    	var yearTab=$(".archcon-new .tab-pane");
    	yearTab.hide();
    	tempyearblock =$(this).find("a").text().trim();
    	var yearblockclick = $(".arc-listit dd[temp = '"+tempyearblock+"']");
    	yearblockclick.addClass("active").siblings().removeClass("active");
    	yearblockIndex =yearblockclick.index();
    	sessionStorage['index'] = tempyearblock;
        initColumn(columimg, columlist);
            columimg.find('.archimg').hide().eq(yearblockIndex).show();
            columlist.find('.ar-list').hide().eq(yearblockIndex).show();
    	
    	
    	$(this).addClass("active").siblings().removeClass("active");
        $(this).addClass("active").parents(".tab-ul").siblings(".tab-ul").find("dd").removeClass("active");
        //$(".ever-year,.tab-content.tab-images>div,.tab-content.tab-images>ul").hide();
    	for(var i=0;i<yearTab.length;i++) {
    		if(yearTab.eq(i).attr("id")==yearA){
    			yearTab.eq(i).show().siblings().hide();
    		}
    	}
    });
    if((his != 0 || his != 1) && sessionStorage['index'] != -1) {
//    	$(yearlistclick).trigger('click');
//    	$(yearblockclick).trigger('click');
    	var aaa = sessionStorage['index'];
		$(".arc-listit dd[temp='"+aaa+"']").trigger('click');
		$(".archcon.archcon-new dl dd a:contains('"+aaa+"')").parents("dd").trigger('click');
		$(".arcmethod li").eq(sessionStorage['method']).trigger('click');
	}
    
    
    //新过刊页js(英文)
    $(".arc-listeng dd").click(function(){
        var _index = $(this).index(".arc-listeng dd");
        console.log(_index);
        $(this).addClass("active").siblings().removeClass("active");
        $(".arcimgeng .archimg").eq(_index).addClass("activein").siblings(".archimg").removeClass("activein");

    })
    
   
    //文章详情页点击年跳转到过刊页显示对应的年
    if(window.location.href.indexOf("archive_list") > 0){
    	var archiveUrl=window.location.href;
    	archiveUrl=archiveUrl.substring(archiveUrl.length-4);
//    	$(".archcon-new .tab-ul").each(function(){
//    		var dd=$(this).find("dd");
//    		for(var i=0;i<dd.length;i++){
//        		if(dd.eq(i).find("a").text().trim()==archiveUrl){
//        			console.log(dd.eq(i).find("a").text().trim())
//        			console.log(archiveUrl)
//        			dd.eq(i).click();
//        		}
//        	}
//    	})
    	$(".guokan-tab li:nth-child(2)").trigger("click");
		$(".guokan-dlwrap .guokan-dl dd[datas= '"+archiveUrl+"']").trigger("click");
    }
    

    //新闻详情页去掉空P标签
    //var advSetting = {columnName:"新闻详情页广告",size:2,callback:showNewsPageAd};
//    $(".box-body p").each(function(i,e){
//        var newsTextImg=$(e).find("img").length;
//        //alert(newsTextImg);
//        if(newsTextImg == 0){
//            var newsText=$(e).text().trim();
//            //alert(newsText);
//            if(newsText === ""){
//                //alert(2);
//                $(e).remove();
//            }
//        }
//    });
    if($(".toolBox1").length>0){
    	if($(".toolBox1").html().trim()==""){
        	$(".toolBox1").hide();
        }
    };
    // 中文文章详情页切换隐藏弹出的参考文献
    $(".nav-wrapper ul.pull-left li").click(function(){
    	if($(".box-tan").css("display")=="block"){
    		$(".box-tan").hide();
    	}
    })
})


//中文过刊调用函数
function initColumn(img, list) {
    img.hide();
    list.hide();
}

/*显示大图后点击关闭按钮和阴影部分srcl问题*/
function src(){
    var allSrc=[];
    var tanSrc=$("#cboxLoadedContent img");
    var allSlide=$(".picList li");
    var allSlideA=allSlide.find("a");
    for (var i = 0; i < allSlide.length; i++) {
        allSrc.push((allSlideA[i].href));
    }
    if($(".picBox").length>0){
        for (var i = 0; i < allSlide.length; i++){
            for(var j=0;j<tanSrc.length;j++){
                if(tanSrc[j].src==allSlideA[i].href){
                    $(".picList li").eq(i).find("a img").attr({"src":$("#myTabContent .picList li").eq(i).find("a").attr("href")});
                    $(".picList li").eq(i).addClass("active").siblings().removeClass("active");
                }
            }
        }
    }
}

/*留言板************************************************************************************************************************************/
function messageBoard(){
	$(".monitor").show();
	$(".messageBoardWrap").show();
	$(".authNum").val("");
	$(".realName").val("");
	$(".email").val("");
	$(".phone").val("");
	$(".title").val("");
	$(".content").val("");
	$(".authImgMB").attr("src",local_host+"util/AuthExpImageServlet?"+Math.random());
	
}

/**
 * 刷新验证码
 * 
 * */
function refreshexpMB(obj) {
	obj.src = local_host+"util/AuthExpImageServlet?"+Math.random();
}

/**
 * 
 * @return
 */
function subMessageBoard(){
	var data = {
			"authNum":$(".authNum").val(),
			"realName":$(".realName").val(),
			"email":$(".email").val(),
			"phone":$(".phone").val(),
			"title":$(".title").val(),
			"content":$(".content").val()
	}
	var ajaxArg={
			url : local_host +"createMessageBoard",   								//url 路径
			data : data,  															//data 传送数据
			returnFun:outputMessageBoard 												//回调函数
		};
		ajaxPost(ajaxArg);
}

function outputMessageBoard(data){
	if(data.message == 'ok'){
		alert(data.extraData);
		$(".monitor").hide();
		$(".messageBoardWrap").hide();
	}else{
		alert(data.extraData);
		$(".authNum").val("");
		$(".authImgMB").attr("src",local_host+"util/AuthExpImageServlet?"+Math.random());
	}
}
$(window).load(function(){
	$(".notice-window .closex").click(function(){
		$(this).find("a").toggleClass("show");
	})
	
	
	
	//悬浮窗local和session形式关闭
	/*var flySession = "",
	    flyStorage = "",
	    fixedSession = "",
	    fixedStorage = "";*/
	
	//sessionStorage
	if(!sessionStorage.getItem("fixedSession") && !localStorage.getItem("fixedStorage")){
		$(".notice-fixed").show();
	}
	$(".notice-fixed .close-session").click(function(){
		$(".notice-fixed").hide();
		sessionStorage.setItem("fixedSession","flySession");
	})
	
	//localStorage
	$(".notice-fixed .close-local").click(function(){
		$(".notice-fly").hide();
		localStorage.setItem("fixedStorage","fixedStorage");
	})
	
	//满屏飞飘窗调用
	if($("#ad1").length > 0 && !sessionStorage.getItem("flySession") && !localStorage.getItem("flyStorage")){
		var ad1=new AdMove("ad1"); 
		ad1.Run(); 
	}
	//满屏飞飘窗形式关闭
	if(!sessionStorage.getItem("flySession") && !localStorage.getItem("flyStorage")){
		$(".notice-fly").show();
	}
	$(".notice-fly .close-session").click(function(){
		$(".notice-fly").remove();
		sessionStorage.setItem("flySession","flySession");
	})
	
	//localStorage
	$(".notice-fly .close-local").click(function(){
		$(".notice-fly").remove();
		localStorage.setItem("flyStorage","flyStorage");
	})
	
	
//	var url = window.location.href;
//	if(url.indexOf("_preview.htm")>0){
//		$("<script>").attr({src: local_host + "style/dwz/ueditor/ueditor.config.js" , type:"text/javascript", charset:"utf-8"}).appendTo("body");
//		//$("<script>").attr({src: local_host + "style/dwz/ueditor/lang/zh-cn/zh-cn.js" , type:"text/javascript", charset:"utf-8"}).appendTo("body");
//		//$("<script>").attr({src: local_host + "style/dwz/ueditor/lang/en/en.js" , type:"text/javascript", charset:"utf-8"}).appendTo("body");
//		$("<script>").attr({src: local_host + "style/dwz/ueditor/ueditor.all.js" , type:"text/javascript", charset:"utf-8"}).appendTo("body");
//		
//		$("<script>").attr({src: local_host + "style/web/js/public/newsEdit.js", type:"text/javascript", charset:"utf-8"}).appendTo("body");
//		
//		
//	}
})
/*移动端响应式(中、英文共用)*/
$(function(){
	//移动端tab切换
    $(".article-box-content .phone-title").click(function(){
    	//$(".phone-title a").removeClass("nonce");
		$(this).find("a").toggleClass("nonce");
		//$(".article-box-content").find("li").removeClass("current");
		/*$(this).next("li").toggle(200,function(){
			if($("#htmlContent").css("display")=="none"){
				$(".article-btn").removeClass("ac");
	        }else{
	        	$(".article-btn").addClass("ac");
	        }
		});*/
		$(this).next("li").toggle(200);
    })
      
})
function phoneShowTab(){
	if($(window).width()<=1200){
		//$(".article-box-content li:first-child").trigger("click");
    	//var abc = $(".article-box-content li.current").attr("id");
    	//$("#" + abc).prev(".phone-title").trigger("click");
    	$("#htmlContent,#FullText").addClass("phone-htmlContent");
    	//$(".article-box-content .phone-title a").trigger("click");
    	//中文
    	if($("#htmlContent").length > 0){
    		$(".article-box-content .phone-title").eq(0).find("a").addClass("nonce");
    		$("#htmlContent.phone-htmlContent h3.navTitle").each(function(){
        		var _id =$(this).attr("id");
        		$("#htmlContent.phone-htmlContent").find("."+_id).hide();
        	})
    	}
    	//英文
    	if($("#FullText").length > 0){
    		$(".article-box-content .phone-title").eq(0).find("a").trigger("click");
    		$("#FullText.phone-htmlContent h3.navTitle").each(function(){
        		var _id =$(this).attr("id");
        		$("#FullText.phone-htmlContent").find("."+_id).hide();
        	})
    	}
    	$(".article-btn").addClass("ac");
    	
    	//移动端全文部分点击显示与隐藏
        $(".phone-htmlContent h3.navTitle").each(function(){
    		var _id =$(this).attr("id");
    		$(".phone-htmlContent").find("."+_id).hide();
    	})
        $(".phone-htmlContent h3.navTitle").click(function(){
        	var tempId =$(this).attr("id");
        	$(".phone-htmlContent").find("."+tempId).toggle(200);
        })
    }
	if($(window).width()>1200){
		//$(".article-nav li:first-child").trigger("click");
		$("#htmlContent,#FullText").removeClass("phone-htmlContent");
/*		$("#htmlContent.phone-htmlContent h3.navTitle").each(function(){
    		var _id =$(this).attr("id");
    		$("#htmlContent").find("."+_id).show();
    	})*/
    	$(".article-btn").removeClass("ac");
	}
}

/*手机文章详情页右下角除全文外目录*/
function getPhoneNav(){
	 var htmlTop ='',htmlBtm ='',arr = $('.article-box-content .phone-title');
	    for (var i=0;i<arr.length;i++){
	        htmlTop+=arr.eq(i).prop("outerHTML");
	        if($(arr[i]).hasClass("html-text")) break;
	    }
	    for (var i=0;i<arr.length;i++){
	    	if($(arr[i]).hasClass("phone-mark")) continue;
	    	htmlBtm+=arr.eq(i).prop("outerHTML");
	    }
	    $(".iphone-wrapper").before(htmlTop);
	    $(".iphone-wrapper").after(htmlBtm);
	    /*if($(window).width() < 1200){*/
	    	$(".article-menu-bot .phone-title").click(function(){
		    	var _index = $(this).index(".article-menu-bot .phone-title");
		    	//console.log(typeof($(".article-box-content .phone-title").eq(_index)))
		    	var _t = $(".article-box-content .phone-title").eq(_index).offset().top;
		    	 $('html,body').animate({scrollTop:_t-10},300);
		    })
	    /*}*/
	    //$(".phone-tab .html-text").after($(".iphone-wrapper").prop("outerHTML"))
}

/*手机文章详情页右下角全文目录*/
function getFullTextPhone(){
    var html ='',arr = $('.article-box-content .navTitle');
    for (var i=0;i<arr.length;i++){
        html+='<li>'+arr.eq(i).prop("outerHTML")+'</li>';
    }
    $(".iphone-wrapper").append(html);
    /*if($(window).width() < 1200){*/
    $(".iphone-wrapper li").each(function(i){
        	$(this).click(function(){
        		if(!$(".html-text a").hasClass("nonce")){$(".html-text.phone-title").trigger("click")}
                $(this).addClass("ac").siblings().removeClass("ac");
                var _this = $(this),index = _this.index(),_id = _this.find(".navTitle span").attr("id"),
                	tempB = $('.phone-htmlContent #' + _id);
               /* if($('.phone-htmlContent .navTitle').eq(index).parent(".group").css("display")=="none"){
                    $('.phone-htmlContent .navTitle').eq(index).parent(".group").show();
                }*/
                if(_this.find(".navTitle")[0].tagName !="H3"){
                	var _num = _this.find(".navTitle").attr("class").lastIndexOf(' ');
                	var tempC = "." + _this.find(".navTitle").attr("class").substring(_num,_num.length).trim();
                }else{
                	var tempC = "." + _this.find(".navTitle").attr("id");
                	
                }
                if($(tempC).css("display")=="none"){
                	$(tempC).show();
                }
                
                setTimeout(function(){
                	var top = $(tempB).offset().top;
                    $('html,body').animate({scrollTop:top},300);
                },300)
                
            })
    	
    });
   /* }*/
    
}
//移动端目录手滑显示与隐藏
/*$(function () {
	if($('.article-menu').length > 0){
	    var articleMenu = $('.article-menu');
	    var startX,endX;
	    var offset = 50;
	    articleMenu.on('touchstart',function (e) {
	        startX = e.originalEvent.touches[0].clientY;
	    });
	    articleMenu.on('touchmove',function (e) {
	        endX = e.originalEvent.touches[0].clientY;
	    });
	    articleMenu.on('touchend',function (e) {
	        var distance = Math.abs(startX - endX);
	        if (distance > offset){
	        	$(this).addClass("ac1")
	        }else{
	        	$(this).removeClass("ac1")
	        }
	    })
	}
});*/

