/**
 * eg :
 * Reg_Verify.account("SFDSFS");
 * Reg_Verify.password("aaaaaa","account")
 */
Reg_Verify = {
	trim : function(s) {
		return (s||"").replace(/^\s+|\s+$/,"");
	},
	account : function(v, tp) {
		v = this.trim(v);
		tp = this.trim(tp);
		var ret;
		
		//通用验证方法
		if(!v){
			return "请输入帐号"
		}
		
		if(v.length<6){
			return "帐号至少为6位，由英文、数字或下划线组成"
		}
		
		//common帐号验证方法(之前还区分邮箱帐号和手机帐号)
		
		if (/^\d+$/.test(v)) {
			return "帐号不能全为数字"
		}
		
		if (v.length > 25) {
			return "帐号不能多于25个字符"
		}
		
		if (/^woniu/i.test(v)) {
			return "帐号不能以'woniu'开头"
		}
		
		if (/^snail/i.test(v)) {
			return "帐号不能以'snail'开头"
		}
		
		if (/^gm/i.test(v)) {
			return "帐号不能以'gm'开头"
		}
		
		if (/^d1xn/i.test(v)) {
			return "帐号不能以'd1xn'开头"
		}
		
		if (/^dixn/i.test(v)) {
			return "帐号不能以'dixn'开头"
		}
		
		if (/^dlxn/i.test(v)) {
			return "帐号不能以'dlxn'开头"
		}
		
		if (/^dyxn/i.test(v)) {
			return "帐号不能以'dyxn'开头"
		}
		
		if (! (/^\w{6,25}$/.test(v) || /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(v)) ) {
			return "帐号只能是英文、数字、下划线的组合（不能为全角字符）或有效电子邮箱"
		}
		
		return true;
			
	},
	
	password:function(v,acc,rv){
//		v = this.trim(v);
		acc = this.trim(acc);
		if(!v){
			return "请输入密码"
		}
		
		if(v==acc){
			return "帐号和密码不能相同"
		}
		
		if(v.length<6){
			return "密码至少为6位"
		}
		
		if(v.length>20){
			return "密码不能多于20个字符"
		}
		
		if(!/^[0-9a-zA-Z]{6,20}$/.test(v)){
			return "密码只能使用英文（区分大小写）和数字"
		}
		
		if(/^(\w)\1*$/.test(v)){
			return "密码不能是完全相同的字母或数字"
		}
		
		for(var i=1,c=[v.charCodeAt(0)],cd=[v.charCodeAt(0)],cu=[v.charCodeAt(0)];i<v.length;i+=1){
			cd[i] = cd[i-1]-1;
			cu[i] = cu[i-1]+1;
			c[i] = v.charCodeAt(i);
		}
		c = c.join(":");
		if(c==cd.join(":") || c==cu.join(":")){
			return "你不能使用该密码，非常容易被猜测！"
		}
		
//		if(rv.length && v!=rv) {
//			return '';
//		}

		return true;
		
	},
	rpwd : function(a, b) {
		if(!a) {
			return "请输入确认密码";
		}
		
		if (a!=b) {
			return '两次密码输入不一致';
		}
		
		return true;
	},
	
	verify : function(v) {
		if(!v){
			return "请输入验证码";						
		}
		
		if(!/^[0-9a-zA-Z]{4}$/.test(v)){
			return "验证码格式不正确";						
		}
		
		return true;
	},
	email:function(v){
		v = this.trim(v);
		if(!v) {
			return true
		}
		
		if(!v){
			return "请输入您的电子邮箱";
		}
		
		if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(v) || v.length<6 || v.length>25){
			return "邮箱格式不正确，请确认后重新输入";			
		}
		
		return true;		
	},
	mobile : function(v) {
		v = this.trim(v);
		if(!v){	//可不填			
			return true;
		} else if(!/^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$/.test(v) || v.length<6 || v.length>25){
			return "您的手机号格式不正确，请重新填写";			
		}
		
		return true;
	}
};