function set_div(t){
   return '<span class="action_po"><span class="action_po_top">'+t+'</span><span class="action_po_bot"></span></span></span>';
}
function addClass(id,c,v){
   var value;
   if(v==''){
	  value = '';
   }else{
	  value = set_div(v); 
   }
   getgm("#"+id).removeClass();
   getgm("#"+id).addClass(c);
   getgm("#"+id).html(value);
}

function checkusername(){
	var username = getgm("#username").val();
	var strleng = strlen(username);
	if(strleng<1){
	   addClass("usernametip","wrong1","您还没有输入用户名");
	}else if(username.match("^[\\d]+$")){
	   addClass("usernametip","wrong1","用户名不能全为数字");
	}else if(strleng>20){
	   addClass("usernametip","wrong1","用户名长度不能大于10个字符");
	}else{
	   addClass("usernametip","chenggong1","");
	}	
}

function checkemail(){
	var email = $("#email").val().trim();
	if(email==''){
	   addClass("emailtip","wrong1","请输入用户免费注册邮箱！");
	}else if(!isEmail(email)){
	   addClass("emailtip","wrong1","您输入的邮箱格式错误");		
	}else{
	   addClass("emailtip","chenggong1","");
	}
}


function checkseccode(){
	var seccode = getgm("#seccode").val();
	var strleng = seccode.length;
	if(strleng!=4){
	   addClass("seccodetip","wrong1","请输入验证码，验证码为4个非中文字符！");
	}else{
       var url ='/index.php?mod=tools&act=ajax&do=seccode&seccode='+seccode+'&floor='+Math.floor(Math.random()*1000+1);
       $.ajax({url: url,type: 'GET',success: function(msg){
			if(msg.trim()=='yes'){
	           addClass("seccodetip","chenggong1","");
			}else{
	           addClass("seccodetip","wrong1","对不起，您输入的验证码有误");
			}										  
	   }});
	}
}

function checkform(){
  var post = true; 
  if(strlen(getgm("#username").val()) < 1){
	addClass("usernametip","wrong1","您还没有输入用户名");
    post = false;
  }
  if(strlen(getgm("#username").val()) > 20){
	addClass("usernametip","wrong1","用户名长度不能大于10个字符");
    post = false;
  }
  
  if(getgm("#username").val().match("^[\\d]+$")){
	addClass("usernametip","wrong1","用户名不能全为数字"); 
    post = false;
  }
   
  if(getgm("#email").val().length<1){
	addClass("emailtip","wrong1","请输入用户免费注册邮箱！");
    post = false;
  }else if(!isEmail(getgm("#email").val())){
	addClass("emailtip","wrong1","您输入的邮箱格式错误");	
    post = false;
  }
  
  if(getgm("#seccode").val().length != 4){
	addClass("seccodetip","wrong1","请输入验证码，验证码为4个非中文字符！");
    post = false;
  }
  if(getgm("#seccodetip").html().indexOf('对不起，您输入的验证码有误') != -1){
	addClass("seccodetip","wrong1","对不起，您输入的验证码有误");
    post = false;
  }   
  return post;  
} 

function checknewpassword(){
	var password = getgm("#newpassword").val();
	if(password.length<1){
	   addClass("newpasswordtip","wrong1","请输入新的登陆密码");
	}else{
	   addClass("newpasswordtip","chenggong1","");
	}
}

function checkcpassword(){
	var cpassword = $("#cpassword").val();
	var password = $("#newpassword").val();
	if(cpassword==""){
	   addClass("cpasswordtip","wrong1","请输入确认密码");
	}else if(cpassword!=password){
	   addClass("cpasswordtip","wrong1","对不起，两次输入密码不一致");
	}else{
	   addClass("cpasswordtip","chenggong1","");
	}
}

function checkreset(){
  var post = true; 

  if($("#newpassword").val().length<6){
	addClass("newpasswordtip","wrong1","请输入新的登陆密码,不得小于6位");
    post = false;
  }  
  
  if($("#cpassword").val()==''){
	addClass("cpasswordtip","wrong1","请输入确认密码");
    post = false;
  } 
  if($("#cpassword").val()!=$("#newpassword").val()){
	addClass("cpasswordtip","wrong1","对不起，两次输入密码不一致");
    post = false;
  }  
  return post;  
} 