<!--
var http_check_comment = getHTTPObject();
var url_check_comment = "check_add_comment.php?";

function handleHttpResponse_check_comment(i,tot,class_name,original_comment,comment) {
	if (http_check_comment.readyState == 4) {
		clearTimeout(timeout_check_comment);
		if(http_check_comment.status == 200 || http_check_comment.status == 304 || http_check_comment.status == 307){
			var xmlDocument_check_comment = http_check_comment.responseXML;
			if(xmlDocument_check_comment.getElementsByTagName('ok').length) {
				setTimeout("document.getElementById('div_area_info1').style.display = 'none'", 1500);
				document.getElementById('td_area_info1').innerHTML = "<table style='border: 0;'><tr style='background:#fff'><td>" + xmlDocument_check_comment.getElementsByTagName('ok').item(0).firstChild.data + "</td></tr></table>";
				document.getElementById('riga_'+i).style.display = 'none';

				if(document.getElementById('riga_'+i).className == 'riga_dispari') k = 0;
				else k = 1;
				//imposta la classe corretta per le varie righe in modo da mantenere l'alternanza tra i colori
				for(j=i;j<=tot;j++) {
					if(document.getElementById('riga_'+j).style.display != 'none') {
						if(++k%2) document.getElementById('riga_'+j).className = 'riga_dispari';
						else document.getElementById('riga_'+j).className = 'riga_pari';
					}
				}
				
				//controlla se ci sono ancora righe visibili nella tabella, altrimenti la nasconde
				for(n=1;n<=tot;n++) {
					if(document.getElementById('riga_'+n).style.display != 'none')
						break;
				}
				if(k == tot-1) {
					document.getElementById('td_area_info1').innerHTML = 'Non ci sono pi&ugrave richieste di aggiunta commenti.';
					document.getElementById('div_area_info1').style.display = 'block';
					document.getElementById('div_area_info').style.display = 'none';
				}
			}
			else if(xmlDocument_check_comment.getElementsByTagName('errore').length) {
				document.getElementById('td_area_info1').innerHTML = "<table style='border: 0;'><tr style='background:#fff'><td>" + xmlDocument_check_comment.getElementsByTagName('errore').item(0).firstChild.data + "</td></tr></table>";
			}
			else if(xmlDocument_check_comment.getElementsByTagName('informazione').length) {
				document.getElementById('td_area_info1').innerHTML = 
					"<table style='border: 0;'><tr style='background:#fff'><td>" + 
					xmlDocument_check_comment.getElementsByTagName('informazione').item(0).firstChild.data + 
					"<br />Vuoi inserirlo lo stesso nella classe " + 
					class_name + "? &nbsp;&nbsp;" + 
					"<a href='javascript:void(0);' onclick='add_comment_xmlhttprequest("+i+","+tot+",\""+class_name+"\",\""+original_comment+"\",\""+comment+"\",\"add\")'>Si</a>&nbsp;&nbsp;-&nbsp;&nbsp;" +
					"<a href='javascript:void(0)' onclick='document.getElementById(\"div_area_info1\").style.display = \"none\"'>No<a/>" +
					"</td></tr></table>";

			}
			else {
				document.getElementById('td_area_info1').innerHTML = "<table style='border: 0;'><tr style='background:#fff'><td>" + "Si sono verificati dei problemi. Si prega di ripetere l'operazione.<br />" + http_check_comment.responseText.split('<').join("&lt;").split('>').join("&gt;") + "</td></tr></table>";
			}
			occupato_check_comment = false;
			document.body.style.cursor = "auto";
		}
		else {
			document.getElementById('td_area_info1').innerHTML = "<table style='border: 0;'><tr style='background:#fff'><td>" + "Si sono verificati dei problemi. Si prega di ripetere l'operazione." + "</td></tr></table>";
			occupato_check_comment = false;
			document.body.style.cursor = "auto";
		}
	}
	else if(max_wait < 1000) {
		max_wait *= 1000;
		check = check_elapsed_time_check_comment(); 
	}
}


var occupato_check_comment = false;
function check_comment_xmlhttprequest(i,tot,class_name,original_comment,comment,operation) {
	if (!occupato_check_comment && http_check_comment) { 
		document.getElementById('td_area_info1').innerHTML = "<table style='border: 0;'><tr style=''><td valign='middle' style='width:50px;'>" + "<img src='./immagini/attesa.gif' width='42' height='42' alt='' /></td><td valign='middle'> Attendere prego..." + "</td></tr></table>";
		
		new_date = new Date();
		initial_time = new_date.getTime(); // tempo in millisecondi dell'inizio
		max_wait = 5; //tempo di attesa massima espresso in secondi
		
		document.body.style.cursor = "wait";
		var url_completo = url_check_comment+"classe="+encodeURIComponent(class_name)+"&commento="+encodeURIComponent(comment)+"&commento_originale="+encodeURIComponent(original_comment)+"&operazione="+encodeURIComponent(operation);
		//alert(url_completo);
		http_check_comment.open("GET", url_completo, true);
		http_check_comment.onreadystatechange = function() {handleHttpResponse_check_comment(i,tot,class_name,original_comment,comment);}
		occupato_check_comment = true;
		http_check_comment.send(null);
	}
}

function check_elapsed_time_check_comment () {
	new_date = new Date();
	if((new_date.getTime() - initial_time) > max_wait) {
		http_check_comment.onreadystatechange = function(){return;};
		http_check_comment.abort();
		document.getElementById('td_area_info1').innerHTML = "<table style='border: 0;'><tr style='background:#fff'><td>" + "Spiacente, richiesta fallita. Si prega di ritentare tra qualche istante." + "</td></tr></table>";
		occupato_check_comment = false;
		document.body.style.cursor = "auto";
	}
	else {
		timeout_check_comment = setTimeout(check_elapsed_time_check_comment, 500);
	}
}

//-->