// $(".div_to_move").scrollFollow("upper_limit", "top_position");

$.fn.scrollFollow=function(upperLimit, topPosition){
		return this.each(function(){
								  
				var theItem = $(this);
				
				$(window).scroll(function () {   
	  
				  var currentWindowScroll = $(window).scrollTop();
				  var refineTop = parseFloat($(theItem).css("top"));
				  var lowerOffsets = $('.content').offset();
				  var lowerBottom = lowerOffsets.top + $('.content').outerHeight();
				  var lowerLimit = lowerBottom - $(theItem).outerHeight()-40;
				  
					  if (currentWindowScroll > upperLimit && currentWindowScroll < lowerLimit){
						var toMove = currentWindowScroll - upperLimit;
						$(theItem).stop().animate({top:toMove},150);
					  }
					  else if (currentWindowScroll > upperLimit && currentWindowScroll > lowerLimit){
						 $(theItem).stop().animate({top:(lowerLimit-$('.content').outerHeight()-50)},150); 
					  }
					  else{
						$(theItem).stop().animate({top:topPosition},150);
					  }
				  
				  
				});
				
				
				
		});	
};
