function checkValue(vInput)
{
	if (vInput.name == 'username' || vInput.name == 'bindingaccount')
	{
		if(vInput.value.strLength() < 6 )
		{
			alert(vLoginNotice['username'][2]);
			vInput.focus();
			return false;
		}
		if (vInput.value.isEmail())
		{
			return true;
		} else {
			alert(vLoginNotice['username'][1]);
			vInput.focus();
			return false;
		}
	}
	
	
	if (vInput.name == 'oldpwd')
	{
		if (vInput.value.isPassword())
		{
			return true;
		} else {
			alert(vChangePwd['passwd_length_not_enough']);
			vInput.focus();
			return false;
		}
		return true;
	}
	
	if (vInput.name == 'password')
	{
		if (vInput.value.isPassword())
		{
			return true;
		} else {
			alert(vChangePwd['passwd_length_not_enough']);
			vInput.focus();
			return false;
		}
	}
	
	if (vInput.name == 'repassword')
	{
		if (vInput.value.isPassword() && vInput.value == vInput.form.elements['password'].value)
		{
			return true;
		} else {
			alert(vChangePwd['both_passwd_not_same']);
			vInput.focus();
			return false;
		}
	}
	
	if (vInput.type == 'file')
	{
		if (vInput.value.strLength() < 5 || vInput.value.strLength() > 100 || 
			(vInput.value.substr(vInput.value.length - 4, 4).toLowerCase() != '.gif' && 
			vInput.value.substr(vInput.value.length - 4, 4).toLowerCase() != '.jpg' && 
			vInput.value.substr(vInput.value.length - 5, 5).toLowerCase() != '.jpeg'))
		{
			alert(vAuthId['no_pic']);
			vInput.focus();
			return false;
		} else {
			return true;
		}
	}	
}


function checkLogin(vForm)
{
	if (vForm.elements['username'].value.trim() == '')
	{
		alert(vLoginNotice['username'][0]);
		vForm.elements['username'].focus();
		return false;
	}
		
	if (!vForm.elements['username'].value.isEmail())
	{
		alert(vLoginNotice['username'][1]);
		vForm.elements['username'].focus();
		return false;
	}

	if (vForm.elements['password'].value=='')
	{
		alert(vLoginNotice['password']);
		vForm.elements['password'].focus();
		return false;
	}
	
	return true;
}

//检查FORM里对应的元素
function checkForm(vForm, vInputs)
{
	for (vKey in vInputs)
	{
		if (vForm.elements[vInputs[vKey]] != undefined)
		{
			vResult = checkValue(vForm.elements[vInputs[vKey]]);
			if (!vResult) return false;
		}
	}
	return true;
}

// 修改密码功能函数
function checkChangePwd(vForm)
{
	var vInputs = ['oldpwd', 'password', 'repassword'];
	return checkForm(vForm, vInputs);
}

//忘记密码检查提交
function checkGetPwd(vForm)
{
	var vInputs = ['username'];
	return checkForm(vForm, vInputs);
}

//密码重置
function checkResetPwd(vForm)
{
	var vInputs = ['password', 'repassword'];
	return checkForm(vForm, vInputs);
}

//身份认证检测
function checkIdentityAuth(vForm)
{
	if($('creditcardno').value=='')
	{
		alert(vAuthId['no_card_num']);
		return false;
	}
	var vInputs = ['picture'];
	return checkForm(vForm, vInputs);
}

//绑定账号检查
function checkBindingAccount(vForm)
{
	var vInputs = ['bindingaccount', 'password', 'repassword'];
	if(checkForm(vForm, vInputs))
	{
		if(!vForm.elements['agree'].checked)
		{
			alert(vBdAccount['no_agree']);
			return false;
		}	
		return true;
	}else{
		return false;	
	}
}

function checkChangeBdAccountPass(vForm)
{
	var vInputs = ['password', 'repassword'];
	return checkForm(vForm, vInputs);	
}
