﻿// 索要电话
function getphone(){
var jxid=document.getElementById("_ctl0_ContentPlaceHolder1_hfid1").value;
          var name=document.getElementById("_ctl0_ContentPlaceHolder1_txtname1").value;
          if(name==""){
            alert('姓名不能为空');
             return false; 
          }else{
                 if(isNaN(name)){
                    
                }else{                   
                         alert('请填写真实姓名以便联系！');
                           return false; 
                }
          }
          
          var tel=document.getElementById("_ctl0_ContentPlaceHolder1_txttel").value;
           if(tel!=""){
                if(isNaN(tel)){
                    alert('请填写有效的联系电话！');
                           return false;  
                }
                if(tel.length>13 || tel.length<6){
                     alert('请填写有效的联系电话！');
                       return false;          
                }
               
           }else{
                           alert('请填写联系电话！');
                             return false;          
           }
          var email=document.getElementById("_ctl0_ContentPlaceHolder1_txtemail").value;        
          if(email==""){          
             alert('请填写电子邮箱！');
             return false;
             }else{
                    if(!/\w+@\w+(\.\w+)+/ig.test(email))
                    {    
                      alert('Email格式不正确!');
                      return false;          
                            
                    }
             }
              
              
             
            sendrequest(jxid,name,tel,email);
             return false;
}


function sendrequest(jxid,name,tel,email){
           http_request = false;
          if(window.XMLHttpRequest)
          {
              //　非IE　浏览器
              http_request = new XMLHttpRequest();
          }
          else if(window.ActiveXObject)
          {
              //IE
              try
              {
                  http_request = new ActiveXObject("Msxml2.XMLHTTP");//较新版本的IE
              }catch(e)
              {
                  try
                  {
                      http_request = new ActiveXOBject("Microsoft.XMLHTTP");//旧版本IE
                  }catch(e){}
              }
          }
          else
          {
              window.alert("不能创建　XMLHttpRequest对象，无法应用Ajax");
              return false;
          }
          //指定回调函数
           http_request.onreadystatechange = result;
            //创建HTTP请求
            var date=new Date(); 
        
            http_request.open("get","../jiaxiao/getphone.ashx?d="+date+"&id="+escape(jxid)+"&name="+escape(name)+"&tel="+escape(tel)+"&email="+escape(email)+"",true);   
        
          //发送上面创建的HTTP请求
          http_request.send(null);
         
}

//检验是否存在用户名结果
function result()
{  
  if(http_request.readyState == 4)//发送成功
  {
      if(http_request.status == 200)//交易成功
      {         
        if(http_request.responseText=="0"){//失败
            alert('索要号码失败');       
            location.href=location.href; 
        }else{
        showModalDialog('Show.aspx?str='+http_request.responseText,'显示驾校联系电话','dialogWidth:400px;dialogHeight:200px;help:0;status:0;location:no;toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
          // alert(""+http_request.responseText+"。");
            location.href=location.href;
        }
      }else{
        alert('索要号码失败'); 
      }
  }
}

function ShowTishi(){ 
var tishi=document.getElementById('tishiimg').style.display;


    if(document.getElementById('tishiimg').style.display=="none"){
        document.getElementById('tishiimg').style.display='block';
       
    }else{
      document.getElementById('tishiimg').style.display='none';
    
    }
}