
/* --------------------------------------------------------------------------------------- */
var http_request = false;
var http = XML_HTTP_Object();		// Creo l'oggetto XHR.
/* --------------------------------------------------------------------------------------- */


/* --------------------------------------------------------------------------------------- */
// To create the object in JavaScript for IE, use new ActiveXObject("Microsoft.XMLHTTP").
// In Mozilla/Firefox and Safari, use new XMLHttpRequest().

function XML_HTTP_Object() 
{
	var xml_http;

	if (window.ActiveXObject) 
	{
		// instanzio l'oggetto
		if (_XML_ActiveX)
		{
			xml_http = new ActiveXObject(_XML_ActiveX);
		} 
		else 
		{
			// ciclo attraverso le varie versioni
			var versions = ["MSXML2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0"];
			for (var i = 0; i < versions.length ; i++)
			{
				try {
					xml_http = new ActiveXObject(versions[i]);		// creo l'oggetto
					if (xml_http)
					{
						var _XML_ActiveX = versions[i];
						break;
					}
				}
				catch (e) {
					// TRAP
				};
			};
		}
	} // se non c'è ActiveX allora sono su un browser diverso da Internet Explorer

	if (!xml_http && typeof XMLHttpRequest != 'undefined')
	{
		try {
			xml_http = new XMLHttpRequest();
			xml_http.overrideMimeType("text/html");
		} catch (e) {
			xml_http = false;
		}
	}

	return xml_http;
}
/* --------------------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------------------- */
function Wait (nStato)
{
	document.getElementById('WaitGif').style.visibility = nStato == 0 ? 'hidden' : 'visible';
}
/* --------------------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------------------- */
/* Eseguire Javascript dopo chiamata AJAX */
/* --------------------------------------------------------------------------------------- */
function ExecuteJS(elementId)
{
	var scripts = document.getElementById(elementId).getElementsByTagName('script');
	var code;

	for (var i = 0; i < scripts.length; i++)
	{
		code =	scripts[i].innerHTML ? scripts[i].innerHTML : scripts[i].text ? scripts[i].text : scripts[i].textContent;
		
		try {eval(code);} 
		catch(e) {alert(e);}
	}
}
/* --------------------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------------------- */
function IsNumber(cNumber)
{
	var IsNumberPositive=true;
	var strMatch="1234567890-";

	for (var i=0; i < cNumber.length; i++)
		IsNumberPositive = (IsNumberPositive && (strMatch.indexOf(cNumber.charAt(i)) != -1))

	return IsNumberPositive;
}
/* --------------------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------------------- */
function SelectItem(cPrefix, cTextCount, cClassOFF, cClassON, nItem)
{
	var nInd = 0;
	var nMaxCount = document.getElementById(cTextCount).value;

	for (nInd = 1; nInd <= nMaxCount; nInd++)
	{
		document.getElementById(cPrefix+nInd).className = cClassOFF;
	}

	document.getElementById(cPrefix+nItem).className = cClassON;

	return false;
}
/* --------------------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------------------- */
function SetColorSubMenu(nItem)
{
	var nInd = 0;
	var nMaxCount = document.getElementById('txtCountSubMenu').value;

	for (nInd = 1; nInd <= nMaxCount; nInd++)
	{
		document.getElementById('SM_'+nInd).style.backgroundColor='#918B7D';
	}

	document.getElementById('SM_'+nItem).style.backgroundColor='#E60004';

	return false;
}
/* --------------------------------------------------------------------------------------- */