 var Register=new function(){

	/** 注册第一步  start */

	this.init = function(){

		$("#reg_username").blur(function(){
			Register.check_loginName();
		});

		$("#reg_password").blur(function(){
			Register.check_password();
		});

		$("#reg_password2").blur(function(){
			Register.check_passwordr();
		});

	};

	this.check_loginName = function(){
		return Register.loginNameCheck("reg_username");
	};

	this.check_password = function(){
		return Register.passwordCheck("reg_password");
	};

	this.check_passwordr = function(){
		return Register.passwordrCheck("reg_password2");
	};


	this.loginNameCheck = function(name){
		var _name = $("#"+name).val();
		if($.trim(_name) == '' ||_name.indexOf(" ")>0 || _name.replace(/[ ]/g,"")==''){
			$("#reg_username_tip").html("<img src=\"images/xingcai/tipimg-r.png\"><font color=\"red\">请输入4-16位用户名</font></img>");
			return false;
		}else if(_name.length<4){
			$("#reg_username_tip").html("<img src=\"images/xingcai/tipimg-r.png\"><font color=\"red\">用户名不能少于4位！</font></img>");
			return false;
		}else if(_name.length>16){
			$("#reg_username_tip").html("<img src=\"images/xingcai/tipimg-r.png\"><font color=\"red\">用户名不能超过16位！</font></img>");
			return false;
		}else{
			var url = "../mobile/checkusername.htm?username="+_name;
		    type = "json";
			var param = {};
			param.name=_name;
			param.uri = encodeURI(window.location);
			return $.post(url, param, function(obj){
			   if(obj=="true"){
				   	$("#reg_username_tip").html('<img src=\"images/xingcai/tipimg-r.png\"><font color=\"red\">该用户名已经被注册，很遗憾！</font></img>');
					$("#fa").val(1);
					return false;
			   }else{
				   $("#reg_username_tip").html("<img src=\"images/xingcai/tipimg-g.png\" ></img>");
					$("#fa").val(0);
					return true;
			   }
			}, type);

		}

		return true;
	};


	this.passwordCheck = function(name){
		var _name = $("#"+name).val();
		
		var cat = /^[\x20-\x7f]+$/;
		
		if($.trim(_name) == '' || _name.length<6 || _name.length>15 || _name.replace(/[ ]/g,"")==''){
			 $("#reg_password_tip").html('<img src=\"images/xingcai/tipimg-r.png\"><font color=\"red\">请输入6-15位密码</font></img>');
			return false;
		}else{
			$("#reg_password_tip").html("<img src=\"images/xingcai/tipimg-g.png\" ></img>");
		}

		return true;
	};
	this.passwordrCheck = function(name){
		if(!$("#"+name).val()){return false;}
		var _name = $("#"+name).val();
		var _newname = $("#"+name+"2").val();
		if(!($.trim(_name)==$.trim(_newname))){
			 $("#reg_password2_tip").html('<img src=\"images/xingcai/tipimg-r.png\"><font color=\"red\">与创建的密码不一致，请重新输入！</font></img>');
			return false;
		}else{
			$("#reg_password2_tip").html("<img src=\"images/xingcai/tipimg-g.png\" ></img>");
		}

		return true;
	};

	
	

	this.checkAndSub = function(){
		
		if(!Register.check_loginName()){
			return false;
		}
		if(!Register.check_password()){
			return false;
		}
		if(!Register.check_passwordr()){
			return false;
		}
		
		if($("#fa").val()==1){
			return false;
		}else{
			return true;
		}
	};

	/** 注册第一步  end */


	

};