$(document).ready(function() {
	$("#stream .pagination a.more").click(feed_getMore);
});


function feed_getMore() {

	var page = ~~$(this).attr("alt");

	$(this).parent().append("<span class=\"moreStatus\">Loading more content...</span>").hide(0).fadeIn(300);
	$.get($(this).attr("href"), {"page": page}, function(html){
		$("#stream .posts > div:not(.loaded)").addClass('loaded');
		$("#stream .posts").append(html);
		
		// Count how many boxes are checked
		var totalLoaded = $("#stream .posts").children("div:not(.loaded)").size();
		//alert("Just added " + totalChecked);

		$("#stream .posts .post:not(.loaded)").css('display','none').fadeIn(1000);
		$(".moreStatus").remove();

		if(!html || (totalLoaded < 20)) {
			//$(".more").parent().append("<span class=\"moreStatus\">No more content to load.</span>").hide(0).fadeIn(300);
			$(".more").remove();
		}

	});

	$(this).attr("alt", page + 1);

	return false;

}



