function $(re) { return document.getElementById(re); } function $n(re) { return document.getElementByName(re); } //是否零长度字符串 function IsNone(s) { var tmp=s.toString().replace(/ /g,""); if (null==tmp) return true; return (tmp.length==0); } //是否只有空白字符 function IsEmpty(s) { var tmp=s.toString().replace(/ /g,""); if (null==tmp) return true; return (tmp.match(/^\s+$/ig)!=null) } //是否是数字 function IsNumber(s) { if (IsNone(s) || IsEmpty(s)) return false; var tmp = s.toString(); return (!isNaN(tmp)); } //是否是整数 function IsInteger(s) { if (!IsNumber(s)) return false; var tmp = (new Number(s)).toString(); return (tmp.match(/^[-]?\d{1,15}$/ig)!=null); //整型精度为15位。 } //是否是双精度型 function IsDouble(s) //未测试 { if (!IsNumber(s)) return false; var tmp = (new Number(s)).toString(); if (null==tmp.match(/^[-]?(\d+)[.]?(\d+)$/ig)) return false; s1 = RegExp.$1; s2 = RegExp.$2; return (s1.length + s2.length<=17); //浮点型精度为17位。 } function IsDate(s) { var reg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/; if (reg.test(s)) return true; return false; } //功能:常用正则表达式 //作者:吴志刚 function isEmail(str) { var tmp = str.toString(); return (tmp.match(/^(?:[;]?[\w_-]+(?:[.][\w_-]+)*@[\w_-]+(?:[.][\w_-]+)+)+$/ig)!=null); } function isQQ(str) { var tmp=str.toString(); return (tmp.match(/^[1-9]\d{4,12}$/g)!=null); } //xxxx-xxxxxxxx-xxxx function isPhone(str) { var tmp=str.toString(); return ((tmp.match(/^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/g))!=null); } //1xxxxxxxxxx function isMobile(str) { var tmp=str.toString(); return (tmp.match(/^((\(\d{2,3}\))|(\d{3}\-))?1\d{10}$/g)!=null); } //1xxxxxxxxxxx,xxxx-xxxxxxxx-xxxx,... //"^(()|())(,(()|()))*$" function isPhoneOrMobileList(str) { var tmp=str.toString(); return (tmp.match(/^((((\(\d{2,3}\))|(\d{3}\-))?1\d{10})|(((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?))(,((((\(\d{2,3}\))|(\d{3}\-))?1\d{10})|(((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?)))*$/g)!=null); } //xx@xx.xx,xx@xx.xx,... function isEmailList(emails) { var isEmailFlag = true; for(var i = 0; i < emails.length; i++) { if(!isEmail(emails[i].replace(/\s/g,""))) { isEmailFlag = false; break; } } return isEmailFlag; } //A-Z,a~z,0~9,",","-" function isAscii(str) { var tmp=str.toString(); return (tmp.match(/^[A-Za-z0-9,-]*$/g)!=null); } //http:// function isUrl(str) { var tmp=str.toString(); return (tmp.match(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^\"\"])*$/g)!=null); } function isHttps(str) { var tmp=str.toString(); return (tmp.match(/^https:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^\"\"])*$/g)!=null); } function isFtp(str) { var tmp=str.toString(); return (tmp.match(/^ftp:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^\"\"])*$/g)!=null); } function checkEmailsReteration(emails) { for(var i=0;i 1) { return true; } } return false; } //功能:页面展示时,处理文章编辑器中插入的图片的尺寸,使之适合页面大小,避免破坏页面布局 function ResizeImage(handleObj,w,h) { var coll = handleObj.getElementsByTagName("IMG"); //alert(coll.length); for(var i = 0; i= iHeight) { if(iWidth> w) { if(coll[i].style.width != "") { coll[i].style.width = w; coll[i].style.height = (w * iHeight)/ iWidth; } else { coll[i].width = w; coll[i].height = (w * iHeight)/ iWidth; } } } else { if(iHeight > h) { if(coll[i].style.width != "") { coll[i].style.width = (h * iWidth)/ iHeight; coll[i].style.height = h; } else { coll[i].height = h; coll[i].width = (h * iWidth)/ iHeight; } } } } } function ResizeImageInWidth(handleObj,w,h) { var coll = handleObj.getElementsByTagName("IMG"); var newW = 0, newH = 0; for(var i = 0; i= iHeight) { if(iWidth> w) { newW = w; newH = (w * iHeight)/ iWidth; } } else { if(iWidth> w) { newW = w; newH = (w * iHeight)/ iWidth; if(newH > (1.5*h)) newH = 1.5*h; } else if(iHeight > (1.5*h)) { newW = iWidth; newH = 1.5*h; } } if(newW > 0) { if(coll[i].style.width != "") { coll[i].style.width = newW; coll[i].style.height = newH; } else { coll[i].width = newW; coll[i].height = newH; } newW = 0; newH = 0; } } } function SetSameHeight() { var divLeft = document.getElementById("divDoorLeft"); var divMiddle = document.getElementById("divDoorMiddle"); var divRight = document.getElementById("divDoorRight"); var divMain = document.getElementById("divDoorMain"); if(divLeft!=null) { var maxHeight = 0; if(divMain != null) { maxHeight = Math.max(divLeft.scrollHeight,divMain.scrollHeight); divLeft.style.height = maxHeight-25 + 'px'; divMain.style.height = maxHeight + 'px'; } else { maxHeight = Math.max(divLeft.scrollHeight,divMiddle.scrollHeight, divRight.scrollHeight); divLeft.style.height = maxHeight-25 + 'px'; if(divMiddle.scrollHeight < maxHeight) divMiddle.style.height = maxHeight + 'px'; divRight.style.height = maxHeight-25 + 'px'; //alert(maxHeight + "," + divLeft.scrollHeight); } } } function SetLate() { window.setTimeout("SetSameHeight()", 1000); } /* if(document.URL.toLowerCase().indexOf("/user/")>0) { window.attachEvent('onload',SetLate); } */ function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i