function isEmail(campo){
	appo=true
	if (campo!=''){
		if (campo.indexOf(' ')!=-1){
			appo=false;
		}
		campo=campo.split('@');
		if (campo.length!=2){appo=false;}
		if (appo){
			if ((campo[0].length < 2) || (campo[1].length < 5)){
				appo=false;
			}
		}
		if (appo){
			campo=campo[1].split('.');
			if(campo.length < 2){appo=false}
			if (appo){
				if (campo[0].length<2){appo=false}
			}
			if(appo){
				if (campo[1].length<2){appo=false}
			}
		}
	}
	return appo;
}

function invio_esperto(){
	with(document){
		err="";
		if (!getElementById('aut').checked){
			err="  - Autorizzare il trattamento dei Dati Personali\n" + err;
		}
		if (getElementById('domanda').value==''){
			err="  - Inserire il testo della Domanda\n"+err;
			getElementById('domanda').focus();
		}
		if (getElementById('email').value!=getElementById('email2').value){
			err="  - Inseriti due indirizzi E-mail diversi\n"+err;
			getElementById('email2').focus();
			getElementById('email2').select();
		}
		if(!isEmail(getElementById('email').value)){
			err="  - Inserire indirizzo E-mail valido\n"+err;
			getElementById('email').focus();
			getElementById('email').select();
		}
		if (getElementById('email').value==''){
			err="  - Inserire il proprio indirizzo E-mail\n"+err;
			getElementById('email').focus();
		}
		if (getElementById('mittente').value==''){
			err="  - Inserire il proprio Mittente\n"+err;
			getElementById('mittente').focus();
		}
		if (err!=""){
			alert("ATTENZIONE!\nRiscontrati i seguenti errori:\n\n" + err);
		}else{
			getElementById('modulo').submit();
		}
	}	
}