
function doZoom(size){
        var zoom = document.all ? document.all['zoom'] : document.getElementById('zoom');
        zoom.style.fontSize = size + 'px';
    }
//设为首页
function SetHome(url){
    if (document.all) {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage(url);
    }else{
        alert("您好,您的浏览器不支持自动设置页面为首页功能,请您手动在浏览器里设置该页面为首页!");
    }
}

//加入收藏
function AddFavorite(sURL, sTitle) {
    sURL = encodeURI(sURL);
    try{
        window.external.addFavorite(sURL, sTitle);
    }catch(e) {
        try{
            window.sidebar.addPanel(sTitle, sURL, "");
        }catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加,或手动在浏览器里进行设置.");
        }
    }
}

//选项卡
$(function(){
    $(".m-gray ul li").not(".u-one").mouseover(function(){
           $(this).addClass("u-active").removeClass("u-gray").siblings().removeClass("u-active");
           $(this).siblings().not(".u-one").addClass("u-gray");
    }); 

    $(".m-box3txt ul li:eq(0)").css("font-weight","blod");
    /* $('.tit-switch').children().children("li").not(".u-zdpublic").mouseover(function(){//导航切换
        $(this).addClass('u-active').siblings().removeClass('u-active');
        if($(this).parents().hasClass("m-zcjdswitch")){
            $(this).parents().siblings(".list-switch").hide().eq($(this).index()).show();
        }else if($(this).parent().parent().siblings().hasClass("switchbox")){
            $(this).parent().parent().siblings(".switchbox").find(".list-switch").hide().eq($(this).index()).show();
        }else{
            $(this).parent().parent().siblings(".list-switch").hide().eq($(this).index()).show();
        }
        
    }); */
	$('.tit-switch').children().children("li").not(".u-zdpublic").mouseover(function(){
    $(this).addClass('u-active').siblings().removeClass('u-active');
    if($(this).parents().hasClass("m-zcjdswitch")){
        $(this).parents().siblings(".list-switch").hide().eq($(this).index()).show();
    }
    else if($(this).parent().parent().siblings().hasClass("switchbox")){
        $(this).parent().parent().siblings(".switchbox").find(".list-switch").hide().eq($(this).index()).show();
        //$(this).parent().parent().siblings(".switchbox").animate({height:"121px",padding:"17px 24px 25px;","overflow-y":"auto"},200)
    }
    else{
        $(this).parent().parent().siblings(".list-switch").hide().eq($(this).index()).show();
    }
});
//$(".m-opennesshomebox5").hover(
//function(){$(".m-opennesshomebox5").animate({"height":"200px"},200);},
//function(){$(".m-opennesshomebox5").animate({"height":"56px"},200);});
var state = false; 
$(".switch1").click(function () { 
    if (state) { 
        $(this).removeClass("close"); 
        $(".m-opennesshomebox5").animate({ height: "57px" }, 200); 
        state = false; 
    } 
    else { 
        $(this).addClass("close"); 
        $(".m-opennesshomebox5").animate({ height: "200px" }, 200); 
        state = true; 
    } });

$(".sub-nav").hover(
function(){
	$(".sub-nav").stop().animate({"height":"110px"},200);
},
function(){
	$(".sub-nav").stop().animate({"height":"61px"},200);
});
    /***头部部门**/
    $(".g-department").click(function(){
        $(".m-drop").slideToggle();
    });
    //友情链接
    $(function(){
      $(".u-links dl").each(function(){
        var s=$(this);
        var z=parseInt(s.css("z-index"));
        var dt=s.children("dt");
        var dd=s.children("dd");
        var _show=function(){dd.slideDown(200);s.css("z-index",z+1);};
        var _hide=function(){dd.slideUp(200);s.css("z-index",z);};
        dt.click(function(){dd.is(":hidden")?_show():_hide();});
        dd.find("a").click(function(){_hide();});
        $("body").click(function(i){ !$(i.target).parents(".u-links dl").first().is(s) ? _hide():"";});
      });
    });

    $(".m-droplist ul li").click(function () {
        $(".u-dropseled").text($(this).text());
    });
    $(".m-droplist1 ul li").click(function () {
        $(".u-dropseled1").text($(this).text());
    });
    $(".m-droplist2 ul li").click(function () {
        $(".u-dropseled2").text($(this).text());
    });
     //置顶
    $(".u-gotop,.u-gotp,.m-top img").click(function(){
        $("html,body").animate({scrollTop:0},1000);
    });
    //右侧栏hover
   $(".u-sp01 a,.u-sp02 a,.u-sp04 a").hover(function(){
    $(this).children("img").stop().animate({height: "148px",width: "106px",left: "-106px"});
    },function(){
        $(this).children("img").stop().animate({height: "0",width: "0",left: "0"});
    });
    $('.u-sp05').hover(function(){
        $(this).children('div').show(500);
    },function(){
        $(this).children("div").hide(500);
    });
    //抖动
    // $("抖动元素").shake(次数, 距离, 持续时间);
    $(".m-yqihy p").mouseover(function(){
          $(this).find("i").shake(2, 10, 400);
    });
    //景区地图站点显示
    $(".m-pictourleft .red-map span").mouseover(function(){
        $(this).siblings("div").show();
        $(this).parent().siblings(".flag").find("div").hide();
    });
    });
    $(function(){
       // $(".is-main").css({"top":$(".is-header").height()});
        $(".m-switchdepart").click(function(){
            $(".header-dropdown,.fog").fadeIn();
            $(".header-dropdown").animate({scrollTop:0},1000);
            $("html").css({"height":"100%","overflow":"hidden"});
            if($(window).width()<769){
                $(".header-dropdown").css({"height":"400px","overflow-y":"auto"});
            }else{
                $(".header-dropdown").css({"min-height":"400px","overflow-y":"visible","height":"auto"});
            }  
        });
        
        $(".header-dropdown").css({
        "left":($(window).width()-($(".header-dropdown").width()+40))/2,
        "top":0
        });
    });
    $(window).resize(function(){
       //$(".is-main").css({"top":$(".is-header").height()});
       $(".header-dropdown").css({
        "left":($(window).width()-($(".header-dropdown").width()+40))/2,
        "top":0
      });
       if($(window).width()<769){
            $(".header-dropdown").css({"height":"400px","overflow-y":"auto"});
        }else{
            $(".header-dropdown").css({"min-height":"400px","overflow-y":"visible","height":"auto"});
        }  
    });
jQuery.fn.shake = function (intShakes /*Amount of shakes*/, intDistance /*Shake distance*/, intDuration /*Time duration*/) {
     this.each(function () {
         var jqNode = $(this);
        jqNode.css({ position: 'relative' });
         for (var x = 1; x <= intShakes; x++) {
             jqNode.animate({ left: (intDistance * -1) }, (((intDuration / intShakes) / 4)))
             .animate({ left: intDistance }, ((intDuration / intShakes) / 2))
           .animate({ left: 0 }, (((intDuration / intShakes) / 4)));
         }
     });
          return this;
 }

 $(function(){
    $('.sub-nav-t li').not($(".u-one")).hover(function(){
        $(this).addClass('u-active').siblings().removeClass();
		
        $('.sub-nav-b .ztree1').hide().eq($(this).index()).show();
    });
});

$(".toggle>span").click(function(){
		$(this).next().show().end().parent().siblings('.toggle').find('.m-box1treebox').hide();

	}) 
	
	function hideAd3(){
	                document.getElementById("floatAdy").style.display="none";
            }


//右侧悬浮
$(function () {
        var dialogBox = function () {
            var zxx = $(".znzs");
            var dialog = zxx.find('.dialogBox');
            zxx.mouseenter(function (event) {
                dialog.fadeIn(200);
            }).mouseleave(function (event) {
                dialog.fadeOut(200);
            });
            ;
        }
        dialogBox();
		$('.home_web').click(function(){
			$('.home_web').remove();
		})
        $('.slide .icon li').mouseenter(function () {
            $('.slide .info').addClass('hover');
            $('.slide .info li').hide();
            $('.slide .info li.' + $(this).attr('class')).show();
            $('.slide .icon li').removeClass('active');
            $(this).addClass('active');
        });
        $('.slide').mouseleave(function () {
            $('.slide .info').removeClass('hover');
            $('.slide .icon li').removeClass('active');
        });

        //返回顶部代码
        $(window).on('scroll', function () {
            var st = $(document).scrollTop();
            if (st > 0) {
                if ($('#main-container').length != 0) {
                    var w = $(window).width(), mw = $('#main-container').width();
                    if ((w - mw) / 2 > 70)
                        $('#go-top').css({'left': (w - mw) / 2 + mw + 20});
                    else {
                        $('#go-top').css({'left': 'auto'});
                    }
                }
                $('#go-top').fadeIn(function () {
                    $(this).removeClass('dn');
                });
            } else {
                $('#go-top').fadeOut(function () {
                    $(this).addClass('dn');
                });
            }
        });

        $('#go-top .go').on('click', function () {
            $('html,body').animate({'scrollTop': 0}, 500);
        });

        // 导航条hover
        var navLis = $("#navbar");

        function changeLis(nav, cls) {
            if (!navLis) {
                return
            }
            var activeLi,
                lis = nav.find('li');
            $.each(lis, function (i, v) {
                $(v).hover(function () {
                    activeLi = nav.find("." + cls);
                    if ($(this).hasClass(cls)) {
                        return
                    }
                    $(this).addClass(cls).siblings().removeClass(cls);
                }, function () {
                    if (!activeLi) {
                        return
                    }
                    $(this).removeClass(cls);
                    activeLi.addClass(cls)
                })
            })
        }

        $(".check-oa").off().on('click', function (e) {
            var $this = $(this);
            e.preventDefault();
            var tips = Ls.tipsLoading("正在打开OA，请稍后。", {times: 10});
            Ls.ping({
                url: 'http://10.235.10.121/masoa',
                afterPing: function (t, res) {
                    //返回时间
                    if (t >= 4000) {
                        Ls.tipsErr("OA办公系统只允许电子政务网用户登录,您当前不在电子政务网", {times: 5});
                    } else {
                        tips.hide();
                        $("#masoa").attr({target: "_blank", href: 'http://10.235.10.121/masoa'}).submit();
                        //location.href = 'http://10.235.10.121/masoa';
                        return true;
                    }

                }
            });
            return false;
        })

        //changeLis(navLis, 'on');
    });

//非政府网站跳转提示
// function getHost(url) {
//     var host = "";
//     if (typeof url == "undefined" || null == url) url = window.location.host;
//     var regex = /^\/[\w\/]*/;
//     var match = url.match(regex);
//     if (typeof match != "undefined" && null != match) host = window.location.host;
//     return host;
// };
// $(function(){
//     var domain = ["gov.cn","223.243.129.195"],ignore = window.location.hostname;
//     $('[href]').click(function(){
//         var o = $(this);
//         var url = o.attr('href'),host = getHost(url);
//         if(url == undefined || url == '' ){
//             return false;
//         }
//         if ((host.indexOf(domain) == -1 && host.indexOf(ignore) == -1 && url.indexOf(domain) == -1 && url.indexOf(ignore) == -1 && url.indexOf("javascript") && url.indexOf('#') == -1 && url != "#")||$(this).attr("data-outer") == 1 ||$(this).find("img").attr("data-bd-imgshare-binded") == 1){
//             $(this).attr({'target':'_self','href':'javascript:;'});
//             var w = '480px';
//             var h = 'auto';
//             if(window.screen.width < 768){
//                 w = '90%';
//                 h = 'auto';
//             }
//             var cf = layer.confirm('<div style="margin-top:15px; font-size:16px;">您访问的链接即将离开“马鞍山市人民政府网站”，将访问外部链接地址为' + url + '，是否继续？</div>', {
//                 btn:[ '继续访问', '放弃' ],
//                 title: false,
//                 shade: 0.7,
//                 area: [w, h],
//                 cancel: function(index){ o.attr('href',url); }
//             }, function() {
//                 window.open(url);
//                 o.attr('href',url);
//                 layer.close(cf);
//             }, function() {
//                 o.attr('href',url);
//             });
//         }
//     });
// });

	//非政府网站跳转提示
    function getHost(url) {
        var host = "";
        if (typeof url == "undefined" || null == url) url = window.location.host;
        var regex = /^\/[\w\/]*/;
        var match = url.match(regex);
        if (typeof match != "undefined" && null != match) host = window.location.host;
        return host;
    };
    $(function(){
        //var domain = 'xuancheng.gov.cn';
        var ignore = window.location.hostname;
        var domainarr = ["gov.cn","223.243.129.195"];
        $("a").click(function(){
            var o = $(this);
            var url = o.attr('href'),host = getHost(url);
            if(url == undefined || url == '' ){
                return;
            }
            var checkLinkCount = 1;
            $.each(domainarr, function (i, domain) {
                if (host.indexOf(domain) == -1 && host.indexOf(ignore) == -1 && url.indexOf(domain) == -1 && url.indexOf(ignore) == -1 && url.indexOf("javascript") && url.indexOf('#') == -1 && url != "#"){
                    checkLinkCount = checkLinkCount + 1;
                }
            });
            if(checkLinkCount > domainarr.length){
                $(this).attr('target','_self');
                $(this).attr('href');
                var w = '480px';
                var h = '170px';
                var siteName = $("meta[name=SiteName]").attr('content');
                if (!siteName) {
                    siteName = '马鞍山市人民政府';
                }
                if(window.screen.width < 768) { w = '90%'; h = '170px';}
                var cf = layer.confirm('<div style="margin-top:15px; font-size:16px;">您访问的链接即将离开“马鞍山市人民政府网站”，将访问外部链接地址为' + url + '，是否继续？</div>', {
                    btn:[ '继续访问', '放弃' ],
                    title: false,
                    shade: 0.7,
                    area: [w, h],
                    cancel: function(index){ o.attr('href',url); }
                }, function() {
                    window.open(url);
                    o.attr('href',url);
                    layer.close(cf);
                }, function() {
                    o.attr('href',url);
                });
            }
        });
    });


