function Trim(str){ //删除左右两端的空格
return str.replace(/(^\s*)|(\s*$)/g, "");
}
function Ltrim(str){ //删除左边的空格
return str.replace(/(^\s*)/g,"");
}
function Rtrim(str){ //删除右边的空格
return str.replace(/(\s*$)/g,"");
}


function logintable(){ 
		  var xmlhttp;
		var str =null;
		var sendstr="";
	     try{
             xmlhttp=new XMLHttpRequest();
           }
		   catch(e){
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
           }
		     xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4){
              if (xmlhttp.status==200){		
			   str = xmlhttp.responseText;	
			     document.getElementById("logintable").innerHTML=str;		
			   }else{
			   alert("系统错误,如有疑问,请与管理员联系!");
			 }
          }
       }
	  xmlhttp.open("post","logintable.asp",true);
      xmlhttp.setRequestHeader('content-type','application/x-www-form-urlencoded');
      xmlhttp.send(sendstr); 
}

function loginout(){
	  var xmlhttp;
		var str =null;
		var sendstr="";
	     try{
             xmlhttp=new XMLHttpRequest();
           }
		   catch(e){
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
           }
		     xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4){
              if (xmlhttp.status==200){		
			     str = xmlhttp.responseText; 				 
				 if (str==1){
					 alert("成功退出登陆！");
			        logintable();				 
				 }
			   }else{
			   alert("系统错误,如有疑问,请与管理员联系!");
			 }
          }
       }
	  xmlhttp.open("post","logout.asp",true);
      xmlhttp.setRequestHeader('content-type','application/x-www-form-urlencoded');
      xmlhttp.send(sendstr); 
}


function checkcontent(arg1){
     var xmlhttp;
		var str =null;
		var sendstr="";
	     try{
             xmlhttp=new XMLHttpRequest();
           }
		   catch(e){
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
           }
		     xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4){
              if (xmlhttp.status==200){		
			   str = xmlhttp.responseText;
			    // document.getElementById(""+pos+"").innerHTML=str;	
				alert(str);			
			    
			   }else{
			 alert("系统错误,如有疑问,请与管理员联系!");
			 }
          }
       }
	  xmlhttp.open("post","checkcontent.asp",true);
      xmlhttp.setRequestHeader('content-type','application/x-www-form-urlencoded');
      xmlhttp.send("para="+escape(arg1)); 
}


function checkuser(arg){ 
	 var arg=arg;
	 var xmlhttp;
		var str =null;
		var sendstr="";
	     try{
             xmlhttp=new XMLHttpRequest();
           }
		   catch(e){
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
           }
		     xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4){
              if (xmlhttp.status==200){		
			   str = xmlhttp.responseText;	
				    if (str==0){
	 				document.getElementById("showinfo").innerHTML="该短信账号可以用！"; 
					  } 
					  else{
					document.getElementById("showinfo").innerHTML="<font color=red>该账号已被使用，请重新输入！</font>";
					  }
			   }else{
			   alert("系统错误,如有疑问,请与管理员联系!");
			 }
          }
       }
	  xmlhttp.open("post","checkuser.asp",true);
      xmlhttp.setRequestHeader('content-type','application/x-www-form-urlencoded');
      xmlhttp.send("arg="+escape(arg)); 
	
}
function  checksubmit(){
    var xingming=document.getElementById("xingming").value;	
	var smspass=document.getElementById("smspass").value;	
	var smsuser=document.getElementById("smsuser").value;	
	var dianhua=document.getElementById("dianhua").value;
	var qq=document.getElementById("qq").value;
	var beizhu=document.getElementById("beizhu").value;
	var bString="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-";
	var bTel="0123456789-";
	var ii=0;
	
	if (Trim(xingming)==""){
	   alert("请留下你的姓名！谢谢！");
	   document.getElementById("xingming").focus();
	   return false;
	}
   if (Trim(smsuser)==""){
	   alert("短信发送账号不可以为空！谢谢！");
	   document.getElementById("smsuser").focus();
	   return false;
	}
	
	 if (Trim(smspass)==""){
	   alert("短信发送密码不可以为空！谢谢！");
	   document.getElementById("smspass").focus();
	   return false;
	}
	
	if (Trim(dianhua)==""){
	   alert("请留下你的电话！谢谢！");
	   document.getElementById("dianhua").focus();
	   return false;
	}
	 while (ii<document.getElementById("dianhua").value.length)
	 {
		if (bTel.indexOf(document.getElementById("dianhua").value.substring(ii,ii+1))==-1)
		{
			alert("\n\n联系电话不符合规范。");
			 document.getElementById("dianhua").focus();
			return false;
		}
		ii=ii+1;
     }
		 
	 var xmlhttp;
		var str =null;
		var sendstr="";
	     try{
             xmlhttp=new XMLHttpRequest();
           }
		   catch(e){
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
           }
		     xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4){
              if (xmlhttp.status==200){		
			   str = xmlhttp.responseText;	
				    if (str==0){
						alert("\n\n信息提交成功，谢谢你的配合，我们将在1-2个工作日内与你取得联系！");
					    window.location.href="sms.asp";					
					  }
					  else if(str==2){
						alert("\n\n短信账号已经存在，请重新选择！")  
					  }
					  else{
						alert("请不要多次重复留言，如果有很多话要和我们说，请给我们电话联系！025-68858607/025-68855069");
						window.location.href="online.asp";
					  }
			   }else{
			   alert("系统错误,如有疑问,请与管理员联系!");
			 }
          }
       }
	  xmlhttp.open("post","/lysave.asp",true);
      xmlhttp.setRequestHeader('content-type','application/x-www-form-urlencoded');
      xmlhttp.send("xingming="+escape(xingming)+"&dianhua="+escape(dianhua)+"&qq="+escape(qq)+"&beizhu="+escape(beizhu)+"&smsuser="+escape(smsuser)+"&smspass="+escape(smspass)); 
}


function  loginuser(arg1,arg2){
   
	if (Trim(arg1)==""){
	   alert("登陆账号必须填写！");
	   return false;
	}
   if (Trim(arg2)==""){
	   alert("登陆密码必须填写！");
	   return false;
	}
 
	 var xmlhttp;
		var str =null;
		var sendstr="";
	     try{
             xmlhttp=new XMLHttpRequest();
           }
		   catch(e){
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
           }
		     xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4){
              if (xmlhttp.status==200){		
			   str = xmlhttp.responseText;	
				    if (str==0){
						alert("\n登陆成功！");
					   logintable();					
					  } 
					  else{
						alert("登陆账号或者密码错误！请核实后登陆！"); 
			 
					  }
			   }else{
			   alert("系统错误,如有疑问,请与管理员联系!");
			 }
          }
       }
	  xmlhttp.open("post","/loginsave.asp",true);
      xmlhttp.setRequestHeader('content-type','application/x-www-form-urlencoded');
      xmlhttp.send("sms_user="+escape(arg1)+"&sms_pass="+escape(arg2)); 
}
  function textCounter(field, countfield, maxlimit) {
		if (field.value.length > maxlimit) 
		field.value = field.value.substring(0,maxlimit);
		else 
		countfield.value = maxlimit - field.value.length;
	}




