function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your browser does not support AJAX!");
	}
}
http = getXmlHttpRequestObject();

function http(){
	//Cream obiectul:
	try{ this.xmlhttp=new XMLHttpRequest(); /* Firefox, Opera 8.0+, Safari */ }
	catch (e){  // Internet Explorer
		try{ this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try{ this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e){ alert("Your browser does not support AJAX!"); }
		}
	}
	
	//Functia cu care facem request:
	this.makerequest=function(method,url,data){
		if(method=="POST"){
			this.xmlhttp.open("POST",url,true);
			request="";
			for(var property in data){
				request += property + "=" + encodeURIComponent(data[property]) + "&";
			}
			this.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			this.xmlhttp.setRequestHeader("Content-length", request.length);
			this.xmlhttp.setRequestHeader("Connection", "close");
			this.xmlhttp.send(request);
		}else{
			this.xmlhttp.open("GET",url,true);
			this.xmlhttp.send(null);
		}
	}
}

// --------------------------------------------------------------------------------------------

/* exemplu:

var x1=new http();

//Raspunsul:
x1.xmlhttp.onreadystatechange=function(){
	if(x1.xmlhttp.readyState==4){
		alert(x1.xmlhttp.responseText);
	}
}

//Cererea:
function ua(str){
	var send=new Array();
	send["autor"]=str; send["ajax_autor"]="";
	x1.makerequest("POST","adaugarecarte.html",send);
}

*/
