/* 基础函数 */ function id(id) {return document.getelementbyid(id);} function trim(str) {return str.replace(/(^\s*)|(\s*$)/g,"");} //去除首尾空格 function ltrim(str){return str.replace(/(^\s*)/g, "");} //去除左空格 function rtrim(str) {return str.replace(/(\s*$)/g, "");} // 去除右空格 function length(str) //获取字符长度,汉字占2个字节 { str=str.replace(/[^\x00-\xff]/g,"**") return str.length; } function left(str,len) //左边截取字段数 { if (isnan(len) || len == null) { len = str.length; } else { if (parseint(len) < 0 || parseint(len) > str.length) { len = str.length; } } return str.substr(0, len); } function right(str,len) //右边截取字段数 { if (isnan(len) || len == null) { len = str.length; } else { if (parseint(len) < 0 || parseint(len) > str.length) { len = str.length; } } return str.substring(str.length-len,str.length); } function request(paras,url) //获取url中参数 { if(url==null){url=location.href;} var parastring = url.substring(url.indexof("?")+1,url.length).split("&"); var paraobj={} for (i=0;j=parastring[i]; i++) { paraobj[j.substring(0,j.indexof("=")).tolowercase()] = j.substring(j.indexof("=")+1,j.length); } var returnvalue = paraobj[paras.tolowercase()]; if(typeof(returnvalue)=="undefined") { return ""; } else { return decodeuri(returnvalue); } } function isstr(str) //是否由数字、字母和下划线组成 { if(trim(str)==""){return false;} return (str.replace(/\w/g,"").length==0); } function islstr(str) //是否由数字、字母和下划线组成 字母开头 { if(trim(str)==""){return false;} var reg = /^[a-za-z][a-za-z0-9_]*$/; if(reg.test(str)) return true; else return false; } function isnum(str) //是否是数值,包括正负数,小数 { if(trim(str)==""){return false;} if(isnan(str)){return false;} else{return true;} } function isusername(str) //由数字、字母和下划线汉字组成 { if(trim(str)==""){return false;} str=str.replace(/[^\x00-\xff]/g,""); if(str==""){return true;} else{return isstr(str);} } function isnumeric(str,flag) //验证数值类型 { if(trim(str)==""){return false;} if(isnan(str)){return false;} switch (flag) { case "+": //正数 return /(^\+?|^\d?)\d*\.?\d+$/.test(str); case "-": //负数 return /^-\d*\.?\d+$/.test(str); case "i": //整数 return /(^-?|^\+?|\d)\d+$/.test(str); case "+i": //正整数 return /(^\d+$)|(^\+?\d+$)/.test(str); case "-i": //负整数 return /^[-]\d+$/.test(str); case "f": //浮点数 return /(^-?|^\+?|^\d?)\d*\.\d+$/.test(str); case "+f": //正浮点数 return /(^\+?|^\d?)\d*\.\d+$/.test(str); case "-f": //负浮点数 return /^[-]\d*\.\d$/.test(str); default: //缺省 return true; } } function digit(str) //只保留数字 { return str.replace(/\d/g, ""); } function isdigit(str) //检测是否是数字 { if(trim(str)==""){return false;} return (str.replace(/\d/g, "").length==0); } function isstrdigit(str) //是否由数字、字母组成 { if(trim(str)==""){return false;} var reg = /^[a-za-z0-9]+$/g; return reg.test(str); } function strdigit(str) //只保留数字、字母部分 { return str.replace(/[\w]/g, ''); } function chinese(str) //只保留汉字 { return (str.replace(/[^\u4e00-\u9fa5]/g, '')); } function includechinese(str) //是否包含汉字 { return (str.length != str.replace(/[^\x00-\xff]/g, "**").length); } function ischinese(str) //是否为汉字 { //[\u4e00-\u9fa5]为汉字,[\ufe30-\uffa0]为全角符号 if(trim(str)==""){return false;} return /^[^\x00-\xff]*$/.test(str); } function isdate(str) { if(trim(str)==""){return false;} var reg1=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/; var reg2=/^(\d{1,2})\/(\d{1,2})\/(\d{4}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; var reg3=/^(\d{1,2})\/(\d{1,2})\/(\d{4}) (\d{1,2}):(\d{1,2}):(\d{1,2}) ([a-za-z]{0,2})$/; var reg4=/^(\d{4})-(\d{1,2})-(\d{1,2})$/; var reg5=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; if(!reg1.test(str) && !reg2.test(str) && !reg3.test(str) && !reg4.test(str) && !reg5.test(str)) { return false; } return true; } function ismobile(mobile) { if(mobile.length!=11){return false;} var myreg = /^((1[3458])+\d{9})$/; if(!myreg.test(mobile)){return false;} return true; } function isemail(str) { var pattern =/^([a-za-z0-9]+[_|\_|\.]?)*[a-za-z0-9]+@([a-za-z0-9]+[_|\_|\.]?)*[a-za-z0-9]+\.[a-za-z]{2,3}$/ var flag=pattern.test(trim(str)); if (!flag) { return false; } else { return true; } } function isip() { var respacecheck = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; if (respacecheck.test(str)) { str.match(respacecheck); if (regexp.$1 <= 255 && regexp.$1 >= 0 && regexp.$2 <= 255 && regexp.$2 >= 0 && regexp.$3 <= 255 && regexp.$3 >= 0 && regexp.$4 <= 255 && regexp.$4 >= 0) { return true; } else { return false; } } else { return false; } } function input_digit() //只能输入数字 { this.value=digit(this.value); } function input_chinese() //只能输入中文 { this.value =chinese(this.value); } function input_strdigit() //只能输入中文 字母 下划线 { this.value=strdigit(this.value); } function setcookie(name,value)//cookies设置 { var argv = setcookie.arguments; var argc = setcookie.arguments.length; var expires = (argc > 2) ? argv[2] : null;//第三个参数为过期时间 if(expires!=null) { var largeexpdate = new date (); //largeexpdate.settime(largeexpdate.gettime() + (expires*1000*60*60*24));//expires为过期天数 largeexpdate.settime(largeexpdate.gettime() + (expires*1000)); //expires为过期秒数值 } document.cookie = name + "=" + escape (value)+((expires == null) ? "" : (";expires=" +largeexpdate.togmtstring()+";path=/")); } function getcookie(name)//cookies读取 { var search = name + "=" if(document.cookie.length > 0) { offset = document.cookie.indexof(search) if(offset != -1) { offset += search.length end = document.cookie.indexof(";", offset) if(end == -1) end = document.cookie.length return unescape(document.cookie.substring(offset, end)) } else return "" } } function delcookie(name)//删除cookie { var exp = new date(); exp.settime(exp.gettime() - 1); var cval = getcookie(name); if (cval != null) document.cookie = name + "=" + escape (value)+((expires == null) ? "" : (";expires=" +exp.togmtstring()+";path=/")); } function urlencode(str) { return escape(str).replace(/\+/g, '%2b').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2f'); } function showitem(id,url) { var obj=document.getelementbyid(id); if(url!="#" || obj==null) { return; } if(obj.style.display=="none") { obj.style.display=""; } else { obj.style.display="none"; } } function removehtml(str) //删除html标签 { var temp = document.createelement("div"); temp.innerhtml =str; var output = temp.innertext || temp.textcontent; temp = null; return output; } function getbrowser() //获取浏览器类型 { if (navigator.useragent.indexof('msie') > -1) return 'msie'; if (navigator.useragent.indexof('firefox') > -1) return 'firefox'; if (navigator.useragent.indexof("safari") > 0) return 'safari'; if (navigator.useragent.indexof("camino") > 0) return 'camino'; if (navigator.useragent.indexof("gecko/") > 0) return 'gecko'; if (navigator.useragent.indexof('opera') > -1) return 'opera'; return 'other'; } function delobj(objname) //删除标签 { var obj = document.getelementbyid(objname); if (obj != undefined) { obj.parentnode.removechild(obj); } obj = null; } function hasclass(obj,cls){return obj.classname.match(new regexp('(\\s|^)' + cls + '(\\s|$)'));} function addclass(obj,cls) {if(!this.hasclass(obj, cls)) obj.classname += " " + cls;} function removeclass(obj,cls){if(hasclass(obj, cls)){var reg = new regexp('(\\s|^)' + cls + '(\\s|$)');obj.classname = obj.classname.replace(reg, ' ');}} function replaceall(str,str1,str2) { while(str.indexof(str1)>= 0) { str=str.replace(str1,str2); } return str; } function ischecked(obj) //检测radid或checkbox是否有选择 { var k=0; for(k=0;k 0) { flag = false; break; } } return flag; } //ajax插件 paajax = function(){ var http_request = false; var result = ""; var method = "get"; var anc = true; this.setarg = function(m, a){//a=false表示顺序同步加载 method = (m == "get") ? "get" : "post"; anc = (a) ? true : false; } this.init = function(){ http_request = false; if (window.xmlhttprequest) { // mozilla, safari,... http_request = new xmlhttprequest(); } else if (window.activexobject) { // ie try { http_request = new activexobject("msxml2.xmlhttp"); } catch (e) { try { http_request = new activexobject("microsoft.xmlhttp"); } catch (e) { alert("can't creat ajax object!"); return false; } } } } this.send = function(url,sendcontent,callback){ this.init(); var ajaxstatechange= function(){ if (http_request.readystate == 4) { if (http_request.status == 200) { result = http_request.responsetext; try{ callback(result); } catch (e) { alert("the callback method wrong!" + e); return false; } } else { if(http_request.status!=0) { alert("ajax出现http"+http_request.status+"错误") } return false; } } }; http_request.onreadystatechange=ajaxstatechange; if (method == "get") { http_request.open('get', url+"?"+sendcontent, anc); http_request.send(null); } else { http_request.open('post', url, anc); http_request.setrequestheader("content-type", "application/x-www-form-urlencoded"); http_request.send(sendcontent); } } } /*滚动插件 使用方法:var marquee=new marquee("对象id","direction",step,width,height,timer,delaytime,scrollstep,waittime); 参数说明: id "marquee" 容器id (必选) direction (left) 滚动方向 (可选,默认为left向左滚动,可设置的值包括:"top","bottom","left","right") step (1) 滚动的步长 (可选,默认值为1,数值越大,滚动越快) width (760) 容器可视宽度 (可选,默认值为容器初始设置的宽度) height (52) 容器可视高度 (可选,默认值为容器初始设置的高度) timer (50) 定时器 (可选,默认值为30,数值越小,滚动的速度越快,1000=1秒,建议不小于20) delaytime (5000) 间歇停顿延迟时间(可选,默认为0不停顿,1000=1秒) scrollstep (52) 间歇滚动间距 (可选,默认为翻屏宽/高度,该数值与延迟均为0则为鼠标左右滑动悬停控制(效果不是很好),-1禁止鼠标控制) waittime (3000) 开始时的等待时间(可选,默认或0为不等待,1000=1秒) */ function marquee() { this.id=document.getelementbyid(arguments[0]);if(!this.id){alert("\""+arguments[0]+"\"初始化错误\r\n请检查标签id设置是否正确!");this.id=-1;return;}this.width=this.height=this.delaytime=this.waittime=this.ctl=this.startid=this.stop=this.mouseover=0;this.direction="left";this.step=1;this.timer=30;if(typeof arguments[1]=="number"||typeof arguments[1]=="string"){this.direction=arguments[1];}if(typeof arguments[2]=="number"){this.step=arguments[2];}if(typeof arguments[3]=="number"){this.width=arguments[3];}if(typeof arguments[4]=="number"){this.height=arguments[4];}if(typeof arguments[5]=="number"){this.timer=arguments[5];}if(typeof arguments[6]=="number"){this.delaytime=arguments[6];}if(typeof arguments[7]=="number"){this.scrollstep=arguments[7];}if(typeof arguments[8]=="number"){this.waittime=arguments[8];}this.id.style.overflow=this.id.style.overflowx=this.id.style.overflowy="hidden";this.id.nowrap=true;this.isnotopera=(navigator.useragent.tolowercase().indexof("opera")==-1);if(arguments.length>=1){this.start();} } marquee.prototype.start = function() { if(this.id==-1)return;if(this.waittime<800)this.waittime=800;if(this.timer<1)this.timer=1; if(this.width==0) { if(this.id.style.width.indexof("px")>0){this.width = parseint(this.id.style.width);}else{this.width = parseint(this.id.offsetwidth);} } if(this.height==0) { if(this.id.style.height.indexof("px")>0){this.height = parseint(this.id.style.height);}else{this.height =parseint(this.id.offsetheight);} } this.halfwidth=math.round(this.width/2);this.halfheight=math.round(this.height/2);this.bakstep=this.step;if(this.width>0){this.id.style.width=this.width+"px";}if(this.height>0){this.id.style.height=this.height+"px";}if(typeof this.scrollstep!="number")this.scrollstep=(this.direction=="left" || this.direction=="right")?this.width:this.height;var templateleft="
msclass_temp_htmlmsclass_temp_html
";var templatetop="
msclass_temp_html
msclass_temp_html
";var msobj=this;msobj.temphtml=msobj.id.innerhtml;if(msobj.direction=="top" || msobj.direction=="bottom"){msobj.id.innerhtml=templatetop.replace(/msclass_temp_html/g,msobj.id.innerhtml);}else{msobj.id.innerhtml=templateleft.replace(/msclass_temp_html/g,msobj.id.innerhtml);} var timer = this.timer;var delaytime = this.delaytime;var waittime = this.waittime;msobj.startid = function(){msobj.scroll()} msobj.continue = function(){if(msobj.mouseover==1){settimeout(msobj.continue,delaytime);}else{clearinterval(msobj.timerid);msobj.ctl=msobj.stop=0;msobj.timerid=setinterval(msobj.startid,timer);}} msobj.pause = function(){msobj.stop = 1;clearinterval(msobj.timerid);settimeout(msobj.continue,delaytime);} msobj.begin = function() { msobj.clientscroll = (msobj.direction=="left" || msobj.direction=="right")? msobj.id.scrollwidth / 2 : msobj.id.scrollheight / 2; if(((msobj.direction=="top" || msobj.direction=="bottom") && msobj.clientscroll <= msobj.height + msobj.step) || ((msobj.direction=="left" || msobj.direction=="right") && msobj.clientscroll <= msobj.width + msobj.step)) {msobj.id.innerhtml = msobj.temphtml;delete(msobj.temphtml);return;} delete(msobj.temphtml); msobj.timerid = setinterval(msobj.startid,timer); if(msobj.scrollstep < 0)return; msobj.id.onmousemove = function(event){if(msobj.scrollstep==0&&(msobj.direction=="left" || msobj.direction=="right")){var event=event||window.event;if(window.event){if(msobj.isnotopera){msobj.eventleft=event.srcelement.id==msobj.id.id?event.offsetx-msobj.id.scrollleft:event.srcelement.offsetleft-msobj.id.scrollleft+event.offsetx;}else{msobj.scrollstep=null;return;}}else{msobj.eventleft=event.layerx-msobj.id.scrollleft;}msobj.direction=msobj.eventleft>msobj.halfwidth?"right":"left";msobj.abscenter=math.abs(msobj.halfwidth-msobj.eventleft);msobj.step=math.round(msobj.abscenter*(msobj.bakstep*2)/msobj.halfwidth);}} msobj.id.onmouseover = function(){if(msobj.scrollstep == 0)return;msobj.mouseover = 1;clearinterval(msobj.timerid);} msobj.id.onmouseout = function(){if(msobj.scrollstep==0){if(msobj.step==0)msobj.step=1;return;}msobj.mouseover=0;if(msobj.stop==0){clearinterval(msobj.timerid);msobj.timerid=setinterval(msobj.startid,timer);}} } settimeout(msobj.begin,waittime);} marquee.prototype.scroll=function(){ switch(this.direction){case "top":this.ctl+=this.step;if(this.ctl>=this.scrollstep&&this.delaytime>0){this.id.scrolltop+=this.scrollstep+this.step-this.ctl;this.pause();return}else{if(this.id.scrolltop>=this.clientscroll){this.id.scrolltop-=this.clientscroll}this.id.scrolltop+=this.step}break;case "bottom":this.ctl+=this.step;if(this.ctl>=this.scrollstep&&this.delaytime>0){this.id.scrolltop-=this.scrollstep+this.step-this.ctl;this.pause();return}else{if(this.id.scrolltop<=0){this.id.scrolltop+=this.clientscroll}this.id.scrolltop-=this.step}break;case "left":this.ctl+=this.step;if(this.ctl>=this.scrollstep&&this.delaytime>0){this.id.scrollleft+=this.scrollstep+this.step-this.ctl;this.pause();return}else{if(this.id.scrollleft>=this.clientscroll){this.id.scrollleft-=this.clientscroll}this.id.scrollleft+=this.step}break;case "right":this.ctl+=this.step;if(this.ctl>=this.scrollstep&&this.delaytime>0){this.id.scrollleft-=this.scrollstep+this.step-this.ctl;this.pause();return}else{if(this.id.scrollleft<=0){this.id.scrollleft+=this.clientscroll}this.id.scrollleft-=this.step}break} } //tab封装 function tabs(tid,cid,tag1,tag2,addclass,theevent) { if(arguments.length==3){theevent=arguments[2];tag1="dd";tag2=tag1;addclass="current";} var defaultindex=0,checknav="",checkwrap=""; var o1=document.getelementbyid(tid),o2=document.getelementbyid(cid),elementnav=new array();elementwrap=new array(); chk=function(e,n){var v=eval("/"+n+"/gi");if(v==undefined){return true}else if(v.test(e.classname)){return true};} function ser(e,arr,g,n,t) { var tags=e.getelementsbytagname(g),v=0; for(i=0;i"; } panelhtml="
"+panelhtml+"
"; $obj_slide_inner.before(panelhtml); var $panel=$obj_slide.children(".panel"); var $baritem=$panel.children("span"); var currentnum=0; $baritem.eq(0).addclass("current"); $li.eq(0).addclass("current"); var $titbar=$obj_slide.children(".titbar"); if($li.eq(0).children("a").children("em").html()!="") { $titbar.show(); $titbar.children("em").html($li.eq(0).children("a").children("em").html()); } if(slidestyle==0) { $li.eq(0).siblings("li").hide(); } else if(slidestyle==1) { $li.css({"width":width+"px"}); $obj_slide_inner.css({"width":width*nums+"px"}); $li.addclass("zy_move"); } else { $obj_slide_inner.css({"position":"absolute","height":"auto"}); $li.addclass("sx_move"); } if(isbanner) { $panel.css({"margin-left":-1*($panel.css('width').replace("px","")/2)+5+"px"}) if(width0){startleft=0;} $obj_slide_inner.css({"margin-left":startleft+"px"}); } } function shownum(num) { if(num<0){num=nums-1;} if(num>(nums-1)){num=0;} $baritem.eq(currentnum).removeclass("current"); $titbar.children("em").html($li.eq(num).children("a").children("em").html()); if(slidestyle==0) { $li.eq(currentnum).removeclass("current"); $li.eq(num).addclass("current"); $li.eq(num).fadein(1000,function(){$(this).siblings("li").hide();}); } else if(slidestyle==1) { $obj_slide_inner.animate({marginleft:(-1*num*width)+startleft+'px'}); } else { $obj_slide_inner.animate({top:(-1*num*height)+'px'}); } $baritem.eq(num).addclass("current"); currentnum=num; }; $baritem.each(function(i){ $(this).unbind("mouseenter").mouseenter(function(){ $li.stop(true); $obj_slide_inner.stop(true); //$li.eq(currentnum).stop(true,true); shownum(i); }); }); var it=setinterval(function(){shownum(currentnum+1)},itimes); $obj_slide.mouseenter(function(){ clearinterval(it); }); $obj_slide.mouseleave(function(){ it=setinterval(function(){shownum(currentnum+1)},itimes); }); $(window).resize(function(){ screenwidth=parseint($(document).width()); startleft=-1*parseint((width-screenwidth)/2); if(startleft>0){startleft=0;} }); if(!ispc()) { function shownum_formobile(num) { if(num<0){return;} if(num>(nums-1)){return;} clearinterval(it); shownum(num); } $obj_slide.touchwipe({ wipeleft: function() {shownum_formobile(currentnum+1);}, wiperight: function() {shownum_formobile(currentnum-1)}, wipeup: function() {}, wipedown: function() {}, min_move_x: 40, min_move_y: 40, preventdefaultevents:true }); } } if(!ispc()){document.write("");}