var xmlHttp;
var elementID;
var tagName;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
    
function doGet(url, elementIDName, tName, params) {
	elementID = elementIDName;
	tagName = tName;
	createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", url + "?"+ params, true);
    xmlHttp.send(null);
}

function doPost(url, elementIDName, tName, params) {
	elementID = elementIDName;
	tagName = tName;
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("POST", url , true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.send(params);
}
    
function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
        	value = xmlHttp.responseXML.getElementsByTagName(tagName)[0].firstChild.nodeValue;
        	if (value != "") {
        		document.getElementById(elementID).innerHTML = value;
        	}
        }
    }
}
