function MyTrim(s)
{
var temp;
var len;
var i;
temp = s;
len = temp.length;
for(i=0 ; i<len ; i++)
{
	if(temp.indexOf(" ") == 0) 
	{
		//去掉前段的一个空格
		temp = temp.substring(1,temp.length);
	}//if
	else
	{
		break;
	}//if
}//for

len = temp.length;
for(i=len ; i>0 ; i--)
{
	if(temp.lastIndexOf(" ") == temp.length - 1 )
	{
		//去掉最后的空格
		temp = temp.substring(0,temp.length - 1);
	}//if
	else
	{
		break;
	}//if
}//for
return temp; 
}//function


function CheckEmail(s)
{
var temp;
var len;
var pos1,pos2,pos3,pos4;
temp = s;
temp = MyTrim(temp);
len = temp.length;
if(len == 0)
{
window.alert("电子邮件不能为空!");
return false;
}//if

if(len > 400 )
{
alert("电子邮件过长!");
return false;
}//if


pos1 = temp.indexOf("@");
pos2 = temp.lastIndexOf("@");
if (pos1 != pos2)
{
	alert("电子邮件地址只能有一个@字符!");
	return false;
}//if

if (pos1 == 0)
{
	alert("电子邮件的地址不能以@字符开头!");
	return false;
}//if

if (pos1 == -1)
{
	alert("无效的电子邮件地址!");
	return false;
}//if
pos3 = temp.indexOf("@.");
pos4 = temp.indexOf(".@");
//alert(pos3);
if (pos3 != -1 )
{
	alert("电子邮件非法!");
	return false;
}//if
if (pos4 != -1 )
{
	alert("电子邮件非法!");
	return false;
}//if

pos3 = temp.indexOf(".");
if(pos3 == -1 || pos3 == temp.length - 1)
{
	alert("电子邮件非法!");
	return false;
}//if

return true;
}//function
//document.write("test");
//CheckEmail(" fgdfg@cde.u");

function isValidInt(s)
{
var temp;
s = MyTrim(s);
temp = Number(s);

if ((Math.ceil(temp) - temp) == 0)
	{
	return true;
	}
else
	{
	return false;
	}
}//function
