// source --> https://www.lesmillepots.fr/wp-includes/js/wp-util.min.js?ver=97606ac7a9bf3f827314a728024685e0&#039; defer  
/*! This file is auto-generated */
window.wp=window.wp||{},function(r){var t="undefined"==typeof _wpUtilSettings?{}:_wpUtilSettings;wp.template=_.memoize(function(a){var n,s={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(t){var e=document.querySelector("script#tmpl-"+a);if(e)return(n=n||_.template(r(e).html(),s))(t);throw new Error("Template not found: #tmpl-"+a)}}),wp.ajax={settings:t.ajax||{},post:function(t,e){return wp.ajax.send({data:_.isObject(t)?t:_.extend(e||{},{action:t})})},send:function(n,t){var e,a;return _.isObject(n)?t=n:(t=t||{}).data=_.extend(t.data||{},{action:n}),t=_.defaults(t||{},{type:"POST",url:wp.ajax.settings.url,context:this}),(e=(a=r.Deferred(function(a){t.success&&a.done(t.success),t.error&&a.fail(t.error),delete t.success,delete t.error,a.jqXHR=r.ajax(t).done(function(t){var e;"1"!==t&&1!==t||(t={success:!0}),_.isObject(t)&&!_.isUndefined(t.success)?(e=this,a.done(function(){n&&n.data&&"query-attachments"===n.data.action&&a.jqXHR.hasOwnProperty("getResponseHeader")&&a.jqXHR.getResponseHeader("X-WP-Total")?e.totalAttachments=parseInt(a.jqXHR.getResponseHeader("X-WP-Total"),10):e.totalAttachments=0}),a[t.success?"resolveWith":"rejectWith"](this,[t.data])):a.rejectWith(this,[t])}).fail(function(){a.rejectWith(this,arguments)})})).promise()).abort=function(){return a.jqXHR.abort(),this},e}}}(jQuery);
// source --> https://www.lesmillepots.fr/wp-content/plugins/msw-plugin/assets/js/MSW_plugin_script.js?ver=97606ac7a9bf3f827314a728024685e0&#039; defer  

jQuery(document).ready(function($) {

	//Ne pas mettre en invalide par défaut l'input de mot de passe à la création de compte pendant le checkout
	$( "#createaccount" ).on( 'click' , function(e) {
		setTimeout(function () {
			$( "#account_password_field" ).removeClass('woocommerce-invalid woocommerce-invalid-required-field').addClass('woocommerce-validated');
		} , 50);
	});
	
	// Animate prend compte du header sticky on Error blur champ Stripe checkout
	$( document.body ).on( 'stripeError', function(){
		setTimeout(function() {
			var minus_offset = 30;
			if ( $( 'header.elementor-section' ).hasClass('elementor-sticky--active') ) minus_offset += $( 'header.elementor-sticky--active' ).innerHeight();
			$( 'html, body' ).animate({ scrollTop: $( '.wpmc-step-payment #wc-stripe-cc-form' ).offset().top - minus_offset, }, 100);
		}, 0);
	});
	
	//Validation de la dernière étape du multi step checkout on place order (stripe et CGV)
	$( document.body ).on( 'click' , '.wpmc-step-payment #payment #place_order' , function(e) {

		var txt_error = '';

		if ( $( "input#payment_method_stripe" ).length && $( "input#payment_method_stripe" ).is( ':checked') )
		{
			if ( $( "div#stripe-card-element" ).hasClass('empty') )
			{
				txt_error+='Le <strong>numéro de carte</strong> est obligatoire.<br />';
				$( "div#stripe-card-element" ).addClass('invalid')
			}
			else if ( $( "div#stripe-card-element" ).hasClass('invalid') ) txt_error+='Le <strong>numéro de carte</strong> est incomplet ou invalide.<br />';

			if ( $( "div#stripe-exp-element" ).hasClass('empty') )
			{
				txt_error+='La <strong>date d\'expiration</strong> de la carte est obligatoire.<br />';
				$( "div#stripe-exp-element" ).addClass('invalid')
			}
			else if ( $( "div#stripe-exp-element" ).hasClass('invalid') ) txt_error+='La <strong>date d\'expiration</strong> de la carte est incomplète ou invalide.<br />';
			
			if ( $( "div#stripe-cvc-element" ).hasClass('empty') )
			{
				txt_error+='Le <strong>code de sécurité</strong> de la carte est obligatoire.<br />';
				$( "div#stripe-cvc-element" ).addClass('invalid')
			}
			else if ( $( "div#stripe-cvc-element" ).hasClass('invalid') ) txt_error+='Le <strong>code de sécurité</strong> de la carte est incomplet ou invalide.<br />';

			if (txt_error != '')
			{
				txt_error+='<br />Merci de vérifier votre saisie.<br />';
				var scroll_to_anim = true;
			}
		}
		
		if ( $( ".wpmc-step-payment #payment input#terms" ).length && ! $( ".wpmc-step-payment #payment input#terms" ).is( ':checked') )
		{
			$( ".wpmc-step-payment #payment input#terms" ).closest('p').addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
			if (txt_error != '') txt_error+='<br />';
			txt_error+='Merci d\'accepter les <strong>conditions générales de vente</strong> pour valider votre commande.<br />';
					
		}
		else $( ".wpmc-step-payment #payment input#terms" ).closest('p').removeClass('woocommerce-invalid woocommerce-invalid-required-field').addClass('woocommerce-validated');

		//Affichage des erreurs
		if (txt_error != '')
		{
			$( ".woocommerce-notices-wrapper" ).prepend( '<ul class="woocommerce-error" role="alert"><li>'+txt_error+'</li></ul>');
			if (scroll_to_anim)
			{
				var minus_offset = 30;
				if ( $( 'header.elementor-section' ).hasClass('elementor-sticky--active') ) minus_offset += $( 'header.elementor-sticky--active' ).innerHeight();
				$( 'html, body' ).animate({ scrollTop: $( '.wpmc-step-payment #wc-stripe-cc-form' ).offset().top - minus_offset, }, 400);
			}
			return false;
		}
	});
	
	//Reorganiser le form checkout au changement de pays (tous les pays n'ont pas besoin des memes champs)
	$( document.body ).on( 'country_to_state_changing', function(e) {
		MSW_reorder_form_billing_shipping();
	});
	
	//Reorganiser le form edit adress au changement de pays (tous les pays n'ont pas besoin des memes champs)
	$( document.body ).on( 'change' , 'form .woocommerce-address-fields #billing_country , form .woocommerce-address-fields #shipping_country', function(e) {
		MSW_reorder_form_billing_shipping();
	});
	
	function MSW_reorder_form_billing_shipping()
	{
		setTimeout(function () {
				if ( $( "p#billing_postcode_field" ).length ) $( "p#billing_postcode_field" ).insertAfter( "p#billing_address_2_field");
				if ( $( "p#billing_postcode_field" ).css('display') == 'none' ) $( "p#billing_city_field" ).removeClass('form-row-last').addClass('form-row-wide');
				else $( "p#billing_city_field" ).removeClass('form-row-wide').addClass('form-row-last');
				
				if ( $( "p#billing_state_field" ).length ) $( "p#billing_state_field" ).insertAfter( "p#billing_country_field");
				if ( $( "p#billing_city_field" ).length ) $( "p#billing_city_field" ).insertAfter( "p#billing_postcode_field");
				if ( $( "p#billing_country_field" ).length ) $( "p#billing_country_field" ).insertAfter( "p#billing_city_field");

				if ( $( "p#billing_postcode_field" ).length ) $( "p#billing_postcode_field" ).removeClass('form-row-wide').addClass('form-row-first');
				
				if ( $( "p#billing_state_field" ).length ) $( "p#billing_state_field" ).removeClass('form-row-wide').addClass('form-row-last');

				if ( $( "p#shipping_postcode_field" ).length ) $( "p#shipping_postcode_field" ).insertAfter( "p#shipping_address_2_field");
				if ( $( "p#shipping_postcode_field" ).css('display') == 'none' )  $( "p#shipping_city_field" ).removeClass('form-row-last').addClass('form-row-wide');
				else $( "p#shipping_city_field" ).removeClass('form-row-wide').addClass('form-row-last');
				
				if ( $( "p#shipping_state_field" ).length ) $( "p#shipping_state_field" ).insertAfter( "p#shipping_country_field");
				if ( $( "p#shipping_city_field" ).length ) $( "p#shipping_city_field" ).insertAfter( "p#shipping_postcode_field");
				if ( $( "p#shipping_country_field" ).length ) $( "p#shipping_country_field" ).insertAfter( "p#shipping_city_field");
				
				if ( $( "p#shipping_postcode_field" ).length ) $( "p#shipping_postcode_field" ).removeClass('form-row-wide').addClass('form-row-first');
				
				if ( $( "p#shipping_state_field" ).length ) $( "p#shipping_state_field" ).removeClass('form-row-wide').addClass('form-row-last');
			} , 50);
	}
	
	//Fermer le menu mobile Elementor on touch s'il est ouvert
	if (window.matchMedia("(max-width: 1024px)").matches)
	{
		$(document).on('touchstart', '#MSW_overlay , #MSW_overlay_sticky_header, .elementor-menu-dropdown__close-button', function (e) {
		// $( "#MSW_overlay , #MSW_overlay_sticky_header, .elementor-menu-dropdown__close-button" ).on("touchstart", function(e) {

			if ( $( ".elementor-location-header .menu_header.menu_left .elementor-menu-toggle" ).hasClass('elementor-active') )
			{
				$( ".elementor-location-header .menu_header.menu_left .elementor-menu-toggle" ).removeClass('elementor-active');
				
				if ( ! $( ".elementor-location-header .menu_header.menu_left" ).hasClass('is_sticky_mobile') )
				{
					$('#MSW_overlay').css({'background-color':'transparent'});
					setTimeout(function() { $('#MSW_overlay').css({'z-index':'3','max-height': '0px'}); $('#MSW_overlay').removeClass('nobefore'); }, 300);
				}
				else
				{
					$('#MSW_overlay_sticky_header').css({'background-color':'transparent'});
					setTimeout(function() { $('#MSW_overlay_sticky_header').css({'z-index':'3','max-height': '0px'}); }, 300); 
				}
				return false;
			}
		});
	}
	
	//Fermer le menu mobile Elementor on touch sur le bouton de fermeture
	// $(document).on("touchstart", ".elementor-menu-dropdown__close-button" , function() {
		
		// alert('got it bouton');
		// $( ".elementor-location-header .menu_header.menu_left .elementor-menu-toggle" ).removeClass('elementor-active');
		
		// if ( ! $( ".elementor-location-header .menu_header.menu_left" ).hasClass('is_sticky_mobile') )
		// {
			// $('#MSW_overlay').css({'z-index':'3','background-color':'transparent','max-height': '0px'});
			// $('#MSW_overlay').removeClass('nobefore');
		// }
		// else
		// {
			// $('#MSW_overlay_sticky_header').css({'z-index':'3','background-color':'transparent','max-height': '0px'});
		// }
	// });

	//Ajouter un bouton de fermeture au menu Elementor sur mobile
	$( "nav.elementor-nav-menu--dropdown.elementor-nav-menu__container" ).prepend('<div class="elementor-menu-dropdown__close-button"></div>');

	//Ajouter une div #MSW_overlay_sticky_header dans le header s'il est sticky (pour palier au problème de z-index)
	if ( window.matchMedia("(max-width: 1024px)").matches ) $( ".elementor-location-header .container_header" ).append('<div id="MSW_overlay_sticky_header"></div>');
	
	//Faire apparaître le menu Elementor par la gauche et afficher un overlay sur mobile
	$( ".elementor-location-header .menu_header.menu_left .elementor-menu-toggle" ).on("touchstart", function(e) {

		e.preventDefault();
		
		if ( $( ".elementor-location-header .menu_header.menu_left .elementor-menu-toggle" ).hasClass('elementor-active') )
		{
			$( ".elementor-location-header .menu_header.menu_left .elementor-menu-toggle" ).removeClass('elementor-active');
			if ( $( ".elementor-location-header .menu_header.menu_left" ).hasClass('is_sticky_mobile') ) $( ".elementor-location-header .container_header #MSW_overlay_sticky_header" ).remove();
			
			return false;
		}
		else $( ".elementor-location-header .menu_header.menu_left .elementor-menu-toggle" ).addClass('elementor-active');

		if ( ! $( ".elementor-location-header .menu_header.menu_left" ).hasClass('is_sticky_mobile') )
		{
			if ( $('#MSW_overlay').css('max-height') == '0px' )
			{
				$('#MSW_overlay').css({'z-index':'9999','background-color':'rgba(0,0,0,0.5)','max-height': '2000px'});
				$('#MSW_overlay').addClass('nobefore');
			}
			else 
			{
				$('#MSW_overlay').css({'background-color':'transparent'});
				setTimeout(function() { $('#MSW_overlay').css({'z-index':'3','max-height': '0px'}); $('#MSW_overlay').removeClass('nobefore'); }, 300);
				
			}
		}
		else
		{
			$('#MSW_overlay_sticky_header').css({'z-index':'9999','background-color':'rgba(0,0,0,0.5)','max-height': '2000px'});
		}
	});
	
	//Si une seule méthode d'expédition est disponible (page panier), pas d'input radio, on adapte le CSS
	if ( $("body ul#shipping_method li input").attr('type') == 'hidden' )
	{
		$("body ul#shipping_method li label").css('width' , '100%');
		// $(".woocommerce .sidebar_cart .cart_totals table.shop_table tr.woocommerce-shipping-totals.shipping th").attr('style' , 'min-width:unset; width:98px;');
	}
	
	if ( $( "#MSW_tab_product" ).length > 0 )
	{
		//Actualiser le tableau on event resize pour le responsive
		$( window ).resize(function() {
			if ( window.matchMedia("(max-width: 767px)").matches )
			{
				$( "#MSW_tab_product .tabs div.tab" ).each(function( e ) { var id = e+1; $( "#MSW_tab_product .content div#contenu_"+id ).insertAfter( $( "#MSW_tab_product .tabs div#tab_"+id ) ); });
				$( "#MSW_tab_product .content" ).remove();
			}
			else
			{
				if ( ! $( "#MSW_tab_product .content" ).length )
				{
					$( "#MSW_tab_product" ).append('<div class="content"></div>');
					$( "#MSW_tab_product .tabs div.contenu" ).each(function( e ) { $( this ).appendTo('#MSW_tab_product .content'); });
				}
			}

			if ( window.matchMedia("(max-width: 767px)").matches ) $( "#MSW_tab_product .tabs div.tab" ).attr('style' , 'width:auto; display:block;');
			else if ( window.matchMedia("(min-width: 768px)").matches && window.matchMedia("(max-width: 1024px)").matches ) $( "#MSW_tab_product .tabs div.tab" ).attr('style' , 'width:'+100/$( "#MSW_tab_product .tabs div.tab" ).length +'%; display:table-cell;');
			else $( "#MSW_tab_product .tabs div.tab" ).attr('style' , 'width:auto; display:table-cell;');
			
		});
		
		//Gestion du tableau sur mobile
		if ( window.matchMedia("(max-width: 767px)").matches )
		{
			$( "#MSW_tab_product .tabs div.tab" ).each(function( e ) { var id = e+1; $( "#MSW_tab_product .content div#contenu_"+id ).insertAfter( $( "#MSW_tab_product .tabs div#tab_"+id ) ); });
			$( "#MSW_tab_product div#contenu_1" ).addClass('active');
			$( "#MSW_tab_product .content" ).remove();
		}

		if ( window.matchMedia("(max-width: 767px)").matches ) $( "#MSW_tab_product .tabs div.tab" ).attr('style' , 'width:auto; display:block;');
		else if ( window.matchMedia("(min-width: 768px)").matches && window.matchMedia("(max-width: 1024px)").matches ) $( "#MSW_tab_product .tabs div.tab" ).attr('style' , 'width:'+100/$( "#MSW_tab_product .tabs div.tab" ).length +'%; display:table-cell;');
		else $( "#MSW_tab_product .tabs div.tab" ).attr('style' , 'width:auto; display:table-cell;');

		//Fonction pour actualiser le tableau d'onglet fiche produit en fonction des clics utilisateur
		$( "#MSW_tab_product .tabs div.tab" ).click(function( e ) {

			e.preventDefault();
			
			//Si click sur le lien, on cherche la div
			if (e.target.nodeName=='A') var div_id = e.target.closest('div').id;
			else if (e.target.nodeName=='DIV') var div_id = e.target.id;
			
			id = div_id.split('_');

			if (div_id && div_id!='')
			{
				$( "#MSW_tab_product div" ).removeClass('active');
				$( "#MSW_tab_product #tab_"+id[1] ).addClass('active');
				$( "#MSW_tab_product #contenu_"+id[1] ).addClass('active');
			}
		});
		
		//Ajouter une classe active au premier onglet
		$( "#MSW_tab_product .tabs div:first-child" ).addClass('active');
		$( "#MSW_tab_product .content div:first-child" ).addClass('active');
		
		//Afficher le custom tab product si il n'est pas vide
		// if ( $( "#MSW_tab_product" ).length > 0 ) $( "#MSW_container_tab_product" ).css('display','block');
	}
	
	//Afficher le champ Email pour être averti du retour de stock sur un produit variable
	$(document).on( 'found_variation', '.single-product', function( event, variation ) {
		if ( ! $( "body" ).hasClass('logged-in') ) $( ".single-product .cwginstock-subscribe-form .cwgstock_email" ).css('display','inline-block');
	});

	//Ajoute une div overlay au panier flottant Elementor
	$( ".elementor-menu-cart__main" ).append('<div id="MSW_overlay_cart"></div>');

	//Supprimer la notice Wishlist ajoutée a la popup lorsqu'on la ferme
	$(document).on("xoo_el_popup_toggled" , function(e , type) {
		if ( type == 'hide' ) setTimeout(function() { $( ".xoo-el-main .xoo_notice_wishlist" ).remove(); }, 400);
	});

	//Modifier l'icone réinitialisation du mot de passe + Email connexion form login / register popup
	if ( $( ".xoo-el-container").length || $( ".xoo-el-form-container").length )
	{
		$( "form.xoo-el-form-lostpw .xoo-aff-input-group span.xoo-aff-input-icon" ).removeClass('fas fa-key');
		$( "form.xoo-el-form-lostpw .xoo-aff-input-group span.xoo-aff-input-icon" ).addClass('fas fa-at');
		
		var icon_email_login = $( "form.xoo-el-form-login .xoo-aff-input-group span.xoo-aff-input-icon.far.fa-user" );
		icon_email_login.removeClass('far fa-user');
		icon_email_login.addClass('fas fa-at');
	}

	//Afficher le container code promo page panier
	$( ".container_coupon #coupon_panier" ).click(function(){
		if ( $('.container_coupon .coupon').hasClass('active') ) $('.container_coupon .coupon').removeClass('active');
		else $('.container_coupon .coupon').addClass('active');
    });
	
	//Afficher le container points fidélité page panier
	$( ".container_coupon_fidelite #coupon_fidelite" ).click(function(){
		if ( $('.container_coupon_fidelite .fidelite').hasClass('active') )
		{
			$('.container_coupon_fidelite .fidelite').removeClass('active');
			$('.container_coupon_fidelite .fidelite .notice_fidelite').removeClass('active');
		}
		else $('.container_coupon_fidelite .fidelite').addClass('active');
    });
	
	//Afficher le container points fidélité page panier
	$( ".container_coupon_fidelite .fidelite a:not(.button)" ).click(function(){
		if ( $('.container_coupon_fidelite .fidelite .notice_fidelite').hasClass('active') ) $('.container_coupon_fidelite .fidelite .notice_fidelite').removeClass('active');
		else $('.container_coupon_fidelite .fidelite .notice_fidelite').addClass('active');
    });

	//Ajouter un bouton submit au search form header full screen
	$( ".MSW_search_form_mobile .elementor-search-form__container" ).append('<button class="elementor-search-form__submit" type="submit" title="Rechercher " aria-label="Rechercher "><i class="fa fa-search" aria-hidden="true"></i><span class="elementor-screen-only">Rechercher </span></button>');
	
	//Cacher les autres dropdown on touch search form header
	$( ".elementor-location-header .elementor-search-form__toggle").on("touchstart", function() {
		if ( $( ".elementor-location-header .container_account_popup").hasClass('active') )
		{
			$( ".elementor-location-header .container_account_popup" ).removeClass('active');
			$( ".elementor-location-header .icone_account").html('<i class="fas fa-user"></i>');
		}
	});
	
	
	//Cacher les autres dropdown on touch mini cart
	$( ".woocommerce_header .elementor-widget-woocommerce-menu-cart").on("touchstart", function() {
		if ( $( ".elementor-location-header .menu_header .elementor-menu-toggle").hasClass('elementor-active') )
		{
			$( ".elementor-location-header .menu_header .elementor-menu-toggle").removeClass('elementor-active');
		}
		
		if ( $( ".elementor-location-header .container_account_popup").hasClass('active') )
		{
			$( ".elementor-location-header .container_account_popup" ).removeClass('active');
			$( ".elementor-location-header .icone_account").html('<i class="fas fa-user"></i>');
		}
	});
	
	//Cacher les autres dropdown on touch menu principal
	$( ".elementor-location-header .menu_header .elementor-menu-toggle" ).on("touchstart", function() {
		if ( $( ".elementor-location-header .container_account_popup").hasClass('active') )
		{
			$( ".elementor-location-header .container_account_popup" ).removeClass('active');
			setTimeout(function() {
			$( ".elementor-location-header .icone_account").html('<i class="fas fa-user"></i>');
			}, 400); 
			
		}
	});
	
	function MSW_DisplayOverlay()
	{
		$('#MSW_overlay').css({'z-index':'1','background-color':'rgba(0,0,0,0.5)','max-height': '2000px'});
	}
	
	//Rétablir l'icône du compte à l'ouverture de la popup
	$('.elementor-location-header .container_account_popup a').on("touchstart", function (e) {
		$( ".elementor-location-header .icone_account").html('<i class="fas fa-user"></i>');
	});
	
	//Faire apparaître les infos du compte on touchstart mon compte header
	$('.elementor-location-header .icone_account').on("touchstart", function (e) {
		"use strict";
		
		e.preventDefault();

		var delay_show = 0;
		
		if ( $( ".elementor-location-header .menu_header .elementor-menu-toggle").hasClass('elementor-active') )
		{
			$( ".elementor-location-header .menu_header .elementor-menu-toggle").removeClass('elementor-active');
			// $( ".elementor-location-header .menu_header .elementor-nav-menu--dropdown").css('display' , 'none');
			delay_show=300;
		}

		if ( $( ".elementor-location-header .container_account_popup").hasClass('active') )
		{
			$( ".elementor-location-header .container_account_popup" ).removeClass('active');
			setTimeout(function() {
			$( ".elementor-location-header .icone_account").html('<i class="fas fa-user"></i>');
			$( ".elementor-location-header .icone_account").removeClass("active");
			}, 400); 
		}
		else 
		{
			setTimeout(function() {
			$( ".elementor-location-header .container_account_popup").addClass("active");
			$( ".elementor-location-header .icone_account").html('<i class="fas fa-times"></i>');
			$( ".elementor-location-header .icone_account").addClass("active");
			}, delay_show); 
			
			
			return false;
		}
	});

	//Faire apparaître les infos du compte au survol de l'icone mon compte header
	$( ".elementor-location-header .icone_account, .elementor-location-header .container_account_popup" ).hover(function() {
		$( ".elementor-location-header .container_account_popup" ).addClass("active");
	}, function(){
		$( ".elementor-location-header .container_account_popup" ).removeClass("active");
    });
	
	//Fermer la popup d'ajout au panier onclick sur bouton poursuivre mes achats
	$(document).on("click", "a.continuer_achats" , function() {
		$.magnificPopup.close();
		$( "#MSW_popup_add_to_cart").css('display' , 'none');
	});
	
	//Supprimer le title du bouton close de la popup quick view
	$( document.body ).on( 'woosq_loaded', function(){
		$( "button.mfp-close" ).attr('title' , '');
	});
	
	//Ajuster le height des images product en fonction du width du grid
	if ( $( ".woocommerce ul.products li" ).length )
	{
		var width_li_grid = $( ".woocommerce ul.products li" ).innerWidth();
		if (width_li_grid > 0) $( ".woocommerce ul.products li .container_image" ).css('height', width_li_grid);

		$( window ).resize(function() {
			var width_li_grid = $( ".woocommerce ul.products li" ).innerWidth();
			if (width_li_grid > 0) $( ".woocommerce ul.products li .container_image" ).css('height', width_li_grid);
		});
	}

	//Smooth scroll anchor link
	jQuery(".smooth_scroll").click(function(){

		var height_minus = 15;
		
		if ( $( "body header" ).hasClass('elementor-sticky') ) height_minus = height_minus + $( "body header" ).outerHeight();
		if ( $( "div.elementor-location-header section.elementor-sticky" ).length > 0 ) height_minus = height_minus + $( "div.elementor-location-header section.elementor-sticky" ).outerHeight();

		var section = jQuery(this).attr('href');
		jQuery('html, body').animate({
			scrollTop: jQuery(section).offset().top - height_minus
		});  
	});
	
	//History back button
	$('#history_back').on('click', function(e){
		e.preventDefault();
		window.history.go(-1);
	});
	
	//Scroll to top button
	$(window).scroll(function(){
        if ($(this).scrollTop() > 100) $('#MSW_scroll_to_top').fadeIn();
        else  $('#MSW_scroll_to_top').fadeOut();
    });

    $('#MSW_scroll_to_top').click(function(){
        $('html, body').animate({scrollTop : 0},500);
        return false;
    });

	//Montrer le password au clic sur la classe MSW-show-password
	$(document).on("click", ".MSW_show_password" , function( e ) {
		if ( $( this ).parent().find('input').attr('type') == 'password' ) $( this ).parent().find('input').attr('type' , 'text');
		else $( this ).parent().find('input').attr('type' , 'password');
	});
	
	//Permettre a l'utilisateur de visualiser les champs mot de passe on login / register
		//Popup login register
		if ( $( ".xoo-el-container").length || $( ".xoo-el-form-inline").length ) $( "form .xoo-aff-group .xoo-aff-password").closest('.xoo-aff-input-group').append('<span class="MSW_show_password"></span>');
		//My account
		if ( $( ".woocommerce-Input--password").length ) $( ".woocommerce-Input--password").closest('.woocommerce-form-row').append('<span class="MSW_show_password"></span>');
		//Page checkout création compte
		if ( $( "body.woocommerce-checkout #account_password_field").length )
		{
			var checkInputPasswordIsLoad = setInterval(function() {
				if ($('.password-input .show-password-input').length ) 
				{
					clearInterval(checkInputPasswordIsLoad);

					$( "#account_password_field .password-input .show-password-input").remove();
					var input_password = $( "#account_password_field .password-input").html();
					$( "#account_password_field .password-input").remove();
					$( "#account_password_field").append(input_password+'<span class="MSW_show_password"></span>');
			   }
		
			}, 200); // check every 200ms
		}

	//Supprimer les show password input par défaut de Woocommerce
	if ( $( "body").hasClass('woocommerce-account') )
	{
		var checkDisplayPasswordInputIsLoad = setInterval(function() {
			if ($('.password-input .show-password-input').length ) 
			{
				clearInterval(checkDisplayPasswordInputIsLoad);
				$( ".show-password-input").remove();	
		   }
	
		}, 200); // check every 200ms
	}

	//Nettoyer les champs invalides à la fermeture de la popup login / register
	$(document).on("xoo_el_popup_closed", function() {
		$( ".xoo-error-notice").remove();
		$( "div.xoo-aff-group").removeClass('invalide');
	});
	
	//Pour la nouvelle version de Easy login
	$('body').on("xoo_el_popup_toggled", function( e , type ) {
		if (type == 'hide' || type == 'show')
		{
			$( ".xoo-error-notice").remove();
			$( "div.xoo-aff-group").removeClass('invalide');
		}
	});
	
	//Vérifier les champs des adresses de facturation et livraison on edit adress
	$(document).on('click', 'form .woocommerce-address-fields button[name="save_address"]' , function( e ) {

		if ( $('#billing_first_name_field').length ) var type_adress = 'billing';
		else if ( $('#shipping_first_name_field').length ) var type_adress = 'shipping';
		if (type_adress) var result = $.CheckAdressForm ( type_adress , 'edit-adress' );
		
		if ( result == 'true' ) return true;
		else
		{
			e.preventDefault();
			return false;
		}
	});
	
	//Vérifier les champs des adresses de facturation et livraison on edit adress (on blur Event)
	$(document).on('keyup change', 'form .woocommerce-address-fields p.validate-required input, form .woocommerce-address-fields p.validate-required select' , function() {
		if ( $(this).val() == '' || ( $(this).prop('nodeName') == 'SELECT' && $(this).val() == 'default' ) )
		{
			var label = '<strong>'+ $(this).closest('p').find('label').html().replace(/&nbsp;/g, '').replace('<abbr class="required" title="obligatoire">*</abbr>', '').replace('<span class="optional">(facultatif)</span>', '') + '</strong>';
			$(this).closest('p').addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
		}
		else $(this).closest('p').removeClass('woocommerce-invalid woocommerce-invalid-required-field').addClass('woocommerce-validated');
	});
	
	//Fonction qui vérifie les éléments du formulaire d'adresse (fonctionne pour edit-adress et pour checkout)
	$.CheckAdressForm = function( type_adress , page ) {

		var txt_error = '';

		if ( type_adress == 'billing' && page == 'checkout') var container = '.wpmc-step-billing ';
		else if ( type_adress == 'shipping' && page == 'checkout') var container = '.wpmc-step-shipping ';
		else var container = '';
		
		
		$( container+"p.form-row" ).each(function() {

			if ( $(this).find('input').length ) var elem_id = '#' + $(this).find('input').attr('id');
			else if ( $(this).find('select').length ) var elem_id = '#' + $(this).find('select').attr('id');

			//Vérification des input vide
			if ( $(this).hasClass('validate-required') && elem_id != '#account_password' && $(this).find(elem_id).val() == '' )
			{
				var label = '<strong>'+ $(this).find('label').html().replace(/&nbsp;/g, '').replace('<abbr class="required" title="obligatoire">*</abbr>', '').replace('<span class="optional">(facultatif)</span>', '') + '</strong>';
				txt_error+='Le champ '+label+' est obligatoire.<br />';
				$(this).addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
			}
			//Vérification des select vide
			else if ( $(this).hasClass('validate-required') && $(this).find('select').length && $(this).find(elem_id).val() == 'default' )
			{
				var label = '<strong>'+ $(this).find('label').html().replace(/&nbsp;/g, '').replace('<abbr class="required" title="obligatoire">*</abbr>', '').replace('<span class="optional">(facultatif)</span>', '') + '</strong>';
				txt_error+='Le champ '+label+' est obligatoire.<br />';
				$(this).addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
			}
			//Vérification des input non vide mais a analyser plus en profondeur
			else if ( $(this).hasClass('validate-required') && elem_id != '#account_password' && $(this).find(elem_id).val() != '' )
			{
				// if ( elem_id == '#billing_postcode' || elem_id == '#shipping_postcode' )
				// {
					// var codepostal = new RegExp("^(([0-8][0-9])|(9[0-5])|(2[ab]))[0-9]{3}$");
					// if ( ! codepostal.test( $(this).find(elem_id).val() ) )
					// {
						// var label = '<strong>'+ $(this).find('label').html().replace(/&nbsp;/g, '').replace('<abbr class="required" title="obligatoire">*</abbr>', '').replace('<span class="optional">(facultatif)</span>', '') + '</strong>';
						// txt_error+='Le champ '+label+' est incorrect.<br />';
						// $(this).addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
					// }
				// }
				if ( elem_id == '#billing_email' )
				{
					var email = new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i);
					if ( ! email.test( $(this).find(elem_id).val() ) )
					{
						var label = '<strong>'+ $(this).find('label').html().replace(/&nbsp;/g, '').replace('<abbr class="required" title="obligatoire">*</abbr>', '').replace('<span class="optional">(facultatif)</span>', '') + '</strong>';
						txt_error+='Le champ '+label+' est incorrect.<br />';
						$(this).addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
					}
				}
				else if ( elem_id == '#billing_phone' )
				{
					var telephone = new RegExp(/^((\+)33|0)[0-9]([-/. ]?[0-9]{2}){4}$/g);
					if ( ! telephone.test( $(this).find(elem_id).val() ) )
					{
						var label = '<strong>'+ $(this).find('label').html().replace(/&nbsp;/g, '').replace('<abbr class="required" title="obligatoire">*</abbr>', '').replace('<span class="optional">(facultatif)</span>', '') + '</strong>';
						txt_error+='Le champ '+label+' est incorrect.<br />';
						$(this).addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
					}
				}
			}
			//Vérification du mot de passe create account on checkout
			else if ( $(this).hasClass('validate-required') && elem_id == '#account_password' &&  ( $( "#createaccount" ).is(':checked') || ! $( "#createaccount" ).length ) )
			{
				if ( $(this).find(elem_id).val() == '' )
				{
					txt_error+='Le champ <strong>mot de passe</strong> est obligatoire.<br />';
					$(this).addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
				}
				else if ( $(this).find(elem_id).val().length < 8 )
				{
					txt_error+='Votre <strong>mot de passe</strong> doit contenir au minimum 8 caractères.<br />';
					$(this).addClass('woocommerce-invalid woocommerce-invalid-required-field').removeClass('woocommerce-validated');
				}
			}

		});
		
		

		if (txt_error != '')
		{
			$( ".woocommerce-notices-wrapper" ).prepend( '<ul class="woocommerce-error" role="alert"><li>'+txt_error+'</li></ul>');
			var resultat = 'false';
		}
		else var resultat = 'true';
		
		return resultat;

	}
	

	//Vérifier les champs de la popup login / register avant la soumission du formulaire de connexion
	$(document).on("click", ".xoo-el-action-btn.xoo-el-login-btn" , function( e ) {

		$( ".xoo-el-form-login .xoo-error-notice-login").remove();
		$( ".xoo-el-form-login div.xoo-aff-group").removeClass('invalide');
		
		//On défini si le form est inline ou en popup pour afficher sur les bons champs et trigger MSW_add_custom_validation plus bas
		if ( $(this).closest('.xoo-el-form-container').hasClass('xoo-el-form-inline') ) var target = '.xoo-el-form-inline ';
		else var target = '.xoo-el-inmodal ';

		if ( $( target+"form.xoo-el-action-form input[name='xoo-el-username']" ).val() == '' )
		{
			$( target+"form.xoo-el-action-form .xoo-aff-group.xoo-el-username_cont" ).addClass('invalide').append('<div class="xoo-error-notice-login">L\'E-mail est obligatoire.</div>');
		}
		else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo-el-username_cont" ).removeClass('invalide');
		
		if ( $( target+"form.xoo-el-action-form input[name='xoo-el-username']" ).val() != '' )
		{
			var email = new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i);
			
			if ( ! email.test( $( target+"form.xoo-el-action-form input[name='xoo-el-username']" ).val() ) )
			{
				$( target+"form.xoo-el-action-form .xoo-aff-group.xoo-el-username_cont" ).addClass('invalide').append('<div class="xoo-error-notice-login">L\'E-mail est invalide.</div>');
			}
			else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo-el-username_cont" ).removeClass('invalide');
		}

		if ( $( target+"form.xoo-el-action-form input[name='xoo-el-password']" ).val() == '' )
		{
			$( target+"form.xoo-el-action-form .xoo-aff-group.xoo-el-password_cont" ).addClass('invalide').append('<div class="xoo-error-notice-login">Le mot de passe est obligatoire.</div>');
		}
		else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo-el-password_cont" ).removeClass('invalide');
		
		if ( $( ".xoo-el-form-login .xoo-error-notice-login" ).length > 0 )
		{
			e.preventDefault();
			e.stopPropagation();
		}
	});

	//Vérifier les champs de la popup login / register avant la soumission du formulaire d'inscription
	$(document).on("click", ".xoo-el-action-btn.xoo-el-register-btn" , function( e ) {

		$( ".xoo-el-form-register .xoo-error-notice").remove();
		$( ".xoo-el-form-register div.xoo-aff-group").removeClass('invalide');
		
		//On défini si le form est inline ou en popup pour afficher sur les bons champs et trigger MSW_add_custom_validation plus bas
		if ( $(this).closest('.xoo-el-form-container').hasClass('xoo-el-form-inline') ) var target = '.xoo-el-form-inline ';
		else var target = '.xoo-el-inmodal ';

		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_email']" ).val() == '' )
		{
			$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_email_cont" ).addClass('invalide').append('<div class="xoo-error-notice">L\'E-mail est obligatoire.</div>');
		}
		else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_email_cont" ).removeClass('invalide');

		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_email']" ).val() != '' )
		{
			var email = new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i);
			
			if ( ! email.test( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_email']" ).val() ) )
			{
				$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_email_cont" ).addClass('invalide').append('<div class="xoo-error-notice">L\'E-mail est invalide.</div>');
			}
			else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_email_cont" ).removeClass('invalide');
		}
		
		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_fname']" ).val() == '' )
		{
			$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_fname_cont" ).addClass('invalide').append('<div class="xoo-error-notice">Le prénom est obligatoire.</div>');
		}
		else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_fname_cont" ).removeClass('invalide');
		
		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_lname']" ).val() == '' )
		{
			$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_lname_cont" ).addClass('invalide').append('<div class="xoo-error-notice">Le nom est obligatoire.</div>');
		}
		else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_lname_cont" ).removeClass('invalide');
		
		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass']" ).val() == '' )
		{
			$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_cont" ).addClass('invalide').append('<div class="xoo-error-notice">Le mot de passe est obligatoire.</div>');
		}
		else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_cont" ).removeClass('invalide');
		
		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass_again']" ).length )
		{
			if ( $(this).closest( "form.xoo-el-action-form").find( "input[name='xoo_el_reg_pass_again']" ).val() == '' )
			{
				$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_again_cont" ).addClass('invalide').append('<div class="xoo-error-notice">La confirmation du mot de passe est obligatoire.</div>');
			}
			else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_again_cont" ).removeClass('invalide');
		}

		if ( ! $( target+"form.xoo-el-action-form .xoo_el_reg_pass_cont .xoo-error-notice" ).length )
		{
			if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass']" ).val().length < 8 )
			{
				$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_cont" ).addClass('invalide').append('<div class="xoo-error-notice">Le mot de passe doit contenir au moins 8 caractères.</div>');
			}
			else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_cont" ).removeClass('invalide');
		}
		
		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass_again']" ).length )
		{
			if ( ! $( target+"form.xoo-el-action-form .xoo_el_reg_pass_again_cont .xoo-error-notice" ).length )
			{
				if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass_again']" ).val().length < 8 )
				{
					$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_again_cont" ).addClass('invalide').append('<div class="xoo-error-notice">Le mot de passe doit contenir au moins 8 caractères.</div>');
				}
				else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_again_cont" ).removeClass('invalide');
			}
		}
		
		if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass_again']" ).length )
		{
			if ( ! $( target+"form.xoo-el-action-form .xoo_el_reg_pass_cont .xoo-error-notice" ).length && ! $( target+"form.xoo-el-action-form .xoo_el_reg_pass_again_cont .xoo-error-notice" ).length )
			{
				if ( $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass']" ).val() != $( target+"form.xoo-el-action-form input[name='xoo_el_reg_pass_again']" ).val() )
				{
					$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_cont" ).addClass('invalide')
					$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_again_cont" ).addClass('invalide').append('<div class="xoo-error-notice">Les mots de passe ne correspondent pas.</div>');
				}
				else
				{
					$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_cont" ).removeClass('invalide');
					$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_pass_again_cont" ).removeClass('invalide');
				}
			}
		}
		
		if ( ! $( target+"form.xoo-el-action-form input[name='xoo_el_reg_terms']" ).is(':checked') )
		{
			$( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_terms_cont" ).addClass('invalide').append('<div class="xoo-error-notice">Vous devez accepter notre politique de confidentialité.</div>');
		}
		else $( target+"form.xoo-el-action-form .xoo-aff-group.xoo_el_reg_terms_cont" ).removeClass('invalide');

		//Trigger les champs additionnels
		$( '.xoo-el-form-register' ).trigger( 'MSW_add_custom_validation' , [ target ]  );
		
		if ( $( ".xoo-el-form-register .xoo-error-notice" ).length > 0 )
		{
			e.preventDefault();
			e.stopPropagation();
		}
		else
		{
			//Call en AJAX pour inscrire l'utilisateur a la newsletter si checkbox cochée
			if ( $( ".xoo-el-form-register input[name='xoo_el_reg_newsletter']" ).is(':checked') )
			{
				var fname = $(this).closest( "form.xoo-el-action-form").find( "input[name='xoo_el_reg_fname']" ).val();
				var lname = $(this).closest( "form.xoo-el-action-form").find( "input[name='xoo_el_reg_lname']" ).val();
				var email = $(this).closest( "form.xoo-el-action-form").find( "input[name='xoo_el_reg_email']" ).val();

				$.ajax({
						type:     'POST',
						dataType: 'json',
						url:      MSW_nonce_URL.url,
						data: {
							action: "MSW_ajax_subscribe_user_to_mailchimp_on_register",
							security : MSW_nonce_URL.nonce,
							fname : fname,
							lname : lname,
							email : email
						}
				});
			}
		}
	});
	
	//Vérifier les champs de la popup login / register avant la soumission du formulaire de login
	$(document).on("click", ".xoo-el-action-btn.xoo-el-login-btn" , function( e ) {

		$( ".xoo-el-form-login .xoo-error-notice").remove();
		
		if ( $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).val() == '' )
		{
			$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).closest('div.xoo-aff-group').addClass('invalide');
			$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).closest('div.xoo-aff-group').append('<div class="xoo-error-notice">Le champ E-mail est obligatoire.</div>');
		}
		else $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).closest('div.xoo-aff-group').removeClass('invalide');
		
		if ( $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).val() != '' )
		{
			var email = new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i);
			
			if ( ! email.test( $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).val() ) ) 
			{
				$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).closest('div.xoo-aff-group').addClass('invalide');
				$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).closest('div.xoo-aff-group').append('<div class="xoo-error-notice">Le champ E-mail est invalide.</div>');
			}
			else $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-username']" ).closest('div.xoo-aff-group').removeClass('invalide');
		}

		if ( $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-password']" ).val() == '' )
		{
			$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-password']" ).closest('div.xoo-aff-group').addClass('invalide');
			$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-password']" ).closest('div.xoo-aff-group').append('<div class="xoo-error-notice">Le mot de passe est obligatoire.</div>');
		}
		else $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-login input[name='xoo-el-password']" ).closest('div.xoo-aff-group').removeClass('invalide');

		if ( $( ".xoo-el-form-login .xoo-error-notice" ).length > 0 )
		{
			e.preventDefault();
			e.stopPropagation();
		}
	});
	
	//Vérifier les champs de la popup login / register avant la soumission du formulaire de mot de passe oublié
	$(document).on("click", ".xoo-el-action-btn.xoo-el-lostpw-btn" , function( e ) {

		$( ".xoo-el-form-lostpw .xoo-error-notice").remove();
		
		if ( $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).val() == '' )
		{
			$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).closest('div.xoo-aff-group').addClass('invalide');
			$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).closest('div.xoo-aff-group').append('<div class="xoo-error-notice">Le champ E-mail est obligatoire.</div>');
		}
		else $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).closest('div.xoo-aff-group').removeClass('invalide');
		
		if ( $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).val() != '' )
		{
			var email = new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i);
			
			if ( ! email.test( $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).val() ) ) 
			{
				$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).closest('div.xoo-aff-group').addClass('invalide');
				$(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).closest('div.xoo-aff-group').append('<div class="xoo-error-notice">Le champ E-mail est invalide.</div>');
			}
			else $(this).closest( "form.xoo-el-action-form").find( ".xoo-el-form-lostpw input[name='user_login']" ).closest('div.xoo-aff-group').removeClass('invalide');
		}

		if ( $( ".xoo-el-form-lostpw .xoo-error-notice" ).length > 0 )
		{
			e.preventDefault();
			e.stopPropagation();
		}
	});
});