function valida3()
{
	var i;
	var trovato=0;

     if (document.richiesta.nome.value.length == 0) {
		alert("Prego inserire NOME e COGNOME");
		document.richiesta.nome.focus();
		return false;
	}
	
	
//CONTROLLI TELEFONO
    if (document.richiesta.telefono.value.length == 0)
    {
     alert("Prego inserite il Vs TELEFONO");
     document.richiesta.telefono.focus();
     return false;
    }  
    if(isNaN(document.richiesta.telefono.value))
    {
      alert("Non inserite spazi bianchi nel numero es:054224242");
      document.richiesta.telefono.focus();
      return false;
    }
//FINE CONTROLLI TELEFONO



//CONTROLLI PER IL CAMPO Eemail
            
  var e_email;
  e_email=document.richiesta.email.value;
  
  
     if (document.richiesta.email.value.length == 0) {
		alert("Prego inserite la Vs E-email");
		document.richiesta.email.focus();
		return false;
	}  

if (document.richiesta.email.value.length > 0)
{
	
	for(i=0;i<document.richiesta.email.value.length;i++)
	{
		if(document.richiesta.email.value.lastIndexOf("@")<1)
		{
		alert("il carattere @ [chiocciola] deve essere presente nel campo E-email");
		document.richiesta.email.focus();
		return false;
		}
	}

if (document.richiesta.email.value.substring(0).charCodeAt()==45||document.richiesta.email.value.substring(0).charCodeAt()==46||document.richiesta.email.value.substring(0).charCodeAt()==64||document.richiesta.email.value.substring(0).charCodeAt()==95) {
		alert("Il PRIMO carattere del campo E-email non può essere nessuno dei seguenti caratteri:\npunto [.], chiocciola [@], trattino [-], underscore [_].");
		document.richiesta.email.focus();
		return false;
		}
		
		for(i=0;i<document.richiesta.email.value.length;i++)  //visualizza l' alert se nel campo sono presenti caratteri non consentiti
		{
        if(document.richiesta.email.value.charCodeAt(i)!=32&&document.richiesta.email.value.charCodeAt(i)!=45&&document.richiesta.email.value.charCodeAt(i)!=46&&document.richiesta.email.value.charCodeAt(i)<48||document.richiesta.email.value.charCodeAt(i)>57&&document.richiesta.email.value.charCodeAt(i)< 64|| document.richiesta.email.value.charCodeAt(i)>90 && document.richiesta.email.value.charCodeAt(i)!=95&&document.richiesta.email.value.charCodeAt(i)<97|| document.richiesta.email.value.charCodeAt(i)>122)
	      {
        alert("Nel campo E-email il carattere ["+document.richiesta.email.value.substring(i,i+1)+"] non è consentito");
         document.richiesta.email.focus();
	return false;
	 }
	}
	
     for(i=0;i<document.richiesta.email.value.length;i++)  //visualizza l' alert se nel campo è presente il carattere (spazio)
	{
        if(document.richiesta.email.value.charCodeAt(i)==32)
        {
        alert("Il carattere [spazio] nel campo E-email non è consentito");
         document.richiesta.email.focus();
         return false;
	 }
         }
   
   
  
         	
var chiocciolaCount = 0;
var foundatposition = 0;
while(foundatposition != -1)  {
	foundatposition = e_email.indexOf("@", foundatposition);
	if (foundatposition != -1) {
		chiocciolaCount++;
		foundatposition++;
	}
	}
	
	if (chiocciolaCount>1) {
	alert("Attenzione! Hai inserito " + chiocciolaCount + " volte il simbolo [@]. Negli indirizzi e-email ne puoi inserire solamente uno!");
	document.richiesta.email.focus();
	return false;
	}


var lunghezza_email;
lunghezza_email = e_email.length;
punto_posizionez=(lunghezza_email-4);
punto_posizione=(lunghezza_email-3);
puntone =e_email.substring(punto_posizionez,punto_posizionez+1);
punto = e_email.substring(punto_posizione,punto_posizione+1);

if (e_email != "es. lorenzo.lovato@europamultimedia.it" && e_email == "") {
	e_email = "";
	}
	else {
		
	for(i=punto_posizione+1;i<lunghezza_email;i++) {

	if (e_email.charCodeAt(i) < 65 || e_email.charCodeAt(i) > 90 && e_email.charCodeAt(i) < 97 || e_email.charCodeAt(i) > 122)
	{
	alert("Nel campo E_email l'estensione (es: .it,.com) non è corretta oppure è mancante.");
	document.richiesta.email.focus();
	return false;
	}
	}
	}

	if (e_email != "es. lorenzo.lovato@europamultimedia.it" && e_email == "") {
	e_email = "";
	}
	else {

	if (punto != "."&&puntone!=".") {
	alert("Nel campo E-email c'é un errore!\nControllare l'estensione.\n\nLe possibili cause sono:\n1. Manca il carattere punto.\n2. L'estensione è troppo lunga");
	document.richiesta.email.focus();
	return false;
	}
	}
	
 	if (e_email.lastIndexOf("@.") > 0 || e_email.lastIndexOf(".@") > 0) {
		alert("Nel campo E-email c'é un errore!\nI caratteri [@] e [.] non sono consentiti consecutivamente");
		document.richiesta.email.focus();
		return false;
	}
 		
	
	if (e_email.lastIndexOf("..") > 0) {
		alert("Nel campo E-email non sono ammessi i punti [..] consecutivi.");
		document.richiesta.email.focus();
		return false;
		}


//FINE CONTROLLI Eemail
}

//CONTROLLI PER LA PRIVACY
   if(document.richiesta.datipersonali.checked == false)
   {
     alert("Prego autorizzare il trattamento ai dati personali.");
     document.richiesta.datipersonali.focus();
     return false; 
   }  
//FINE CONTROLLI PRIVACY


//CONTROLLI TELEFONO
   if (document.richiesta.messaggio.value.length == 0)
    {
     alert("Prego inserire il testo della RICHIESTA! Il riferimento all'annuncio verra' inserito automaticamente!");
     document.richiesta.messaggio.focus();
     return false;
    }  


return true;
}	
