var xmlhttp;

var xmlhttpLoad = 1;

function XMLHttpLoad(url, type, data, code )
{
	xmlhttp=null;
	if (window.XMLHttpRequest)
	{
		// code for all new browsers
		xmlhttp=new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
		// code for IE5 and IE6
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null)
	{
		xmlhttp.onreadystatechange=state_Change;
		if ( type == "GET" )
		{
			xmlhttp.open( "GET", url, true);
			xmlhttp.send(null);
		} else {
			xmlhttp.open( "POST", url, false);
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xmlhttp.send(data);
		}
	} else {
		alert("Attenzione, il tuo browser non supporta XMLHttp");
	}
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {
		// 200 = OK
	    // ...our code here...
		return xmlhttp.responseText;
    }
  else
    {
		alert("Impossibile ricevere i dati XML");
    }
  }
}
