$(document).ready(function(){
	var tbOldPwd=$("#tbOldPwd");
	var tbNewPwd=$("#tbNewPwd");
	var tbNewPwd2=$("#tbNewPwd2");
	
	var spanOldPwd=$("#spanOldPwd");
	var spanNewPwd=$("#spanNewPwd");
	var spanNewPwd2=$("#spanNewPwd2");
	
	var btnOk=$("#btnOk");	
	///////////////////////////////////////
	tbOldPwd.keyup(function(){
		var tbOldPwdVal=tbOldPwd.val();
		if(tbOldPwdVal!="")
		{
			tbOldPwd.removeClass();
			tbOldPwd.addClass("tskInputBox");	
		}
	});
	
	tbOldPwd.blur(function(){
		var tbOldPwdVal=tbOldPwd.val();
		if(tbOldPwdVal!="")
		{
			if(tbOldPwdVal.length<6||tbOldPwdVal.length>16)
			{
				tbOldPwd.addClass("tskInputError");
				spanOldPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码长度为6-16位！</font>");				
			}
			else
			{				
				tbOldPwd.removeClass();
				tbOldPwd.addClass("tskInputBox");	
				spanOldPwd.html("");	
			}
		}
		else
		{
			tbOldPwd.addClass("tskInputError");
			spanOldPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码不能为空！</font>");
		}		
	});
	
	///////////////////////////////////////
	tbNewPwd.keyup(function(){
		var tbNewPwdVal=tbNewPwd.val();
		if(tbNewPwdVal!="")
		{
			tbNewPwd.removeClass();
			tbNewPwd.addClass("tskInputBox");	
		}
	});
	
	tbNewPwd.blur(function(){
		var tbNewPwdVal=tbNewPwd.val();
		if(tbNewPwdVal!="")
		{
			if(tbNewPwdVal.length<6||tbNewPwdVal.length>16)
			{
				tbNewPwd.addClass("tskInputError");
				spanNewPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码长度为6-16位！</font>");				
			}
			else
			{				
				tbNewPwd.removeClass();
				tbNewPwd.addClass("tskInputBox");	
				spanNewPwd.html("");	
			}
		}
		else
		{
			tbNewPwd.addClass("tskInputError");
			spanNewPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码不能为空！</font>");
		}		
	});
	
	///////////////////////////////////////
	tbNewPwd2.keyup(function(){
		var tbNewPwd2Val=tbNewPwd2.val();
		if(tbNewPwd2Val!="")
		{
			tbNewPwd2.removeClass();
			tbNewPwd2.addClass("tskInputBox");	
		}
	});
	
	tbNewPwd2.blur(function(){
		var tbNewPwd2Val=tbNewPwd2.val();
		if(tbNewPwd2Val!="")
		{
			if(tbNewPwd2Val.length<6||tbNewPwd2Val.length>16)
			{
				tbNewPwd2.addClass("tskInputError");
				spanNewPwd2.html("<font color='red'><img src='/templates/images/err.gif' /> 密码长度为6-16位！</font>");				
			}
			else
			{
				var tbNewPwdVal=tbNewPwd.val();
				if(tbNewPwdVal!=tbNewPwd2Val)
				{
					tbNewPwd2.addClass("tskInputError");
					spanNewPwd2.html("<font color='red'><img src='/templates/images/err.gif' /> 两次输入的密码不一致！</font>");
				}
				else
				{
					tbNewPwd2.removeClass();
					tbNewPwd2.addClass("tskInputBox");	
					spanNewPwd2.html("");	
				}
			}
		}
		else
		{
			tbNewPwd2.addClass("tskInputError");
			spanNewPwd2.html("<font color='red'><img src='/templates/images/err.gif' /> 密码不能为空！</font>");
		}		
	});
	
	
	//////++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	btnOk.click(function(){
		var tbOldPwdVal=tbOldPwd.val();
		if(tbOldPwdVal!="")
		{
			if(tbOldPwdVal.length<6||tbOldPwdVal.length>16)
			{
				tbOldPwd.addClass("tskInputError");
				spanOldPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码长度为6-16位！</font>");	
				return false;
			}
		}
		else
		{
			tbOldPwd.addClass("tskInputError");
			spanOldPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码不能为空！</font>");
			return false;
		}
		
		var tbNewPwdVal=tbNewPwd.val();
		if(tbNewPwdVal!="")
		{
			if(tbNewPwdVal.length<6||tbNewPwdVal.length>16)
			{
				tbNewPwd.addClass("tskInputError");
				spanNewPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码长度为6-16位！</font>");	
				return false;			
			}			
		}
		else
		{
			tbNewPwd.addClass("tskInputError");
			spanNewPwd.html("<font color='red'><img src='/templates/images/err.gif' /> 密码不能为空！</font>");
			return false;
		}		
		
		var tbNewPwd2Val=tbNewPwd2.val();
		if(tbNewPwd2Val!="")
		{
			if(tbNewPwd2Val.length<6||tbNewPwd2Val.length>16)
			{
				tbNewPwd2.addClass("tskInputError");
				spanNewPwd2.html("<font color='red'><img src='/templates/images/err.gif' /> 密码长度为6-16位！</font>");	
				return false;			
			}
			else
			{
				if(tbNewPwdVal!=tbNewPwd2Val)
				{
					tbNewPwd2.addClass("tskInputError");
					spanNewPwd2.html("<font color='red'><img src='/templates/images/err.gif' /> 两次输入的密码不一致！</font>");
					return false;
				}				
			}
		}
		else
		{
			tbNewPwd2.addClass("tskInputError");
			spanNewPwd2.html("<font color='red'><img src='/templates/images/err.gif' /> 密码不能为空！</font>");
			return false;
		}		
	
	});
});