// Simple ajax function call
// $Id: Validate.js,v 1.2 2007/06/05 23:19:55 cosimo Exp $

var val_xmlHttpReq = false;
var val_timer      = 0;

// Is there a simpler AJAX code? I don't think so
function call(url, callback)
{
    // Terminate pending requests
    var req = xmlHttpReqHandle();
    if(!req) return;
    req.abort();
    // Open prepare new request
    req.open('GET', url, true);
    req.onreadystatechange = function()
    {
        if(!callback) return;
        if(req.readyState == 4 && req.status == 200)
            callback(req.responseText);
    }
    req.send(null);
}

// Get handle to xmlHttpRequest object
function xmlHttpReqHandle ()
{
    if(val_xmlHttpReq) return val_xmlHttpReq;
    //navigator.appName == "Microsoft Internet Explorer")
    try {
        val_xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
        val_xmlHttpReq = new XMLHttpRequest();
    }
    return(val_xmlHttpReq);
}

