
    var boolShowAlerte = false;
    var urlWebServices = "https://secure.fondation-nature-homme.org";

    $(function(){  

        /** Formatage de la boîte de dialogue pour les alertes */
        $("#divAlerte").dialog({
            modal: true,
            autoOpen: false,
            width: 500,
            height: 550,
			buttons: {
				"Fermer": function() { 
                    if ( $.browser.msie && $.browser.version=="6.0" ) {
                        $("#affectation").css("display", "");
    				    $("#civilite").css("display", "");
                        $("#pays").css("display", "");
                    }
					$(this).dialog("close");
				} 
			}
        });

        /** Analyse sur soumission du formulaire de don */
        $("#formulaireDon").submit( function () {

            /** Annulation des messages précédents */
            boolShowAlerte = false;
            $("#messageEtape1").html("");
            $("#messageEtape2").html("");
            $("#messageEtape3").html("");

            analyserTypeDons();
            analyserSympathisant();
            analyserModePaiement();
            showDivAlerte();
            if ( ! boolShowAlerte ) {

                $("#montantDon").val(jsMontantDon);

                switch ( jsModePaiement ) {
                    case "CB":

								/** Les formulaires en étapes ne peuvent utiliser le kit bancaire */
                        switch ( monTheme ) {
                        	case "fnh_portail_etapes":
                        		$("#formulaireDon").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + "fnh_portail_complet" + "/payer/carte-bleue-paiement.html");
                        		break;
                        	default:
                        		$("#formulaireDon").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + monTheme + "/payer/carte-bleue-paiement.html");
                        		break;	
                        }

                        break;

                    case "CHQ":
                        $("#formulaireDon").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + monTheme + "/payer/cheque-paiement.html");
                        break;

                    case "PAYPAL":
                        $("#formulaireDon").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + monTheme + "/payer/paypal-paiement.html");
                        break;

                    case "PRLVT":
                        $("#formulaireDon").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + monTheme + "/payer/prelevement-paiement.html");
                        break;

                    default:
                        break;

                }

                return true;
            }

            return false;

        });

		/** Analyse sur soumission du formulaire de don, suite à échec paiement CB, ou PAYPAL	 */
		$("#formulaireDonReprise").submit( function () {

            /** Annulation des messages précédents */
            boolShowAlerte = false;
            $("#messageEtape1").html("");
            $("#messageEtape2").html("");
            $("#messageEtape3").html("");

            analyserModePaiement();
            showDivAlerte();
            if ( ! boolShowAlerte ) {

                $("#montantDon").val(jsMontantDon);

                switch ( jsModePaiement ) {

                    case "CB":
                        $("#formulaireDonReprise").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + monTheme + "/reprise_paiement/carte-bleue-paiement.html");
                        break;

                    case "CHQ":
                        $("#formulaireDonReprise").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + monTheme + "/reprise_paiement/cheque-paiement.html");
                        break;

                    case "PAYPAL":
                        $("#formulaireDonReprise").attr("action", window.location.protocol + "//" + window.location.hostname + "/" + monTheme + "/reprise_paiement/paypal-paiement.html");
                        break;

                    default:
                        break;

                }

                return true;
            }

            return false;		

        });

    });

/* ************************************ */
/* ************************************ */

    $(document).ready( function() {
        
    });

/* ************************************ */
/* ************************************ */

    function showDivAlerte() {
        boolDisplay = false;
        if ( boolShowAlerte ) {
            boolShowAlerte = false;
            $("#blocMessageEtape1").css("display", "none");
            $("#blocMessageEtape2").css("display", "none");
            $("#blocMessageEtape3").css("display", "none");
            
            if ( $("#messageEtape1").html().length > 0 ) {
                boolDisplay = true;
                $("#blocMessageEtape1").css("display", "");
            }
            if ( $("#messageEtape2").html().length > 0 ) {
                boolDisplay = true;
                $("#blocMessageEtape2").css("display", "");
            }
            if ( $("#messageEtape3").html().length > 0 ) {
                boolDisplay = true;
                $("#blocMessageEtape3").css("display", "");
            }
            if ( boolDisplay ) {
                boolShowAlerte = true;
                if ( $.browser.msie && $.browser.version=="6.0" ) {
                    $("#affectation").css("display", "none");
				    $("#civilite").css("display", "none");
                    $("#pays").css("display", "none");
                }
                $("#divAlerte").dialog('open');
            }
        }
    }

