function scrollOnPageLoad() {
  // to top right away
 // if (window.location.hash) scroll(0, 0);
  // void some browsers issue
 // setTimeout(scroll(0, 0), 1);
  var hashLink = window.location.hash;
    if (hashLink.length) {	
      jQuery(function () {
          // *only* if we have anchor on the url
          // smooth scroll to the anchor id
          jQuery('html, body').animate({
            scrollTop: jQuery("#postcarte").offset().top - 40}, 500);
							

							
      });
    }
}

scrollOnPageLoad();



jQuery("a.decouvrir").click(function (event) {
 event.preventDefault();

	
	
	var $elem = jQuery(this).attr("href")
	
	if(jQuery($elem).is(':visible'))
{
	 $elem = jQuery(this).attr("href")
	
	}
	
	
 else { $elem = '#postcarte';}
	
 jQuery("html, body").animate({
  scrollTop: jQuery($elem).offset().top - 40
 }, 500);
	
	
	
	
	
	
});





/*
jQuery( "*[id*=codespacing_progress_map]" ).append( '<div class="alertperso"><p>Pour afficher la carte et les participants, vous devez accepter les cookies externes</p><a href="#" class="_brlbs-btn-cookie-preference borlabs-cookie-preference btnperso">Changer les préférences</a></div>' );
	
jQuery( "#cs_gmaps__cspm_location" ).append( '<div class="alertperso"><p>Pour afficher la carte, vous devez accepter les cookies externes</p><a href="#" class="_brlbs-btn-cookie-preference borlabs-cookie-preference btnperso">Changer les préférences</a></div>' );
*/
	
jQuery( ".cspml_fs_container" ).append( '<a class="returnhome" href="https://semaine-du-foie-gras.fr/#tocarte">En Métropole</a>' );
	
	


jQuery( ".cspml_input_container:contains('separateur')" ).addClass( "seprarateur" );


  jQuery(".cspml_input_container").slice(2, 15).addClass( "enmetropole" );
  jQuery(".cspml_input_container").slice(16, 27).addClass( "domtom" );


jQuery(document).on("click", ".enmetropole", function () {
  jQuery(".cspml_input_container:eq(0)").find('input[type=checkbox]').slice(0).prop("checked", false).trigger("change");
 

});



jQuery(document).on("click", ".cspml_input_container:contains('Toute la France') .icr-label", function () {
 if (jQuery(this).hasClass('checked')) {
  jQuery(".cspml_fs_item_container:eq(0) input[type=checkbox]").slice(2, 15).prop("checked", false).trigger("change");
  //jQuery(".cspml_fs_item_container:eq(0) input[type=checkbox]").slice(16, 27).prop("checked", false).trigger("change");
 } else {
  jQuery(".cspml_fs_item_container:eq(0) input[type=checkbox]").slice(2, 15).prop("checked", true).trigger("change");
	//	jQuery(".cspml_fs_item_container:eq(0) input[type=checkbox]").slice(16, 27).prop("checked", false).trigger("change");

 }
});




jQuery(document).on("click", ".cspml_input_container:contains('Guadeloupe') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/guadeloupe/#tocarte";
});


jQuery(document).on("click", ".cspml_input_container:contains('Guyane') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/guyane/#tocarte";
});


jQuery(document).on("click", ".cspml_input_container:contains('La Réunion') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/la-reunion/#tocarte";
});



jQuery(document).on("click", ".cspml_input_container:contains('Martinique') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/martinique/#tocarte";
});


jQuery(document).on("click", ".cspml_input_container:contains('Mayotte') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/mayotte/#tocarte";
});

jQuery(document).on("click", ".cspml_input_container:contains('Nouvelle-Calédonie') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/nouvelle-caledonie/#tocarte";
});


jQuery(document).on("click", ".cspml_input_container:contains('Polynésie française') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/polynesie-francaise/#tocarte";
});



jQuery(document).on("click", ".cspml_input_container:contains('Saint-Barthélemy') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/saint-barthelemy/#tocarte";
});




jQuery(document).on("click", ".cspml_input_container:contains('Saint-Martin') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/saint-martin/#tocarte";
});




jQuery(document).on("click", ".cspml_input_container:contains('Saint-Pierre-et-Miquelon') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/saint-pierre-et-miquelon/#tocarte";
});




jQuery(document).on("click", ".cspml_input_container:contains('Futuna') .icr-label", function () {
window.location.href = "https://semaine-du-foie-gras.fr/wallis-et-futuna/#tocarte";
});







jQuery(document ).ready(function() {
	//jQuery( '<a href="https://patrimoine-foiegras.fr/politique-de-confidentialite/">la politique de confidentialité de ce site</a>').insertBefore(".cmb2-id-rgpd")
jQuery(".cmb2-id-rgpd .cmb-td").append( '<a href="https://semaine-du-foie-gras.fr/politique-de-confidentialite/" target="_blank"><em>la politique de confidentialité de ce site</em></a>' );

	
	
	//jQuery( "#codespacing_progress_map_div_map49" ).append( jQuery(".alertperso"));
	
	jQuery('[id^="codespacing_progress_map_div_map"]').append( jQuery(".alertperso"));
		
	jQuery( "*[id*=codespacing_progress_map_light]" ).append( jQuery(".alertperso.single"));
	
	jQuery( "#cs_gmaps__cspm_location" ).append( jQuery(".alertperso"));
	
});




jQuery(window).on('load ', function () {




    if (window.matchMedia("(max-width: 640px)").matches) {
     // jQuery(this).attr("src", jQuery(this).data("thumbsrc"));
			//	jQuery(this).css("background-image", "url(" + jQuery(this).data("thumbsrc") + ")");

    } 
	/**/
	
	

});



jQuery(document).on('click', '.fermepanier, .litlefermepanier', function (e) {

  jQuery('.fermepanier').animate({
    opacity: 0
  }, {
    duration: 400,
    queue: false,
    complete: function () {
      jQuery(this).remove();
    }
  });

    jQuery('.menu-header').removeClass("move");
 jQuery('.hamburger').removeClass('active');

  e.preventDefault();

});




  jQuery(".scroller").on('click', function(e) {
    e.preventDefault();
    jQuery('html, body').animate({scrollTop:0}, '300');
  });




var previousScroll = 0;
jQuery(window).scroll(function () {
	
	
	
	  if (jQuery(window).scrollTop() > jQuery(window).height()) {
      jQuery(".scroller").removeClass('hide');
    } else {
      jQuery(".scroller").addClass('hide');
					  jQuery(".widgetfoot.third a").attr('style','color: #db0b14 !important');


    }
	

});


jQuery(document).on('click', '.hamburger ', function () {
  if (jQuery(this).hasClass("active")) {
    jQuery(this).toggleClass('active');
    jQuery('.fermepanier').animate({
      opacity: 0
    }, {
      duration: 400,
      queue: false,
      complete: function () {
        jQuery(this).remove();
      }
    });
    jQuery('.menu-header').removeClass("move");
    jQuery('.hamburger').removeClass('active');
  } else {
    jQuery(this).toggleClass('active');
    // jQuery('<div class="fermepanier"></div>').prepend(jQuery(".header")).fadeIn(400);

    jQuery('.header').prepend(jQuery('<div class="fermepanier"></div>'));


    jQuery('.menu-header').addClass("move");
    jQuery('.fermepanier').fadeIn(400);

  }
});


jQuery('.logo').clone().prependTo('.menu-header .menu').wrap('<li class="logmenu">');

  
jQuery(document).on('click', '.menu-header.mobile li.menu-item-has-children > a', function (event) {

   if (jQuery(this).hasClass("ulopen")) {
      jQuery(this).removeClass("ulopen");
      jQuery(this).next('ul').slideUp('200');
      event.preventDefault();
    } else {
      event.preventDefault();
      jQuery(this).addClass("ulopen");
      jQuery(this).next('ul').slideDown('200');
    }

});
  

  



function replacelement() {

    if (window.matchMedia("(max-width: 1370px)").matches) {
      jQuery(".menu-header").addClass("mobile");
        jQuery(".sub-menu").css("display","none");
					
			//		jQuery( ".search_bar" ).prepend( jQuery( ".menu-header li.contact" ) );
					
} 
   



}


  




jQuery(window).on('load resize', function () {
  replacelement();
});

