// Build $BuildVersion$

var AuthDoc;
var AuthCallBack;

function AfterAuthenticate() {
    if (AuthDoc.readyState != 4) return;
    var root = AuthDoc.responseXML.documentElement;
    if (root == null) {
        alert("Authentication failed");
    } else {
        if (root.text == null) {
            AuthCallBack(root.textContent);
        } else {
            AuthCallBack(root.text);
        }
    }
}

function Authenticate(callback) {
    AuthCallBack = callback;
    if (window.XMLHttpRequest){
        AuthDoc = new XMLHttpRequest()
    } else {
        AuthDoc = new ActiveXObject("MSXML2.XMLHTTP");
    }
    AuthDoc.onreadystatechange = function () {
        if (AuthDoc.readyState == 4) {
            AfterAuthenticate ();
        }
    }

    AuthDoc.open("POST", "/QvAjaxZfc/QvsViewClient.asp", true);
    try {
        AuthDoc.send("<Global method='GetTicketForMe'/>");
    } catch(e) {
        alert("Authentication failed");
    }
}
