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(strleng>20){
	   addClass("usernametip","wrong1","用户名长度不能大于10个字符");
	}else{
	   addClass("usernametip","chenggong1","");
	}	
}

function checkpassword(){
	var password = getgm("#password").val();
	var strleng = password.length;
	if(strleng<1){
	   addClass("passwordtip","wrong1","请输入您的登陆密码");
	}else{
	   addClass("passwordtip","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("#password").val().length<1){
	addClass("passwordtip","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;  
} 