/*var include_js=document.createElement("script");  
include_js.setAttribute("type","text/javascript");  
include_js.setAttribute("src","http://pass.tom.com/script/xhconn.js");  
document.body.appendChild(include_js); */

var PassUtils = new Object();

PassUtils.trim = function(text)
{
  if (typeof(text) == "string")
  {
    return text.replace(/^\s*|\s*$/, "");
  }
  else
  {
    return text;
  }
}

PassUtils.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 );
}

PassUtils.password	= function(password)
{
	var tompwd	= /^[a-zA-Z0-9-_\?\.`!@#\$%\^\*\(\)\+\|\{\}\'\[\]\";:\/\?> <,]{6,32}$/;
	return tompwd.test(password);
}

PassUtils.isChinese = function(str)
{
	var nLen	= str.length;
	for(i = 0; i < nLen; i ++)
	{
		if(str.charCodeAt(i) > 255)	return true;
	}
	return false;
}

PassUtils.isNumber = function(str)
{
	 var regexp=/^(\d+)$/;
	 return regexp.test(str);
}


PassUtils.autoComplete = function(id)
{
	var tomid	= PassUtils.trim(document.getElementById(id).value);
	
	if(PassUtils.isNumber(tomid) && tomid.length == 11)return;
	
	var constant = "@tom.com";
	if(tomid.length > 0 && tomid.indexOf("@") == -1) document.getElementById(id).value = tomid + constant;
	return;
}

PassUtils.authTomId = function(id,pwd)
{
	var tomid = PassUtils.trim(document.getElementById(id).value);
	var tompwd = PassUtils.trim(document.getElementById(pwd).value);
	  
}