﻿
function GetXmlHttpObject() 
{
    //����XMLHttpRequest���������ͺͽ���HTTP��������Ӧ
    xmlHttpObj = null;
    try 
    {
        // FireFox Opera 8.0+ Safari
        xmlHttpObj = new XMLHttpRequest();
        if(xmlHttpObj.overrideMimeType) 
        {
            xmlHttpObj.overrideMimeType('text/xml');
        }
    } 
    catch(e) 
    {
        // IE
        try 
        {
            xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch(e) 
        {
            xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttpObj;
}

function StateChanged() 
{
    /* readyState
     0: (δ��ʼ��)��û�е���send()����
     1: (����)�ѵ���send()���������ڷ�������
     2: (�������)send()����ִ����ɣ��Ѿ����յ�ȫ����Ӧ����
     3: (����)���ڽ�����Ӧ����
     4: (���)��Ӧ���ݽ�����ɣ������ڿͻ��˵�����*/

    if(___xmlHttp.readyState == 4) 
    { 
        if(___xmlHttp.status == 200) 
        {
            var text = ___xmlHttp.responseText;
            
            if(text=="True" || text=="true")
            {
                SetValidateState(1);
                ___IsValidate=true;
            }
            else
            {
                SetValidateState(2);
                ___IsValidate=false;
            }
        } 
        else 
        {
            SetValidateState(-1);
            ___IsValidate=false;
        }
    }
}

var ___xmlHttp=null;
var ___IsValidate=false;
function GetIsValidate(inputCode) 
{
    if(___xmlHttp==null)
        ___xmlHttp = GetXmlHttpObject();
    if(___xmlHttp == null) 
        return false;
        
    SetValidateState(0);

    var url = "?___command=GetIsValidate&___param="+inputCode+"&___clientRandom=" + Math.random();

    ___xmlHttp.open("GET", url, true);
    ___xmlHttp.onreadystatechange = StateChanged;
    ___xmlHttp.send(null);
    
}


function SetValidateState(state)
{
    objs=document.getElementById("___authStr").getElementsByTagName("img");
    objs[0].style.display=objs[1].style.display=objs[2].style.display="none";
    
    if(state>=0 && state<=2)
        objs[state].style.display="";
}