var Utils = new Object();

Utils.trim = function(text)
{
  if (typeof(text) == "string")
  {
    return text.replace(/(^\s*)|(\s*$)/g, "");
  }
  else
  {
    return text;
  }
}

Utils.isEmail = function(email)
{
  var tomid	= /^(\d|[a-zA-Z])+(-|\.|\w)*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return tomid.test( email );
}

Utils.isTomEmail = function(email)
{
  var tomid	= /^([a-zA-Z])+(-|\.|\w)*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return tomid.test( email );
}

Utils.password	= function(password)
{
	var tompwd	= /^[a-zA-Z0-9-_\?\.=`!@#\$%\^\*\(\)\+\|\{\}\'\[\]\";:\/\?> <,\\]{6,32}$/;
	return tompwd.test(password);
}

Utils.isChinese = function(str)
{
	var nLen	= str.length;
	for(i = 0; i < nLen; i ++)
	{
		if(str.charCodeAt(i) > 255)	return true;
	}
	return false;
}


Utils.isNumber = function(str)
{
	 var regexp=/^(\d+)$/;
	 return regexp.test(str);
}


Utils.autoComplete = function(id)
{
	var tomid	= Utils.trim(document.getElementById(id).value);

	if(Utils.isNumber(tomid) && tomid.length == 11)return;

	var constant = "";
	if(tomid.length > 0 && tomid.indexOf("@") == -1) document.getElementById(id).value = tomid + constant;
	return;
}
