function addClass(id,c,v){
   $("#"+id).removeClass();
   $("#"+id).addClass(c);
   $("#"+id).html(v);
}
function checkusername(){
	var username = $("#username").val();
	if(username.length<1){
	   addClass("usernametip","tipsno","您还没有输入用户名");
	}else if(username.match("^[\\d]+$")){
	   addClass("usernametip","tipsno","用户名不能全为数字");
	}else if(username.length>20){
	   addClass("usernametip","tipsno","用户名长度不能大于20个字符");
	}else{
       $.ajax({url:ajaxurl('&do=chkusername&username='+encodeURIComponent(username)),type: 'GET',success: function(msg){
			if(msg.trim()=='ok'){
	           addClass("usernametip","tipsyes","&nbsp;");
			}else{
	           addClass("usernametip","tipsno","对不起，该用户名已存在");
			}	
	   }});
	}	
}

function checkpassword(){
	var password = $("#password").val();
	var strleng = password.length;
	if(strleng<6){
	   addClass("passwordtip","tipsno","对不起用户密码长度不得小于6位");
	}else{
	   addClass("passwordtip","tipsyes","&nbsp;");
	}
}

function checkemail(){
	var email = $("#email").val().trim();
	if(email!==''&&email!=oldemail){
	   if(!isEmail(email)){
	      addClass("emailtip","tipsno","您输入的邮箱格式错误");	  
	   }else{
          $.ajax({url:ajaxurl('do=chkemail&email='+email),type: 'GET',success: function(msg){
			if(msg.trim()=='ok'){
	           addClass("emailtip","tipsyes","&nbsp;");
			}else{
	           addClass("emailtip","tipsno","对不起，该邮箱已存在");
			}	
	      }});
	   }
	}else{
	   addClass("emailtip","","&nbsp;");	
    }
}

function checkuserphone(){
	var phone = $("#userphone").val().trim();
	if(phone.length==0){
       addClass("userphonetip","tipsno","对不起，联系电话不能为空！");
	}else if(!isPhone(phone)){
       addClass("userphonetip","tipsno","对不起，联系电话格式不正确，请正确填写！");
	}else{
	   addClass("userphonetip","tipsyes","","");
	}
}

function checks_county(){
    if($("#s_county").val()=='市、县级市'){
	   addClass("s_countytip","tipsno","对不起，请正确填写区域信息！");
    }else{
	   addClass("s_countytip","tipsyes","","");
    }	
}


function useredit(){
  var post = true; 
  
  if($("#password").val().length<6&&$("#password").val().length>0){
	addClass("passwordtip","tipsno","请输入密码,长度不得小于6位");
    post = false;
  } 
  
  
  if($("#email").val().length>0&&!isEmail($("#email").val())){
	addClass("emailtip","tipsno","您输入的邮箱格式错误");
    post = false;
  } 
  if($("#email").val().length>0&&$("#emailtip").html().indexOf('对不起，该邮箱已存在') != -1){
  	addClass("emailtip","tipsno","对不起，该邮箱已存在");
    post = false;
  } 
  
  if($("#userphone").val().trim().length==0){
    addClass("userphonetip","tipsno","对不起，联系电话不能为空！");
    post = false;
  }
	
  if(!isPhone($("#userphone").val().trim())){
    addClass("userphonetip","tipsno","对不起，联系电话格式不正确，请正确填写！");
    post = false;
  }

  if($("#userbank").val().trim().length<20){
    addClass("userbanktip","tipsno","对不起，收款方式必须填写，返款将通过该方式支付给您！");
    post = false;
  }

  return post;  
} 

function useradd(){
  var post = true; 
  if(strlen($("#username").val()) < 1){
	addClass("usernametip","tipsno","您还没有输入用户名");
    post = false;
  }
  if(strlen($("#username").val()) > 20){
	addClass("usernametip","tipsno","用户名长度不能大于10个字符");
    post = false;
  }
  
  if($("#username").val().match("^[\\d]+$")){
	addClass("usernametip","tipsno","用户名不能全为数字"); 
    post = false;
  }
  
  if($("#usernametip").html().indexOf('对不起，该用户名已存在') != -1){
	addClass("usernametip","tipsno","对不起，该用户名已存在");
    post = false;
  } 
  
  
  if($("#password").val().length<6){
	addClass("passwordtip","tipsno","请输入密码,长度不得小于6位");
    post = false;
  } 
  
  
  if($("#email").val().length>0&&!isEmail($("#email").val())){
	addClass("emailtip","tipsno","您输入的邮箱格式错误");
    post = false;
  } 
  
  if($("#email").val().length>0&&$("#emailtip").html().indexOf('对不起，该邮箱已存在') != -1){
  	addClass("emailtip","tipsno","对不起，该邮箱已存在");
    post = false;
  } 
  
  if($("#userphone").val().trim().length==0){
    addClass("userphonetip","tipsno","对不起，联系电话不能为空！");
    post = false;
  }
	
  if(!isPhone($("#userphone").val().trim())){
    addClass("userphonetip","tipsno","对不起，联系电话格式不正确，请正确填写！");
    post = false;
  }

  if($("#userbank").val().trim().length<20){
    addClass("userbanktip","tipsno","对不起，收款方式必须填写，返款将通过该方式支付给您！");
    post = false;
  }

  return post;  
} 


function aboutform(){
  var post = true; 
  if(strlen($("#name").val()) < 1){
	addClass("nametip","tipsno","您还没有输入单页名称");
    post = false;
  }  
  if(strlen(KE.text("content")) < 10){
    addClass("contenttip","tipsno",'对不起，请认真填写详细信息，不可小于10个字！');
    post = false;
  }
  return post;  
} 

function addlink(){
  var html = '<tr class="s_out" onmouseover="this.bgColor=\'#F5F5F5\';" onmouseout="this.bgColor=\'ffffff\';" bgcolor="#ffffff">';
  html += '<input type="hidden" name="id[]" value="">';
  html += '<td align="center">&nbsp;&nbsp;</td>';
  html += '<td align="left" style="padding-left:10px;">';
  html += '<input type="text" name="linkname[]" id="linkname[]" class="skey" style=\'width:130px;\'/>';
  html += '</td><td align="left" style="padding-left:10px;">';
  html += '<input type="text" name="linkurl[]" id="linkurl[]" value="http://" class="skey" style=\'width:250px;\'/>';
  html += '</td><td align="left" style="padding-left:10px;">';
  html += '<input type="text" name="linkorder[]" id="linkorder[]" value="0" class="skey" style=\'width:50px;\'/>';
  html += '</td><td align="center"><a onclick="$(this).parent().parent().remove();" href="javascript:;">移除</a></td></tr>';
  $("#type").append(html);
}


function addtype(){
  var html = '<tr class="s_out" onmouseover="this.bgColor=\'#F5F5F5\';" onmouseout="this.bgColor=\'ffffff\';" bgcolor="#ffffff">';
  html += '<input type="hidden" name="id[]" value="">';
  html += '<td align="center">&nbsp;&nbsp;</td>';
  html += '<td align="left" style="padding-left:10px;">';
  html += '<input type="text" name="typename[]" id="typename[]" class="skey" style=\'width:130px;\'/>';
  html += '</td><td align="left" style="padding-left:10px;">';
  html += '<input type="text" name="typeorder[]" id="typeorder[]" class="skey" style=\'width:50px;\'/>';
  html += '</td><td align="center"><a onclick="$(this).parent().parent().remove();" href="javascript:;">移除</a></td></tr>';
  $("#type").append(html);
}
function addchannel(){
  var html = '<tr class="s_out" onmouseover="this.bgColor=\'#F5F5F5\';" onmouseout="this.bgColor=\'ffffff\';" bgcolor="#ffffff">';
  html += '<input type="hidden" name="id[]" value="">';
  html += '<td align="center">&nbsp;&nbsp;</td>';
  html += '<td align="center">';
  html += '<input type="text" name="name[]" id="name[]" class="skey" style=\'width:130px;\'/>';
  html += '</td><td align="center">';
  html += '<input type="text" name="money[]" id="money[]" class="skey" style=\'width:50px;\'/> 元';
  html += '</td><td align="center">';  
  html += '<input type="text" name="number[]" id="number[]" class="skey" style=\'width:50px;\'/> 张';
  html += '</td><td align="center">'; 
  html += '<input type="text" name="order[]" id="order[]" class="skey" style=\'width:30px;\'/>';
  html += '</td><td align="center">'; 
  html += '<input type="text" name="jifen[]" id="jifen[]" class="skey" style=\'width:30px;\'/>';
  html += '</td><td align="center"><a onclick="$(this).parent().parent().remove();" href="javascript:;">移除</a></td></tr>';
  $("#type").append(html);
}
function plmake(obj){
  obj.value = '正在结算，请耐心等待.....';
  obj.disabled = true;
}
function seach(obj){
  obj.value = '正在查询，请耐心等待.....';
  obj.disabled = true;
  document.form1.submit();
}
function plout(obj){
  obj.value = '正在生成预导出，请耐心等待.....';
  obj.disabled = true;
  document.form1.submit();	
}