
function controllo_campi(registrazione) {



         if (registrazione.edit_email.value == "") {
             alert("Non ha inserito la sua e-mail");
             registrazione.edit_email.focus();
             return false;
         }

         if (controllo_email(registrazione.edit_email)==false){
                     alert("L'email inserita non è valida. La preghiamo di correggere.");
                     registrazione.edit_email.focus();
                     return false;
         }

         if (registrazione.edit_conferma_email.value == "") {
             alert("Non ha inserito nuovamente la sua email per conferma");
             registrazione.edit_conferma_email.focus();
             return false;
         }


         if (registrazione.edit_email.value != registrazione.edit_conferma_email.value) {
             alert("L'e-mail di conferma non corrisponde con quella inserita");
             registrazione.edit_conferma_email.focus();
             return false;
         }

         if (registrazione.anno_nascita.value == "0") {
                     alert("Non ha selezionato l'anno di nascita");
                     registrazione.anno_nascita.focus();
                     return false;
         }

         if (registrazione.peso.value == "0") {
                     alert("Non ha selezionato il suo peso");
                     registrazione.peso.focus();
                     return false;
         }

         if (registrazione.altezza.value == "0") {
                     alert("Non ha selezionato la sua altezza");
                     registrazione.altezza.focus();
                     return false;
         }
         
         if (registrazione.sesso.value == "0") {
                     alert("Non ha selezionato il suo sesso");
                     registrazione.sesso.focus();
                     return false;
         }

       if (registrazione.edit_scopi.value == "") {
             alert("Non ha descritto gli scopi che intende raggiungere");
             registrazione.edit_scopi.focus();
             return false;
         }

        if (registrazione.ore_allenamento.value == "0") {
                     alert("Non ha selezionato le ore di allenamento che puo' dedicare settimanalmente");
                     registrazione.ore_allenamento.focus();
                     return false;
         }

         if (registrazione.op_malattie_reumatiche[0].checked || registrazione.op_malattie_reumatiche[1].checked){
            if (registrazione.op_malattie_reumatiche[0].checked==true){
                if (registrazione.edit_malattie_reumatiche.value==""){
                    alert ("MALATTIE REUMATICHE! Descrivere i problemi selezionati nell'apposito spazio");
                    registrazione.edit_malattie_reumatiche.focus();
                    return false;
                }
            }
         }
         else{
             alert ("MALATTIE REUMATICHE! Selezionare SI o NO");
             registrazione.op_malattie_reumatiche[0].focus();
             return false;
         }



         if (registrazione.op_problemi_circolatori[0].checked || registrazione.op_problemi_circolatori[1].checked){
            if (registrazione.op_problemi_circolatori[0].checked==true){
                if (registrazione.edit_problemi_circolatori.value==""){
                    alert ("PROBLEMI CIRCOLATORI! Descrivere i problemi selezionati nell'apposito spazio");
                    registrazione.edit_problemi_circolatori.focus();
                    return false;
                }
            }
         }
         else{
             alert ("PROBLEMI CIRCOLATORI! Selezionare SI o NO");
             registrazione.op_problemi_circolatori[0].focus();
             return false;
         }

        if (registrazione.op_malattie_metaboliche[0].checked || registrazione.op_malattie_metaboliche[1].checked){
            if (registrazione.op_malattie_metaboliche[0].checked==true){
                if (registrazione.edit_malattie_metaboliche.value==""){
                    alert ("MALATTIE METABOLICHE! Descrivere i problemi selezionati nell'apposito spazio");
                    registrazione.edit_malattie_metaboliche.focus();
                    return false;
                }
            }
         }
         else{
             alert ("MALATTIE METABOLICHE! Selezionare SI o NO");
             registrazione.op_malattie_metaboliche[0].focus();
             return false;
         }

         if (registrazione.op_traumi[0].checked || registrazione.op_traumi[1].checked){
            if (registrazione.op_traumi[0].checked==true){
                if (registrazione.edit_traumi.value==""){
                    alert ("TRAUMI! Descrivere i problemi selezionati nell'apposito spazio");
                    registrazione.edit_traumi.focus();
                    return false;
                }
            }
         }
         else{
             alert ("TRAUMI! Selezionare SI o NO");
             registrazione.op_traumi[0].focus();
             return false;
         }


         if (registrazione.op_terapie[0].checked || registrazione.op_terapie[1].checked){
            if (registrazione.op_terapie[0].checked==true){
                if (registrazione.edit_terapie.value==""){
                    alert ("TERAPIE! Descrivere utilizzando l'apposito spazio");
                    registrazione.edit_terapie.focus();
                    return false;
                }
            }
         }
         else{
             alert ("TERAPIE! Selezionare SI o NO");
             registrazione.op_terapie[0].focus();
             return false;
         }


         if (registrazione.check_privacy.checked == false) {
             alert("Per continuare con la registrazione deve consentire il trattamento dei dati personali");
             registrazione.check_privacy.focus();
             return false;
         }



         return true;
}


function controllo_email(email) {
        if (email.value != null && email.value != "") {
                        a = email.value.lastIndexOf("@");
                        b = email.value.lastIndexOf(".");
                        c = email.value.indexOf(":");
                        d = email.value.indexOf("/");
                        e = email.value.substring(0,a);
                        f = e.indexOf("@");
                        g = email.value.substring(a+1,email.value.length);
                        h = g.indexOf("[");
                        i = g.indexOf("]");
                        j = g.indexOf("<");
                        k = g.indexOf(">");
                        l = email.value.substring(a+1,b);
                        m = email.value.substring(b+1,email.value.length);
                        n = email.value.substring(0,a);
                        o = 0;
                        if (a > b) {o++};
                        if (c != -1) {o++};
                        if (d != -1) {o++};
                        if (f != -1) {o++};
                        if (h != -1) {o++};
                        if (i != -1) {o++};
                        if (j != -1) {o++};
                        if (k != -1) {o++};
                        if (l.length < 3) {o++};
                        if (m.length < 2) {o++};
                        if (n.length < 1) {o++};
                        if (o == 0) {    // document.Form.requiredeaddress.value = email;
                                return true;
                        }
                        else {
                                //alert("Indirizzo mail non valido ! Per favore inserire la mail con il formato corretto mail@dominio.xx");
                                return false;
                             }
                    }
}

function messaggio(testo_messaggio) {
         alert(testo_messaggio);
}


function mod_malattie_reumatiche(valore){
         if (valore==1){
             malattie_reumatiche.innerHTML="<input name='edit_malattie_reumatiche' type='text'  size='50'>";
         }
         else{
              malattie_reumatiche.innerHTML="<input name='edit_malattie_reumatiche' type='text'  size='50' disabled>";
         }
}

function mod_problemi_circolatori(valore){
         if (valore==1){
             problemi_circolatori.innerHTML="<input name='edit_problemi_circolatori' type='text' size='50'>";
         }
         else{
             problemi_circolatori.innerHTML="<input name='edit_problemi_circolatori' type='text' size='50' disabled>";
         }
}

function mod_malattie_metaboliche(valore){
         if (valore==1){
             malattie_metaboliche.innerHTML="<input name='edit_malattie_metaboliche' type='text' size='50'>";
         }
         else{
             malattie_metaboliche.innerHTML="<input name='edit_malattie_metaboliche' type='text' size='50' disabled>";
         }
}

function mod_traumi(valore){
         if (valore==1){
             traumi.innerHTML="<input name='edit_traumi' type='text' size='50'>";
         }
         else{
             traumi.innerHTML="<input name='edit_traumi' type='text' size='50' disabled>";
         }
}

function mod_terapie(valore){
         if (valore==1){
             terapie.innerHTML="<input name='edit_terapie' type='text' size='50'>";
         }
         else{
             terapie.innerHTML="<input name='edit_terapie' type='text' size='50' disabled>";
         }
}
