// Essaie de fixer la div de menu lors d'un scrolling...
var afixer = document.getElementById("menuetsousmenu");
var adecaler = document.getElementById("main");
var position=afixer.offsetTop;

var afixerpub = document.getElementById("pubdroite");
var positionpub= afixerpub.offsetTop;

console.log(positionpub);


function scrolled(){
	var windowHeight = window.innerHeight,
		currentScroll = document.body.scrollTop || document.documentElement.scrollTop;
	
	if (currentScroll>=position)
	{
		afixer.className = "fixed";
		adecaler.className = "decale";
	}
	else
	{
		afixer.className="";
		adecaler.className="";
	}
	
	// Ne fixer la pub que si la taille de l'écran est suffisante....
	console.log(windowHeight);
	
	if ( (currentScroll>=positionpub-100) && (windowHeight>=800) )
	{
		afixerpub.className="fixedpub";
	}
	else
	{
		afixerpub.className="";
	}
}

addEventListener("scroll", scrolled, false);
/*
<script>
var positionElementInPage = $('#menu').offset().top;
$( window ).resize(function() {
    positionElementInPage = $('#menu').offset().top;
});
$(window).scroll(
    function() {
        if ($(window).scrollTop() > positionElementInPage) {
            // fixed
            $('#menu').addClass("fixedTop");
        } else {
            // unfixed
            $('#menu').removeClass("fixedTop");
        }
    }
 
  );
</script>*/
