﻿<!--
	function onlychinese3() 
	{
		if ((window.event.keyCode >=32) && (window.event.keyCode <= 126)) 
		{
		window.event.keyCode = 0 ;
		}
	} 


	function input_check3(form)
	{
		if(form.name_txt.value.length<1)
		{
			alert("姓名输入不正确！");
			form.name_txt.focus();
			return false;
		}
		
		if(form.mobile.value=="")
		{
			alert("手机号码不能为空！");
			form.mobile.focus();
			return false;
		}
		else
		{
			reg=/^1\d{10}$/gi;
			if(!reg.test(form.mobile.value))
			{
				alert("非法的手机号码！");
				form.mobile.focus();
				return false;
			}
		}
		if(!chkMobile(form.mobile.value,form)) return false;
		var reg1=/[^0-9]/gi;
		if(form.validenum.value=="")
		{
			alert("请输入验证码！");
			form.validenum.focus();
			return false;
		}
		
		if(reg1.test(form.validenum.value))
		{
			alert("验证码输入错误!");
			form.validenum.focus();
			return false;
		}
		
		if(form.content.value=="")
		{
			alert("请输入咨询问题内容！");
			form.content.focus();
			return false;
		}
	return true;
	}
	
	function getCookie(name)
	{
	this.path = "/"; //设置访问路径
	if (document.cookie != "") {
		var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
		if(arr!=null){
		return arr[2];
	}
		else{
			return null;
		}
	}
 }
	
	function mobile_check3(form)
	{
		
		var send_type=form.send_type.value;
		var mobiles=form.mobile.value;
		var http_url=window.location.href;
		var source_id=getCookieOfValue("sourceid");
		
		if ( source_id==null)
		{
			source_id=0;
		}

		
		 if(form.mobile.value=="")
		 {
		  alert("手机号码不能为空！");
		  form.mobile.focus();
		  return false;
		 }
		 else
		 {
		  reg2=/^1\d{10}$/gi;
		 if(!reg2.test(form.mobile.value))
		 {
		  alert("非法的手机号码！");
		   form.mobile.focus();
		   return false;
		  }
		 }
		 if(!chkMobile(form.mobile.value,form)) return false;

		recMsg(source_id,send_type,http_url);

		doPost3(send_type,mobiles,http_url,source_id);
		 //window.location.href="http://58.61.153.82/Sms_send.asp?send_type="+send_type+"&mobile="+mobiles+"&http_url="+http_url;
		return true;
	}
//start ajax
function recMsg(source_id,send_type,http_url)
{
	var xmlHttp
	var url="/include/rember_sms.asp?q=" + source_id + "&t=" + send_type + "&u=" + http_url;
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("txtHint").innerHTML=xmlHttp.responseText
	}
}
function GetXmlHttpObject(handler)
{
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesnt work in Opera")
		return;
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		}
		try
		{
		objXmlHttp=new ActiveXObject(strName)
		//objXmlHttp.onreadystatechange=handler
		return objXmlHttp
		}
		catch(e)
		{
			alert("Error. Scripting for ActiveX might be disabled")
			return
		}
	}
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		//objXmlHttp.onload=handler
		//objXmlHttp.onerror=handler
		return objXmlHttp
	}
}
//end ajax


	function chkMobile(m,form){
		if (m != ""){
			 var mobile=m;
			 var reg0 = /^13\d{5,9}$/;
			 var reg1 = /^153\d{4,8}$/;
			 var reg2 = /^158\d{4,8}$/;
			 var reg3 = /^159\d{4,8}$/;
			 var my = false;
			 if (reg0.test(mobile))my=true;
			 if (reg1.test(mobile))my=true;
			 if (reg2.test(mobile))my=true;
			 if (reg3.test(mobile))my=true;
			 if (!my){
				 alert('对不起，您输入的手机号码有错误。');
				 form.mobile.focus();
				 return false;
			 }
			 return true;
    	}
		return false;
	}

function getTag3(response,i,objTagName){
	try{
		var nodeV = response.getElementsByTagName(objTagName)[i].firstChild.nodeValue;
	}catch(e){
		var nodeV = "";
	}
	return nodeV;
}

//---------------------------------------------------------
function doPost33(send_type,mobiles,http_url){
	var xmldoc=createxmldoc3();
	var url = "http://w1.788111.com/Sms_send.asp?send_type="+send_type+"&mobile="+mobiles+"&http_url="+http_url;

	try{
		xmldoc.open("POST",url,true);
	}catch(e){
		alert("发送失败，请重试！");
		return;
	}
	xmldoc.onreadystatechange = function(){
		if(xmldoc.readyState == 4){
			if(xmldoc.status == 200){
				var res = xmldoc.responseXML.documentElement;
				var type = getTag3(res,0,"type");
				var msg = getTag3(res,0,"msg");
				var code = getTag3(res,0,"code");
				if (type==""){
					alert("发送失败，返回错误！");
					return;
				}
				if (type==1){
					alert(msg);
				}else if(type==0){
					alert(msg);
				}
			}else{
					alert("发送失败，通信错误！");
			}
		}
	}
	xmldoc.setRequestHeader("Cache-Control","no-cache");
	//xmldoc.setrequestheader("content-length",postdata.length);
	xmldoc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmldoc.send(url);
}

function createxmldoc3(){
	var xmldoc;
	if(window.XMLHttpRequest){
		xmldoc = new XMLHttpRequest();
		if(xmldoc.overrideMimeType){
				xmldoc.overrideMimeType("text/xml");
		}
	}else if(window.ActiveXObject){
		try{
			xmldoc = new ActiveXObject("Msxml4.XMLHTTP");
		}catch(e){
			try{
				xmldoc = new ActiveXObject("Msxml3.XMLHTTP");
			}catch(e){
				try{
					xmldoc = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e){
					try{
						xmldoc = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
			}
		}
	}
	if(!xmldoc){
		return false;
	}
	return xmldoc;
}
//-->
//------------------------------------
var xmlHttp
function doPost3(send_type,mobiles,http_url,source_id)
{
	if (send_type.length > 0)
	{
		
		//var url = "http://w1.788111.com/Sms_send.asp?send_type="+send_type+"&mobile="+mobiles+"&http_url="+http_url+"&source_id="+source_id;
		var url = "/include/Sms.asp?send_type="+send_type+"&mobile="+mobiles+"&http_url="+http_url+"&source_id="+source_id;
		xmlHttp=GetXmlHttpObjecta(stateChangeda)
		xmlHttp.open("post", url , true)
		xmlHttp.send(null)
	}
	else
	{
	document.getElementById("txtHint").innerHTML=""
	}
}
function stateChangeda()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("txtHint").innerHTML=xmlHttp.responseText
	var result=xmlHttp.responseText;
	//alert(result);
	callback(result);

	}
}
function callback(res)
{

 	//alert(res);
 	var endID=res.lastIndexOf("</msgid>");
	var startID=res.lastIndexOf("<msgid>");
	var idString=res.substring(startID+7,endID);//验证码值
			//alert(idString);
 //---验证码值
	var endCode=res.lastIndexOf("</code>");
	var startCode=res.lastIndexOf("<code>");
	var codeString=res.substring(startCode+6,endCode);//验证码值
	//alert(codeString);
//----type值
	var endType=res.lastIndexOf("</type>");
	var startType=res.lastIndexOf("<type>");
	var typeString=res.substring(startType+6,endType);//type
	//alert(typeString);
//判断type得出msg值
//alert(idString);
  if (typeString=="0")
  {
  	alert("您的短信已发送，5分钟内请不要连续索取。\r\r如暂未收到，请稍候。服务热线：4006-788-111");
  	}
 else
  {
  	//把code值存入cookie
  	setCookiea("randnum",codeString,1,1,0);
  	var reCode=getCookiea("randnum");
  	setCookiea("id",idString,1,1,0);
  	var reID=getCookiea("id");
  	//alert(reCode);
  	//alert(reID);
  	alert("发送成功");
  	}
  	
}
function GetXmlHttpObjecta(handler)
{
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesnt work in Opera")
		return;
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		}
		try
		{
		objXmlHttp=new ActiveXObject(strName)
		objXmlHttp.onreadystatechange=handler
		return objXmlHttp
		}
		catch(e)
		{
			alert("Error. Scripting for ActiveX might be disabled")
			return
		}
	}
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler
		return objXmlHttp
	}
}
function setCookiea(name,value,expires,number,isSign){
			this.path = "/"; //设置访问路径 
			this.domain = ""; //设置访问主机 
			var list=null;//cookie中保存属性名称的集合,以‘,’隔开,如valueName="01,02,03"
			var newName="";
			var exp = new Date();
			exp.setTime(exp.getTime()+ expires*1*60*60*1000);
			if(document.cookie==""){
				//如果没有cookie，则写cookie
				document.cookie=name+"="+ value +";expires="+exp.toGMTString()+";path="+this.path;
				if(isSign==1){
					alert("保存成功！");
				}
			}else{
				//如果有cookie，则查找名称为name的值
				list = getCookie(name);
				//alert("list="+list);
				//如果名称为name的值为空，则写cookie
				if(list==null){
					document.cookie=name+"="+ value +";expires="+exp.toGMTString()+";path="+this.path;
					if(isSign==1){
						alert("保存成功！");
					}
				}else{
					//如果名称为name的值存在，则读取
					var alltxt=list.split(",");
					for(i=0;i<alltxt.length;i++){
						if(alltxt[i]==value){//如果现有的值中已存在要写入的值
								newName=list;
								break;
						}else{
							if(alltxt.length>=number){//如果当前值的数量已超过规定的数量number
								if(i!=alltxt.length-1){
									alltxt[i]=alltxt[i+1];
									newName+=alltxt[i]+",";
								}else{
									alltxt[alltxt.length-1]=value;
									newName=newName+alltxt[alltxt.length-1];
								}
							}else{
								newName=list+","+value;
							}
						}
					}//end for
					document.cookie=name+"="+newName+";expires="+exp.toGMTString()+";path="+this.path;
					if(isSign==1){
						alert("保存成功！");
					}
				}//end else 91
			}//end else 84
		}
function getCookiea(name){
			this.path = "/"; //设置访问路径 
			this.domain = ""; //设置访问主机 
			if (document.cookie != "") {
		　　var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	      if(arr!=null){
	      	return arr[2];
	      }else{
	      	return null;
	      }
			}
　　}
function getCookieOfValue(name){
				this.path = "/";
				this.domain = "";
				if (document.cookie != "") {
		　　var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	      if(arr!=null){
	      	var cval = arr[2].split("=");
	      	return cval[1];
	      }else{
	      	return null;
	      }
			}
		}
		