/*
//conversione date GG/MM/AAAA in AAAA-MM-GG
function convData($data){
list ($d, $m, $y) = explode ("/", $data);
return "$y-$m-$d";
}
*/

//controllo validità email
function controllomail(mail){

	var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;	
	if (!espressione.test(mail.value)){
		//alert('Email: '+mail.value+' errata');
		return false;
		} else{
			return true;
			}
}

//controllo campi del form mailingList
function controlloFormMailingList(){
//	alert(controllomail(document.getElementById('mailML')));
	if ( (document.getElementById('nomeML').value!='')&&(controllomail(document.getElementById('mailML'))==true) ){
		//showDialogSend('Info','Gentile'+document.forms['mailingList'].getElementById('nomeML').value+',<br><br>l\'email '+document.forms['mailingList'].getElementById('mailML')+' è stata aggiunta alla mailing list.','success',5);
		//alert('ok');
		document.forms['formML'].submit();
		return true;
	}else{
		//alert('errore');
		showDialogPersonale('Errore','Gentile '+document.getElementById('nomeML').value+',<br><br>non è stato possibile effettuare la registrazione della email '+document.getElementById('mailML').value+'  alla mailing list.','','','error');
		return false;
	}
}

//controllo campi del form assistenza clienti della pagina servizi
function controlloFormFAQ(){	
//	if ((document.getElementById('nominativoFAQ').value!='')||(document.getElementById('nominativoFAQ').value!='Nome')) alert(document.getElementById('nominativoFAQ').value);
//	if (document.getElementById('testoFAQ').value!=null) alert(document.getElementById('testoFAQ').value+'wee');
//	alert(controllomail(document.getElementById('mailFAQ')));
	if ( ((document.getElementById('nominativoFAQ').value!='')||(document.getElementById('nominativoFAQ').value!='Nome'))&&(document.getElementById('testoFAQ').value!=null)&&(controllomail(document.getElementById('mailFAQ'))==true) ){
//		showDialogPersonale('Info','Gentile Utente,<br> l\'email è stata inviata all\'indirizzo di posta desiderato.<br><br>Al più presto sarete contattati da un Nostro responsabile.','','','success',5);
//		setTimeout("document.forms['formFAQ'].submit()",5100);	
//		$('a#msgML').alert(function(){$("a#msgML").fancybox();});	
		return true;
	}else{
//		showDialogPersonale('Errore','Impossibile inviare l\'email.<br>Controllare che:<br>il nominativo sia stato inserito;<br>l\'email sia corretta;<br>il testo dell\'email sia presente.','','','error');		
		return false;
	}
}
