﻿

function $() {
    return document.getElementById(arguments[0]);
}
String.prototype.trim = function () {
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
};
String.prototype.lTrim = function () {
    return this.replace(/(^[\s]*)/g, "");
};
String.prototype.rTrim = function () {
    return this.replace(/([\s]*$)/g, "");
};

function checkcharuname(charstr,isempty) {
	var str = charstr;
	var flag = false;
	if(str.trim() == "" && isempty) {
		return true;
	} else if(unamekwstr.trim() == "") {
		return false;
	} else {
		str = str.toLowerCase();
		var strs = unamekwstr.split(",");
		for(var i=0;i<strs.length;i++) {
			if(str.indexOf(strs[i]) != -1) {
				checkstrtemp = strs[i];
				flag = true;
				break;
			}
		}
		return flag;
	}
}
//取字和字符的长度
function getStrLength(idstr) {
    var str = $(idstr).value.trim();
    return idstr.replace(/[^\x00-\xff]/gi, "xx").length;
}

function getStrLength2(str) {
    return str.replace(/[^\x00-\xff]/gi, "xx").length;
}

//测试合法邮件地址
function testMail(str) {
    var myReg = /^[_\-a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/g;
    return myReg.test(str.trim());
}

//判断字符时候包含,|,",',<,>,
function testStr(idstr) {
    var testStr = $(idstr).value.trim();
//	alert(testStr);
    var myReg = /[\\\|\"\'\/<>]/g;
    return myReg.test(testStr);
}

//得到最新的验证码
function getimgcode(){
    var numkey = Math.random();
    numkey = Math.round(numkey*10000);

    var getimagecode = ge("getcode");
    getimagecode.src = "/inc/Image.aspx?k=" + numkey;
}
function ge()
{
   var ea;
   for(var i = 0; i < arguments.length; i ++ )
   {
      var e = arguments[i];
      if(typeof e == 'string')
      e = document.getElementById(e);
      if(arguments.length == 1)
      {
         return e;
      }
      if( ! ea)
      ea = new Array();
      ea[ea.length] = e;
   }
   return ea;
}