 var ChangePwd=new function(){

	this.init = function(){
		$("#oldpassword").blur(function(){
			ChangePwd.check_oldpassword();
		});

		$("#newpassword").blur(function(){
			ChangePwd.check_newpassword();
		});

		$("#newpasswordr").blur(function(){
			ChangePwd.check_newpasswordr();
		});

	};

	this.check_oldpassword = function(){
		return ChangePwd.oldPasswordCheck("oldpassword");
	};

	this.check_newpassword = function(){
		return ChangePwd.newPasswordCheck("newpassword");
	};

	this.check_newpasswordr = function(){
		return ChangePwd.newPasswordrCheck("newpassword");
	};


	this.oldPasswordCheck = function(name){
		var _name = $("#"+name).val();
		
		if($.trim(_name) == '' ||_name.indexOf(" ")>0 || _name.replace(/[ ]/g,"")==''){
			$("#oldpwdtips").addClass("error");
			$("#oldpwdtips").html("请输入旧密码");
			return false;
		}else{
			$("#oldpwdtips").removeClass("error");
			return true;
		}
	};


	this.newPasswordCheck = function(name){
		var _name = $("#"+name).val();
		
		var cat = /^[\x20-\x7f]+$/;
		
		if($.trim(_name) == '' || _name.length<6 || _name.length>15 || _name.replace(/[ ]/g,"")==''){
			$("#newpwdtips").addClass("error");
			$("#newpwdtips").html("请输入6-15位密码");
			return false;
		}else{
			$("#newpwdtips").removeClass("error");
		}

		return true;
	};
	
	this.newPasswordrCheck = function(name){
		
		if(!$("#"+name).val()){return false;}
		var _name = $("#"+name).val();
		var _newname = $("#"+name+"r").val();
		if(!($.trim(_name)==$.trim(_newname))){
			$("#newpwdrtips").addClass("error");
			$("#newpwdrtips").html("与创建的密码不一致");
			return false;
		}else{
			$("#newpwdrtips").removeClass("error");
		}

		return true;
	};

	this.checkAndSub = function(){
		
		if(!ChangePwd.check_oldpassword()){
			return false;
		}
		if(!ChangePwd.check_newpassword()){
			return false;
		}
		if(!ChangePwd.check_newpasswordr()){
			return false;
		}
		
		return true;
		
	};
	
};



