function swap_m(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_m('adhimg1','adhesion/votre-adhesion1');
        swap_m('adhimg2','adhesion/vos-coordonees');
        swap_m('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_m('adhimg1','adhesion/votre-adhesion');
        swap_m('adhimg2','adhesion/vos-coordonees1');
        swap_m('adhimg3','adhesion/reglement');
        if (theForm.paiement_don.value!='0')
         {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 ((theForm.adhere[1].checked)&&(theForm.num_adherent.value==''))
         {form_adhesion_ok = false;
          alert('Veuillez saisir votre numéro d\'adhérent');
          theForm.num_adherent.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('Adhesion-coordonnes.html');

        }
        if(theForm.paiement_adh[0].checked)
            paiement = theForm.paiement_adh[0].value;
        if(theForm.paiement_adh[1].checked)
            paiement = theForm.paiement_adh[1].value;
        if(theForm.paiement_adh[2].checked)
            paiement = theForm.paiement_adh[2].value;
        if (theForm.paiement_autre.value!="") {
            nb_paiement = eval(theForm.paiement_autre.value)+eval(theForm.paiement_don.value);
        }
        else {
            nb_paiement = eval(paiement)+eval(theForm.paiement_don.value);
        }
        if (theForm.abonnement.checked)
         {nb_paiement = eval(nb_paiement)+eval(theForm.abonnement.value);}

        theForm.total.value=nb_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 (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_m('adhimg1','adhesion/votre-adhesion');
            swap_m('adhimg2','adhesion/vos-coordonees');
            swap_m('adhimg3','adhesion/reglement1');
            if (theForm.abonnement.checked)
             {document.getElementById('supplement').style.display = '';}
            else
             {document.getElementById('supplement').style.display = 'none';}
            pageTracker._trackPageview('Adhesion-choixpaiement.html');
            document.getElementById('etape_1').style.display = 'none';
            document.getElementById('etape_2').style.display = 'none';
            document.getElementById('etape_3').style.display = '';
        }
    }
}
