// EFFETS DE NAVIGATION IN-PAGE

var header = $('#header').innerHeight();
var homenav = $('#homenav').innerHeight();
var footer = $('#footer').innerHeight();

var totalh = $(document).height();

var margin = null


$(function(){
	$(window).resize(function(){
		var elem = $(this);
		var viewh = elem.height();
		var vieww = elem.width();
		header = $('#header').innerHeight();
		homenav = $('#homenav').innerHeight();
		footer = $('#footer').innerHeight();
		var content = header+homenav+footer+40
		// $('body').text( 'window width: ' + vieww + ', height: ' + viewh);

		// ajoute une marge sous le footer pour les grandes fenêtres :
		if (viewh > (content+100)) {
			margin = (viewh-content)/2+"px";
			// $('#footer .bottom p.black').text( 'margin: ' + margin + " | content: " + content + " | visible H: " + viewh)
			$('#homenav').css({"margin-top": margin, "margin-bottom": margin}, 100 );
		}
		else if (viewh < (content+100)) {
			// $('#footer .bottom p.black').text( 'margin: ' + margin + " | content: " + content + " | visible H: " + viewh)
			$('#homenav').css({"margin-top": "40px","margin-bottom": "40px"}, 100 );
		}
	});
	$(window).resize();
});


// NAVIGATION DYNAMIC STYLING

// $(document).ready(function(){

// 	// active/désactive .current sur les liens de navigation :

// 	$(window).scroll(function () {
// 		if (($(document).scrollTop() > Apos) && ($(document).scrollTop() < Bpos)) {
// 			$('a[href$="#service"]').addClass('current');
// 			$('a[href!="#service"]').removeClass('current');
// 		}
// 		else if (($(document).scrollTop() > Bpos) && ($(document).scrollTop() < Cpos)) {
// 			$('a[href$="#portfolio"]').addClass('current');
// 			$('a[href!="#portfolio"]').removeClass('current');
// 		}
// 		else if (($(document).scrollTop() > Cpos) && ($(document).scrollTop() < Dpos)) {
// 			$('a[href$="#about"]').addClass('current');
// 			$('a[href!="#about"]').removeClass('current');
// 		}
// 		else if (($(document).scrollTop() > Dpos) && ($(document).scrollTop() < maxH)) {
// 			$('a[href$="#contact"]').addClass('current');
// 			$('a[href!="#contact"]').removeClass('current');
// 		}
// 		else if ($(document).scrollTop() < (Apos + 40)) {
// 			$('a[href^="#"]').removeClass('current');
// 		}
// 	});


  //   var name = ".sidebar";
  //   var ylocate = null;
  //   var maxh = null;

  //   $(document).ready(function(){
        
		// ylocate = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")));
		// maxh = $(document).outerHeight()-1050;
        
  //       $(window).scroll(function () {
		
		// 	if ($(document).scrollTop() < 400) {
  //      			$(name).animate({top:ylocate}, {duration:500,queue:false});
  //       	}
  //       	else if ($(document).scrollTop() > maxh) {
  //       		offset = maxh-450+"px";
  //       		$(name).animate({top:offset}, {duration:100,queue:false});
  //       	}
  //      		else {
		// 		offset = $(document).scrollTop()-380+"px";
		// 		$(name).animate({top:offset}, {duration:500,queue:false});
  //      		}
  //       });// fin boucle $(window).scroll()
  //   }); // fin boucle $(document).ready()

