var AjaxCaching = false;
function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
		try {
			request = new XMLHttpRequest();
		}
		catch (err1) 
		{
			request = false;
		}
            }
        }
    return request;
}

function display(content, storage)
{
    storage.innerHTML = content;
}

function retrieve(url,destinazione)
{
	var storage = document.getElementById(destinazione);
	var xhr = createXHR();
	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			if(xhr.status == 200)
			{
				var 	content = xhr.responseText;
				display(content, storage)
			}
		} 
	}; 

	if(AjaxCaching == false)
		url = url + "?nocache=" + Math.random();
	xhr.open("GET", url , true);
	xhr.send('');  
}


function submitForm(url,destinazione)
{ 
  
	var xhr = createXHR();
  
//	var script = "ajax-cross-get.php?"+url;
//	var script = "./ajax/ajax-cross-get.php?"+url+"%"+url1;
//	var filename = "./ajax/dati.html";	

    var script = url;
  	
	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			 retrieve(url,destinazione);
		}
	}; 
	xhr.open("POST", script, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


	xhr.send(''); 
} 

