function fillPlatformCont(addr, dettaglio){
	var getUrl = addr+"srv/getPlatformCont.php?dettaglio=" + dettaglio;
	new Ajax.Updater("platformCont", getUrl)
}

function sendcommento(addr){
	
	var nome = document.getElementById("nome").value;
	var email = document.getElementById("email").value;
	var commento = document.getElementById("commento").value;
	var provincia = document.getElementById("provincia").value;
	var citta = document.getElementById("citta").value;			
	
	if (document.getElementById("nome").value=='') {
		messaggio("Nome");
		return false;
	}
	
	if(!checkMail(email)){
			messaggio("email");
		return false;
	}	
	
	if (document.getElementById("commento").value=='') {
		messaggio("commento");
		return false;
	}
	
	if (document.getElementById("citta").value=='') {
		messaggio("citta");
		return false;
	}	
	
	if (document.getElementById("provincia").value=='') {
		messaggio("provincia");
		return false;
	}			

	var getUrl = addr+"srv/send_commento.php?nome=" + nome + "&email=" + email + "&commento=" + commento + "&citta=" + citta + "&provincia=" + provincia; 
/*	var getUrl = addr+"srv/send_commento.php?nome=" + nome + "&email=" + email + "&commento=" + commento; */
	new Ajax.Updater("sendcommento", getUrl);
}

function checkMail(datain){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(datain))
		testresults=true
	else{
		testresults=false
	}
	return (testresults)
}

function gallery() {
    window.open("/gallery.php","","channelmode");
}

function tooLong(strTest, maxLength){
//	alert(strTest.value.length);
	if(strTest.value.length > maxLength)
	{
		strTest.value = strTest.value.substr(0, maxLength);
	}
}

function messaggio(txt) {
	alert("Manca un campo necessario.\nRiempire il campo '"+txt+"'");
}

function test_carattere(variab){
	var good_chars = "abcdefghijklmnopqrstuvwxyz_1234567890";
	for (i=0; i < variab.value.length; i++) {	
		var caratt = variab.value.charAt(i);		
		var lowerCaratt = caratt.toLowerCase();
		if (good_chars.indexOf(lowerCaratt) == -1) {
			return false;
		}
	}
	return true;
}

