// 普通信息发布，表单验证　
function CheckIssueNormalForm( HaveVerifyCode )
{
	TitleEmptyError.style.display = "none";
	DetailEmptyError.style.display = "none";
	EmailFormatError.style.display = "none";
	EmailEmptyError.style.display = "none";

	MSNFormatError.style.display = "none";
	PhoneEmptyError.style.display = "none";
	AreaNOFormatError.style.display = "none";
	PhoneNOFormatError.style.display = "none";
	MobileFormatError.style.display = "none";

	// 验证标题
	if ( titleObj.value == "" )
	{
		TitleEmptyError.style.display = "";
		titleObj.focus();
		return false;
	}

	// 验证描述
	if ( detailObj.value == "" )
	{
		DetailEmptyError.style.display = "";
		detailObj.focus();
		return false;
	}

	// 验证Email
	if ( emailObj.value == "" )
	{
		EmailFormatError.style.display = "none";
		EmailEmptyError.style.display = "";
		emailObj.focus();
		return false;
	}

	// 验证Email
	if ( !CheckEmail( emailObj.value ) )
	{
		EmailEmptyError.style.display = "none";
		EmailFormatError.style.display = "";
		emailObj.focus();
		return false;
	}

	// 验证MSN
	if ( msnObj.value != "" )
	{
		if ( !CheckEmail( msnObj.value ) )
		{
			MSNFormatError.style.display = "";
			msnObj.focus();
			return false;
		}
	}

	// 验证电话区号
//	if ( phoneAreaObj.value != "" )
//	{
//		if ( !CheckAreaNo( phoneAreaObj.value ) )
//		{
//			AreaNOFormatError.style.display = "";
//			PhoneEmptyError.style.display = "none";
//			PhoneNOFormatError.style.display = "none";
//			phoneAreaObj.focus();
//			return false;
//		}
//	}

	// 电话区号为空
//	if ( phoneAreaObj.value == "" && phoneObj.value != "" )	
//	{
//		AreaNOFormatError.style.display = "";
//		PhoneEmptyError.style.display = "none";
//		PhoneNOFormatError.style.display = "none";
//		phoneObj.focus();
//		return false;
//	}

	// 验证电话号码
	if ( phoneObj.value != "" )
	{
		if ( !CheckPhoneNo( phoneObj.value ) )
		{
			AreaNOFormatError.style.display = "none";
			PhoneEmptyError.style.display = "none";
			PhoneNOFormatError.style.display = "";
			phoneObj.focus();
			return false;
		}
	}

	// 验证手机号码
	if ( mobileObj.value != "" )
	{
		if ( !CheckMobileNo( mobileObj.value ) )
		{
			MobileFormatError.style.display = "";
			mobileObj.focus();
			return false;
		}
	}
	
	// 电话号码和手机号码都为空
	if ( mobileObj.value == "" && phoneObj.value == "" )
	{
		AreaNOFormatError.style.display = "none";
		PhoneEmptyError.style.display = "";
		PhoneNOFormatError.style.display = "none";
		phoneObj.focus();
		return false;
	}

	if ( HaveVerifyCode == 'True' )
		// 验证码验证
		return CheckVerifyCode();

	return true;
}

// 房租信息发布，表单验证　
function CheckIssueHouseForm( HaveVerifyCode )
{
	TitleEmptyError.style.display = "none";
	UseAcreageError.style.display = "none";
	MonthHireError.style.display = "none";
	DetailEmptyError.style.display = "none";
	EmailFormatError.style.display = "none";
	EmailEmptyError.style.display = "none";

	MSNFormatError.style.display = "none";
	PhoneEmptyError.style.display = "none";
	AreaNOFormatError.style.display = "none";
	PhoneNOFormatError.style.display = "none";
	MobileFormatError.style.display = "none";

	if ( titleObj.value == "" )
	{
		TitleEmptyError.style.display = "";
		titleObj.focus();
		return false;
	}
	
	if ( useAcreageObj.value != "" )
	{
		if ( !isNumber(useAcreageObj.value) )
		{
			UseAcreageError.style.display = "";
			useAcreageObj.focus();
			return false;
		}
	}
	
	if( monthHireObj.value != "" )
	{
		if ( !isNumber(monthHireObj.value) )
		{
			MonthHireError.style.display = "";
			monthHireObj.focus();
			return false;
		}
	}
	
	if ( detailObj.value == "" )
	{
		DetailEmptyError.style.display = "";
		detailObj.focus();
		return false;
	}
	
	if ( emailObj.value == "" )
	{
		EmailFormatError.style.display = "none";
		EmailEmptyError.style.display = "";
		emailObj.focus();
		return false;
	}
	
	if ( !CheckEmail( emailObj.value ) )
	{
		EmailEmptyError.style.display = "none";
		EmailFormatError.style.display = "";
		emailObj.focus();
		return false;
	}
	

	// 验证电话区号
//	if ( phoneAreaObj.value != "" )
//	{
//		if ( !CheckAreaNo( phoneAreaObj.value ) )
//		{
//			AreaNOFormatError.style.display = "";
//			PhoneEmptyError.style.display = "none";
//			PhoneNOFormatError.style.display = "none";
//			phoneAreaObj.focus();
//			return false;
//		}
//	}

	// 电话区号为空
//	if ( phoneAreaObj.value == "" && phoneObj.value != "" )	
//	{
//		AreaNOFormatError.style.display = "";
//		PhoneEmptyError.style.display = "none";
//		PhoneNOFormatError.style.display = "none";
//		phoneObj.focus();
//		return false;
//	}
	
	// 验证电话号码
	if ( phoneObj.value != "" )
	{
		if ( !CheckPhoneNo( phoneObj.value ) )
		{
			AreaNOFormatError.style.display = "none";
			PhoneEmptyError.style.display = "none";
			PhoneNOFormatError.style.display = "";
			phoneObj.focus();
			return false;
		}
	}

	// 验证手机号码
	if ( mobileObj.value != "" )
	{
		if ( !CheckMobileNo( mobileObj.value ) )
		{
			MobileFormatError.style.display = "";
			mobileObj.focus();
			return false;
		}
	}
	
	// 电话号码和手机号码都为空
	if ( mobileObj.value == "" && phoneObj.value == "" )
	{
		AreaNOFormatError.style.display = "none";
		PhoneEmptyError.style.display = "";
		PhoneNOFormatError.style.display = "none";
		phoneObj.focus();
		return false;
	}
	
	if ( HaveVerifyCode == 'True' )
		// 验证码验证
		return CheckVerifyCode();

	return true;
}

// 买卖信息发布，表单验证　
function CheckIssueBusinessForm( HaveVerifyCode )
{
	TitleEmptyError.style.display = "none";
	PriceError.style.display = "none";
	AmountError.style.display = "none";
	EmailFormatError.style.display = "none";
	EmailEmptyError.style.display = "none";

	MSNFormatError.style.display = "none";
	PhoneEmptyError.style.display = "none";
	AreaNOFormatError.style.display = "none";
	PhoneNOFormatError.style.display = "none";
	MobileFormatError.style.display = "none";

	if ( titleObj.value == "" )
	{
		TitleEmptyError.style.display = "";
		titleObj.focus();
		return false;
	}
	
	if ( priceObj.value != "" )
	{
		if ( !isNumber(priceObj.value) )
		{
			PriceError.style.display = "";
			priceObj.focus();
			return false;
		}
	}
	
	if( amountObj.value != "" )
	{
		if ( !isNumber(amountObj.value) )
		{
			AmountError.style.display = "";
			amountObj.focus();
			return false;
		}
	}
	
	if ( detailObj.value == "" )
	{
		DetailEmptyError.style.display = "";
		detailObj.focus();
		return false;
	}
	
	if ( emailObj.value == "" )
	{
		EmailFormatError.style.display = "none";
		EmailEmptyError.style.display = "";
		emailObj.focus();
		return false;
	}
	
	if ( !CheckEmail( emailObj.value ) )
	{
		EmailEmptyError.style.display = "none";
		EmailFormatError.style.display = "";
		emailObj.focus();
		return false;
	}
	

	// 验证电话区号
//	if ( phoneAreaObj.value != "" )
//	{
//		if ( !CheckAreaNo( phoneAreaObj.value ) )
//		{
//			AreaNOFormatError.style.display = "";
//			PhoneEmptyError.style.display = "none";
//			PhoneNOFormatError.style.display = "none";
//			phoneAreaObj.focus();
//			return false;
//		}
//	}

	// 电话区号为空
//	if ( phoneAreaObj.value == "" && phoneObj.value != "" )	
//	{
//		AreaNOFormatError.style.display = "";
//		PhoneEmptyError.style.display = "none";
//		PhoneNOFormatError.style.display = "none";
//		phoneObj.focus();
//		return false;
//	}
	
	// 验证电话号码
	if ( phoneObj.value != "" )
	{
		if ( !CheckPhoneNo( phoneObj.value ) )
		{
			AreaNOFormatError.style.display = "none";
			PhoneEmptyError.style.display = "none";
			PhoneNOFormatError.style.display = "";
			phoneObj.focus();
			return false;
		}
	}

	// 验证手机号码
	if ( mobileObj.value != "" )
	{
		if ( !CheckMobileNo( mobileObj.value ) )
		{
			MobileFormatError.style.display = "";
			mobileObj.focus();
			return false;
		}
	}
	
	// 电话号码和手机号码都为空
	if ( mobileObj.value == "" && phoneObj.value == "" )
	{
		AreaNOFormatError.style.display = "none";
		PhoneEmptyError.style.display = "";
		PhoneNOFormatError.style.display = "none";
		phoneObj.focus();
		return false;
	}
	
	if ( HaveVerifyCode == 'True' )
		// 验证码验证
		return CheckVerifyCode();

	return true;
}


// 信息发布，用户确认表单验证
function CheckIssueUserConfirm()
{
	document.all.UserAccountEmptyError.style.display = "none";
	document.all.UserAccountFormatError.style.display = "none";
	document.all.UserPassWordEmptyError.style.display = "none";
	if ( document.all.UserAccount.value == "" )
	{
		document.all.UserAccountEmptyError.style.display = "";
		document.all.UserAccount.focus();
		return false;
	}

	if ( !CheckStr( document.all.UserAccount.value ) )
	{
		document.all.UserAccountFormatError.style.display = "";
		document.all.UserAccount.focus();
		return false;
	}
	
	if ( document.all.UserPassWord.value == "" )
	{
		document.all.UserPassWordEmptyError.style.display = "";
		document.all.UserPassWord.focus();
		return false;
	}
	
	return true;
}

// 用户注册表单，表单验证　
function CheckRegister( HaveVerifyCode )
{
	UserAccountEmptyError.style.display = "none";
	UserAccountFormatError.style.display = "none";
	PassWordEmptyError.style.display = "none";
	PassWord1EmptyError.style.display = "none";
	PassWordNotMatchingError.style.display = "none";
	EMailEmptyError.style.display = "none";
	EMailFormatError.style.display = "none";

	if ( userAccountObj.value == "" )
	{
		UserAccountEmptyError.style.display = "";
		userAccountObj.focus();
		return false;
	}
	
	if ( !CheckStr( userAccountObj.value ) )
	{
		UserAccountFormatError.style.display = "";
		userAccountObj.focus();
		return false;
	}
	
	if ( passWordObj.value == "" )
	{
		PassWordEmptyError.style.display = "";
		passWordObj.focus();
		return false;
	}
	
	if ( passWord1Obj.value == "" )
	{
		PassWord1EmptyError.style.display = "";
		passWord1Obj.focus();
		return false;
	}
	
	if ( passWordObj.value != passWord1Obj.value )
	{
		PassWordNotMatchingError.style.display = "";
		passWordObj.focus();
		return false;
	}

	if ( emailObj.value == "" )
	{
		EMailFormatError.style.display = "none";
		EMailEmptyError.style.display = "";
		emailObj.focus();
		return false;
	}

	if ( !CheckEmail( emailObj.value ) )
	{
		EMailEmptyError.style.display = "none";
		EMailFormatError.style.display = "";
		emailObj.focus();
		return false;
	}

	if ( HaveVerifyCode == 'True' )
		// 验证码验证
		return CheckVerifyCode();

	return true;
}

// 用户登录表单验证
function CheckLogin( HaveVerifyCode )
{
	UserAccountEmptyError.style.display = "none";
	PassWordEmptyError.style.display = "none";
	
	if ( userAccountObj.value == "" )
	{
		UserAccountEmptyError.style.display = "";
		userAccountObj.focus();
		return false;
	}

	if ( passWordObj.value == "" )
	{
		PassWordEmptyError.style.display = "";
		passWordObj.focus();
		return false;
	}

	if ( HaveVerifyCode == 'True' )
		// 验证码验证
		return CheckVerifyCode();

	return true;
}

// 验证验证码
function CheckVerifyCode()
{
	VerifyCodeEmptyError.style.display = "none";
	VerifyCodePrompt.style.display = "none";
	VerifyCodeError.style.display = "none";

	var pageVerifyCode = Go007.Components.Ajax.AjaxVerifyCode.GetCurrentVerifyCode().value;
	// 页面验证码已失效
	if ( pageVerifyCode == "" )
	{
		VerifyCodeEmptyError.style.display = "none";
		VerifyCodePrompt.style.display = "";
		VerifyCodeError.style.display = "none";
		document.all.VerifyCodeImage.src='/Components/MakeCode.aspx?'+Math.random();
		verifyCodeObj.focus();
		return false;
	}

	if ( verifyCodeObj.value == "" )
	{
		VerifyCodeEmptyError.style.display = "";
		VerifyCodePrompt.style.display = "none";
		VerifyCodeError.style.display = "none";
		verifyCodeObj.focus();
		return false;
	}

	if ( pageVerifyCode != verifyCodeObj.value )
	{
		VerifyCodeEmptyError.style.display = "none";
		VerifyCodePrompt.style.display = "none";
		VerifyCodeError.style.display = "";
		verifyCodeObj.focus();
		return false;
	}
	return true;
}

/*=============================================分类信息页面表单验证=============================================*/
// 联系发布人
function CheckContentLinkMan()
{
	document.all.EmailEmptyError.style.display = "none";
	document.all.EmailFormatError.style.display = "none";
	document.all.NameEmptyError.style.display = "none";
	document.all.ContentEmptyError.style.display = "none";
	if ( contactEmail.value == "" )
	{
		document.all.EmailEmptyError.style.display = "";
		contactEmail.focus();
		return false;
	}
	
	if ( !CheckEmail( contactEmail.value ) )
	{
		document.all.EmailFormatError.style.display = "";
		contactEmail.focus();
		return false;
	}

	if ( contactName.value == "" )
	{
		document.all.NameEmptyError.style.display = "";
		contactName.focus();
		return false;
	}

	if ( contactContent.value == "" )
	{
		document.all.ContentEmptyError.style.display = "";
		contactContent.focus();
		return false;
	}
	
	return true;
}

// 发布评论
function CheckPostComment()
{
	
	if ( commentNickName.value == "" )
	{
		alert("请填写您的姓名！");
		commentNickName.focus();
		return false;
	}

	if ( commentContent.value == "" )
	{
		alert("请填写您的评论内容！");
		commentContent.focus();
		return false;
	}
if ( commentValiCode.value == "" )
	{
		alert("请填写验证码！");
		commentValiCode.focus();
		return false;
	}
	return true;
}

// 推荐给朋友
function CheckRecommendFriend()
{
	document.all.InceptEmailEmptyError.style.display = "none";
	document.all.InceptEmailFormatError.style.display = "none";

	if ( commentInceptEmail.value == "" )
	{
		document.all.InceptEmailEmptyError.style.display = "";
		commentInceptEmail.focus();
		return false;
	}
	
	if ( !CheckEmail( commentInceptEmail.value ) )
	{
		document.all.EmailFormatError.style.display = "";
		InceptEmailFormatError.focus();
		return false;
	}
	return true;
}
/*===========================================分类信息页面表单验证结束===========================================*/

/*验证区号*/
function CheckAreaNo(s)
{
   var reg = "^[0-9]{3,4}$";
   var re = new RegExp(reg);
   if(s.search(re) != -1)
       return true;
   else
       return false;	
}

/*验证电话号码*/
function CheckPhoneNo(s)
{
	return isNumber(s);
//   var reg = "^[0-9]{7,8}$";
//   var re = new RegExp(reg);
//   if(s.search(re) != -1)
//       return true;
//   else
//       return false;
}

/*验证手机号码*/
function CheckMobileNo(s)
{
	return isNumber(s);
//   var reg = "/^[0-9]{11}$/";
//   var re = new RegExp(reg);
//   if(s.search(re) != -1)
//       return true;
//   else
//       return false;	
}

/*验证是否是字母跟数字*/
function CheckStr(s)
{
   var reg = "^([a-zA-Z-_0-9@.]+)$";
   var re = new RegExp(reg);
   if(s.search(re) != -1)
       return true;
   else
       return false;
}

/*验证字符是否为数字*/
function isNumber(num)
{
	var Letters = "1234567890"; 
	var i; 
	var c; 
	for( i = 0; i < num.length; i ++ ) 
	{ 
		c = num.charAt( i ); 
		if (Letters.indexOf( c ) ==-1) 
			return false;
	}
	return true; 
}