$(function() { index(); tel400(); searcher(); banner(); nav(); tools(); checkform(); toolbar2(); imsg(); $(".nav .subnav").each(function() { if(!$(this).find("a").length){ $(this).remove(); } }); // 主导航 - 上拉 $(".nav > ul > li").hover(function(){ $(this).children(".subnav").stop(true).slidedown(200); },function(){ $(this).children(".subnav").stop(true).slideup(200); }); }); function imsg() { $("#imsg .item .txt").each(function() { var txt=$(this).val(); $(this).focus(function() { if ($(this).val() == "只能是纯数字" || $(this).val()=="姓名"|| $(this).val()=="手机" || $(this).val() == "不能为空!" || $(this).val() == "汉字或者英文" || $(this).val() == "邮箱格式不正确" ) { $(this).val("").removeclass("red"); } }).blur(function() { if ($(this).val() == ""){ $(this).val(txt); } }); }); $("#imsg textarea").focus(function(){ if ($(this).val() == "问题" ) { $(this).text(""); } }).blur(function() { if ($(this).val() == ""){ $(this).val("问题"); } });; $("#imsg #sub").click(function() { var bool = true; $("#imsg .required").each(function() { var a, b; if ($(this).find("input").length) { a = $(this).find("input").val().replace(/\s+/gm, ' '); b = $(this).find("input").attr("model"); } if (a == "" || a == " "|| a=="您的姓名" || a=="姓名" || a=="手机" || a=="您的联系方式" || a=="您的邮箱" || a=="不能为空!" ) { $(this).find("input").val("不能为空!").addclass("red"); bool = false; } else { // 验证格式 switch (b){ case "name": // 验证姓名: 汉字或者英文 if(!a.match(/^[a-za-z]+$/) && !a.match(/^[\u4e00-\u9fa5]{0,}$/)){ $(this).find("input").val("汉字或者英文").addclass("red"); bool = false; } break; case "phone": // 验证手机: 纯数字没有限制数量 if(!a.match(/^[0-9]*$/)){ $(this).find("input").val("只能是纯数字").addclass("red"); bool = false; } break; case "email": // 验证邮箱: a@b.com if(!a.match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/)){ $(this).find("input").val("邮箱格式不正确").addclass("red"); bool = false; } break; } } }); // 验证完成。决定是否跳转 return bool; }); $("#imsg #ctian").click(function(){ $("#imsg .item input").val(""); $("#imsg textarea").text(""); return false; }); } function toolbar2(){ $("#toolbar2 ul li").hover(function(){ $(this).find(".sidebox").stop().animate({"width":"135px"},200).css({"opacity":"1","filter":"alpha(opacity=100)","background":"#43934e"}); $(this).find(".sidebox i").attr({"class":$(this).find(".sidebox i").attr("class")+"_s"}); },function(){ $(this).find(".sidebox").stop().animate({"width":"62px"},200).css({"opacity":"1","filter":"alpha(opacity=100)","background":"#43934e"}); $(this).find(".sidebox i").stop().attr({"class":$(this).find(".sidebox i").attr("name")}); }); $("#toolbar2 ul li i.top").hover(function(){ $(this).addclass("hover"); },function(){ $(this).removeclass("hover"); }); $('#toolbar2 li .js_ht').mouseover(function(){ $(this).siblings(".ht").stop().animate({"left":"-240px","opacity":"1"}, 500).show(); $(this).closest("li").css("background","#43934e"); }) $('#toolbar2 li .js_ht').mouseout(function(){ $(this).siblings(".ht").stop().animate({"left":"-300px","opacity":"0"}, 500).hide(); $(this).closest("li").css("background","#43934e"); }) // var top=($(window).height()-$("#toolbar2").height())/2+$(window).scrolltop()+"px"; // $("#toolbar2").css({'top':top}); $("#toolbar2 li.first").hide(); window.onscroll = function(){ if($(document).scrolltop() > 100){ $("#toolbar2 li.first").show(); }else{ $("#toolbar2 li.first").hide(); } } $("#toolbar2 li.first").click(function(){ $("#toolbar2").animate({'top':top},600); $('html,body').animate({'scrolltop':0},600); $("#toolbar2 li.first").hide(); }) $(window).scroll(function(){ var scrolltop = $(document).scrolltop(); $("#toolbar2").stop().animate({"top":(scrolltop+320)}, 550); }); } function index(){ var murl=$("#inews").find(".itit2 h3").eq(0).attr("data-url"); $("#inews").find(".itit2 .more").attr("href",murl); $("#inews").find(".itit2 h3").mouseenter(function() { var index = $(this).index() - 1; $(this).addclass("cur").siblings("h3").removeclass("cur"); $(".inewscon").eq(index).show().siblings(".inewscon").hide(); var url = $(this).attr("data-url"); $(this).parent().find("a").attr("href", url); }); $("#floor_7_main").find(".itit2 h3").mouseenter(function() { var index = $(this).index(); $(this).addclass("cur").siblings("h3").removeclass("cur"); $(".indeximgtogcon").eq(index).show().siblings(".indeximgtogcon").hide(); var url = $(this).attr("data-url"); $(this).parent().find("a").attr("href", url); }); $(".indeximgtogcon").each(function(){ var _this=$(this); indeximgtogcon(_this); }); $("#ihonor").piccarousel({ "width":472, //幻灯片的宽度 "height":200, //幻灯片的高度 "posterwidth":263, //幻灯片第一帧的宽度 "posterheight":199, //幻灯片第一张的高度 "scale":0.9, //记录显示比例关系 "speed":800, //记录幻灯片滚动速度 "autoplay":true, //是否开启自动播放 "delay":7000, //自动播放间隔 "verticalalign":"center" //图片对齐位置 }); } function indeximgtogcon(_this){ if(!$(".indeximgtogcon").length || $(".indeximgtogcon .listcon .list").length <= 1){ return false; } var a = _this, b = a.find(".listcon"), c = b.children(".list"), d = a.children(".tip"), length = c.length, width = c.width(), i = 0, interval = 1000, speed = 800, t; b.width(width*(length+1)).append(c.eq(0).clone()).css({"left": 0}); for(var j=0; j"); }else{ d.append(""); } } function fun(){ if(i > length){ b.css({'left': 0}); i = 1; fun(); }else if(i < 0){ b.css({'left': -length*width}); i = length - 1; fun(); }else{ b.stop().animate({'left': -i*width}, speed); } tip(); } function tip(){ var index; i >= length ? index = 0 : index=i ; d.children("span").eq(index).addclass("cur").siblings().removeclass("cur"); } d.children("span").bind("click", function(){ i = $(this).index(); fun(); }); // a.hover( // function(){ clearinterval(t); }, // function(){ t = setinterval(fun, interval); } // ); // t = setinterval(fun, interval); } function checkform(){ if($("#formpost").length){ $("#formpost tr.code input").val(""); } $("#formpost input[type='submit']").click(function(){ var bool = true; $("#formpost tr.required").each(function(){ var a, b, c; $(this).find(".tip").html(""); if($(this).find("input").length){ a = $(this).find("input").val().replace(/\s+/gm,' '); b = $(this).find("input").attr("model"); c = $(this).find("label").text(); c = c.substr(0, c.length-1); }else{ a = $(this).find("textarea").val().replace(/\s+/gm,' '); b = "text"; c = $(this).find("label").text(); c = c.substr(0, c.length-1); } if(a == "" || a == " "){ $(this).find(".tip").html(""+ c +" 不能为空!"); bool = false; }else{ switch (b){ case "name": if(!a.match(/^[a-za-z]+$/) && !a.match(/^[\u4e00-\u9fa5]{0,}$/)){ $(this).find(".tip").html("只能是汉字或英文"); bool = false; }else{ $(this).find(".tip").html(""); } break; case "phone": if(!a.match(/^[0-9]*$/)){ $(this).find(".tip").html("只能是纯数字"); bool = false; }else{ $(this).find(".tip").html(""); } break; case "email": if(!a.match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/)){ $(this).find(".tip").html("请输入正确的邮箱格式"); bool = false; }else{ $(this).find(".tip").html(""); } break; } } }); return bool; }); } // banner图片 function banner(){ if(!$("#banner").length || $("#banner li").length <= 1){ return false; } var _this = $("#banner"), me = $("#banner ul"), tip = $("#banner .tip"), t, interval = 10000, speed = 1000, speed2 = 700, n = 0,prev = _this.find(".prev"), next = _this.find(".next"), n = me.find("li").length; if($("#banner .tip").length){ var htmltip = ""; for(var i=0; i= n-1){ n = 0; }else{ n ++; } me.find("li").eq(n).css({"z-index":2}).stop().fadein(speed).siblings("li").css({"z-index":1}).stop().fadeout(speed2); if($("#banner .tip").length){ tip.children("span").eq(n).addclass("cur").siblings("span").removeclass("cur"); } } next.bind('click', function(){ clearinterval(t); func(); }) prev.bind('click', function(){ console.log(n) if(n <=0){ n = n-2; }else{ n-=2; } clearinterval(t); func(); }); tip.children("span").click(function(){ clearinterval(t); n = $(this).index()-1; func(); t = setinterval(func, interval); }) t = setinterval(func, interval); } function nav(){ $(".nav .subnav").each(function() { if(!$(this).find("a").length){ $(this).remove(); } }); // 主导航 - 上拉 $(".inav .head_menu>li").hover(function(){ $(this).children(".subnav").stop(true).slidedown(200); },function(){ $(this).children(".subnav").stop(true).slideup(200); }); // 侧栏导航 $(".leftnav .drop").each(function() { if(!$(this).find("a").length){ $(this).remove(); } }); $(".leftnav dd").hover(function(){ $(this).find(".drop").stop().slidedown(300); },function(){ $(this).find(".drop").stop().slideup(300); }); } function tel400(){ var tel400=$(".format400").html(); var tellength = tel400.length; if(tellength == 11){ var firstnum = tel400.substr(0,1); if(firstnum == 0){ var tel1 = tel400.substr(0, 4); var tel2 = tel400.substr(4, 7); tel400 = tel1+ "-" + tel2; } }else if(tellength == 12){ var tel1 = tel400.substr(0, 4); var tel2 = tel400.substr(4, 8); tel400 = tel1+ "-" + tel2; }else if(tellength == 10){ var tel1 = tel400.substr(0, 3); var tel2 = tel400.substr(3, 3); var tel3 = tel400.substr(6, 4); tel400 = tel1+ "-" + tel2 + "-" + tel3; } if($(".format400").length){ $(".format400").html(tel400); } } function searcher(){ var isfocus = false; var searchva=$("#searchtxt").val(); $("#searchtxt").val(searchva).focus(function(){ isfocus = true; $(this).val(""); }).blur(function(){ isfocus = false; if($(this).val() == ""){ $(this).val(searchva); } }); $("#searchsubmit").click(function(){ if($("#searchtxt").val() == "" || $("#searchtxt").val() == searchva){ alert(searchva); return false; } search(); }); } function tools(){ $("#sethome").click(function(){ sethome(this, location.href); }); $("#addfavo").click(function(){ var fm = $("title").html(); addfavorite(fm, location.href, ''); }); $("a").focus(function(){ $(this).blur(); }); $(".returntop").click(function(){ $("body, html").stop().animate({"scrolltop":0}); }); $("#setfont a").click(function(){ $(this).addclass("cur").siblings().removeclass("cur"); var size = $(this).attr("rel"); $(this).parents(".information").find(".info").css({"font-size":size+"px"}); }); $("#book").click(function(){ var a = $("#booktip").offset().top; $("body, html").stop().animate({"scrolltop":a}, 500); }); if($("#sitepath").length){ var txt = $("#sitepath a:last-child").text(); $("#sitepath a:last-child").remove(); $("#sitepath").append(""+ txt +""); } if($("#baidumap").length){ var func = function(){ if($("#baidumap .bmap_bubble_title a").length < 1){ settimeout(func, 100); }else{ $("#baidumap .bmap_bubble_title a").attr({"target":"_blank"}); } } func(); } } function addfavorite(title, url) { try { window.external.addfavorite(url, title); } catch (e) { try { window.sidebar.addpanel(title, url, ""); } catch (e) { alert("抱歉,您所使用的浏览器无法完成此操作。\n\n加入收藏失败,请使用ctrl+d进行添加"); } } } function sethome(obj,url){ try{ obj.style.behavior='url(#default#homepage)'; obj.sethomepage(url); }catch(e){ if(window.netscape){ try{ netscape.security.privilegemanager.enableprivilege("universalxpconnect"); }catch(e){ alert("抱歉,此操作被浏览器拒绝!\n\n请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'"); } }else{ alert("抱歉,您所使用的浏览器无法完成此操作。\n\n您需要手动将【"+url+"】设置为首页。"); } } }