
function swap_d(img_name,to_what) {
    var swap, towhat;
    swap    = eval('document.images.'+img_name);
    towhat='../images/modeles/modele_spe/'+to_what+'.gif';
    swap.src    = towhat;
}


function JSAdhesion(o) {
    var nb_paiement = 0;
    var paiement    = 0;
    var theForm = document.form_adhesion;
    if (o==1) {
        swap_d('adhimg1','don/votre-don1');
        swap_d('adhimg2','adhesion/vos-coordonees');
        swap_d('adhimg3','adhesion/reglement');
        document.getElementById('etape_1').style.display = '';
        document.getElementById('etape_2').style.display = 'none';
        document.getElementById('etape_3').style.display = 'none';
    }
    if (o==2) {
        form_adhesion_ok = true;
        swap_d('adhimg1','don/votre-don');
        swap_d('adhimg2','adhesion/vos-coordonees1');
        swap_d('adhimg3','adhesion/reglement');
        if ((theForm.type_paiement[0].checked) && ((!theForm.paiement_autre.value) && (!theForm.paiement_don[0].value) && (!theForm.paiement_don[1].value) && (!theForm.paiement_don[2].value)))
         {theForm.frequence.value='4';}
        if((theForm.type_paiement[1].checked) && ((!theForm.paiement_regulier.value) && (!theForm.paiement_don[3].value) && (!theForm.paiement_don[4].value) && (!theForm.paiement_don[5].value))) {
            form_adhesion_ok = false;
            alert('Veuillez noter votre don de façon régulière');
            theForm.paiement_regulier.focus();
            return;
        }
        if((theForm.type_paiement[1].checked) && (theForm.frequence.value==''))
         {form_adhesion_ok = false;
          alert('Merci d\'indiquer la fréquence des prélevements automatique');
          theForm.chx_frequence.focus();
          return;
         }
         if ((!theForm.orientation_don[0].checked) && (!theForm.orientation_don[1].checked)&&(!theForm.orientation_don[2].checked))
          {form_adhesion_ok = false;
           alert('Merci de sélectionner l\'action bénéficiare du don');
           theForm.chx_comite.focus();
           return;
          }

        if (form_adhesion_ok==true) {
            document.getElementById('etape_1').style.display = 'none';
            document.getElementById('etape_2').style.display = '';
            document.getElementById('etape_3').style.display = 'none';
            pageTracker._trackPageview('Don-coordonnes.html');

        }
        if(theForm.type_paiement[0].checked) {
            if(theForm.paiement_don[0].checked)
                paiement = theForm.paiement_don[0].value;
            if(theForm.paiement_don[1].checked)
                paiement = theForm.paiement_don[1].value;
            if(theForm.paiement_don[2].checked)
                paiement = theForm.paiement_don[2].value;
            if (theForm.paiement_autre.value!="") {
                paiement = eval(theForm.paiement_autre.value);
            }
        }
        if(theForm.type_paiement[1].checked) {
            if(theForm.paiement_don[3].checked)
                paiement = theForm.paiement_don[3].value;
            if(theForm.paiement_don[4].checked)
                paiement = theForm.paiement_don[4].value;
            if(theForm.paiement_don[5].checked)
                paiement = theForm.paiement_don[5].value;
            if (theForm.paiement_regulier.value!="") {
                paiement = eval(theForm.paiement_regulier.value);
             }
        }
        if (theForm.abonnement.checked)
         {paiement = eval(paiement)+eval(theForm.abonnement.value);}
        theForm.total.value=paiement;
    }
    if (o==3) {
        form_adhesion_ok = true;
        if (theForm.prenom.value=="") {
                form_adhesion_ok = false;
                alert('Veuillez ajouter votre prénom');
                theForm.prenom.focus();
                return;
        }
        if (theForm.nom.value=="") {
                form_adhesion_ok = false;
                alert('Veuillez ajouter votre nom');
                theForm.nom.focus();
                return;
        }
        if (theForm.adresse.value=="") {
                form_adhesion_ok = false;
                alert('Veuillez ajouter votre adresse');
                theForm.adresse.focus();
                return;
        }
        if (theForm.cp.value=="") {
                form_adhesion_ok = false;
                alert('Veuillez ajouter votre code postal');
                theForm.cp.focus();
                return;
        }
        if (theForm.ville.value=="") {
                form_adhesion_ok = false;
                alert('Veuillez ajouter votre ville');
                theForm.ville.focus();
                return;
        }
        if (theForm.pays.value=="") {
                form_adhesion_ok = false;
                alert('Veuillez ajouter votre pays');
                theForm.pays.focus();
                return;
        }
        if (verif_annee(theForm.naissance)==false)
         {form_adhesion_ok = false;return;}
        if (verif_annee(theForm.diagnostic)==false)
         {form_adhesion_ok = false;return;}
        if (theForm.email.value!=""){
            var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
            var check=/@[\w\-]+\./;
            var checkend=/\.[a-zA-Z]{2,3}$/;
            var bEmailCheck = true ;
            if(((theForm.email.value.search(exclude) != -1)||(theForm.email.value.search(check)) == -1)||(theForm.email.value.search(checkend) == -1)){
                alert("L'adresse email est incorrecte !");
                theForm.email.focus();
                return;
            }
        } else {
            alert('Le champ \'E-mail\' est obligatoire');
            theForm.email.focus();
            return;
        }
        if (form_adhesion_ok==true) {
            swap_d('adhimg1','don/votre-don');
            swap_d('adhimg2','adhesion/vos-coordonees');
            swap_d('adhimg3','adhesion/reglement1');
             if ((theForm.type_paiement[1].checked) && (theForm.abonnement.checked))
             {document.getElementById('supplement').style.display = '';}
            else
             {document.getElementById('supplement').style.display = 'none';}
            if (theForm.type_paiement[0].checked)
             {document.getElementById('paiement_cheque').style.display = '';
              document.getElementById('paiement_prelv').style.display = 'none';
              document.getElementById('paiement_web').style.display = '';
              document.getElementById('paiement_non_web').style.display = 'none';
             }
            if (theForm.type_paiement[1].checked)
             {document.getElementById('paiement_cheque').style.display = 'none';
              document.getElementById('paiement_prelv').style.display = '';
              document.getElementById('paiement_web').style.display = 'none';
              document.getElementById('paiement_non_web').style.display = '';}
            pageTracker._trackPageview('Don-choixpaiement.html');
            document.getElementById('etape_1').style.display = 'none';
            document.getElementById('etape_2').style.display = 'none';
            document.getElementById('etape_3').style.display = '';
        }
    }
}