﻿//声明XMLHttpRequest对象
var xmlHttp;

//检测用户名是否存在
function CheckName(userName)
{
   // createXMLHTTP();//创建XMLHttpRequest对象
    var url="DisposeEvent.aspx?Name="+userName+"&Event=Check";
     retCode=openUrl(url);
     retCode = retCode.substring(retCode.indexOf('^'),retCode.Length-retCode.indexOf('^'));
     //alert(retCode);//true可以注册，flase不能注册
      if(userName.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)
     {
        if(retCode=="true")
        {
            alert('The account is available for registration.');
        }
        else
        {
            alert('The account has been already registered.');
        return;
        }
     }
     else
     {
        alert('Please input the correct email.');
        return;
     }
      
}

function createXMLHTTP()
{
    if(window.XMLHttpRequest)
    {
        xmlHttp=new XMLHttpRequest();//mozilla浏览器
    }
    else if(window.ActiveXObject)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");//IE老版本
        }
        catch(e)
        {}
        try
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");//IE新版本
        }
        catch(e)
        {}
        if(!xmlHttp)
        {
            window.alert("不能创建XMLHttpRequest对象实例！");
            return false;
        }
    }
}



function   openUrl(url)
   {  
        if   (window.XMLHttpRequest)  
        {   
                objxml   =   new   XMLHttpRequest();   
        }  
         else   if   (window.ActiveXObject)  
        {   
                objxml   =   new   ActiveXObject("Msxml2.XMLHTTP");   
        }   
        
        objxml.open("GET",url,false);
        
        objxml.send(""); 
        retInfo=objxml.responseText;          
        if   (objxml.status== "200 ")
        {  
                return   retInfo;  
        }  
        else
        {  
                return   "";  
        }  
}  

function clear_r()
{
    
}