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); 
   }
   $("#"+id).removeClass();
   $("#"+id).addClass(c);
   $("#"+id).html(value);
}

function checktruename(){
	var truename = $("#truename").val().trim();
	if(!isChinese(truename)){
	   addClass("truenametip","wrong1","对不起，真实姓名必须是中文！");
	}else if(strlen(truename)<4){
	   addClass("truenametip","wrong1","对不起，真实姓名不能少于2个字！");
	}else if(strlen(truename)>10){
	   addClass("truenametip","wrong1","对不起，真实姓名不能多于5个字！");
	}else{
	   addClass("truenametip","chenggong","","");
	}
}

function checkidcard(){
	var idcard = $("#idcard").val().trim();
	if(!checkId(idcard)){
	   addClass("idcardtip","wrong1","对不起，请正确填写身份证信息！");
	}else{
	   var url = ajaxurl('&do=checkidcard&idcard='+encodeURIComponent(idcard)+'&floor='+Math.floor(Math.random()*1000+1));
       $.ajax({url:url,type: 'GET',success: function(msg){
			if(msg.trim()=='ok'){
	           addClass("idcardtip","chenggong","");
			}else{
	           addClass("idcardtip","wrong1","对不起，该身份证信息已存在");
			}	
	   }});
	}
}

function auth(){
  var post = true; 
  
  if(!isChinese($("#truename").val().trim())){
	 addClass("truenametip","wrong1","对不起，真实姓名必须是中文！");
	 post = false;
  }else if(strlen($("#truename").val().trim())<4){
	 addClass("truenametip","wrong1","对不起，真实姓名不能少于2个字！");
	 post = false;
  }else if(strlen($("#truename").val().trim())>10){
	 addClass("truenametip","wrong1","对不起，真实姓名不能多于5个字！");
	 post = false;
  }else{
	 addClass("truenametip","chenggong","");  
  }
  
  if(!checkId($("#idcard").val().trim())){
    addClass("idcardtip","wrong1","对不起，请正确填写身份证信息！");
    post = false;
  }else if($("#idcardtip").html().indexOf('对不起，该身份证信息已存在') != -1){
    addClass("idcardtip","wrong1","对不起，该身份证信息已存在");
    post = false;
  }else{
    addClass("idcardtip","chenggong","");		
  }
    
  return post;  
} 