/*************************************************************/
/* function nuovo_ajax()                                     */
/* --------------------------------------------------------- */
/* Crea, inizializza e rende un oggetto XMLHTTPRequest.      */
/*************************************************************/
function nuovo_ajax()
{
	var xmlhttp = false;
	
	try
	{
		// Internet Explorer 6 e successivi.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(exception_1)
	{
		try
		{
			// Internet Explorer 5.5.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(exception_2)
		{
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
		// Altri browsers.
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}

/*****************************************************/
/* function get_html()                               */
/* ------------------------------------------------- */
/* Esegue le chiamate AJAX e inserisce il risultato  */
/* in un oggetto contenitore.                        */
/*                                                   */
/* Parametri:                                        */
/* elem_id: id del contenitore da modificare.        */
/* url: URL di destinazione per le chiamate AJAX.    */
/* metodo: GET o POST.                               */
/*****************************************************/
function get_html(elem_id, url, metodo)
{
	var ajax = false;
	var elem = document.getElementById(elem_id);
	
	ajax = nuovo_ajax();
	ajax.open(metodo, url + (url.indexOf("?") < 0 ? "?" : "&") + "ms="+new Date().getTime());
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 4 && ajax.status == 200) 
		{
			txt = unescape(ajax.responseText);
			txt = txt.replace (/\+/gi, " ");
			elem.innerHTML = txt;
		}
	}
	ajax.send(null);
}
