<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/******/ (() =&gt; { // webpackBootstrap
/*!***************************************!*\
  !*** ./resources/assets/js/common.js ***!
  \***************************************/
$(document).ready(function () {
  ini_header();
  init_a2hs();
  ini_menu();
  ini_footer();
  ini_stats_analyser();
  ini_filtres();
  ini_video("");
  ini_formulaire_commentaires();
  ini_commentaires();
  ini_forum();
  ini_giphy();
  ini_livredor();
  ini_partage();
  ini_menu_sections();
  ini_widget_a_la_une();
  ini_widgets_evenements();
  ini_widget_reservations();
  ini_widget_rss();
  ini_widget_calendrier();
  ini_widget_flux();
  ini_widget_recherche();
  ini_widgets_avec_zooms();
  ini_evenement();
  ini_newsletter();
  ini_liste_equipes();
  ini_recherche_partenaire();
  ini_panier();
  if ($('#choix_livraison input[name=mode_de_livraison]').length) maj_mode_livraison();
  ini_moyens_paiements();
  ini_printable();
  ini_contact();

  // Tipsy

  $('[data-bs-toggle="tooltip"]').tooltip();

  // Fancybox

  Fancybox.bind("[data-fancybox]", {
    // Your custom options
  });

  // Recherche de mots clÃ©s

  if (termes_recherche) surligneMotsCles(termes_recherche);

  // ContrÃ´le de l'age

  $('.add_age').on('click', add_age);

  //  https://stackoverflow.com/questions/69269449/ckeditors-popup-input-fields-dont-work-when-used-with-bootstrap-5-modal-ckedit
  // bootstrap.Modal.prototype._initializeFocusTrap = function () { return { activate: function () { }, deactivate: function () { } } };
});
$.fn.pulse = function (options) {
  // S'efface puis se rallume

  var options = $.extend({
    times: 3,
    duration: 1000
  }, options);
  var period = function period(callback) {
    $(this).animate({
      opacity: 0
    }, options.duration, function () {
      $(this).animate({
        opacity: 1
      }, options.duration, callback);
    });
  };
  return this.each(function () {
    var i = +options.times,
      self = this,
      repeat = function repeat() {
        --i &amp;&amp; period.call(self, repeat);
      };
    period.call(this, repeat);
  });
};
$.fn.unpulse = function (options) {
  // s'allume puis se rÃ©-Ã©teint

  var options = $.extend({
    times: 3,
    duration: 1000
  }, options);
  var period = function period(callback) {
    $(this).animate({
      opacity: 1
    }, options.duration, function () {
      $(this).animate({
        opacity: 0
      }, options.duration, callback);
    });
  };
  return this.each(function () {
    var i = +options.times,
      self = this,
      repeat = function repeat() {
        --i &amp;&amp; period.call(self, repeat);
      };
    period.call(this, repeat);
  });
};

/*****************************************************************************************/
/*      Header                                                                           */
/*****************************************************************************************/

// Gestion du bandeau responsive

function ini_header() {
  height_header();
  $(window).on('resize', height_header);
}
function height_header() {
  var w = $('#conteneur_bandeau').width();
  $('#conteneur_bandeau').height(w * 200 / 1140);
  $('#bandeau-et-titre').height(w * 200 / 1140);
  $('#lien-bandeau img').height(w * 200 / 1140);
}
var deferredPrompt_a2hs;
function init_a2hs() {
  var a2hs = document.getElementById("a2hs");
  a2hs.style.display = "none";
  //$('body').addClass('with-a2hs');
  window.addEventListener("beforeinstallprompt", function (e) {
    // Prevent Chrome 67 and earlier from automatically showing the prompt
    e.preventDefault();
    // Stash the event so it can be triggered later.
    deferredPrompt_a2hs = e;
    // Update UI to notify the user they can add to home screen
    a2hs.style.display = "block";
    $('body').addClass('with-a2hs');
  });
}

/*****************************************************************************************/
/*      Gestion des menus et navigation                                                  */
/*****************************************************************************************/

// Gestion du menu

var dropdown_menu_do_once = 0;
function ini_menu() {
  // PrÃ©paration du menu en version sÃ©lecteur

  $('#mainmenu &gt; ul').each(function (e) {
    $('#navigation-select').append(ul_to_options($(this)));
  });
  $('#navigation-select').change(function () {
    if ($('#navigation-select').val() != '') go($('#navigation-select').val());
  });

  // PrÃ©paration du menu en onglet en version sÃ©lecteur

  $('ul.nav.onglets &gt; li').each(function (e) {
    $('#onglet-select').append(ul_onglet_to_options($(this)));
  });
  $('#onglet-select').change(function () {
    if ($('#onglet-select').val() != '') go($('#onglet-select').val());
  });

  // Gestion des intitulÃ©s de menus trop longs (D1)

  $('#mainmenu a.long').each(function (e) {
    if ($(this).height() &gt; 40) {
      $(this).parent().addClass('parent_troplong');
      $(this).removeClass('long').addClass('troplong');
    }
  });

  // Gestion des menus trop longs pour la taille d'Ã©cran

  show_and_hide_menu();
  show_and_hide_menu();
  $(window).on('resize', function () {
    show_and_hide_menu();
    dropdown_menu_do_once = 1;
    change_menu_position();
  });
  $('#mainmenu .dropdown').on('click', function () {
    if (!$(this).hasClass('show')) dropdown_menu_do_once = 1;
  });
  $('#mainmenu .dropdown').on('shown.bs.dropdown', function () {
    change_menu_position();
  });
}
function ul_to_options(ul) {
  var retour = '';
  ul.children('li').each(function () {
    var href = $(this).children('a').attr('href');
    var text = $(this).children('a').text();
    var uldiv = $(this).children('div');
    if (uldiv.length == 0) {
      retour = retour + '&lt;option value="' + href + '"' + ($(this).hasClass('current') ? 'selected="selected" ' : '') + '&gt;' + text + '&lt;/option&gt;';
    } else {
      if ($(this).find('ul div').length == 0) {
        var text = $(this).children('button').text();
        retour = retour + '&lt;optgroup label="' + text + '"&gt;';
        uldiv.children('a').each(function () {
          var href = $(this).attr('href');
          var text = $(this).text();
          retour = retour + '&lt;option value="' + href + '"' + ($(this).hasClass('current') ? 'selected="selected" ' : '') + '&gt;' + text + '&lt;/option&gt;';
        });
        retour = retour + '&lt;/optgroup&gt;';
      } else {
        //	retour = retour +  ul_to_options( uldiv );
      }
    }
  });
  return retour;
}
function ul_onglet_to_options(li) {
  var retour = '';

  // le niveau 1

  var a = $(li).children('a').clone();
  var href = a.attr('href');
  var active = a.hasClass('active');
  var nb = a.children('.badge').text();
  a.find('.badge').remove();
  var text = a.text();
  text += nb ? ' (' + nb + ')' : '';
  if ($(li).children('ul').length == 0) {
    retour += '&lt;option value="' + href + '"' + (active ? 'selected="selected" ' : '') + '&gt;' + text + '&lt;/option&gt;';
  } else {
    var page_parente_accessible = false;
    retour_enfants = '';
    active_enfant = false;
    $(li).children('ul').children('li').each(function () {
      var a = $(this).children('a').clone();
      var href_enfant = a.attr('href');
      var is_active = a.hasClass('active');
      var nb_enfant = a.children('.badge').text();
      a.find('.badge').remove();
      var text_enfant = a.text();
      text_enfant += nb_enfant ? ' (' + nb_enfant + ')' : '';
      if (is_active) active_enfant = true;
      retour_enfants += '&lt;option value="' + href_enfant + '"' + (is_active ? 'selected="selected" ' : '') + '&gt;' + (page_parente_accessible ? text + ' &amp;gt; ' : '') + text_enfant + '&lt;/option&gt;';
    });
    if (page_parente_accessible) {
      retour += '&lt;option value="' + href + '"' + (active &amp;&amp; !retour_enfants ? 'selected="selected" ' : '') + '&gt;' + text + '&lt;/option&gt;';
      retour += retour_enfants;
    } else {
      retour += '&lt;optgroup label="' + text + '"&gt;' + retour_enfants + '&lt;/optgroup&gt;';
    }
  }
  return retour;
}
function menu_fail(max_height, classnameIfFail) {
  var actual_h = $("#mainmenu &gt; ul").height();
  if (actual_h &gt; max_height) {
    $("#mainmenu").removeClass('taille1').removeClass('taille2').removeClass('taille3').removeClass('taille4').removeClass('taille5').removeClass('taille6');
    $("#mainmenu").addClass(classnameIfFail);
    return true;
  }
  return false;
}
function show_and_hide_menu() {
  $("#mainmenu").removeClass('taille1').removeClass('taille2').removeClass('taille3').removeClass('taille4').removeClass('taille5').removeClass('taille6');
  $("#mainmenu &gt; ul").css("display", "flex");
  $("#mainmenu form").css("display", "none");

  // On vÃ©rifie que cela tient sur une ligne

  if ($('#mainmenu').hasClass('allow2lines')) {
    if (menu_fail(50, 'taille2')) if (menu_fail(50, 'taille3')) if (menu_fail(50, 'taille4')) if (menu_fail(50, 'taille5')) if (menu_fail(50, '')) {
      $("#mainmenu").removeClass('taille1').removeClass('taille2').removeClass('taille3').removeClass('taille4').removeClass('taille5').removeClass('taille6');
      if (menu_fail(100, 'taille2')) if (menu_fail(100, 'taille3')) if (menu_fail(100, 'taille4')) if (menu_fail(100, 'taille5')) if (menu_fail(100, '')) {
        $("#mainmenu &gt; ul").css("display", "none");
        $("#mainmenu form").css("display", "block");
      }
    }
  } else {
    if (menu_fail(100, 'taille2')) if (menu_fail(100, 'taille3')) if (menu_fail(100, 'taille4')) if (menu_fail(100, 'taille5')) if (menu_fail(100, 'taille6')) if (menu_fail(100, '')) {
      $("#mainmenu &gt; ul").css("display", "none");
      $("#mainmenu form").css("display", "block");
    }
  }
  $("ul.nav.onglets").css("display", "flex");
  $("#onglet-select").css("display", "none");
  var actual_h = $("ul.nav.onglets").height();
  if (actual_h &gt; 50) {
    $("ul.nav.onglets").css("display", "none");
    $("#onglet-select").css("display", "inline-block");
  }
}
function change_menu_position() {
  // Sur un menu positionnÃ© Ã&nbsp; gauche, et dont un Ã©lÃ©ment est ouvert pendant que l'on redimentionne la fenÃªtre, on regarde pour changer la position du dropdown pour que le menu ouvert reste visible.

  if (dropdown_menu_do_once == 0) return;
  dropdown_menu_do_once = 0;
  var element_parent = $('#mainmenu .dropdown.show');
  var element_ouvert = $('#mainmenu .dropdown-menu.show');
  if (element_parent.length &amp;&amp; element_ouvert.length) {
    var right = parseInt(element_parent.offset().left) + parseInt(element_ouvert.width());
    var width_body = parseInt($('body').width());

    // Doit-on changer la direction du sous-menu ?

    var changedir = false;
    if (right &gt;= width_body) {
      if (!element_ouvert.hasClass('dropdown-menu-end')) {
        changedir = true;
      }
    } else {
      if (element_ouvert.hasClass('dropdown-menu-end')) {
        changedir = true;
      }
    }
    if (changedir) {
      element_ouvert.toggleClass('dropdown-menu-end');
      element_ouvert.dropdown('toggle');
      element_ouvert.dropdown('toggle');
      element_ouvert.dropdown('dispose');
    }
  }
}
function go(url) {
  window.location = url;
}

/*****************************************************************************************/
/*      Module sections                                                                  */
/*****************************************************************************************/

function ini_menu_sections() {
  $('.openSectionContent').on('click', openSectionContent);
}
function openSectionContent() {
  var etat = $(this).parent().find('.niveau1').css("display");
  $("#barre-selection-section .niveau1").css("display", "none");
  $("#barre-selection-section .fa-angle-up").removeClass('fa-angle-up').addClass('fa-angle-down');
  if (etat != "block") {
    $(this).parent().find('.niveau1').toggle();
    $(this).find('.fa-angle-down').removeClass('fa-angle-down').addClass('fa-angle-up');
  } else {
    $(this).find('.fa-angle-up').removeClass('fa-angle-up').addClass('fa-angle-down');
  }
}

/*****************************************************************************************/
/*      Footer                                                                           */
/*****************************************************************************************/

function ini_footer() {
  // Compteur dans le footer

  $.ajax({
    type: 'POST',
    url: '/visites',
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    data: {
      association_id: association_id
    },
    success: function success(response) {
      $("#nb-visites").html(response);
    }
  });
  ini_footer_finalite();
  $('#footer_name, #footer_firstname, #footer_email_contact, #footer_objet, #footer_message').on('keyup', ini_footer_finalite);
}
function ini_footer_finalite() {
  if ($('#footer_name').val() &amp;&amp; $('#footer_firstname').val() &amp;&amp; $('#footer_email_contact').val() &amp;&amp; $('#footer_objet').val() &amp;&amp; $('#footer_message').val()) $('#block_finalite_footer_contact').show();else $('#block_finalite_footer_contact').hide();
}
function ini_stats_analyser() {
  if (!('ab' in window)) {
    window.ab = true;
  }
  if (window.ab) $('#contenu').append('&lt;img src="/home/imagecpt1.gif?' + Math.random() + '" alt=""&gt;');else $('#contenu').append('&lt;img src="/home/imagecpt2.gif?' + Math.random() + '" alt=""&gt;');
  return 1;
}

/*****************************************************************************************/
/*      Partage                                                                          */
/*****************************************************************************************/

function ini_partage() {
  $('.facebookShare').on('click', function () {
    var url = $(this).attr('url');
    var descr = $(this).attr('text');
    facebookShare(url, "", descr, "", 520, 350);
  });
  $('.twitterShare').on('click', function () {
    var url = $(this).attr('url');
    var descr = $(this).attr('text');
    twitterShare(url, descr, 520, 350);
  });
}
function facebookShare(url, title, descr, image, winWidth, winHeight) {
  var winTop = screen.height / 2 - winHeight / 2;
  var winLeft = screen.width / 2 - winWidth / 2;
  window.open('https://www.facebook.com/sharer.php?u=' + url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
}
function twitterShare(url, descr, winWidth, winHeight) {
  var winTop = screen.height / 2 - winHeight / 2;
  var winLeft = screen.width / 2 - winWidth / 2;
  window.open('https://twitter.com/intent/tweet?text=' + encodeURIComponent(descr + (descr &amp;&amp; url ? ' ' : '') + url), 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
}

/*****************************************************************************************/
/*      Filtres                                                                          */
/*****************************************************************************************/

function ini_filtres() {
  // Filtrages dans les listes en mode "selecteur"

  $('select.filtre').on('change', do_filtrage);
  $('input.filtre').on('change', do_search_filtre);
  $('.filter .recherche .btn, #barre-de-filtrage .recherche .btn').on('click', function () {
    $(this).parent().find('input').each(do_search_filtre);
  });
}
function do_filtrage() {
  window.location = $(this).val();
}
function do_search_filtre() {
  var parser = new URL(window.location);
  parser.searchParams.set($(this).attr('id'), $(this).val());
  window.location = parser.href;
}

/*****************************************************************************************/
/*      VidÃ©os                                                                           */
/*****************************************************************************************/

var video_iframe_intervalID = new Array();
function ini_video(racine) {
  if ($((racine ? racine + " " : "") + ".elastic &gt; div").length || $((racine ? racine + " " : "") + ".elastic &gt; iframe").length) {
    $((racine ? racine + " " : "") + ".elastic").each(function () {
      var aspectRatio = $(this).attr("infoheight") / $(this).attr("infowidth");
      $(this).data("aspectRatio", aspectRatio).removeAttr("height").removeAttr("width");
    });
    video_iframe_intervalID[racine] = window.setInterval(function () {
      if ($((racine ? racine + " " : "") + ".elastic iframe").length) {
        video_resize(racine);
        $(window).on("resize", function () {
          video_resize(racine);
        });
        window.clearInterval(video_iframe_intervalID[racine]);
      }
    }, 1000);
  }
}
function video_resize(racine) {
  $((racine ? racine + " " : "") + ".elastic").each(function () {
    var newWidth = $(this).attr("elasticwidth") ? $($(this).attr("elasticwidth")).width() : $(this).width();
    if (newWidth &gt; 1000) newWidth = 1000;
    var aspectRatio = $(this).data("aspectRatio");
    var newHeight = newWidth * parseFloat(aspectRatio);
    var el = $(this).find("iframe");
    el.width(newWidth + "px").height(newHeight + "px");
  });
}

/*****************************************************************************************/
/*      Commentaires et forum                                                            */
/*****************************************************************************************/

function ini_formulaire_commentaires() {
  init_form('formulaire_commentaire');
  $('#formulaire_commentaire button[type=submit]').on('click', post_message_commentaire);
  init_form('formulaire_message_forum');
  $('#formulaire_message_forum button[type=submit]').on('click', post_message_forum);
  $('#fakeform').on('click', affiche_formulaire_commentaire);
}
function affiche_formulaire_commentaire() {
  $('#fakeform').hide();
  $('.note-editor').show();
}
function ini_commentaires() {
  $('.modifier_commentaire').each(function () {
    $(this).attr('rel', $(this).attr('href'));
    $(this).attr('href', 'javascript:void(0);');
    $(this).on('click', function () {
      popup_modifier_commentaire($(this).attr('rel'));
    });
  });
  $('.supprimer_commentaire').each(function () {
    $(this).attr('rel', $(this).attr('href'));
    $(this).attr('href', 'javascript:void(0);');
    $(this).on('click', function () {
      supprimer_commentaire($(this).attr('rel'));
    });
  });
}
function ini_forum() {
  // Sujets du forum

  $('.nouveau_sujet').each(function () {
    $(this).attr('rel', $(this).attr('href'));
    $(this).attr('href', 'javascript:void(0);');
    $(this).on('click', function () {
      popup_nouveau_sujet($(this).attr('rel'));
    });
  });
  $('.modifier_sujet_forum').each(function () {
    $(this).attr('rel', $(this).attr('href'));
    $(this).attr('href', 'javascript:void(0);');
    $(this).on('click', function () {
      popup_modifier_sujet($(this).attr('rel'));
    });
  });
  $('.supprimer_sujet_forum').each(function () {
    $(this).attr('rel', $(this).attr('href'));
    $(this).attr('href', 'javascript:void(0);');
    $(this).on('click', function () {
      supprimer_sujet($(this).attr('rel'));
    });
  });

  // Messages du forum

  $('.modifier_message_forum').each(function () {
    $(this).attr('rel', $(this).attr('href'));
    $(this).attr('href', 'javascript:void(0);');
    $(this).on('click', function () {
      popup_modifier_message_forum($(this).attr('rel'));
    });
  });
  $('.supprimer_message_forum').each(function () {
    $(this).attr('rel', $(this).attr('href'));
    $(this).attr('href', 'javascript:void(0);');
    $(this).on('click', function () {
      supprimer_message($(this).attr('rel'));
    });
  });
  $('.liste.forum-message .moderable .modifier_message_forum').each(function () {
    popup_modifier_message_forum($(this).attr('rel'));
  });
}

// CrÃ©ation d'un commentaire

function post_message_commentaire() {
  ajax_post('formulaire_commentaire', "Commentaire", refresh_commentaires);
  return false;
}

// CrÃ©ation d'un message du forum

function post_message_forum() {
  ajax_post('formulaire_message_forum', "Message du forum", refresh_forum);
  return false;
}

// CrÃ©ation d'un sujet de forum

function popup_nouveau_sujet(url) {
  $.ajax({
    url: url,
    success: function success(response) {
      $("#multi_modal").html(response);
      $('#multi_modal .modal-footer .btn-success').on('click', do_nouveau_sujet);
      add_nested_modal('multi_modal');
      init_form('form_nouveau_sujet');
    }
  });
}
function do_nouveau_sujet() {
  ajax_post('form_nouveau_sujet', 'Nouveau sujet', function () {
    remove_nested_modal('multi_modal');
    refresh_forum();
  });
}

// Modification d'un sujet de forum

function popup_modifier_sujet(url) {
  $.ajax({
    url: url,
    success: function success(response) {
      $("#multi_modal").html(response);
      $('#multi_modal .modal-footer .btn-success').on('click', do_edit_sujet);
      add_nested_modal('multi_modal');
      init_form('form_edit_sujet');
    }
  });
}
function do_edit_sujet() {
  ajax_post('form_edit_sujet', "Modification d'un sujet", function () {
    remove_nested_modal('multi_modal');
    refresh_forum();
  });
}

// Modification d'un commentaire

function popup_modifier_commentaire(url) {
  $.ajax({
    url: url,
    success: function success(response) {
      $("#multi_modal").html(response);
      $('#multi_modal .modal-footer .btn-success').on('click', do_modifier_commentaire);
      add_nested_modal('multi_modal');
      init_form('form_edit_message');
    }
  });
}
function do_modifier_commentaire() {
  ajax_post('form_edit_message', "Modification d'un commentaire", function () {
    remove_nested_modal('multi_modal');
    refresh_commentaires();
  });
}

// Modification d'un message de forum

function popup_modifier_message_forum(url) {
  $.ajax({
    url: url,
    success: function success(response) {
      $("#multi_modal").html(response);
      $('#multi_modal .modal-footer .btn-success').on('click', do_modifier_confirmation_forum);
      add_nested_modal('multi_modal');
      init_form('form_edit_message');
    }
  });
}
function do_modifier_confirmation_forum(url, texte, rubrique_id, refresh_fn) {
  ajax_post('form_edit_message', "Modification d'un message du forum", function () {
    remove_nested_modal('multi_modal');
    refresh_forum();
  });
}

// Suppression d'un commentaire, d'un sujet de forum, d'un message de forum

function supprimer_commentaire(url) {
  showConfirmMessage('Suppression d\'un message', 'Etes-vous sÃ»r de vouloir supprimer ce message ?', function () {
    supprimer_confirmation_forum_do(url, refresh_commentaires);
  });
}
function supprimer_message(url) {
  showConfirmMessage('Suppression d\'un message', 'Etes-vous sÃ»r de vouloir supprimer ce message ?', function () {
    supprimer_confirmation_forum_do(url, refresh_forum);
  });
}
function supprimer_sujet(url) {
  showConfirmMessage('Suppression d\'un sujet', 'Etes-vous sÃ»r de vouloir supprimer ce sujet ?&lt;br/&gt;Tout les messages seront dÃ©finitivement perdus.', function () {
    supprimer_confirmation_forum_do(url, refresh_forum);
  });
}
function supprimer_confirmation_forum_do(url, refresh_fn) {
  $.ajax({
    type: "POST",
    url: url,
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    data: {},
    dataType: 'json',
    success: function success(response) {
      remove_nested_modal('confirmPop');
      if (response.status == 200) {
        refresh_fn();
      } else {
        showInformationMessage("Suppression", response.message);
      }
    }
  });
}
function refresh_commentaires() {
  var url = $('#messages_commentaires').attr('rel');
  $.ajax({
    url: url,
    success: function success(response) {
      $('#messages_commentaires').html(response);
      $('#nouveau_commentaire').summernote('reset');
      ini_commentaires();
    }
  });
}
function refresh_forum() {
  location.reload();
}

/*****************************************************************************************/
/*      Commentaires GIPHY                                                               */
/*****************************************************************************************/

function ini_giphy() {
  $('#selectionne_commentaire').on('click', function () {
    $('#selectionne_commentaire').addClass("actif");
    $('#selectionne_giphy').removeClass("actif");
    $('#formulaire_commentaire, #formulaire_message_forum').css('display', 'block');
    $('#formulaire_giphy').css('display', 'none');
  });
  $('#selectionne_giphy').on('click', function () {
    $('#selectionne_commentaire').removeClass("actif");
    $('#selectionne_giphy').addClass("actif");
    $('#formulaire_commentaire, #formulaire_message_forum').css('display', 'none');
    $('#formulaire_giphy').css('display', 'block');
  });
  $('button.add_giphy').on('click', function () {
    var sujet_id = $(this).parents('form').attr('rel');
    add_giphy(sujet_id);
  });
}
function add_giphy(sujet_id) {
  $.ajax({
    type: "POST",
    url: "/forum/explorateur_giphy/" + sujet_id,
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    data: {},
    success: function success(response) {
      $("#multi_modal").html(response);
      add_nested_modal('multi_modal');
      init_giphy_buttons(sujet_id);
    }
  });
}
function set_giphy(sujet_id, keyword, title, page) {
  $.ajax({
    type: "POST",
    url: "/forum/get_giphy/" + sujet_id,
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    data: {
      keyword: keyword,
      title: title,
      page: page
    },
    success: function success(response) {
      if (page == 1) {
        $('#giphy_liste_medias').html(response);
        $('#giphy_pop').animate({
          scrollTop: 0
        }, 'slow');
      } else {
        $('.giphy_more').remove();
        $('#liste_medias_giphy').append(response);
      }
      init_giphy_buttons(sujet_id);
    }
  });
}
function init_giphy_buttons(sujet_id) {
  $('#giphy_retour').on('click', function () {
    set_giphy(sujet_id, "", "", 1);
  });
  $('.theme_giphy').on('click', function () {
    var mot_clef = $(this).attr('rel').substring(0, $(this).attr('rel').indexOf(","));
    var title = $(this).attr('rel').substring($(this).attr('rel').indexOf(",") + 1);
    set_giphy(sujet_id, mot_clef, title, 1);
  });
  $('#giphy_search').on('click', function () {
    var mot_clef = $('#giphy_sujet').val();
    set_giphy(sujet_id, mot_clef, "", 1);
  });
  $('.preview_giphy').on('click', add_giphy_gif);
  $('.giphy_more').on('click', function () {
    var sujet_id = $('#forum_sujet_id').val();
    var mot_clef = $('#giphy_sujet').val();
    var title = $('#giphy_title').val();
    var page = parseInt($('#giphy_page').val()) + 1;
    $('#giphy_page').val(page);
    set_giphy(sujet_id, mot_clef, title, page);
  });
}
function add_giphy_gif() {
  var query = $('#giphy_sujet').val();
  var title = $(this).attr('alt');
  var url = $(this).attr('src');
  var id = $(this).attr('rel');
  var html = "&lt;p&gt;Ajout de l'image en cours...&lt;/p&gt;" + "&lt;div class='text-center my-5'&gt;&lt;div class='progress' role='progressbar' aria-valuenow='100' aria-valuemin='0' aria-valuemax='100'&gt;" + "&lt;div class='progress-bar progress-bar-striped progress-bar-animated' style='width: 100%'&gt;&lt;/div&gt;" + "&lt;/div&gt;&lt;/div&gt;";
  $("#giphy_liste_medias").html(html);
  $('#giphy_query').val(query);
  $('#giphy_title').val(title);
  $('#giphy_id').val(id);
  $('#giphy_url').val(url);
  $('#formulaire_giphy').submit();
}

/*****************************************************************************************/
/*      Livre d'or                                                                       */
/*****************************************************************************************/

function ini_livredor() {
  var form_racine = 'message_livre_form';
  $('#' + form_racine + ' button').on('click', post_message_livredor);
  init_form(form_racine);
}
function post_message_livredor() {
  ajax_post('message_livre_form', "Message du livre d'or", refresh_livredor);
  return false;
}
function refresh_livredor() {
  var form_racine = 'message_livre_form';
  $('#' + form_racine).find('input, textarea').val("");
  location.reload();
}

/*****************************************************************************************/
/*      Widget A La Une                                                                  */
/*****************************************************************************************/

function ini_widget_a_la_une() {
  if ($(".widget_a_la_une.vertical").length) {
    $(".widget_a_la_une").each(function () {
      ini_widget_slidant($(this), widget_a_la_une_direction, widget_a_la_une_defilement_auto);
    });
  }
}

/*****************************************************************************************/
/*      Widgets Evenement                                                                */
/*****************************************************************************************/

function ini_widgets_evenements() {
  if ($(".grand_widget.widget_evenement.defilant").length) {
    $(".grand_widget.widget_evenement").each(function () {
      ini_widget_slidant($(this), 1, false);
    });
  }
}

/*****************************************************************************************/
/*      Widgets Evenement                                                                */
/*****************************************************************************************/

function ini_widget_recherche() {
  $('.widget_recherche form').each(function () {
    init_form($(this).attr('id'));
  });
}

/*****************************************************************************************/
/*      Widget rÃ©servations                                                              */
/*****************************************************************************************/

function ini_widget_reservations() {
  $('.widget_reservations').each(function () {
    var identifiant = $(this).attr('id');
    maj_infos_creneaux_widget_reservation(identifiant);
    $("#" + identifiant + "_date, #" + identifiant + "_type_equipement").on('change', function () {
      maj_infos_creneaux_widget_reservation($(this).parents('.widget_reservations').attr('id'));
    });
    $(this).find('form').each(function () {
      init_form($(this).attr('id'));
    });
  });
}
function maj_infos_creneaux_widget_reservation(identifiant) {
  $.ajax({
    type: "POST",
    url: '/widgets/creneaux-disponibles',
    dataType: "json",
    data: {
      date: $("#" + identifiant + "_date").val(),
      type: $("#" + identifiant + "_type_equipement").val()
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    success: function success(response) {
      if (response.nb == 0) $("#" + identifiant + " .infos_creneau").html("&lt;p&gt;Aucun crÃ©neau disponible&lt;/p&gt;");else $("#" + identifiant + " .infos_creneau").html("&lt;p&gt;&lt;strong&gt;" + response.nb + "&lt;/strong&gt; crÃ©neau" + (response.nb &gt; 1 ? "x" : "") + " disponible" + (response.nb &gt; 1 ? "s" : "") + "&lt;/p&gt;");
    }
  });
}

/*****************************************************************************************/
/*      Widget RSS                                                                       */
/*****************************************************************************************/

function ini_widget_rss() {
  $('.widget_rss, .widget_rss_fede').each(function () {
    var identifiant = $(this).attr('id');
    var association_widget_id = $(this).attr('data-id');
    var section_id = $(this).attr('data-section_id');
    var discipline_id = $(this).attr('data-discipline_id');
    var groupe_id = $(this).attr('data-groupe_id');
    var saison_id = $(this).attr('data-saison_id');
    var taille = 'PETIT';
    if ($(this).hasClass('grand_widget')) taille = 'GRAND';
    $.ajax({
      type: "POST",
      url: '/widgets/rss-content',
      data: {
        association_widget_id: association_widget_id,
        section_id: section_id,
        discipline_id: discipline_id,
        groupe_id: groupe_id,
        saison_id: saison_id,
        taille: taille
      },
      headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      },
      success: function success(response) {
        $('#' + identifiant + " .content").html(response);
      }
    });
  });
}

/*****************************************************************************************/
/*      Widget Calendrier                                                                */
/*****************************************************************************************/

function ini_widget_calendrier() {
  $('.widget_calendrier').each(function () {
    var date = $(this).attr('data-date');
    show_calendrier($(this), date);
  });
}
function ini_calendrier(calendrier) {
  $(calendrier).find('[data-date]').on('click', function () {
    var calendrier = $(this).parents('.widget_calendrier');
    var date = $(this).attr('data-date');
    show_calendrier(calendrier, date);
  });
  $(calendrier).find('[data-illuminate]').on('mouseover', function () {
    var calendrier = $(this).parents('.widget_calendrier');
    var days = $(this).attr('data-illuminate').split(', ');
    illuminate_calendrier(calendrier, days);
  });
  $(calendrier).find('[data-illuminate]').on('mouseleave', function () {
    var calendrier = $(this).parents('.widget_calendrier');
    var days = $(this).attr('data-illuminate').split(', ');
    stop_illuminate_calendrier(calendrier, days);
  });
}
function show_calendrier(calendrier, date) {
  var identifiant = $(calendrier).attr('id');
  var association_widget_id = $(calendrier).attr('data-id');
  var section_id = $(calendrier).attr('data-section_id');
  var discipline_id = $(calendrier).attr('data-discipline_id');
  var groupe_id = $(calendrier).attr('data-groupe_id');
  var saison_id = $(calendrier).attr('data-saison_id');
  var taille = 'PETIT';
  if ($(calendrier).hasClass('grand_widget')) taille = 'GRAND';
  $.ajax({
    type: "POST",
    url: '/widgets/calendrier-content',
    data: {
      association_widget_id: association_widget_id,
      date: date,
      section_id: section_id,
      discipline_id: discipline_id,
      groupe_id: groupe_id,
      saison_id: saison_id,
      taille: taille
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    success: function success(response) {
      $('#' + identifiant + ' [data-bs-toggle="tooltip"]').each(function () {
        var tooltip = bootstrap.Tooltip.getOrCreateInstance($(this));
        tooltip.dispose();
      });
      $('#' + identifiant + " .content").html(response);
      ini_calendrier($(calendrier));
      $('#' + identifiant + ' [data-bs-toggle="tooltip"]').tooltip();
    }
  });
}
function illuminate_calendrier(calendrier, days) {
  var str = '';
  for (var i = 0; i &lt; days.length; i++) {
    str += (str ? ',' : '') + '[data-jour=' + days[i] + "]";
  }
  $(calendrier).find(str).addClass('illuminate');
}
function stop_illuminate_calendrier(calendrier, days) {
  var str = '';
  for (var i = 0; i &lt; days.length; i++) {
    str += (str ? ',' : '') + '[data-jour=' + days[i] + "]";
  }
  $(calendrier).find(str).removeClass('illuminate');
}

/*****************************************************************************************/
/*      Widget Flux                                                                      */
/*****************************************************************************************/

function ini_widget_flux() {
  $('.widget_flux').each(widget_flux);
}
function widget_flux() {
  var identifiant = $(this).attr('id');
  var association_widget_id = $(this).attr('data-id');
  var section_id = $(this).attr('data-section_id');
  var discipline_id = $(this).attr('data-discipline_id');
  var groupe_id = $(this).attr('data-groupe_id');
  var saison_id = $(this).attr('data-saison_id');
  var page = $(this).attr('data-page');
  var taille = 'PETIT';
  if ($(this).hasClass('grand_widget')) taille = 'GRAND';
  var div_widget = $(this);
  page = parseInt(page) + 1;
  $.ajax({
    type: "POST",
    url: '/widgets/flux-content',
    data: {
      association_widget_id: association_widget_id,
      section_id: section_id,
      discipline_id: discipline_id,
      groupe_id: groupe_id,
      saison_id: saison_id,
      page: page,
      taille: taille
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    success: function success(response) {
      div_widget.attr('data-page', page);
      $('#' + identifiant + " .content .suite_widget_flux").remove();
      $('#' + identifiant + " .content").append(response);
      $('#' + identifiant + " .content .suite_widget_flux").on('click', function () {
        $(this).parents('.widget_flux').each(widget_flux);
      });
      ini_video('#' + identifiant + ' .page-' + page);
    }
  });
}

/*****************************************************************************************/
/*      Widgets avec section zoomable (Partenaires, pubs)                                */
/*****************************************************************************************/

function ini_widgets_avec_zooms() {
  $('.liste-avec-zoom').each(function () {
    widget_avec_zoom($(this));
  });
}
function widget_avec_zoom(widget) {
  var i = 0;
  $(widget).find('.element-zoomable').each(function () {
    $(this).data("numero", i++);
    $(this).bind('click', function () {
      var bloc = $(this).parents('.liste-avec-zoom');
      widget_zoom_change_photo($(bloc), $(this).data("numero"));
      var timer = $(bloc).data("timer");
      clearInterval(timer);
      return false;
    });
  });
  $(widget).data("actual", 0);
  var timer = setInterval(function () {
    $(widget).data("actual", $(widget).data("actual") + 1);
    widget_zoom_change_photo($(widget), $(widget).data("actual"));
  }, 4000);
  $(widget).data("timer", timer);
}
function widget_zoom_change_photo(bloc, numero) {
  var agrandie = $(bloc).find('.agrandie');
  numero = numero % $(bloc).find('.liste_photos a').length;
  var element_choisi = $(bloc).find('.liste_photos a')[numero];
  $(bloc).find('.liste_photos img').addClass('desaturate');
  $(element_choisi).find('img').removeClass('desaturate');
  $(agrandie).attr('href', $(element_choisi).attr('href'));
  $(agrandie).attr('title', $(element_choisi).attr('title'));
  $(agrandie).find('img').attr('src', $(element_choisi).attr('rel'));
}

/*****************************************************************************************/
/*      Widget slidant (A la une, Ã©vÃ¨nements)                                            */
/*****************************************************************************************/

function ini_widget_slidant(widget, direction, auto) {
  var nb_defilement = $(widget).find(".defilement").length;
  $(widget).data("nb_defilement", nb_defilement);
  $(widget).data("direction", direction);
  $(widget).data("auto", auto);
  init_scroll($(widget));
  height_scroll($(widget));
  timer2 = setInterval(function () {
    height_scroll($(widget));
  }, 1000);
  $(window).bind('resize', function () {
    height_scroll($(widget));
  });
  if (nb_defilement &gt; 1) {
    if (auto) {
      if (direction == 1) var timer = setInterval(function () {
        right_scroll($(widget));
      }, 7000);else var timer = setInterval(function () {
        bottom_scroll($(widget));
      }, 7000);
      $(widget).data("timer", timer);
    }
    if (direction == 1) {
      $(widget).find(".defilement_gauche").show();
      $(widget).find(".defilement_droite").show();
    } else {
      $(widget).find(".defilement_haut").show();
      $(widget).find(".defilement_bas").show();
    }
    $(widget).hover(function () {
      if (auto) {
        var timer = $(widget).data("timer");
        clearInterval(timer);
      }
    }, function () {
      if (auto) {
        var timer = $(widget).data("timer");
        if (direction == 1) timer = setInterval(function () {
          right_scroll($(widget));
        }, 7000);else timer = setInterval(function () {
          bottom_scroll($(widget));
        }, 7000);
        $(widget).data("timer", timer);
      }
    });
  }
}
function block_scroll_buttons(widget) {
  $(widget).find(".defilement_bas img, .defilement_haut img, .defilement_gauche img, .defilement_droite img").unbind("click");
}
function allow_scroll_buttons(widget) {
  // au click sur la flÃ¨che de dÃ©filement gauche
  $(widget).find(".defilement_gauche img").bind("click", function (event) {
    event.stopPropagation();
    left_scroll($(widget));
  });

  // au click sur la flÃ¨che de dÃ©filement droite
  $(widget).find(".defilement_droite img").bind("click", function (event) {
    event.stopPropagation();
    right_scroll($(widget));
  });

  // au click sur la flÃ¨che de dÃ©filement gauche
  $(widget).find(".defilement_haut img").bind("click", function (event) {
    event.stopPropagation();
    top_scroll($(widget));
  });

  // au click sur la flÃ¨che de dÃ©filement droite
  $(widget).find(".defilement_bas img").bind("click", function (event) {
    event.stopPropagation();
    bottom_scroll($(widget));
  });
}
function init_scroll(widget) {
  var nb_defilement = $(widget).data("nb_defilement");
  var direction = $(widget).data("direction");
  allow_scroll_buttons($(widget));

  // dÃ©place la derniere liste de dÃ©filement en premiere position
  if (nb_defilement &gt; 2) {
    move_last_scroll($(widget));
  } else if (nb_defilement &lt; 2) {
    $(widget).find(".defilement_gauche img, .defilement_droite img, .defilement_haut img, .defilement_bas img").hide();
    $(widget).find(".liste_defilement").css("left", 0).css("top", 0);
  } else {
    var last_scroll = $(widget).find(".liste_defilement .defilement:last");
    var clone_last_scroll = last_scroll.clone();
    $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0).before(clone_last_scroll);
  }

  // dÃ©fini la taille du bloc contenant toutes les div de dÃ©filement
  if (nb_defilement &lt; 2) {
    $(widget).find(".liste_defilement").css("width", "100%").css("height", "100%");
    $(widget).find(".liste_defilement .defilement").css("width", "100%").css("height", "100%");
  } else {
    if (direction == 1) {
      $(widget).find(".liste_defilement").css("width", "300%").css("left", "-100%");
      $(widget).find(".liste_defilement .defilement").css("width", "33.333%");
    } else {
      $(widget).find(".liste_defilement").css("height", "300%").css("top", "-100%");
      $(widget).find(".liste_defilement .defilement").css("height", "33.333%");
    }
  }
}
function height_scroll(widget) {
  var nb_defilement = $(widget).data("nb_defilement");
  var direction = $(widget).data("direction");
  $(widget).find(".defilement, .a_la_une").css('height', 'auto');
  var heights = $(widget).find(".defilement").map(function () {
    return $(this).height();
  }).get();
  var maxHeight = Math.max.apply(null, heights);
  if (direction == 1 || nb_defilement &lt; 2) $(widget).find(".liste_defilement").height(maxHeight);else {
    $(widget).find(".liste_defilement").height(3 * maxHeight);
    $(widget).find(".contenu_defilement").height(maxHeight);
  }
  $(widget).find(".defilement, .a_la_une").css('height', maxHeight + 'px');
}
function move_last_scroll(widget) {
  var nb_defilement = $(widget).data("nb_defilement");
  var last_scroll = "";
  var clone_last_scroll = "";
  if (nb_defilement &gt; 2) {
    last_scroll = $(widget).find(".liste_defilement .defilement:last");
    clone_last_scroll = last_scroll.clone();
    $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0).before(clone_last_scroll);
    last_scroll.remove();
  } else {
    last_scroll = $(widget).find(".liste_defilement .defilement:last");
    last_scroll.remove();
    last_scroll = $(widget).find(".liste_defilement .defilement:last");
    clone_last_scroll = last_scroll.clone();
    $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0).before(clone_last_scroll);
  }
}
function move_first_scroll(widget) {
  var nb_defilement = $(widget).data("nb_defilement");
  var first_scroll = "";
  var clone_first_scroll = "";
  if (nb_defilement &gt; 2) {
    first_scroll = $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0);
    clone_first_scroll = first_scroll.clone();
    $(widget).find(".liste_defilement .defilement:last").after(clone_first_scroll);
    first_scroll.remove();
  } else {
    first_scroll = $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0);
    first_scroll.remove();
    first_scroll = $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0);
    clone_first_scroll = first_scroll.clone();
    $(widget).find(".liste_defilement .defilement:last").after(clone_first_scroll);
  }
}

// Animations

function left_scroll(widget) {
  block_scroll_buttons($(widget));
  var w = $(widget).find(".liste_defilement .defilement:first").width() + "px";
  $(widget).find(".liste_defilement .defilement:first").animate({
    marginLeft: w
  }, 500, function () {
    move_last_scroll($(widget));
    allow_scroll_buttons(widget);
  });
}
function right_scroll(widget) {
  block_scroll_buttons($(widget));
  var w = $(widget).find(".liste_defilement .defilement:first").width() + "px";
  $(widget).find(".liste_defilement .defilement:first").animate({
    marginLeft: "-" + w
  }, 500, function () {
    move_first_scroll($(widget));
    allow_scroll_buttons(widget);
  });
}
function top_scroll(widget) {
  block_scroll_buttons($(widget));
  var heights = $(widget).find(".defilement").map(function () {
    return $(this).height();
  }).get();
  var h = Math.max.apply(null, heights) + "px";
  $(widget).find(".liste_defilement .defilement:first").animate({
    marginTop: h
  }, 500, function () {
    move_last_scroll($(widget));
    allow_scroll_buttons(widget);
  });
}
function bottom_scroll(widget) {
  block_scroll_buttons($(widget));
  var heights = $(widget).find(".defilement").map(function () {
    return $(this).height();
  }).get();
  var h = Math.max.apply(null, heights) + "px";
  $(widget).find(".liste_defilement .defilement:first").animate({
    marginTop: "-" + h
  }, 500, function () {
    move_first_scroll($(widget));
    allow_scroll_buttons(widget);
  });
}

/*****************************************************************************************/
/*      Newsletter                                                                       */
/*****************************************************************************************/
function ini_newsletter() {
  if ($('#newsletter_form').length) init_form('newsletter_form');
}

/*****************************************************************************************/
/*      Contact                                                                          */
/*****************************************************************************************/
function ini_contact() {
  if ($('#contact_form').length) init_form('contact_form');
  if ($('#footer_contact_form').length) {
    init_form('footer_contact_form');
    $('#footer_contact_form button[type=submit]').on('click', function () {
      ajax_post('footer_contact_form', "Contact", function () {
        showInformationMessage('Contact', "Merci, c'est envoyÃ© !");
      });
      return false;
    });
  }
}

/*****************************************************************************************/
/*      Convocations et covoiturage                                                      */
/*****************************************************************************************/

function ini_evenement() {
  if ($('.evenement_inscription input[name^=covoiturage]').length) {
    mise_a_jour_covoiturage();
    $('.evenement_inscription input[name^=covoiturage]').bind('click', function () {
      mise_a_jour_covoiturage();
      sauve_covoiturage($(this));
    });
    $('.evenement_inscription select[name^=nombre_places_besoin], .evenement_inscription select[name^=nombre_places_proposees]').bind('change', function () {
      sauve_covoiturage($(this));
    });
  }
  if ($('input[name=covoiturage_type_covoiturage]').length) {
    mise_a_jour_covoiturage();
    $('.formulaire_covoiturage input[name=covoiturage_type_covoiturage]').bind('click', function () {
      mise_a_jour_covoiturage();
    });
  }
  $('.convocation_oui').on('click', convocation_oui);
  $('.convocation_non').on('click', convocation_non);
  $('.convocation_Annulation').on('click', convocation_Annulation);
}
function convocation_oui() {
  do_reponse_convocation($(this), 1);
}
function convocation_non() {
  do_reponse_convocation($(this), 0);
}
function convocation_Annulation() {
  do_reponse_convocation($(this), -1);
}
function do_reponse_convocation(e, reponse) {
  var evenement_id = e.attr('data-evenement_id');
  var membre_id = e.attr('data-membre_id');
  var convoques = e.attr('data-convoques');
  var post = {
    evenement_id: evenement_id,
    membre_id: membre_id,
    reponse: reponse
  };
  if ($('input#ual').length) post.ual = $('input#ual').val();
  $.ajax({
    type: 'POST',
    url: '/evenements/valide-presence',
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    data: post,
    dataType: 'JSON',
    success: function success(response) {
      if (response.errors &amp;&amp; response.errors.length) {
        showInformationMessage("Inscription", response.errors.join("&lt;br&gt;"));
      } else if (response.message) {
        mise_a_jour_covoiturage();
        if (convoques == true) {
          mise_a_jour_convocations_evenement();
          mise_a_jour_liste_convoques();
        }
      }
    }
  });
}
function mise_a_jour_covoiturage() {
  $('.covoiturage_boutons').each(function () {
    if ($(this).find('input[name^=covoiturage]:checked').length) {
      switch ($(this).find('input[name^=covoiturage]:checked').val()) {
        case 'non':
          $(this).find('select[name^=nombre_places_besoin], select[name^=nombre_places_proposees]').prop('disabled', true);
          break;
        case 'besoin':
          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', false);
          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', true);
          break;
        case 'propose':
          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', true);
          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', false);
          break;
      }
    }

    // Dans le formulaire
    if ($(this).find('input[name^=covoiturage_type_covoiturage]:checked').length) {
      switch ($(this).find('input[name^=covoiturage_type_covoiturage]:checked').val()) {
        case 'non':
          $(this).find('select[name^=nombre_places_besoin], select[name^=nombre_places_proposees]').prop('disabled', true);
          break;
        case 'besoin':
          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', false);
          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', true);
          break;
        case 'propose':
          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', true);
          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', false);
          break;
      }
    }
  });
}
function mise_a_jour_convocations_evenement() {
  $('#presence').load(page_courante + ' #presence &gt; div', function () {
    ini_evenement();
  });
}
function mise_a_jour_liste_convoques() {
  $('#participants').load(page_courante + ' #participants &gt; *');
}
function sauve_covoiturage(bt) {
  var racine = $(bt).parents('.covoiturage_boutons');
  var evenement_id = $('.evenement_inscription #covoiturage_evenement_id').val();
  var ual = $('#covoiturage_autoconnectkey').val();
  var membre_id = racine.attr('rel');
  if (!ual) ual = $('input#ual').val();
  if ($(racine).find('input[name^=covoiturage]:checked').length) {
    var bt = $(racine).find('input[name^=covoiturage]:checked').val();
    switch (bt) {
      case 'non':
        var propose = 0;
        var besoin = 0;
        break;
      case 'besoin':
        var propose = 0;
        var besoin = $(racine).find('select[name^=nombre_places_besoin]').val();
        break;
      case 'propose':
        var propose = $(racine).find('select[name^=nombre_places_proposees]').val();
        var besoin = 0;
        break;
    }
    $.ajax({
      type: 'POST',
      url: '/evenements/valide-covoiturage',
      headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      },
      data: {
        evenement_id: evenement_id,
        membre_id: membre_id,
        besoin: besoin,
        propose: propose,
        ual: ual
      },
      dataType: 'JSON',
      success: function success(response) {
        if (response.errors &amp;&amp; response.errors.length) {
          showInformationMessage("Covoiturage", response.errors.join("&lt;br&gt;"));
        } else if (response.message) {
          $('#flash_alert_' + bt + "_" + membre_id).unpulse({
            times: 2,
            duration: 500
          });
          maj_detail_covoiturage();
        }
      }
    });
  }
}
function maj_detail_covoiturage() {
  if ($('#detail_covoiturage').length) {
    $('#detail_covoiturage').fadeOut("normal").load(page_courante + " #detail_covoiturage &gt; *").fadeIn("normal");
  }
}

/*****************************************************************************************/
/*      Recherches de partenaires                                                        */
/*****************************************************************************************/

function ini_recherche_partenaire() {
  $('.creer_annonce').on('click', function () {
    creer_annonce($(this).attr('data-evenementid'));
  });
  $('.modifier_annonce').on('click', function () {
    modifier_annonce($(this).attr('data-annonceid'));
  });
  $('.supprimer_annonce').on('click', function () {
    supprimer_annonce($(this).attr('data-annonceid'));
  });
  $('.repondre_annonce').on('click', function () {
    repondre_annonce($(this).attr('data-annonceid'));
  });
}

/* CrÃ©ation et modification d'annonce */

function creer_annonce(evenement_id) {
  modifier_annonces_do(null, evenement_id);
}
function modifier_annonce(annonce_id) {
  modifier_annonces_do(annonce_id, null);
}
function modifier_annonces_do(annonce_id, evenement_id) {
  $.ajax({
    type: "POST",
    url: "/recherche-de-partenaires/edit-annonce-popup",
    data: {
      annonce_id: annonce_id,
      evenement_id: evenement_id
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    success: function success(response) {
      $("#multi_modal").html(response);
      $('#multi_modal .modal-footer .btn-success').on('click', post_edit_annonce);
      add_nested_modal('multi_modal');
      var config = {
        height: 120,
        lang: 'fr-FR',
        toolbar: [['style', ['bold', 'italic', 'underline']], ['link', ['linkDialogShow', 'unlink']]]
      };
      $("#edit_annonce_description").summernote(config);
      $('#multi_modal input, #multi_modal textarea').focus(function () {
        $('#multi_modal input, #multi_modal textarea').removeClass('is-invalid');
      });
      $('#multi_modal input, #multi_modal textarea').blur(function () {
        $('#multi_modal input, #multi_modal textarea').removeClass('is-invalid');
      });
    }
  });
}
function post_edit_annonce() {
  if ($('#edit_annonce_titre').val() == '') {
    $('#edit_annonce_titre').addClass('is-invalid');
  } else {
    modifier_confirmation_annonces_do($('#edit_annonce_id').val(), $('#edit_annonce_titre').val(), $('#edit_annonce_description').val(), $('#edit_annonce_type').val(), $('#edit_annonce_intention').val(), $('#edit_annonce_niveau').val(), $('#edit_annonce_evenement_id').val(), $('#edit_annonce_action_id').val(), $('#edit_annonce_membre_id').val(), refresh_annonces);
  }
}
function modifier_confirmation_annonces_do(annonce_id, titre, description, type, intention, niveau, evenement_id, action_id, membre_id, refresh_fn) {
  $.ajax({
    type: "POST",
    url: "/recherche-de-partenaires/edit-annonce",
    data: {
      annonce_id: annonce_id ? annonce_id : null,
      titre: titre,
      description: description,
      type: type,
      intention: intention,
      niveau: niveau,
      evenement_id: evenement_id,
      action_id: action_id,
      membre_id: membre_id
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    'dataType': 'JSON',
    success: function success(response) {
      remove_nested_modal('multi_modal');
      if (response.status == 200) {
        refresh_fn();
      } else {
        showInformationMessage("Modification", response.message + "&lt;br&gt;" + response.errors.join("&lt;br&gt;"));
      }
    }
  });
}

/* Suppression d'annonce */

var annonce_a_supprimer = -1;
function supprimer_annonce(annonce_id) {
  annonce_a_supprimer = annonce_id;
  showConfirmMessage('Suppression d\'une recherche de partenaire', 'Etes-vous sÃ»r de vouloir supprimer cette annonce ?', supprimer_annonce_confirmation);
}
function supprimer_annonce_confirmation() {
  supprimer_confirmation_annonce_do(refresh_annonces);
}
function supprimer_confirmation_annonce_do(refresh_fn) {
  $.ajax({
    type: "POST",
    url: "/recherche-de-partenaires/delete-annonce",
    data: {
      annonce_id: annonce_a_supprimer
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    'dataType': 'JSON',
    success: function success(response) {
      remove_nested_modal('confirmPop');
      if (response.status == 200) {
        refresh_fn();
      } else {
        showInformationMessage("Suppression d'une annonce", response.message + "&lt;br&gt;" + response.errors.join("&lt;br&gt;"));
      }
    }
  });
}

/* RÃ©pondre Ã&nbsp; une annonce */

function repondre_annonce(annonce_id) {
  $.ajax({
    type: "POST",
    url: "/recherche-de-partenaires/reponse-annonce-popup",
    data: {
      annonce_id: annonce_id
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    success: function success(response) {
      $("#multi_modal").html(response);
      $('#multi_modal .modal-footer .btn-success').on('click', post_repondre_annonce);
      add_nested_modal('multi_modal');
      var config = {
        height: 120,
        lang: 'fr-FR',
        toolbar: [['style', ['bold', 'italic', 'underline']], ['link', ['linkDialogShow', 'unlink']]]
      };
      $("#edit_annonce_description").summernote(config);
      $('#multi_modal input, #multi_modal textarea').focus(function () {
        $('#multi_modal input').removeClass('is-invalid');
      });
      $('#multi_modal input, #multi_modal textarea').blur(function () {
        $('#multi_modal input').removeClass('is-invalid');
      });
    }
  });
}
function post_repondre_annonce() {
  if ($('#edit_annonce_description').val() == '') {
    // $('#cke_edit_annonce_description').addClass('is-invalid');
  } else {
    repondre_confirmation_annonces_do($('#edit_annonce_id').val(), $('#edit_annonce_description').val(), $('#edit_annonce_membre_id').val(), refresh_annonces);
  }
}
function repondre_confirmation_annonces_do(annonce_id, description, membre_id, refresh_fn) {
  $.ajax({
    type: "POST",
    url: "/recherche-de-partenaires/reponse-annonce",
    data: {
      annonce_id: annonce_id,
      description: description,
      membre_id: membre_id
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    'dataType': 'JSON',
    success: function success(response) {
      remove_nested_modal('multi_modal');
      if (response.status == 200) {
        refresh_fn();
      } else {
        showInformationMessage("Reponse a une annonce", response.message + "&lt;br&gt;" + response.errors.join("&lt;br&gt;"));
      }
    }
  });
}

/* Refresh */

function refresh_annonces() {
  $('#messages_annonces_container').fadeOut("normal").load(page_courante + " #messages_annonces", function () {
    $('#messages_annonces_container').fadeIn("normal");
    ini_recherche_partenaire();
  });
}

/*****************************************************************************************/
/*      Page liste des equipes                                                           */
/*****************************************************************************************/

function ini_liste_equipes() {
  if ($('.liste.equipes').length) {
    set_height_element_liste_equipe();
    $(window).on('resize', set_height_element_liste_equipe);
  }
}
function set_height_element_liste_equipe() {
  var rule = '.liste.equipes .element-inline &gt; div';
  normalize_height(rule, 16);
}

/*****************************************************************************************/
/*      Page panier                                                                      */
/*****************************************************************************************/

function ini_panier() {
  if ($('#panier').length) {
    init_form('panier');
    $('#panier .panier_zero').each(function () {
      $(this).bind('click', function () {
        $(this).parents('td').find('input.quantite').val(0);
        $('#panier').submit();
      });
    });
    $('#panier .quantite').each(function () {
      $(this).bind('change', function () {
        $('#panier').submit();
      });
    });
  }
  $('#facturation_rue, #facturation_codepostal, #facturation_ville').each(function () {
    verifie_regex($(this));
    $(this).on('keyup', function () {
      verifie_regex($(this));
    });
    $(this).on('change', function () {
      verifie_regex($(this));
    });
  });
  $('#form_adresses').bind('submit', function () {
    var erreur = 0;
    $('input.obligatoire, textarea.obligatoire, select.obligatoire').each(function () {
      if ($(this).val() == '') erreur = 1;
    });
    if (erreur == 1) {
      alert('Merci de saisir toutes les informations de facturation');
      return false;
    }
    $('#facturation_rue, #facturation_codepostal, #facturation_ville').each(function () {
      var regex_test = new RegExp($(this).attr('regex'));
      val = $(this).val();
      if (val &amp;&amp; !regex_test.test(val)) {
        erreur = "Le champ \"" + $(this).parents('.form-group').find('label').text() + "\" est incorrect ou comporte des caractÃ¨res interdits.";
      }
    });
    if (erreur) {
      alert(erreur);
      return false;
    }
    if (!is_email_valid($('#facturation_email').val())) {
      alert("L'email saisi dans l'adresse de facturation n'est pas valide");
      return false;
    }
    if ($('#livraison_email').length &amp;&amp; $('#livraison_email').val() != '' &amp;&amp; !is_email_valid($('#livraison_email').val())) {
      alert("L'email saisi dans l'adresse de livraison n'est pas valide");
      return false;
    }
  });
}
function is_email_valid(email) {
  var email_regex = /^(([^&lt;&gt;()[\]\\.,;:\s@\"]+(\.[^&lt;&gt;()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return email_regex.test(email);
}
function verifie_regex(input) {
  var regex_test = new RegExp(input.attr('regex'));
  val = input.val();
  if (val &amp;&amp; !regex_test.test(val)) {
    // console.log( '"' + val + '" ne passe pas la REGEX ' + input.attr('regex'));
    input.addClass('is-invalid');
  } else {
    input.removeClass('is-invalid');
  }
}

/*****************************************************************************************/
/*      Tunnel de commande                                                               */
/*****************************************************************************************/

function ini_moyens_paiements() {
  maj_moyens_paiements();
  $('#choix_livraison input[name=mode_de_livraison]').on('change', function () {
    maj_mode_livraison();
  });
  $('#moyen_paiement input[name="moyen_de_paiement"]').on('change', function () {
    maj_moyens_paiements();
  });
}
function bouton_coupon() {}
function maj_moyens_paiements() {
  $('#moyen_paiement input[name="moyen_de_paiement"]').each(function () {
    if ($(this).is(':checked')) $(this).parents('.groupe').find('.paiements_successifs').show();else $(this).parents('.groupe').find('.paiements_successifs').hide();
  });
  $('.popup_coupon').on('click', function () {
    popup_coupon($(this).attr('rel'));
  });
  $('.delete_coupon').on('click', function () {
    delete_coupon($(this));
  });
}
function maj_mode_livraison() {
  var modedelivraison_id = 0;
  var moyendepaiement_id = 0;
  var moyendepaiement_paiement_multiple = 0;
  var moyendepaiement_coupons_id = [];
  var moyendepaiement_coupons_montants = [];
  var moyendepaiement_coupons_codes = [];
  var moyendepaiement_coupons_codes_complementaires = [];
  if ($('#choix_livraison input[name=mode_de_livraison]:checked').length) modedelivraison_id = $('#choix_livraison input[name=mode_de_livraison]:checked').val();
  if ($('#moyen_paiement input[name=moyen_de_paiement]:checked').length) {
    var moyen_de_paiement = $('#moyen_paiement input[name=moyen_de_paiement]:checked').val();
    moyendepaiement_id = moyen_de_paiement.substring(0, moyen_de_paiement.indexOf('_'));
    moyendepaiement_paiement_multiple = moyen_de_paiement.substring(moyen_de_paiement.indexOf('_') + 1);
  }
  $('input[name^=moyendepaiement_coupons_id]').each(function () {
    moyendepaiement_coupons_id[moyendepaiement_coupons_id.length] = $(this).val();
  });
  $('input[name^=moyendepaiement_coupons_montants]').each(function () {
    moyendepaiement_coupons_montants[moyendepaiement_coupons_montants.length] = $(this).val();
  });
  $('input[name^=moyendepaiement_coupons_codes]:not([name^=moyendepaiement_coupons_codes_complementaires])').each(function () {
    moyendepaiement_coupons_codes[moyendepaiement_coupons_codes.length] = $(this).val();
  });
  $('input[name^=moyendepaiement_coupons_codes_complementaires]').each(function () {
    moyendepaiement_coupons_codes_complementaires[moyendepaiement_coupons_codes_complementaires.length] = $(this).val();
  });
  var parameters = {
    modedelivraison_id: modedelivraison_id,
    moyendepaiement_id: moyendepaiement_id,
    moyendepaiement_paiement_multiple: moyendepaiement_paiement_multiple,
    moyendepaiement_coupons_id: moyendepaiement_coupons_id,
    moyendepaiement_coupons_montants: moyendepaiement_coupons_montants,
    moyendepaiement_coupons_codes: moyendepaiement_coupons_codes,
    moyendepaiement_coupons_codes_complementaires: moyendepaiement_coupons_codes_complementaires
  };
  $.ajax({
    type: "POST",
    url: '/commande/paiement-et-livraison/choix',
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    data: parameters,
    success: function success(response) {
      $('#choix_commande_paiement_livraison').html(response);
      ini_moyens_paiements();
    }
  });
}
function popup_coupon(moyendepaiement_coupons_id) {
  $.ajax({
    type: "GET",
    url: '/commande/paiement-et-livraison/popup-coupon',
    data: {
      moyendepaiement_id: moyendepaiement_coupons_id
    },
    success: function success(response) {
      $('#confirmPop').html(response);
      add_nested_modal('confirmPop');
      $('#confirmPop .modal-footer .btn[rel=success]').bind('click', add_coupon);
    }
  });
}
function add_coupon() {
  var moyendepaiement_coupon_id = $('#moyendepaiement_coupon_id').val();
  var moyendepaiement_coupon_value = parseFloat($('#moyendepaiement_coupon_value').val());
  var moyendepaiement_coupon_code = $('#moyendepaiement_coupon_code').val();
  var moyendepaiement_coupon_code_obligatoire = $('#moyendepaiement_coupon_code').hasClass('obligatoire');
  var moyendepaiement_coupon_code_complementaire = $('#moyendepaiement_coupon_code_complementaire').val();
  var moyendepaiement_coupon_code_complementaire_nom = $('#moyendepaiement_coupon_code_complementaire').attr('rel');
  var moyendepaiement_coupon_code_complementaire_obligatoire = $('#moyendepaiement_coupon_code_complementaire').hasClass('obligatoire');
  if (moyendepaiement_coupon_value &gt; 0) {
    if (moyendepaiement_coupon_code_obligatoire &amp;&amp; !moyendepaiement_coupon_code) {
      alert("Il est obligatoire de saisir la rÃ©fÃ©rence du coupon");
    } else if (moyendepaiement_coupon_code_complementaire_obligatoire &amp;&amp; !moyendepaiement_coupon_code_complementaire) {
      alert("Il est obligatoire de complÃ©ter la case " + moyendepaiement_coupon_code_complementaire_nom);
    } else {
      remove_nested_modal('confirmPop');
      $('#coupons').append('&lt;input type="hidden" name="moyendepaiement_coupons_id[]" value="' + moyendepaiement_coupon_id + '" &gt;' + '&lt;input type="hidden" name="moyendepaiement_coupons_montants[]" value="' + moyendepaiement_coupon_value + '"&gt;' + '&lt;input type="hidden" name="moyendepaiement_coupons_codes[]" value="' + moyendepaiement_coupon_code + '"&gt;' + '&lt;input type="hidden" name="moyendepaiement_coupons_codes_complementaires[]" value="' + moyendepaiement_coupon_code_complementaire + '"&gt;');
      maj_mode_livraison();
    }
  } else {
    alert("Le coupon doit avoir un montant supÃ©rieur Ã&nbsp; 0â‚¬");
  }
}
function delete_coupon(e) {
  $(e).parents('.coupon').remove();
  maj_mode_livraison();
}

/*****************************************************************************************/
/*      Fonctions utilitaires                                                            */
/*****************************************************************************************/

function init_form(form) {
  $('#' + form).find('input, textarea, select').on('focus', function () {
    $(this).removeClass('is-invalid');
  });
  var config = {
    height: 120,
    lang: 'fr-FR',
    toolbar: [['style', ['bold', 'italic', 'underline']], ['link', ['linkDialogShow', 'unlink']]]
  };
  $('#' + form).find(".with-summernote").each(function () {
    $(this).summernote(config);
  });
  if ($('#' + form).hasClass('with-messagepourletest2')) init_messagepourletest2(form);
}
function init_messagepourletest2(form) {
  $('#' + form).on('mouseover', function (event) {
    $('#' + form).find('[name=messagepourletest2]').val(event.timeStamp);
  });
  $('#' + form).find('[type=submit]').on('focus', function (event) {
    $('#' + form).find('[name=messagepourletest2]').val(event.timeStamp);
  });
}
function ajax_post(form, action_type, refresh_fn) {
  $.ajax({
    type: $('#' + form).attr('method'),
    url: $('#' + form).attr('action'),
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    data: $('#' + form).serialize(),
    dataType: 'json',
    success: function success(response) {
      if (response.errors &amp;&amp; response.errors.length) {
        var m = '';
        for (var i = 0; i &lt; response.errors.length; i++) {
          if (response.errors[i].error) m += (m ? '&lt;br&gt;' : '') + '&lt;i class="fa-solid fa-circle-exclamation text-danger"&gt;&lt;/i&gt;&amp;nbsp;' + response.errors[i].error;
          if (response.errors[i].field) $('#' + form).find('[name=' + response.errors[i].field + ']').addClass('is-invalid');
        }
        if (m) showInformationMessage(action_type, m);
      } else {
        refresh_fn();
      }
    }
  });
}
function normalize_height(rule) {
  var padding = arguments.length &gt; 1 &amp;&amp; arguments[1] !== undefined ? arguments[1] : 0;
  $(rule).css('height', 'auto');
  var heights = $(rule).map(function () {
    return $(this).height();
  }).get();
  var maxHeight = Math.max.apply(null, heights);
  maxHeight += padding;
  $(rule).css('height', maxHeight + 'px');
}

/*****************************************************************************************/
/*      Imprimer un DIV                                                                  */
/*****************************************************************************************/

function ini_printable() {
  $('button.print-button').off('click');
  $('button.print-button').on('click', function () {
    if ($(this).data("div")) PrintElem($(this).data("div"), $(this).data("title"));else if ($(this).data("url")) PrintUrl($(this).data("url"), $(this).data("title"));
  });
}
function PrintElem(elem, titre) {
  var html = $(elem).html();
  $(elem).find('input').each(function () {
    html = html.replace('id="' + $(this).attr('id') + '"', 'id="' + $(this).attr('id') + '" value="' + $(this).val() + '"');
    html = html.replace("id='" + $(this).attr('id') + "'", "id='" + $(this).attr('id') + "' value='" + $(this).val() + "'");
  });
  $(elem).find('input[type=checkbox], input[type=radio]').each(function () {
    if ($(this).is(':checked')) {
      html = html.replace('id="' + $(this).attr('id') + '"', 'id="' + $(this).attr('id') + '" checked');
      html = html.replace("id='" + $(this).attr('id') + "'", "id='" + $(this).attr('id') + "' checked");
    }
  });
  Popup(html, titre);
}
function Popup(data, titre) {
  var base = document.head.querySelector("base").href;
  var mywindow = window.open('', titre, 'height=400,width=600');
  var html = '&lt;!DOCTYPE html&gt;&lt;html lang="fr"&gt;&lt;head&gt;';
  html = html + '&lt;base href="' + base + '"&gt;';
  html = html + '&lt;meta charset="utf-8"&gt;';
  html = html + '&lt;title&gt;' + titre + '&lt;/title&gt;';
  html = html + '&lt;link type="text/css" rel="stylesheet" href="/css/common.css"&gt;';
  html = html + '&lt;/head&gt;&lt;body style="background:white;"&gt;';
  html = html + data;
  html = html + '&lt;/body&gt;&lt;/html&gt;';
  mywindow.document.write(html);
  mywindow.document.close();
  mywindow.focus();
  setTimeout(function () {
    mywindow.print();
    mywindow.close();
  }, 2000);
  return true;
}
function PrintUrl(url, titre) {
  var mywindow = window.open(url, titre, 'height=400,width=600');
  mywindow.focus();
  setTimeout(function () {
    mywindow.print();
    mywindow.close();
  }, 2000);
  return true;
}

/*****************************************************************************************/
/*      Recherche                                                                        */
/*****************************************************************************************/

function getTextNodesIn(node, includeWhitespaceNodes, onlyWithClass) {
  var textNodes = [],
    whitespace = /^\s*$/;
  function getTextNodes(node, parentNode, onlyWithClass) {
    if (node.nodeType == Node.TEXT_NODE) {
      if ((includeWhitespaceNodes || !whitespace.test(node.nodeValue)) &amp;&amp; (!onlyWithClass || parentNode.classList.contains(onlyWithClass))) {
        textNodes.push(node);
      }
    } else {
      for (var i = 0, len = node.childNodes.length; i &lt; len; ++i) {
        getTextNodes(node.childNodes[i], node, onlyWithClass);
      }
    }
  }
  getTextNodes(node, null, onlyWithClass);
  return textNodes;
}
function surligneMotsCles(motClefs) {
  var motClef = motClefs.split(' ');
  var nodes, e, patt;
  nodes = getTextNodesIn(document.getElementById('main'), false, 'surlignable');

  // Pour tous les mots clefs

  for (var j = 0; j &lt; motClef.length; ++j) {
    patt = new RegExp(motClef[j], "i");

    // Pour tous les textes du site

    for (var i = 0; i &lt; nodes.length; ++i) {
      if (nodes[i]) {
        if ('textContent' in nodes[i]) {
          var t = nodes[i].textContent;
        } else {
          var t = nodes[i].nodeValue;
        }

        // Le mot clef est prÃ©sent dans le paragraphe
        if (patt.test(t)) {
          var longueur = 0;

          // je coupe le paragraphe en plusieurs morceaux sÃ©parÃ©s par le mot recherchÃ©
          var tab = t.split(patt);
          for (var k = 0; k &lt; tab.length; k++) {
            if (tab[k].length) {
              e = document.createTextNode(tab[k]);
              nodes[i].parentNode.insertBefore(e, nodes[i]);
              nodes.push(e);
              longueur += tab[k].length;
            }
            if (k &lt; tab.length - 1) {
              e = document.createElement('strong');
              e.className = "spot" + j;
              e.innerHTML = t.substring(longueur, longueur + motClef[j].length);
              nodes[i].parentNode.insertBefore(e, nodes[i]);
              longueur += motClef[j].length;
            }
          }
          nodes[i].parentNode.removeChild(nodes[i]);
          nodes[i] = null;
        }
      }
    }
  }
}

/*****************************************************************************************/
/*      ContrÃ´le de l'age                                                                */
/*****************************************************************************************/

function add_age(ageMin) {
  var ageMin = $(this).data('agemin');
  $.ajax({
    type: "GET",
    url: "/add-age/popup",
    data: {
      ageMin: ageMin
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    success: function success(response) {
      $("#multi_modal").html(response);
      $('#multi_modal .modal-footer .btn-success').on('click', post_add_age);
      add_nested_modal('multi_modal');
      $('#multi_modal input').focus(function () {
        $('#multi_modal input').removeClass('is-invalid');
      });
      $('#multi_modal input').blur(function () {
        $('#multi_modal input').removeClass('is-invalid');
      });
    }
  });
}
function post_add_age() {
  $.ajax({
    type: "POST",
    url: "/add-age/popup",
    data: {
      date_naissance: $('#complete_date_naissance').val(),
      messenger_validation_conditions: $('#messenger_validation_conditions').is(':checked') ? 1 : 0
    },
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    success: function success(response) {
      location.reload();
    }
  });
}
/******/ })()
;</pre></body></html>