function check_disagi(sd){
 if(document.getElementById("nome").value.length<1){
  return false;
 }
 
 if(document.getElementById("cognome").value.length<1){
  return false;
 }
 
 if(document.getElementById("telefono").value.length<1){
  return false;
 }
 
 if(document.getElementById("mail").value.length<1){
  return false;
 }
 
 if(document.getElementById("messaggio").value.length<1){
  return false;
 }
 
 if(document.getElementById("privacy").checked==false){
  return false;
 }
 
  return true;
}

function controlla_prima_pagina(){
  svuota_div(document.getElementById("errore"));
  var err=0;
  if(document.getElementById("nome").value.length<1){
    err=1;
    notifica="Il campo nome è obbligatorio";
  }
  
  if(document.getElementById("cognome").value.length<1){
    err=1;
    notifica="Il campo cognome è obbligatorio";
  }
  
  if(document.getElementById("cellulare").value.length<1){
    err=1;
    notifica="Il campo cellulare è obbligatorio";
  }
  
  var mail_inserita = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if (!mail_inserita.test(document.getElementById("mail").value)){
    err=1;
    notifica="La mail inserita non è corretta";
  }
  if(document.getElementById("psw").value!=document.getElementById("psw2").value){
    err=1;
    notifica="Inserite due password diverse";
  }
  
  if(document.getElementById("psw").value.length<5){
    err=1;
    notifica="La password deve contenere almeno 5 caratteri";
  }
  
  if(document.getElementById("psw").value.length<1){
    err=1;
    notifica="Campo password è obbligatorio";
  }
  
  if (err==0){ 
  document.getElementById('pagina2').className='pagina2';
  document.getElementById('pagina1').className='nascondi';
  svuota_div(document.getElementById("errore"));
  } else document.getElementById("errore").appendChild(document.createTextNode(notifica));
}

function controlla_seconda_pagina(){
  svuota_div(document.getElementById("errore"));
   if(document.getElementById("privacy").checked==false){
    notifica="Accettare le condizioni sulla privacy per proseguire";
    document.getElementById("errore").appendChild(document.createTextNode(notifica));
    return false;
 }
  return true;
}

function questionario(){
  svuota_div(document.getElementById("errore"));
  var mail_inserita = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if (!mail_inserita.test(document.getElementById("email").value)){
    notifica="La mail inserita non è corretta";
    document.getElementById("errore").appendChild(document.createTextNode(notifica));
    return false;
  }
  if(document.getElementById("privacy").checked==false){
    notifica="Accettare le condizioni sulla privacy per proseguire";
    document.getElementById("errore").appendChild(document.createTextNode(notifica));
  return false;
 }
  return true;
}

function svuota_div(obj) {
	var nObj =obj.cloneNode(false);
	obj.parentNode.insertBefore(nObj,obj);
	obj.parentNode.removeChild(obj);
}


function valida_target() { 
    for (var i=0; i<document.links.length; i++)
        if (document.links[i].className=="blank") {
            document.links[i].target="_blank";
        } 
}

