function invio(e,modulo) {
	e=e||window.event;
	if (e.keyCode == 13){
		if (modulo=='it'){
			controllo()
		}
		if (modulo=='en'){
			controllo_en()
		}
	}
}

function isEmail(campo){
	appo=true
	if (campo!=''){
		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 controllo(){
	with(document){
		err='';
		if (getElementById('privacy').checked==false){
			err="  - Per inviare il modulo e' obbligatorio acconsentire al trattamento dei dati personali    \n"+err;
			getElementById('privacy').focus();
		}
		if (getElementById('testo').value==''){
			err="  - Il campo Richiesta di Informazioni e' obbligatorio     \n"+err;
			getElementById('testo').focus();
		}
		if (getElementById('email').value!=getElementById('email2').value){
			err="  - Il campo E-mail ed il campo Conferma E-mail devono essere uguali     \n"+err;
			getElementById('email2').focus();
		}
		if (isEmail(getElementById('email').value)==false){
			err="  - Non e' stata scritto un indirizzo e-mail valido nel campo E-mail     \n"+err;
			getElementById('email').focus();
		}
		if (getElementById('email2').value==''){
			err="  - Il campo Conferma E-mail e' obbligatorio     \n"+err;
			getElementById('email2').focus();
		}
		if (getElementById('email').value==''){
			err="  - Il campo E-mail e' obbligatorio     \n"+err;
			getElementById('email').focus();
		}
		if (getElementById('conoscenza').value==''){
			err="  - Il campo In che modo ha conosciuto Villa Aurelia e' obbligatorio     \n"+err;
			getElementById('conoscenza').focus();
		}
		if (getElementById('data').value==''){
			err="  - Il campo Data/Stagione e' obbligatorio     \n"+err;
			getElementById('data').focus();
		}
		if (getElementById('tipologia').value==''){
			err="  - Il campo Tipologia Evento e' obbligatorio     \n"+err;
			getElementById('tipologia').focus();
		}
		if (getElementById('nome').value==''){
			err="  - Il campo Nome/Azienda e' obbligatorio     \n"+err;
			getElementById('nome').focus();
		}
		if (err!=''){
			alert('ATTENZIONE!!!\nSono stati riscontrati i seguenti errori:\n\n'+err);	
		}else{
			getElementById('modulo').submit();
		}
	}	
}
function controllo_en(){
	with(document){
		err='';
		if (getElementById('privacy').checked==false){
			err="  - To send the form is required to agree to the processing of personal data\n"+err;
			getElementById('privacy').focus();
		}
		if (getElementById('testo').value==''){
			err="  - Field Request for Information is required\n"+err;
			getElementById('testo').focus();
		}
		if (getElementById('email').value!=getElementById('email2').value){
			err="  - Fields E-mail and Confirm E-mail must be equal\n"+err;
			getElementById('email2').focus();
		}
		if (isEmail(getElementById('email').value)==false){
			err="  - E-mail address is not valid\n"+err;
			getElementById('email').focus();
		}
		if (getElementById('email2').value==''){
			err="  - Field Confirm E-mail is required\n"+err;
			getElementById('email2').focus();
		}
		if (getElementById('email').value==''){
			err="  - Field E-mail is required\n"+err;
			getElementById('email').focus();
		}
		if (getElementById('conoscenza').value==''){
			err="  - Field 'How did you hear about Villa Aurelia?' is required\n"+err;
			getElementById('conoscenza').focus();
		}
		if (getElementById('data').value==''){
			err="  - Field Data/Season is required\n"+err;
			getElementById('data').focus();
		}
		if (getElementById('tipologia').value==''){
			err="  - Field Type of Event is required\n"+err;
			getElementById('tipologia').focus();
		}
		if (getElementById('nome').value==''){
			err="  - Field Name/Company is required\n"+err;
			getElementById('nome').focus();
		}
		if (err!=''){
			alert('ATTENTION!!!\nWere the following errors:\n\n'+err);	
		}else{
			getElementById('modulo').submit();
		}
	}	
}
