
gestionErrori = function()
{
    this.assegnaXMLHttpRequest = function()
	{
		XHR = null,
		browserUtente = navigator.userAgent.toUpperCase();
		if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
			XHR = new XMLHttpRequest();
		else if(
			window.ActiveXObject &&
			browserUtente.indexOf("MSIE 4") < 0
		) {
			if(browserUtente.indexOf("MSIE 5") < 0)
				XHR = new ActiveXObject("Msxml2.XMLHTTP");
			else
				XHR = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return XHR;
	}
	
	this.setError = function(codError)
	{
		ajax = this.assegnaXMLHttpRequest();
		if(ajax)
		{
			ajax.open("get", "/funzioni/get_XMLerror.asp?codError="+codError, true);
			ajax.onreadystatechange = function()
			{
				if (ajax.readyState == 4) 
				{
					
					var xmlDoc = ajax.responseXML;
					if (xmlDoc.documentElement)
					{
						
						var RESULT = xmlDoc.documentElement.getElementsByTagName("RESULT")[0].childNodes[0].nodeValue;
						if (RESULT=="OK")
						{
							alertDiv(xmlDoc.documentElement.getElementsByTagName("TXT")[0].childNodes[0].nodeValue);
							
						}
						else
						{
							alertDiv('Errore generale! autodistruzione innescata!');
						}
					}
				}
			}
		ajax.send(null);
		}
	}
}

var ge = new gestionErrori();
