	$(document).ready(function(){
		function last_msg_funtion() 
		{ 		   
           var ID=$(".box:last").attr("id").slice(4);
			 $.post("inc/load_news.php",{
				id: ID
                }, function (data){
				if (data.error){
                    alert("Błąd serwera");
                } else{		
				if(data != '0'){	
				$(".box:last").after(data);		
                }else{
				$(".box:last").after(data);	
				}}
                });
		};  
		
		$(window).scroll(function(){
			if  ($(window).scrollTop() == $(document).height() - $(window).height()){
			   last_msg_funtion();
			}
		}); 
		
	});
