// JScript source code
function InsertComm(testo,id,action)
{
	
	if(testo=="")
	{
		alert("Inserire il commento prima di procedere");
		
	}
	else
	{
		document.getElementById("bntdiv").style.display = "none";
		document.getElementById("layer").innerHTML = "Caricamento in corso";
		var url;

		xmlHttp = GetXmlHttpObject();
		if (xmlHttp == null)
		{
			alert("Il browser non supporta AJAX!");
			return;
		} 
		url = "public/funzioni/ajaxdb.asp?testo=" + testo.replace(/\n/gi,"<br>") + "&id=" + id + "&action=" + action ;
		xmlHttp.onreadystatechange = stateChanged;
		xmlHttp.open("POST", url, true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send(null);
		document.getElementById("layer").innerHTML = "";
		document.getElementById("testo").value = "";
		document.getElementById("bntdiv").style.display = "inline";
	}

}

function stateChanged() 
{ 
	if (xmlHttp.readyState == 4)
	{ 
		document.getElementById("editedelement").innerHTML = xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
	var xmlHttp = null;

	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function GetStato(valore)
{
	var url;
	var xDiv = "";
	var xValues = "";
		
	for (i=0;i<=document.form2.codtycoda.options.length - 1;i++)
	{
		if (document.form2.codtycoda.options[i].selected)
		{	
			xValues = xValues + xDiv + document.form2.codtycoda.options[i].value;
			xDiv = "|";
		}
	}
	
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert("Il browser non supporta AJAX!");
		return;
	} 
	url = "getstato.asp?t_values=" + xValues;
	xmlHttp.onreadystatechange = stateChangedLstStato;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function stateChangedLstStato() 
{ 
	if (xmlHttp.readyState == 4)
	{ 
		document.getElementById("lstStato").innerHTML = xmlHttp.responseText;
	}
}

function GetStatoQU(valore)
{
	var url;
	var xDiv = "";
	var xValues = "";
		
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert("Il browser non supporta AJAX!");
		return;
	} 
	url = "getstato_qu.asp?t_value=" + valore;
	xmlHttp.onreadystatechange = stateChangedLstStato;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

// JScript source code
function GetRelaz(valore, tycoda)
{
	var url;
	var xDiv = "";
	var xValues = "";
		
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert("Il browser non supporta AJAX!");
		return;
	} 
	url = "getrelaz.asp?t_value=" + valore + "&tycoda=" + tycoda;
	xmlHttp.onreadystatechange = stateChangedTxtRelaz;
	xmlHttp.open("POST", url, true);
	xmlHttp.send(null);
}

function stateChangedTxtRelaz() 
{ 
	if (xmlHttp.readyState == 4)
	{ 
		document.getElementById("taRel").innerHTML = xmlHttp.responseText;
	}
}
