//检查姓名
function checkusername(id){	
   // alert(id)
	var username = document.getElementById("username"+id);		
	var spanusername = document.getElementById("spanusername"+id);	
	changemsgcolor(username, "input-box", "" );
	changemsgcolor(spanusername, "font-000", "√" );
	if( username.value == "" || username.value.length == 0 )
	{
		changemsgcolor(username, "input-erro", "");
		changemsgcolor(spanusername, "font-erro", "* Please Enter your name");		
		return false;		
	}
	//alert(id)
	return true;
}
//检查密码
function checkpwd(id){	
   // alert(id)
	var pwd = document.getElementById("pwd"+id);
	var pwdd = document.getElementById("pwd"+1);
	var spanpwd = document.getElementById("spanpwd"+id);
	//alert(pwd.value)
	//alert(pwdd.value)
	changemsgcolor(pwd, "input-box", "" );
	changemsgcolor(spanpwd, "font-000", "√" );
	if( pwd.value == "" || pwd.value.length == 0 )
	{
		changemsgcolor(pwd, "input-erro", "");
		changemsgcolor(spanpwd, "font-erro", "* Please Enter Password");		
		return false;		
	}
	if( !(Validator.ValidatePassWord(pwd.value, true)) )	//判断是否有效
	{
		changemsgcolor(pwd, "input-erro", "");
		changemsgcolor(spanpwd, "font-erro", "* Please Enter Right Password");
		return false;
	}//pwd=false;
	if(id==2)
	 {//alert(pwd.value);
	//alert(pwdd.value);
	  	if (pwd.value!= pwdd.value)		
		{
		changemsgcolor(pwd, "input-erro", "");
		changemsgcolor(spanpwd, "font-erro", "* Please Enter Right Password"); 	
	   	
		return false;
	 } }
	return true;
	
}
function checkcode(){	
   // alert(id)
	var code = document.getElementById("code");
	var spancode = document.getElementById("spancode");
	changemsgcolor(code, "input-box", "" );
	changemsgcolor(spancode, "font-000", "√" );
	if( code.value == "" || code.value.length == 0 )
	{
		changemsgcolor(code, "input-erro", "");
		changemsgcolor(spancode, "font-erro", "* Please Enter Code");		
		return false;		
	}
	
	return true;
}
//检查地址
function checkaddress(id){	
	var address = document.getElementById("address"+id);		
	var spanaddress = document.getElementById("spanaddress"+id);	
	changemsgcolor(address, "input-box", "" );
	changemsgcolor(spanaddress, "font-000", "√" );
	if( address.value == "" || address.value.length == 0 )
	{
		changemsgcolor(address, "input-erro", "");
		changemsgcolor(spanaddress, "font-erro", "* Please Enter Address");
		return false;		
	}
	return true;
}
//检查电话号码
function checktelphone(id)
{   
	var tel = document.getElementById("tel"+id);			
	var spantel = document.getElementById("spantel"+id);
	changemsgcolor(tel, "input-box", "" );
	changemsgcolor(spantel, "font-000", "√" );
	if( tel.value == "" || tel.value.length == 0 )	
	{
		changemsgcolor(tel, "input-erro", "");
		changemsgcolor(spantel, "font-erro", "* Please Enter Telephone");		
		telphoneok1=false;
		if(id==2){
		telphoneok2=false;}
		return false;	
	}
	
	changemsgcolor(tel, "input-box", "");
	changemsgcolor(spantel, "font-000", "");
	telphoneok1 = true;
	if(id==2){
	telphoneok2 = true;}
	getAjax("tel",tel.value,id);
}
//检查手机号码
function checkmobile(id)
{   
	var mobile = document.getElementById("mobile"+id);			
	var spanmobile = document.getElementById("spanmobile"+id);
	changemsgcolor(mobile, "input-box", "" );
	changemsgcolor(spanmobile, "font-000", "√" );
	if( mobile.value == "" || mobile.value.length == 0 )	
	{
		changemsgcolor(mobile, "input-erro", "");
		changemsgcolor(spanmobile, "font-erro", "* Please Enter Mobile");
		mobileok1=false;
		if(id==2){
		mobileok2=false;}
		return false;			   		
	}
	
	changemsgcolor(mobile, "input-box", "");
	changemsgcolor(spanmobile, "font-000", "");
	mobileok1=true;
	if(id==2){
	mobileok2=true;}
	getAjax("mobile",mobile.value,id);
}
//检查EMAIL
function checkemail(id)
{   
	var email = document.getElementById("email"+id);			
	var spanemail = document.getElementById("spanemail"+id);
	changemsgcolor(email, "input-box", "" );
	changemsgcolor(spanemail, "font-000", "√" );
	if( email.value == "" || email.value.length == 0 )	//判断email是否为空
	{
		changemsgcolor(email, "input-erro", "");
		changemsgcolor(spanemail, "font-erro", "* Please Enter Right Email");
		emailok1=false;
		if(id==2){
		emailok2=false;}
		return false;			   		
	}
	if( email.value.length > 40 )
	{
		changemsgcolor(email, "input-erro", "");
		changemsgcolor(spanemail, "font-erro", "* Please Enter Right Email");
		emailok1=false;
		if(id==2){
		emailok2=false;}
		return false;
	}
	if( !(Validator.ValidateEmail(email.value, true)) )	//判断是否有效
	{
		changemsgcolor(email, "input-erro", "");
		changemsgcolor(spanemail, "font-erro", "* Please Enter Right Email");
		emailok1=false;
		if(id==2){
		emailok2=false;}
		return false;
	}
	changemsgcolor(email, "input-box", "");
	changemsgcolor(spanemail, "font-000", "");
	emailok1 = true;
	if(id==2){
	emailok2 = true;}
	getAjax("email",email.value,id);
}
//检查协议
function checkorderme()
{
	var orderme = document.getElementById("orderme");
	var spanorderme = document.getElementById("spanorderme");
	if( orderme.checked != true )	//判断协议是否已经被阅读
	{
		changemsgcolor(spanorderme, "font-erro", "请填写收件者资料");
		return false;
	}
	return true;
}
//修改提示颜色，并修改提示信息
function changemsgcolor( obj, classname, msg )
{
	if( obj != null )
	{
		obj.className = classname;
		if( msg != "" || msg.length != 0 )
			obj.innerText = msg;
	}
}
