//http://www.ajaxf1.com/tutorial/ajax-php.html
var httpObject = null;
var tagId;
var ajaxFileName = 'ajax.php';

// Get the HTTP Object
function getHTTPObject(){
    if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
    else if (window.XMLHttpRequest) return new XMLHttpRequest();
    else {
        alert("Your browser does not support AJAX.");
        return null;
    }
}

// Change the value of the outputText field
function setOutput(){
    if(httpObject.readyState == 4){
//alert(httpObject.responseText);
//alert(document.getElementById(tagId).innerHTML);
        document.getElementById(tagId).innerHTML = httpObject.responseText;
    }
}

// Implement business logic
function ajax(inFunctionName, inTagId, inArgList){


    httpObject = getHTTPObject();
    tagId = inTagId;

    var get = ajaxFileName + "?ajax=" + inFunctionName  + "&tagId=" + tagId + "&" + inArgList;

    if (httpObject != null) {
        httpObject.open("GET", get, true);
        httpObject.send(null);
        httpObject.onreadystatechange = setOutput;
    }
}