var bajax_debug_enable = false;
function bajax_send(url, callback, fdata, method, sdata, asyn)
{
    fdata = (fdata === undefined)? null: fdata;
    method = method || "GET";
    sdata = (sdata === undefined)? null: sdata;
    asyn = (asyn === undefined)? true: asyn;

    var X = new bajax_object();
    if(asyn)
        X.onreadystatechange = function(){ callback(X, fdata); };
    X.open(method, url, asyn);

    if(bajax_debug_enable)
        bajax_debugger(callback);
    X.send(sdata);

    if(asyn) return X;
    else callback(X, fdata);
}
function bajax_object()
{
    var A;
    var _msxmlhttp = new Array(
        'Msxml2.XMLHTTP.5.0',
        'Msxml2.XMLHTTP.4.0',
        'Msxml2.XMLHTTP.3.0',
        'Msxml2.XMLHTTP',
        'Microsoft.XMLHTTP');
    for(var i = 0; i < _msxmlhttp.length; i++) {
        try {
            if(A = new ActiveXObject(_msxmlhttp[i])) break;
        } catch (e) {
            A = null;
        }
    }
    if(!A && typeof XMLHttpRequest != "undefined")
        A = new XMLHttpRequest();
    if(!A)
        alert("Could not create connection object.");

    return A;
}

// Debug information...
function bajax_debugger(func)
{
    var S = func.toString();
    alert('[Running] ' + S.slice(9, S.indexOf(')', 10)) + ')');
}
