function validaFrmCommento(modulo) {
	if ((modulo.testo_commento.value.length == 0) || (modulo.nome.value.length == 0)) {
		alert("Per favore, un nome e un testo per il commento, grazie.");
		return false;
	} else {
		if (modulo.antispam.value.length == 0) {
			alert("L'antispaaam!!!");
			return false;
		} else {
			return true;
		}
	}
}
function validaFrmRicerca(modulo) {
	if ((modulo.ricerca.value.length < 3)) {
		alert("Please, almeno tre caratteri per una ricerca.");
		return false;
	} else {
		return true;
	}
}
function mostra(blocco) {
	with (document.getElementById(blocco).style) {
		if (display != "block") {
			display = "block";
		} else {
			display = "none";
		}
	}
}

function avviaRicerca() {
	if (document.getElementById("ricerca").value.length >= 3) {
		ricercaRisultati("ricercaajax.php?ricerca=" + document.getElementById("ricerca").value);
		document.getElementById("risultatiricerca").style.display = "block";
	} else {
		document.getElementById("risultatiricerca").style.display = "none";
		document.getElementById("risultatiricerca").innerHTML = "";
	}
}

function ricercaRisultati(url) {
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// Vedi note sotto
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Non riesco a creare una istanza XMLHTTP');
		return false;
	}
	http_request.onreadystatechange = function() {
		aggiornaRisultati(http_request);
	};
	http_request.open('GET', url, true);
	http_request.send(null);
	
}

function aggiornaRisultati(http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById("risultatiricerca").innerHTML = http_request.responseText;
		} else {
			alert('Si è verificato un problema con la richiesta');
		}
	}
}