function InviaDati(){

if (document.modulo.mail.value == "")
  {
    alert("Inserisci correttamente la tua E-mail.");
    document.modulo.mail.focus();
    return (false);
  }

  if (document.modulo.mail.value != "")
  {
  if (document.modulo.mail.value.indexOf('@') != -1)
  {
     datoEmail=document.modulo.mail.value;
     var datiEm = new Array();
     datiEm=datoEmail.split("@");
     var datiEm2 = new Array();
     datiEm2=datiEm[1].split(".");
     var numPezzi=datiEm2.length;

     if (datiEm[0].length == 0)
     {
        alert("Indirizzo E-mail non valido!");
        document.modulo.mail.focus();
        return (false);
     }

     if (numPezzi != 2)
     {
        alert("Indirizzo E-mail non valido!");
        document.modulo.mail.focus();
        return (false);
     }
  }
  else
  {
    alert("Indirizzo E-mail non valido!");
    document.modulo.mail.focus();
    return (false);
  }
  }
  else
  {
    alert("Inserisci correttamente la tua E-mail.");
    document.modulo.mail.focus();
    return (false);
  }


  PreparaDati('modulo',false);
  AJAXReq("POST","info.php",true);
}




var ele = new Array();
function PreparaDati(nome,ele){
  stringa = "";
  var form = document.forms[nome];
   if(ele){
    var numeroElementi = ele.length;
    for(var i = 0; i < numeroElementi; i++){
     if(i < numeroElementi-1){
      stringa += ele[i]+"="+encodeURIComponent(form.elements[ele[i]].value)+"&";
    }else{
      stringa += ele[i]+"="+encodeURIComponent(form.elements[ele[i]].value);
    }
   }
  }else{
    var numeroElementi = form.elements.length;
    for(var i = 0; i < numeroElementi; i++){
     if(i < numeroElementi-1){
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
    }else{
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
    }
   }
  }
}



function AJAXReq(method,url,bool){
  if(window.XMLHttpRequest){
    myReq = new XMLHttpRequest();
  } else

  if(window.ActiveXObject){
    myReq = new ActiveXObject("Microsoft.XMLHTTP");

    if(!myReq){
      myReq = new ActiveXObject("Msxml2.XMLHTTP");
    }
  }

  if(myReq){
    execfunc(method,url,bool);
  }else{
    alert("Impossibilitati ad usare AJAX");
  }
}




function execfunc(method,url,bool){
  myReq.onreadystatechange = handleResponse;
  myReq.open(method,url,bool);
  myReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  myReq.send(stringa);
}



function handleResponse() {
    if(myReq.readyState == 4){
        var response = myReq.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}