
function checkEmail(str){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str)){	return true;	}else{		return false;	}
}		
function subme(modulo) {
var errors='';
  mama=modulo;

  ook=true;
  
  if (mama.firstname.value=="") {
	errors+='- Nome\n';
    ook=false;
  };
    
  if (mama.realname.value=="") {
	errors+='- Cognome\n';
    ook=false;
  };
    if (mama.indirizzo.value=="") {
	errors+='- Indirizzo\n';
    ook=false;
  };
 
 if (mama.citta.value=="") {
   errors+='- Città\n';
   ook=false;
  };
 
  if (mama.provincia.value=="") {
   errors+='- Provincia\n';
   ook=false;
  };

 
if (!checkEmail(mama.email.value)) {
	errors+='- Indirizzo E-mail valido\n';
    ook=false;
  };
 
   if (mama.telefono.value=="") {
   errors+='- Telefono\n';
   ook=false;
  };

 if (mama.messaggio.value=="") {
	errors+='- Messaggio\n';
    ook=false;
  }; 
    
if (!(mama.tratt_dati.checked)) {
	errors+='\n'+'É necessario acconsentire al trattamento dei dati personali\n';
    ook=false;
  };

if (!ook) {
  alert('Attenzione: i seguenti campi sono obbligatori:\n\n'+errors);
  }
  
  return ook;
}

var extFile = Array("pdf","rtf","doc","txt");

function verificaImg(fileInput){
   var file = fileInput.value;
   var temp = file.split(".");
   var numPunti = temp.length;
   if(numPunti < 2)
       return false;
   numPunti = numPunti-1;
   var ext = temp[numPunti].toLowerCase();
   
   if(ext.length != 3)
      return false;
   // Verifichiamo l'estensione
   
   var lenExt = extFile.length;
   
   for(var i=0;i<lenExt;i++){
       
   if(extFile[i] == ext){
        return true;
   }
   }
   return false;
}