/** * created by administrator on 2016/10/19. */ //************************垂直导航**************************** // $(function(){ // $(".jh_gl_ml_a1").click(function(){ // $(this).next().slidetoggle("slow"); //a1的下一个元素缓慢显示或者隐藏 // //$(this).parent().find("dl").toggle(); 不要动画效果 // $(this).parent().siblings().find("dl").slideup("slow"); //遍历a1的所有父元素找到dl缓慢向上隐藏 // //$(this).parent().siblings().find("dl").slideup("slow"); 不要动画效果 // }); // }); //************************控制字体**************************** $(function(){ $(".jh_xl_ml_a1").click(function(){ $(".jh_xl_m2 p").css("font-size","24px"); }); $(".jh_xl_ml_a2").click(function(){ $(".jh_xl_m2 p").css("font-size","18px"); }); $(".jh_xl_ml_a3").click(function(){ $(".jh_xl_m2 p").css("font-size","14px"); }); }); //***********************轮播**************************** $(function() { var imglen = $(".jh_fw_n_lb ul").find("li").length;//获取图片数量。 //添加和图片数量相等的li(切换按钮)。 if( imglen > 1){ for(var i=0;i"); } } $(".jh_fw_n_lb ol li").first().addclass("jh_fw_n_act1"); var liwid = $(".jh_fw_n_lb ul li").width(); //获取li的宽度。 var oli = $(".jh_fw_n_lb ol li"); //获取底部圆点,做点击事件用。 var aimg = $(".jh_fw_n_lb ul li img"); //获取所有图片。 var text = $(".jh_fw_n_text"); //标题。 var ailen = aimg.length; //图片数量。 var wrapul=$(".jh_fw_n_lb ul"); //动画区域。 wrapul.width(liwid * ailen); //计算出动画区域的宽度,方便扩展。 var ulwid = wrapul.width(); //动画区域宽度。 var imgalt=aimg.eq(0).attr('alt'); var timeid; var now = 0; var now2 = 0; text.html(imgalt); //初始化标题文字,第一个标题。 //单击圆点切换 oli.click(function() { clearinterval(timeid); if (!wrapul.is(":animated")) { now = $(this).index(); now2 = $(this).index(); imgalt = aimg.eq(now).attr('alt'); text.html(imgalt); $(this).addclass('jh_fw_n_act1').siblings().removeclass('jh_fw_n_act1'); wrapul.animate({ "margin-left": -liwid * now }, 1000); } timeid = setinterval(slider, 3500); }); //单击右侧箭头切换 $(".jh_fw_n_right").click(function slider() { clearinterval(timeid); if (!wrapul.is(":animated")) { if (now == ailen - 1) { aimg.eq(0).css({ "position": "relative", "left": ulwid }); now = 0; } else { now++; } now2++; imgalt = aimg.eq(now).attr('alt'); oli.eq(now).addclass('jh_fw_n_act1').siblings().removeclass('jh_fw_n_act1'); text.html(imgalt); wrapul.animate({ "margin-left": -liwid * now2 }, 1000, function() { if (now == 0) { aimg.eq(0).css("position", "static"); wrapul.css("margin-left", 0); now2 = 0; } }) } timeid = setinterval(slider, 3500); }); //单击左侧箭头切换 $(".jh_fw_n_left").click(function() { clearinterval(timeid); if (!wrapul.is(":animated")) { if (now == 0) { aimg.eq(ailen - 1).css({ "position": "relative", "left": -liwid * ailen }); now = ailen - 1; } else { now--; }; imgalt = aimg.eq(now).attr('alt'); oli.eq(now).addclass('jh_fw_n_act1').siblings().removeclass('jh_fw_n_act1'); text.html(imgalt); now2--; wrapul.animate({ "margin-left": liwid * (-now2) }, 1000, function() { if (now == ailen - 1) { aimg.eq(ailen - 1).css("position", "static"); wrapul.css("margin-left", -liwid * (ailen - 1)); now2 = ailen - 1; } }) } timeid = setinterval(slider, 3500); }); //自动切换 function slider() { if (now == ailen - 1) { aimg.eq(0).css({ "position": "relative", "left": ulwid }); now = 0; } else { now++; } now2++; imgalt = aimg.eq(now).attr('alt'); oli.eq(now).addclass('jh_fw_n_act1').siblings().removeclass('jh_fw_n_act1'); text.html(imgalt); wrapul.animate({ "margin-left": -liwid * now2 }, 1000,function() { if (now == 0) { aimg.eq(0).css("position", "static"); wrapul.css("margin-left", 0); now2 = 0; } }) } timeid = setinterval(slider, 3500); wrapul.hover(function() { clearinterval(timeid); }, function() { timeid = setinterval(slider, 3500); }); }); //***********************切换**************************** $(function(){ //定义tab切换函数 function tab_change(tabname,current){ tabname.find("div").mouseover(function(){ var _this = $(this); _this.addclass(current).siblings().removeclass(current); var _index = _this.index(); _this.parent().nextall(".jh_toggle").eq(_index).show().siblings(".jh_toggle").hide(); }); } //调用tab切换函数 tab_change($(".jh_hd_ml_c3"),"jh_hd_ml_act2"); }); //***********************下拉菜单**************************** // $(function(){ // $(".jh_n_ul1 li").mouseover(function(){ // $(this).find(".jh_n_menu").show(); // $(this).find("a").css("background-color","#8e0608"); // }); // $(".jh_n_ul1 li").mouseout(function(){ // $(this).find(".jh_n_menu").hide(); // $(this).find("a").css("background-color","#ef3037"); // }); // }); //***********************弹出框**************************** $(function(){ $(".jh_sr_a3").click(function(){ $(".jh_sr_tan").show(); }); $(".jh_sr_a4").click(function(){ $(".jh_sr_tan").hide(); }); }); //***********************轮播**************************** $(function() { var imglen = $(".jh_ns_lb ul").find("li").length;//获取图片数量。 //添加和图片数量相等的li(切换按钮)。 if( imglen > 1){ for(var i=0;i"); } } $(".jh_ns_lb ol li").first().addclass("jh_ns_act1"); var liwid = $(".jh_ns_lb ul li").width(); //获取li的宽度。 var oli = $(".jh_ns_lb ol li"); //获取底部圆点,做点击事件用。 var aimg = $(".jh_ns_lb ul li img"); //获取所有图片。 var text = $(".jh_ns_text"); //标题。 var ailen = aimg.length; //图片数量。 var wrapul=$(".jh_ns_lb ul"); //动画区域。 wrapul.width(liwid * ailen); //计算出动画区域的宽度,方便扩展。 var ulwid = wrapul.width(); //动画区域宽度。 var imgalt=aimg.eq(0).attr('alt'); var timeid; var now = 0; var now2 = 0; text.html(imgalt); //初始化标题文字,第一个标题。 //单击圆点切换 oli.click(function() { clearinterval(timeid); if (!wrapul.is(":animated")) { now = $(this).index(); now2 = $(this).index(); imgalt = aimg.eq(now).attr('alt'); text.html(imgalt); $(this).addclass('jh_ns_act1').siblings().removeclass('jh_ns_act1'); wrapul.animate({ "margin-left": -liwid * now }, 1000); } timeid = setinterval(slider, 3500); }); //单击右侧箭头切换 $(".jh_ns_right").click(function slider() { clearinterval(timeid); if (!wrapul.is(":animated")) { if (now == ailen - 1) { aimg.eq(0).css({ "position": "relative", "left": ulwid }); now = 0; } else { now++; } now2++; imgalt = aimg.eq(now).attr('alt'); oli.eq(now).addclass('jh_ns_act1').siblings().removeclass('jh_ns_act1'); text.html(imgalt); wrapul.animate({ "margin-left": -liwid * now2 }, 1000, function() { if (now == 0) { aimg.eq(0).css("position", "static"); wrapul.css("margin-left", 0); now2 = 0; } }) } timeid = setinterval(slider, 3500); }); //单击左侧箭头切换 $(".jh_ns_left").click(function() { clearinterval(timeid); if (!wrapul.is(":animated")) { if (now == 0) { aimg.eq(ailen - 1).css({ "position": "relative", "left": -liwid * ailen }); now = ailen - 1; } else { now--; }; imgalt = aimg.eq(now).attr('alt'); oli.eq(now).addclass('jh_ns_act1').siblings().removeclass('jh_ns_act1'); text.html(imgalt); now2--; wrapul.animate({ "margin-left": liwid * (-now2) }, 1000, function() { if (now == ailen - 1) { aimg.eq(ailen - 1).css("position", "static"); wrapul.css("margin-left", -liwid * (ailen - 1)); now2 = ailen - 1; } }) } timeid = setinterval(slider, 3500); }); //自动切换 function slider() { if (now == ailen - 1) { aimg.eq(0).css({ "position": "relative", "left": ulwid }); now = 0; } else { now++; } now2++; imgalt = aimg.eq(now).attr('alt'); oli.eq(now).addclass('jh_ns_act1').siblings().removeclass('jh_ns_act1'); text.html(imgalt); wrapul.animate({ "margin-left": -liwid * now2 }, 1000,function() { if (now == 0) { aimg.eq(0).css("position", "static"); wrapul.css("margin-left", 0); now2 = 0; } }) } timeid = setinterval(slider, 3500); wrapul.hover(function() { clearinterval(timeid); }, function() { timeid = setinterval(slider, 3500); }); }); //***********************轮播**************************** $(function() { var imglen = $(".jh_xl_lb ul").find("li").length;//获取图片数量。 //添加和图片数量相等的li(切换按钮)。 if( imglen > 1){ for(var i=0;i"); } } $(".jh_xl_lb ol li").first().addclass("jh_ns_act1"); var liwid = $(".jh_xl_lb ul li").width(); //获取li的宽度。 var oli = $(".jh_xl_lb ol li"); //获取底部圆点,做点击事件用。 var aimg = $(".jh_xl_lb ul li img"); //获取所有图片。 var text = $(".jh_ns_text"); //标题。 var ailen = aimg.length; //图片数量。 var wrapul=$(".jh_xl_lb ul"); //动画区域。 wrapul.width(liwid * ailen); //计算出动画区域的宽度,方便扩展。 var ulwid = wrapul.width(); //动画区域宽度。 var imgalt=aimg.eq(0).attr('alt'); var timeid; var now = 0; var now2 = 0; text.html(imgalt); //初始化标题文字,第一个标题。 //单击圆点切换 oli.click(function() { clearinterval(timeid); if (!wrapul.is(":animated")) { now = $(this).index(); now2 = $(this).index(); imgalt = aimg.eq(now).attr('alt'); text.html(imgalt); $(this).addclass('jh_ns_act1').siblings().removeclass('jh_ns_act1'); wrapul.animate({ "margin-left": -liwid * now }, 1000); } timeid = setinterval(slider, 3500); }); //自动切换 function slider() { if (now == ailen - 1) { aimg.eq(0).css({ "position": "relative", "left": ulwid }); now = 0; } else { now++; } now2++; imgalt = aimg.eq(now).attr('alt'); oli.eq(now).addclass('jh_ns_act1').siblings().removeclass('jh_ns_act1'); text.html(imgalt); wrapul.animate({ "margin-left": -liwid * now2 }, 1000,function() { if (now == 0) { aimg.eq(0).css("position", "static"); wrapul.css("margin-left", 0); now2 = 0; } }) } timeid = setinterval(slider, 3500); wrapul.hover(function() { clearinterval(timeid); }, function() { timeid = setinterval(slider, 3500); }); }); //***********************内容切换**************************** $(function(){ //定义tab切换函数 function tab_change(tabname,current){ tabname.find("a").mouseover(function(){ var _this = $(this); _this.addclass(current).siblings().removeclass(current); var _index = _this.index(); _this.parent().nextall(".jh_toggle").eq(_index).show().siblings(".jh_toggle").hide(); }); } //调用tab切换函数 tab_change($(".jh_ns_c1"),"jh_ns_act2"); tab_change($(".jh_pl_c1"),"jh_pl_act1"); tab_change($(".jh_pl_c3"),"jh_pl_act1"); tab_change($(".jh_pl_c4"),"jh_pl_act1"); tab_change($(".jh_pr_t1"),"jh_pr_act1"); tab_change($(".jh_i_c1"),"jh_i_act1"); tab_change($(".jh_tr_c2"),"jh_tr_act1"); tab_change($(".jh_w_m1"),"jh_w_act1"); // tab_change($(".jh_sr_m1"),"jh_sr_act1"); tab_change($(".jh_fw_l_m1"),"jh_fw_l_act1"); tab_change($(".jh_gk_pl_c2"),"jh_gk_pl_act1"); }); $(function(){ //定义tab切换函数 function tab_change(tabname,column,current){ tabname.find("a").mouseover(function(){ var _this = $(this); _this.addclass(current).siblings().removeclass(current); var _index = _this.index(); _this.parent().parent().find(column).nextall(".jh_toggle").eq(_index).show().siblings(".jh_toggle").hide(); }); } //调用tab切换函数 tab_change($(".jh_pl_c4"),".jh_pl_t9","jh_pl_act2"); }); $(function(){ //定义tab切换函数 function tab_change(tabname,current){ tabname.find("a").mouseover(function(){ var _this = $(this); _this.addclass(current).siblings().removeclass(current); var _index = _this.index(); _this.parent().parent().nextall(".jh_toggle").eq(_index).show().siblings(".jh_toggle").hide(); }); } //调用tab切换函数 tab_change($(".jh_i_t1"),"jh_i_act2"); tab_change($(".jh_c_t1"),"jh_c_act1"); }); //热点服务 $(function(){ $(".jh_sl_t3").find("a").click(function(){ var _this = $(this); _this.addclass("jh_sl_act1").siblings().removeclass("jh_sl_act1"); var _index = _this.index(); _this.parent().parent().nextall(".jh_sl_c5").eq(_index).show().siblings(".jh_toggle").hide(); }); var _index = 0; function chan() { _index == 2 ? _index=0:_index++; $(".jh_sl_t3 a").eq(_index).addclass("jh_sl_act1").siblings().removeclass("jh_sl_act1"); $(".jh_sl_cr .jh_sl_c5").eq(_index).show().siblings(".jh_sl_c5").hide(); } timeid = setinterval(chan, 5000); $(".jh_sl_cr").hover(function() { clearinterval(timeid); }, function() { timeid = setinterval(chan, 5000); }); }); //根据文本字数多少改变字号大小 $(function(){ if($('.jh_gl_ml_m1 a').length>0){ var text=$('.jh_gl_ml_m1 a').text(); var wid=$('.jh_gl_ml_m1 a').height(); var height=0; var font =28; function change_font(){ $('.jh_gl_ml_m1 a').html(text).css('font-size', font+'px'); height = $('.jh_gl_ml_m1 a').height(); if(height>30){ font--; change_font(); } } change_font(); } }); //网站纠错 function jiucuo(url){ var uri=' add.html?groupid=1292&appid=95&url='+url; $('#jiucuo').attr('href',uri); } //机器人 function encodeutf8(s1) { var s = escape(s1); var sa = s.split("%"); var retv =""; if(sa[0] != "") { retv = sa[0]; } for(var i = 1; i < sa.length; i ++) { if(sa[i].substring(0,1) == "u") { retv += hex2utf8(str2hex(sa[i].substring(1,5))); } else retv += "%" + sa[i]; } return retv; } function str2hex(s) { var c = ""; var n; var ss = "0123456789abcdef"; var digs = ""; for(var i = 0; i < s.length; i ++) { c = s.charat(i); n = ss.indexof(c); digs += dec2dig(eval(n)); } //return value; return digs; } function dec2dig(n1) { var s = ""; var n2 = 0; for(var i = 0; i < 4; i++) { n2 = math.pow(2,3 - i); if(n1 >= n2) { s += "1"; n1 = n1 - n2; } else s += "0"; } return s; } function dig2dec(s) { var retv = 0; if(s.length == 4) { for(var i = 0; i < 4; i ++) { retv += eval(s.charat(i)) * math.pow(2, 3 - i); } return retv; } return -1; } function hex2utf8(s) { var rets = ""; var temps = ""; var ss = ""; if(s.length == 16) { temps = "1110" + s.substring(0, 4); temps += "10" + s.substring(4, 10); temps += "10" + s.substring(10,16); var sss = "0123456789abcdef"; for(var i = 0; i < 3; i ++) { rets += "%"; ss = temps.substring(i * 8, (eval(i)+1)*8); rets += sss.charat(dig2dec(ss.substring(0,4))); rets += sss.charat(dig2dec(ss.substring(4,8))); } return rets; } return ""; } function opensearch() { var t=document.getelementbyid("searchvalue").value; var t1= encodeutf8(t); window.open("http://ss.jinhua.gov.cn/index.html?q="+t1); return false; } function contentchange() { if (document.getelementbyid("searchvalue").value=='') { document.getelementbyid("jqrcontent").style.display="none"; } else { document.getelementbyid("jqrcontent").style.display="block"; var num=document.getelementbyid("searchvalue").value; var url = "http://ss.jinhua.gov.cn/jquerysg?q="+num+"&callback=callbackcontent"; var script = document.createelement('script'); script.setattribute('src', url); document.getelementsbytagname('head')[0].appendchild(script); } } function callbackcontent(content) { var html="
    "; for(var i=0;i/g,""); stringobj=stringobj.replace(//g,""); html+=""+stringobj+""; } html+='
'; document.getelementbyid('jqrcontent').innerhtml = html; } function changetocallbackcontent(number) { var obj_lis = document.getelementbyid("test").getelementsbytagname("li"); for(i=0;i/g,""); document.getelementbyid('searchvalue').value = stringobj; document.getelementbyid("jqrcontent").style.display="none"; var oinput = document.getelementbyid("searchvalue"); oinput.focus(); } } } function contentout() { if(document.activeelement.id == "jqrcontent"){ return false; } else { settimeout("document.getelementbyid('jqrcontent').style.display='none';",1000) } }