//检查姓名
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", "* 请填写姓名");		
		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", "* 请填写密码");		
		return false;		
	}
	if( !(Validator.ValidatePassWord(pwd.value, true)) )	//判断是否有效
	{
		changemsgcolor(pwd, "input-erro", "");
		changemsgcolor(spanpwd, "font-erro", "* 密码格式不正确");
		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", "* 请保持密码一致"); 	
	   	
		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", "* 请填写邮编");		
		return false;		
	}
	if( !(Validator.ValidateZip(code.value, true)) )	//判断是否有效
	{
		changemsgcolor(code, "input-erro", "");
		changemsgcolor(spancode, "font-erro", "* 请填写正确邮编");
		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", "* 请填写联系地址");
		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", "* 请填写固定电话");		
		telphoneok1=false;
		if(id==2){
		telphoneok2=false;}
		return false;	
	}
	if( tel.value.length > 13 )
	{
		changemsgcolor(tel, "input-erro", "");
		changemsgcolor(spantel, "font-erro", "* 请输入正确的电话");
		telphoneok1=false;
		if(id==2){
		telphoneok2=false;}
		return false;
	}
	if( !(Validator.ValidatePhone(tel.value, true)) )	//判断是否有效
	{
		changemsgcolor(tel, "input-erro", "");
		changemsgcolor(spantel, "font-erro", "* 电话格式错误");
		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", "* 请输入您的手机号码");
		mobileok1=false;
		if(id==2){
		mobileok2=false;}
		return false;			   		
	}
	if( mobile.value.length > 11 )
	{
		changemsgcolor(mobile, "input-erro", "");
		changemsgcolor(spanmobile, "font-erro", "* 手机号码最多11个数字");
		mobileok1=false;
		if(id==2){
		mobileok2=false;}
		return false;
	}
	if( !(Validator.ValidateMobile(mobile.value, true)) )	//判断是否有效
	{
		changemsgcolor(mobile, "input-erro", "");
		changemsgcolor(spanmobile, "font-erro", "* 手机号码格式错误");
		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", "* 请填写E-mail地址");
		emailok1=false;
		if(id==2){
		emailok2=false;}
		return false;			   		
	}
	if( email.value.length > 40 )
	{
		changemsgcolor(email, "input-erro", "");
		changemsgcolor(spanemail, "font-erro", "* E-mail地址最多40個字");
		emailok1=false;
		if(id==2){
		emailok2=false;}
		return false;
	}
	if( !(Validator.ValidateEmail(email.value, true)) )	//判断是否有效
	{
		changemsgcolor(email, "input-erro", "");
		changemsgcolor(spanemail, "font-erro", "* E-mail地址格式错误");
		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;
	}
}