function testMail(){
		if(document.F_mail.mail.value != ""){
			EmailAddr = document.F_mail.mail.value;
			Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
			if (!Filtro.test(EmailAddr)){
				alert("Controlla l'indirizzo di e-mail inserito");
				return false;
			}else{
				return true;
			}
		}
	}
	
function ver_form(a,b,c){	
		elementi = b.split(",");
		control = 0;
		for (var i = 0; i < a; i++) {			
			stringa='document.'+c+'.'+elementi[i]+'.value';
			nome='document.'+c+'.'+elementi[i]+'.name';
			if (eval(stringa)==''){
				alert("Attenzione, compilare tutti i campi");
				control=1;
				return false;
			}
		}
		return true;
	}
	
function invia_F(a,b,c){
	if(ver_form(a,b,c)){
		if(testMail()){
				if(document.F_mail.privacy.checked){
					return true;
					}else{
						alert("E' necessario fornire l'autorizzazione al trattamento dei dati personali");
						return false;
					}
			}else{
				return false;
			}
	}else{
		return false;
	}
}


function trim(stringToTrim) {
	return stringToTrim.replace(/\n/g,"");
}



function chkFormIscr(a,b,c){
		if(invia_F(a,b,c))
		{			
			if(document.F_mail.pagato.checked)
			{
				if(trim(document.F_mail.elaborato.value).length < 16000){
					return true;
				}
				else
				{
					alert("il racconto supera la 16.000 battute");
					return false;
				}
			}
			else
			{
				alert("E' necessario versare la quota di iscrizione.");
				return false;
			}
		}
		else
		{
			return false;
		}
}
