(function($){
 
	$.fn.scrollDiv = function(params){
				params = $.extend( {butH: 0, butB: 99999}, params);
				var $scrollingDiv = $(this);
				var buteHaut = params.butH;
				var hauteurFoot = $scrollingDiv.height()+params.butB;
				var hauteurPage = $(this).parent().height();
				var buteBas = hauteurPage-hauteurFoot;
			
					$(window).scroll(function(){
						if($(window).scrollTop() > buteHaut &&  $(window).scrollTop() < buteBas){
					
						 $scrollingDiv
						.stop()
						.animate({"top":("0px"), "marginTop" : ($(window).scrollTop()) + "px"}, "slow”");

						}else if($(window).scrollTop() <= buteHaut){

						$scrollingDiv
						.stop()
						.animate({"marginTop": ("0px"), "top":(buteHaut)+"px"}, "slow" );

						}else if($(window).scrollTop() > buteBas){

						$scrollingDiv
						.stop()
						.animate({"top":(buteBas)+"px","marginTop": ("0px")}, "slow" );

						}

					});
        };
 
})(jQuery)
