function Controllainput() {
  errore = "";
   Impresa = document.quest.Impresa.value;
  Indirizzo = document.quest.Indirizzo.value;
  Citta = document.quest.Citta.value;
  Prov = document.quest.Prov.value;
  Cap = document.quest.Cap.value;
  Telefono = document.quest.Telefono.value;
  Fax = document.quest.Fax.value;
  email = document.quest.email.value;
   Referente_azienda = document.quest.Referente_azienda.value;
  Ruolo_aziendale = document.quest.Ruolo_aziendale.value;
   Occupati_in_impresa = document.quest.Occupati_in_impresa.value;
 Tirocinanti_richiesti = document.quest.Tirocinanti_richiesti.value;
  Titolo_di_studio = document.quest.Titolo_di_studio.value;
  Mesi_tirocinio = document.quest.Mesi_tirocinio.value;
  dal = document.quest.dal.value;
  al = document.quest.al.value;
   Annotazioni = document.quest.Annotazioni.value;
 Altro_specifica = document.quest.Altro_specifica.value;
 if (Impresa  == "") 		{ errore += "\nDenominazione Sociale dell'Impresa"; } 
 if (Indirizzo  == "") 		{ errore += "\nIndirizzo"; }
 if (Citta  == "") 		{ errore += "\nCitta'"; }
 if (Prov  == "") 		{ errore += "\nProvincia"; }
 if (Cap  == "") { errore += "\nCap"; }
 if (Telefono  == "") 	{ errore += "\nTelefono"; }
 if (Fax  == "") 		{ errore += "\nFax"; }
 if (email  == "") 		{ errore += "\nIndirizzo e-mail"; }
 if (Referente_azienda  == "") 			{ errore += "\nReferente dell'Azienda"; }
 if (Ruolo_aziendale  == "") 			{ errore += "\nRuolo che ricopre in Azienda"; }
 if (Occupati_in_impresa  == "") 			{ errore += "\nIl numero di occupati a Tempo Ind. nell'impresa"; } 
  if (Tirocinanti_richiesti  == "") 			{ errore += "\nIl numero di tirocinanti richiesti"; } 
 if (Titolo_di_studio  == "") 			{ errore += "\nTitolo di studio"; }
 if (Mesi_tirocinio  == "") 			{ errore += "\nLa durata in mesi del tirocinio"; }
 if (dal  == "") 			{ errore += "\nL'inizio del tirocinio"; }
 if (al  == "") 			{ errore += "\nLa fine del tirocinio"; }
if (Annotazioni  == "") 			{ errore += "\nAnnotazioni"; }
 
 /*return errori*/

 
  
  
 
if (errore != "") {
    alert ("ATTENZIONE! Hai dimenticato di specificare:\n" + errore);
    return false;
  } 
 
    Errore_email = check_email(document.quest.email.value);
  if (Errore_email != "") {
    errore += "\n\nL'indirizzo E-MAIL non e' corretto:" + Errore_email + "\n";
  } 

if (document.quest.Profilo1.checked==false && document.quest.Profilo2.checked==false && document.quest.Profilo3.checked==false && document.quest.Profilo4.checked==false ) {
    alert ("ATTENZIONE! Hai dimenticato di scegliere il profilo");
	return false;
  }
  if ( document.quest.Profilo4.checked==true ) {
 		 if  (Altro_specifica  == "") 		
  			{ 
   alert ("ATTENZIONE! Hai dimenticato di scrivere il campo Altro");
    
	return false;
  } 
  }	
    /* return privacy */
  if (document.quest.Privacy.checked==false) {
    alert ("ATTENZIONE! Hai dimenticato di accettare l'informativa sulla Privacy");
	return false;
  }
function check_email(email) {

/*
LEGENDA DEGLI ERRORI:

1) La chiocciola e' presente: come primo o ultimo carattere o ne sono state digitate piu' di una;
2) L'e-mail contiene uno o piu' caratteri non ammessi contenuti nella variabile nochar;
3) Il punto e' presente: come primo, ultimo o penultimo carattere, prima o dopo la chiocciola;
4) Ci sono 2 punti (..) oppure due trattini (--) vicini;
5) Non c'e' nessun punto dopo la chiocciola
*/

var errors=""
var i

// Posizione della chiocciola.
var chiocPos=email.indexOf("@")

// Insieme dei caratteri non ammessi in un e-mail.
var nochar="\\/^,;:+אטלעש'<>()%=?!| " + '"'

// Prima lettera dell'e-mail.
var first_letter=email.substring(0,1)

// Ultima lettera dell'e-mail.
var last_letter=email.substring(email.length-1,email.length)

// Penultima lettera dell'e-mail.
var Penultima_letter=email.substring(email.length-2,email.length-1)

// Lettera a sinistra della chiocciola.
var sx_chioc=email.substring(chiocPos-1,chiocPos)

// Lettera a destra della chiocciola.
var dx_chioc=email.substring(chiocPos+1,chiocPos+2)


if ((chiocPos<"1") || (chiocPos==(email.length-1)) || (chiocPos!=(email.lastIndexOf("@")))) {
errors+="\n- Carattere chiocciola (@) mancante o in posizione errata"
}

else {
  for (var i=0; i<=nochar.length-1; i++) {
    if (email.indexOf(nochar.substring(i,i+1))!="-1") {
     errors+="\n- Hai digitato dei caratteri non ammessi"
     break
    }
  }
}

if (errors=="") {
  if ((first_letter==".") || (sx_chioc==".") || (dx_chioc==".") || (last_letter==".") || (Penultima_letter==".") ) {
     errors+="\n- Il punto (.) e' in posizione errata"
  }  
  else {

    for (var i=0; i<=email.length-1; i++) {
      if ((email.substring(i,i+1)==".") && (email.substring(i+1,i+2)==".")) {
        errors+="\n- Ci sono due caratteri punto (.) vicini"
        break
      }
      if ((email.substring(i,i+1)=="-") && (email.substring(i+1,i+2)=="-")) {
        errors+="\n- Ci sono due caratteri trattino (-) vicini"
        break
      }
    }
  }
}
PuntoDopoChioc = 0

if (errors=="") {

  for (var i=chiocPos+1; i<=email.length-3; i++) {
    if (email.substring(i,i+1)==".") {
      PuntoDopoChioc = 1
      break
    }
  }
  if (PuntoDopoChioc == 0) {
    errors+="\n- Non hai indicato il dominio (.it .com .net ecc..)"
  }
}

return errors
}
}
