// dichiarazione costanti
var myConst = 
{
	UNINITIALIZED: 0,
	OPEN: 1,
	SENT: 2,
	RECEIVING: 3,
	LOADED:	4,
	SUCCESSFUL_HTTP_REQUEST: 200,
	ENTER_KEYCODE: 13
};

//------------------------------------------------------------
// Inizializzazione oggetto XMLHttpRequest
//------------------------------------------------------------
function InitXMLHttpRequest()
{
	obj = false;
	browser = navigator.userAgent.toUpperCase();

	// browser standard con supporto nativo
	if (typeof(XMLHttpRequest) === "function" || typeof (XMLHttpRequest) === "object" || window.XMLHttpRequest)
		{ obj = new XMLHttpRequest(); }
  
	// Internet Explorer
	else if (window.ActiveXObject) 
	{
		// Esclude IE versione 4
		if (browser.indexOf("MSIE 4") < 0)
		{
			// ActiveX per IE versione 6
			try { obj = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch(e) 
			{
				// ActiveX per IE versione 5 e 5.5				
				try { obj = new ActiveXObject("Microsoft.XMLHTTP"); }
				catch(e) {}
			}
		}
	}
	
	// AJAX non supportato
	if (!obj) { return false; }

	// AJAX supportato
	else
	{		
		// sovrascrive header MIME per alcuni browser della famiglia Mozilla
		if (obj.overrideMimeType) { obj.overrideMimeType('text/xml'); }
		return obj;
	}
}

//------------------------------------------------------------
// Invio di una richiesta GET
//------------------------------------------------------------
function AjaxGetRequest(obj, url)
{
	obj.open('GET', url, true);
	obj.send(null);
}

//------------------------------------------------------------
// Ridefinizione compatibile di getElementByID
//------------------------------------------------------------
function getElementFromHTML(id)
{
	var element;
	if (document.getElementById) { element = document.getElementById(id); }
	else { element = document.all[id]; }
	return element;
}

