/* 通用脚本函数,最后更新于2012-2-9 */ //容错脚本 resumeerror=function (){return true;} window.onerror = resumeerror; //检查是否中文字符 is_zw=function(str){ exp=/[0-9a-za-z_.,#@!$%^&*()-+=|\?/<>]/g; if(str.search(exp) != -1){return false;} return true; } //验证是否包含逗号 checkbadchar=function (obj,alertstr) { exp=/[,,]/g; if(obj.value.search(exp) != -1) { alert(alertstr+"不能包含逗号"); obj.value=""; obj.focus(); return false; } return true; } // 检查是否有效的扩展名 isext=function(filename, allowext){ var stemp; var s=allowext.touppercase().split("|"); for (var i=0;i=255||charascii<=31) { errorstr=errorstr+tempstr.charat(i); } else { if (!checkerrorstr(charascii)) { errorstr=errorstr+tempstr.charat(i); } } } if (errorstr!='') { alert("出错信息:\n\n"+descriptionstr+'发现非法字符:'+errorstr); obj.focus(); return false; } if (!(((tempstr.charcodeat(0)>=48)&&(tempstr.charcodeat(0)<=57))||((tempstr.charcodeat(0)>=65)&&(tempstr.charcodeat(0)<=90))||((tempstr.charcodeat(0)>=97)&&(tempstr.charcodeat(0)<=122)))) { alert(descriptionstr+'首字符只能够为数字或者字母'); obj.focus(); return false; } } return true; } function checkerrorstr(charasciicode) { var temparray=new array(34,47,92,42,58,60,62,63,124); for (var i=0;i
'); }else{ inserthtmltoeditorbyid(editorid,'
'); } }else{ var str="
[uploadfiles]"+maxid+","+filesize+","+fileext+","+title+"[/uploadfiles]


"; if (editorid==''||editorid==undefined){ inserthtmltoeditor(str); }else{ inserthtmltoeditorbyid(editorid,str); } } } function inserthtmltoeditorbyid(editorid,codestr) {eval('ckeditor.instances.'+editorid).inserthtml(codestr);} //选择附件 var box=''; function popinsertannex(upfrom){ box=$.dialog({title:'选择附件插入',content:'url:../plus/selectannex.asp?upfrom='+upfrom,width:690,height:400}); } function getcolor(obj,url){ box=$.dialog({id:'colorbox',title:false,content:'url:'+url,top:$('#'+obj).position().top+80,width:225,height:148,min:false,max:false,padding:0}); } function openimgcutwindow(deloriginphoto,installdir,photourl){ openimgcutwindows(deloriginphoto,installdir,photourl,$('#photourl')[0]); } function openimgcutwindows(deloriginphoto,installdir,photourl,obj){ openthensetvalue(installdir+'plus/imgcut.asp?del='+deloriginphoto+'&photourl='+photourl,680,380,window,obj); } //网站验证码,调用 writeverifycode(安装目录,显示tips,cssname); if (typeof codenum == 'undefined'){ var codenum = 1;}else{codenum++;} function writeverifycode(dir,tips,cssname){ codenum++; if (dir==undefined) dir='/';if (tips==undefined) tips=0;if (cssname==undefined) cssname='textbox'; document.write(''); if (tips==1) document.write(' 请输入上图中字符 '); } var seccodefocus = 0; function showverifycode(id) { var obj=document.getelementbyid("codebox"+id); obj.style.top = (-parseint(obj.style.height) - 4) + 'px'; obj.style.left = '0px'; obj.style.display = ''; var pos=getelementpos("codebox"+id); if (pos.y<0) obj.style.top=parseint(obj.style.height)-20+"px"; document.getelementbyid('vcodeimg'+id).src =document.getelementbyid('vcodeimg'+id).src.split('?')[0]+'?time=' + math.random(); try{$("#codebox"+id).fadeout('fast').fadein('fast');}catch(e){} } function getelementpos(elementid) { var ua = navigator.useragent.tolowercase(); var isopera = (ua.indexof('opera') != -1); var isie = (ua.indexof('msie') != -1 && !isopera); // not opera spoof var el = document.getelementbyid(elementid); if(el.parentnode === null || el.style.display == 'none') { return false; } var parent = null;var pos = []; var box; if(el.getboundingclientrect) //ie { box = el.getboundingclientrect();var scrolltop = math.max(document.documentelement.scrolltop, document.body.scrolltop); var scrollleft = math.max(document.documentelement.scrollleft, document.body.scrollleft);return {x:box.left + scrollleft, y:box.top + scrolltop};}else if(document.getboxobjectfor) // gecko {box = document.getboxobjectfor(el); var borderleft = (el.style.borderleftwidth)?parseint(el.style.borderleftwidth):0; var bordertop = (el.style.bordertopwidth)?parseint(el.style.bordertopwidth):0; pos = [box.x - borderleft, box.y - bordertop];} else // safari & opera {pos = [el.offsetleft, el.offsettop]; parent = el.offsetparent; if (parent != el) {while (parent) {pos[0] += parent.offsetleft; pos[1] += parent.offsettop; parent = parent.offsetparent;}} if (ua.indexof('opera') != -1 || ( ua.indexof('safari') != -1 && el.style.position == 'absolute' )) { pos[0] -= document.body.offsetleft;pos[1] -= document.body.offsettop;}} if (el.parentnode) {parent = el.parentnode;} else {parent = null;} while (parent && parent.tagname != 'body' && parent.tagname != 'html') { // account for any scrolled ancestors pos[0] -= parent.scrollleft;pos[1] -= parent.scrolltop;if (parent.parentnode) {parent = parent.parentnode;} else { parent = null;}} return {x:pos[0], y:pos[1]}; } function addfavorite(surl, stitle) { try { //ie window.external.addfavorite(surl, stitle); } catch (e) { try { //firefox window.sidebar.addpanel(stitle, surl, ""); } catch (e) { try{//chrome无法自动收藏,用创建快应用程序的捷方式来替代。js特效大全 www.www.111cn.net createshortcut(); } catch(e){ alert("请按ctrl+d之后按“确定”完成收藏!"); } } } } function sethomepage(pageurl) { if (document.all) { document.body.style.behavior='url(#default#homepage)'; document.body.sethomepage(pageurl); } else { try { //ie netscape.security.privilegemanager.enableprivilege("universalxpconnect"); } catch (e) { try{ //firefox var prefs = components.classes['@mozilla.org/preferences-service;1'] .getservice(components. interfaces.nsiprefbranch); prefs.setcharpref('browser.startup.homepage',pageurl); } catch(e) { alert( "您的浏览器不支持该操作,请使用浏览器菜单手动设置." ); } } } } var kesionjs={ //通用对话框 alert:function(msg,act){ if (frameelement==null || frameelement.api==undefined){ this.alert1(msg,act); }else{ var api = frameelement.api, w = api.opener; w.jquery.dialog.alert(msg,function(){ settimeout(function(){ eval(act);},1);}); } }, alert1:function(msg,act){ jquery.dialog.alert(msg,function(){eval(act);}); }, alertbytime:function(src,msg,t){ if (src==1){ src="success.gif"; }else{ src="error.gif"; } if (t=='') t=2; jquery.dialog.tips(msg,t,src,function(){}); }, confirm:function(msg,fun1,fun2){ if (frameelement==null ||frameelement.api==undefined){ this.confirm1(msg,fun1,fun2); }else{ var api = frameelement.api, w = api.opener; w.jquery.dialog.confirm(msg,function(){settimeout(function(){ eval(fun1);},1);},function(){ settimeout(function(){ eval(fun2);},1);}); } }, confirm1:function(msg,fun1,fun2){ jquery.dialog.confirm(msg,function(){eval(fun1);},function(){eval(fun2);}); }, message:function(ico,msg,fun){ if (frameelement==null ||frameelement.api==undefined){ this.message1(ico,msg,fun); }else{ var api = frameelement.api, w = api.opener; w.jquery.dialog.tips(msg,2,ico,function(){ settimeout(function(){ eval(fun);},1); }); } }, message1:function(ico,msg,fun){ jquery.dialog.tips(msg,2,ico,function(){eval(fun);}); }, tips:function(title,msg,w,h){ jquery.dialog({ title:title, content: msg, width:w, height:h, max:false, min:false }); } }; /*鼠标切换脚本*/ function scrolldoor(){ } scrolldoor.prototype = { sd : function(menus,divs,openclass,closeclass){ var _this = this; if(menus.length != divs.length) { alert("菜单层数量和内容层数量不一样!"); return false; } for(var i = 0 ; i < menus.length ; i++) { _this.$(menus[i]).value = i; _this.$(menus[i]).onmouseover = function(){ for(var j = 0 ; j < menus.length ; j++) { _this.$(menus[j]).classname = closeclass; _this.$(divs[j]).style.display = "none"; } _this.$(menus[this.value]).classname = openclass; _this.$(divs[this.value]).style.display = "block"; } } }, $ : function(oid){ if(typeof(oid) == "string") return document.getelementbyid(oid); return oid; } } //==============================限时抢购倒计时================================/ function calculagraph(){ this._id=null; //this._st=null; this._ct=null; this._et=null; this._lt=null; this._tasktype=null; this.timerrunning=false; this.nowyear=null; this.nowdate=null; this.nowmonth=null; this.nowhour=null; this.nowminute=null; this.nowsecond=null; this._gt=function(){ if (this._tasktype==1){ //限时抢购 //if (this._lt==null){ var t=this._ct.split(' ')[0]; var tarr=t.split('-'); if (this.timerrunning==false){ this.nowyear = tarr[0]; this.nowmonth = tarr[1]; this.nowdate = tarr[2]; t=this._ct.split(' ')[1]; if (t==''||t==null) t='00:00:00' tarr=t.split(':'); this.nowhour = tarr[0]; this.nowminute = tarr[1]; this.nowsecond = tarr.length==3?tarr[2]:0; }else{ if (this.nowmonth>12){ this.nowmonth=0; this.nowyear++; } if(this.nowdate>=parseint(getdaysinmonth(this.nowyear,this.nowmonth))){ this.nowdate=0; this.nowmonth++; } if (this.nowhour>=24){ this.nowhour=0; this.nowdate++; } if (this.nowminute>=59){ this.nowminute=0; this.nowhour++; } if (this.nowsecond>=59){ this.nowsecond=0; this.nowminute++; } this.nowsecond++; } if (this.nowyear <2000) this.nowyear=1900+this.nowyear; var t=this._et.split(' ')[0]; var tarr=t.split('-'); yearleft = tarr[0] - this.nowyear monthleft = tarr[1] - this.nowmonth dateleft = tarr[2] - this.nowdate t=this._et.split(' ')[1]; if (t==''||t==null) t='00:00:00' tarr=t.split(':'); var ehour = tarr[0]; var eminute = tarr[1]; var esecond = tarr.length==3?tarr[2]:0; hourleft = ehour - this.nowhour minuteleft = eminute - this.nowminute secondleft = esecond - this.nowsecond if (secondleft<0) { secondleft=60+secondleft; minuteleft=minuteleft-1; } if (minuteleft<0) { minuteleft=60+minuteleft; hourleft=hourleft-1; } if (hourleft<0) { hourleft=24+hourleft; dateleft=dateleft-1; } if (dateleft<0) { dateleft=31+dateleft; monthleft=monthleft-1; } if (monthleft<0) { monthleft=12+monthleft; yearleft=yearleft-1; } var temp=''; if (yearleft>0){ temp=''+yearleft+'年' } if (monthleft>0){ temp+=''+monthleft+'月'; } temp+=''+dateleft+''+hourleft+'小时'+minuteleft+''+secondleft+'秒'; if (getminuteindates(this._st.replace(/(-)/g,'/'),this.nowyear+'/'+this.nowmonth+'/'+this.nowdate+' '+this.nowhour+':'+this.nowminute+':'+this.nowsecond)<0){ document.getelementbyid(this._id).innerhtml='开始时间:'+this._st+''; } else if (getminuteindates(this.nowyear+'/'+this.nowmonth+'/'+this.nowdate+' '+this.nowhour+':'+this.nowminute+':'+this.nowsecond,this._et.replace(/(-)/g,'/'))>=0){ document.getelementbyid(this._id).innerhtml=temp; }else{ document.getelementbyid(this._id).innerhtml="抢购结束"; clearinterval(timerid); } this.timerrunning = true; var timerid = settimeout("function(){var oo=this;oo.gt()}",1000); }else{ //限量抢购 document.getelementbyid(this._id).innerhtml="限量抢购"; clearinterval(this._interval); } } this._interval=function(){ var o=this; this._interval=setinterval(function(){o._gt()},1000) } } function getdaysinmonth(year,month){ month = parseint(month,10)+1; var temp = new date(year+"/"+month+"/0"); return temp.getdate(); } /** * 判断两个时间这间间隔几分钟 * date1与date2格式:yyyy/mm/dd hh:mm:ss ,它们是字符串类型 * */ function getminuteindates(date1,date2){ var begindate= new date(date1); var enddate = new date(date2); var date = enddate.gettime() - begindate.gettime(); var time = math.floor(date / (1000 * 60 )); return time; } function getupinput(obj){ var getstr=$(obj).next('span').find('input[name=up_contactman]').val(); $('input[name=contactman]').val(getstr); getstr=$(obj).next('span').find('input[name=up_address]').val(); $('input[name=address]').val(getstr); getstr=$(obj).next('span').find('input[name=up_zipcode]').val(); $('input[name=zipcode]').val(getstr); getstr=$(obj).next('span').find('input[name=up_mobile]').val(); $('input[name=mobile]').val(getstr); getstr=$(obj).next('span').find('input[name=up_phone]').val(); $('input[name=phone]').val(getstr); getstr=$(obj).next('span').find('input[name=up_qq]').val(); $('input[name=qq]').val(getstr); getstr=$(obj).next('span').find('input[name=up_email]').val(); $('input[name=email]').val(getstr); } //==============================限时抢购倒计时结束================================/