﻿var GLOBAL_CaptchaRoot = "/_include/common/Captcha/";

function Captcha_GetXmlHttpRequest(strURL)
{
    /// Create XmlHttpRequest object
    try
    {
        req = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc)
        {
            req = null;
        }
    }

    if(!req && typeof XMLHttpRequest != "undefined")
    {
        req = new XMLHttpRequest();
    }
    
    req.open("GET", strURL, false);
    req.send(null);
    
    return req.responseText
}

function ValidateCaptchaText(strFileName, strText)
{    
    if(Captcha_GetXmlHttpRequest(GLOBAL_CaptchaRoot + "AJAXCaptchaValidate.asp?VAR_Captcha=" + strFileName + "&VAR_CaptchaText=" + strText + "&dt=" + (new Date()) + "") == "TRUE")
        return true;
    else
        return false;
}

function GetNewCaptchaImage()
{
    var strFilename = Captcha_GetXmlHttpRequest(GLOBAL_CaptchaRoot + "AJAXNewCaptcha.asp?dt=" + (new Date()) + "");
    return strFilename;
}