﻿// JScript File
var xmlHTTP;
    
function Ajax(url, paramlist, async, func_name) {
    xmlHTTP = null;
    
    if (paramlist == null)
        paramlist = "";

    if (async == null)
        async = false;

    try {
        // Firefox, Opera 8.0+, Safari 
        xmlHTTP=new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer 6.0+
        try {
            xmlHTTP=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            // Internet Explore 5.5+
            try {
                xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                //alert("Your browser does not support AJAX.");
                return;
            }
        }
    }

    if (async && func_name != null)
        xmlHTTP.onreadystatechange = eval(func_name);
     
    xmlHTTP.open("POST", url, async);
    xmlHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHTTP.send(paramlist);
}

function AjaxFP(url, paramlist, async, func_name, myxmlHTTP) {
//Ajax function name with functional pointer for return and xmlHTTP pointer
    if (myxmlHTTP == null)
        return;

    if (paramlist == null)
        paramlist = "";

    if (async == null)
        async = false;

    if (async && func_name != null)
        myxmlHTTP.onreadystatechange = func_name;

    myxmlHTTP.open("POST", url, async);
    myxmlHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    myxmlHTTP.send(paramlist);
}

function AjaxCB(url, paramlist, async, func_name) {
    var xmlHTTP = GetXMLHTTP();

    if (xmlHTTP == null)
        return;
        
    if (paramlist == null)
        paramlist = "";

    if (async == null)
        async = false;

    

    if (async && func_name != null) {
        xmlHTTP.onreadystatechange = function() {
            if (func_name.toUpperCase() == "PROCESSGRAPHUPDATE")
                ProcessGraphUpdate(xmlHTTP);
            else
                eval(func_name);
        };
                
    }

    xmlHTTP.open("POST", url, async);
    xmlHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHTTP.send(paramlist);
}
    
function GetXMLHTTP() {
    var xmlHTTP = null;
    
    try {
        // Firefox, Opera 8.0+, Safari 
        xmlHTTP = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer 6.0+
        try {
            xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            // Internet Explore 5.5+
            try {
                xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                //alert("Your browser does not support AJAX.");
            }
        }
    }

    return xmlHTTP;
}

