var url = location.href;
fileUrl = url.substr(url.lastIndexOf('/')+1, url.length).match(/[0-9a-zA-Z_]+/)[0];
var wapViewportContent = 'width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no';
var otherViewportContent = 'width=1200';
function setRem() {
    if(location.search=='?clientType=PC'){
        var viewport = document.querySelector("meta[name=viewport]");
        viewport.setAttribute('content', 'width=1200');
    }else if(fileUrl.match(/^t\d+_\d+/)!=null){
        var doc = window.document;
        var docEl = doc.documentElement;
        var desinWidth = 1242;
        var baseFont = 28;
        var layoutView = window.screen.width;
        var viewportContent = layoutView < 768 ? wapViewportContent : otherViewportContent;
        var viewport = document.querySelector("meta[name=viewport]");
        viewport.setAttribute('content', viewportContent);
        if(layoutView < 768){
            newBase = 100 * layoutView / desinWidth;
            docEl.style.fontSize = newBase + 'px';
        }
    }
}
setRem();
window.onresize = function(){
    setRem();
}
$(function(){
    var url = location.href;
    $('.menu-list>a').each(function () {
        if($(this).attr('id')){
            var code = $(this).attr('id').replace('a_','/');
            if(url.indexOf(code)>-1){
                $(this).addClass('on').siblings('a').removeClass('on');
            }
        }
     });
})
$(document).ready(function(){
    $("#topscolle").click(function() {
        $('html,body').animate({ 'scrollTop': 0}, 600);
    });
    setInterval(function() {
	$(window).bind('scroll resize', function() {
	    if($(window).scrollTop() <= 300) {
	        $("#topscolle").hide();
	    } else {
	        $("#topscolle").show();
            }
        })
    }, 1000);
var a = $(".xgly-ul-li").length;
    if (a == null || a == 0) {
    $(".xgld").hide();
}
var appendix_1 = $('.nr_li .nr a').html() && $('.nr_li .nr').html();
if(appendix_1 == '' || appendix_1 == undefined){
    $('.nr_li .nr').parent().hide();
}
var appendix_2 = $('.nr_li .read a').html() && $('.nr_li .read').html();
if(appendix_2 == '' || appendix_2 == undefined){
    $('.nr_li .read').parent().hide();
}
        //tabShow($('.nav-list'),$('.nav-con'),'mouseover');
        tabShow($('.xmt_left'),$('.xmt_right'),'mouseover');
        tabShow($('.container-right-one .h33'),$('.xj-ul1'),'mouseover');
        tabShow($('.container-right-one .h44'),$('.fl-ul1'),'mouseover');

        $('.friend-link').hover(    
            function(){
                //$("html,body").stop(true,true).animate({scrollTop:$(".footer-info").offset().top-100},300);

                $(this).addClass("on");
                $(this).children('div').stop(true,true).show();
            },
            function(){
            
                $(this).removeClass("on");
                $(this).children('div').stop(true,true).hide();
            }
        )
        
        //专题页样式变换
        $('.zt-our').hover(function(){
            $(this).addClass("on");
          },function(){$(this).removeClass("on");}
        )
        
        //政府数据年鉴
        $('.timeline_con').hover(function(){
              $(this).parent().addClass("active");
            },function(){$(this).parent().removeClass("active");}
        )
		
		//顶部头部菜单
		var $childMenu = $('#childMenu');
		$('#navMenu').on('mouseenter', 'dl', function(){
				var $this = $(this),
				index = $this.index();
  				$this.addClass('on').siblings().removeClass('on');
  				$childMenu.show().find('.nav-con').animate({top:"20px"},100).hide().eq(index).animate({top:"55px"}).show();
			}).on('mouseleave', function(){
				$(this).find('dl.on').removeClass('on');
  				$childMenu.find('.nav-con').animate({top:"20px"}).hide();
			})
});

    function tabShow(oNav, oCon, sEvent) {
            var oElem = oNav.children();
            oCon.hide().eq(0).show();
            oElem.each(function (index) {
                $(this).on(sEvent, function(){
                    $(this).addClass('on').siblings().removeClass('on');
                    oCon.hide().eq(index).show();
                })
            })
        }
        
//滑动门
function ChangDiv(uid,css,num,totle){ 
    var tabList = document.getElementById(uid);
    for(i=1; i<=totle; i++){
        if (i ==num ){ 
             //$("#"+uid+i).attr("class",css);
            $("#"+uid+i).addClass(css);
             $("#"+uid+"Swich"+i).show();
        }else{
            //$("#"+uid+i).attr("class","");
            $("#"+uid+i).removeClass(css);
            $("#"+uid+"Swich"+i).hide();
        }
    }
}

//字体大中小
function doZoom(size){
    document.getElementById('zoom').style.fontSize=size+'px';
    document.getElementById('zoom').style.lineHeight="165%";
}


$(function(){

    //图片新闻
    $('.ptnews_content li:nth-child(3n)').css('border-right','1px solid #dcdcdc');
    //列表菜单切换
    $('.fwl-menu li').hover(function(){
        $(this).addClass('active').find('.syc-nax').show();
        $(this).siblings().removeClass('active').find('.syc-nax').hide();
    })
    //首页二维码
    $('.right-nav li').hover(function(){
        $(this).find('.show-ewm').animate({'left':'-140px','opacity':'1'}).show();
    },function(){
        $(this).find('.show-ewm').animate({'left':'-50px','opacity':'0'}).hide();
    })
	//移动适配二维码
    $('.right-nav li').hover(function(){
        $(this).find('#mapp').animate({'left':'-140px','opacity':'1'}).show();
    },function(){
        $(this).find('#mapp').animate({'left':'-50px','opacity':'0'}).hide();
    })
    /*
    //湖南概况查看大图 取消 无障碍冲突
    var gkHei=$(window).height();
    //var gkWei=$(window).width();
   // $('.imgsb').css('left',($(window).width()-602)/2+gkHei);
    $('.imgsb-on').css('top',(gkHei-792)/2+$(window).scrollTop());
    $('.jx-click').click(function(){
        $('.imgsb-bg').fadeIn();
        $('.imgsb-on').fadeIn();
    })
     $('.imgsb-bg').click(function(){
        $(this).hide();
        $('.imgsb-on').hide();
    })
	*/
	//通过layer.js 查看大图
	$('.jx-click').click(function(){
		layer.open({
  			type: 1,
  			title: false,
  			closeBtn: 0,
  			area: '600px',
  			skin: 'layui-layer-nobg', //没有背景色
  			shadeClose: true,
  			content: $('#tong')
		});
    })
})
