

function xhr( foo, fooPar, url )
{
	this.foo = foo;
	this.fooPar = fooPar;
	this.xhttp = null;
	this.url = url;


	this.loadXMLDoc = function()
	{
		// codice per Mozilla, etc.
		if (window.XMLHttpRequest)
		{
			this.xhttp = new XMLHttpRequest()
			/*
			this.xmlhttpChange.xhttp = this.xhttp
			this.xmlhttpChange.foo = this.foo
			this.xmlhttpChange.fooPar = this.fooPar
			*/
			//this.xhttp.onreadystatechange = this.xmlhttpChange
			
			this.xhttp.onreadystatechange = this.xmlhttpChange( this.xhttp, this.foo, this.fooPar );
			/*
			function() 
			{
				return function() {
					alert( this.parentNode )
				};
			}();
			*/
			this.xhttp.open("GET",this.url,true)
			this.xhttp.send(null)

		} else if (window.ActiveXObject) {
		
			this.xhttp = new ActiveXObject("Microsoft.XMLHTTP");

			if (this.xhttp)
			{
				this.xhttp.onreadystatechange = this.xmlhttpChange( this.xhttp, this.foo, this.fooPar );
				this.xhttp.open("GET",this.url,true)
				this.xhttp.send()
			}
		}
	}

	


	this.xmlhttpChange = function( xhttp, foo, fooPar )
	{
		return function()
		{
			// if xmlhttp shows "loaded"
			if ( xhttp.readyState == 4 )
			{
				// if "OK"
				if ( xhttp.status == 200 )
				{
					var response = xhttp.responseText;

					foo( response, fooPar );
			
				} else {

					//alert("Impossibile ricevere i dati")
			
				}
			}
		}
	}



	this.loadXMLDoc();

}



function pasticcio(x,f,fp)
{
	return function()
	{
		alert(x)
	}
}

