function AJAXInteraction(url, callback, response_xml) {

	var req = init();
	req.onreadystatechange = processRequest;
	if (typeof response_xml != 'undefined')
	    req.response_xml = response_xml;

	function init() {
	    //alert('try');
	    var xmlDoc = null ;
	    if (typeof window.ActiveXObject != 'undefined' ) {
            	var ieversion = ['Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
            	for(var i=0; !xmlDoc && i<ieversion.length; i++) {
            	    //alert(i);
        	    //alert(ieversion[i]);
        	    try {xmlDoc = new ActiveXObject(ieversion[i]);} catch(e) {xmlDoc = false;}
        	    //alert(ieversion[i]);
        	}
            } else {
        	xmlDoc = new XMLHttpRequest();
            }
            return xmlDoc;
	}

	function processRequest() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				if (callback)
					callback(req.response_xml?req.responseXML:req.responseText);
			}
		}
	}

	this.doGet = function() {
		req.open("GET", url, true);
		req.send(null);
	}

	this.doPost = function(body) {
		req.open("POST", url, true);
		req.setRequestHeader("Content-Type",
				"application/x-www-form-urlencoded");
		if (typeof(body)=='object') {
		    var param = [];
		    for (i in body) param.push(i+'='+encodeURIComponent(body[i]));
		    body = param.join('&');
		}
		req.send(body);
	}
	
}

function ajaxGet(url, callback) {
    var ai = new AJAXInteraction(url, callback);
    ai.doGet();
}
	
function ajaxPost(url, data, callback) {
    var ai = new AJAXInteraction(url, callback);
    ai.doPost(data);
}

function ajaxXmlGet(url, callback) {
    var ai = new AJAXInteraction(url, callback, 1);
    ai.doGet();
}

function ajaxXmlPost(url, data, callback) {
    var ai = new AJAXInteraction(url, callback, 1);
    ai.doPost(data);
}
