
$(function() {
		   
	$.ajax({
		url: "ajax/newtweets.php",
		cache: false,
		success: function(html){
			if (html.length > 0) {
				$("#newtweeets").html(html);
				$("#newtweeets").animate({ height: 'show' }, 'slow');
			}
		}
	});

	$('#moreposts').click(function () { return moreTweets(); });
	

	// using some custom options
	$(document).endlessScroll({
		fireOnce: true,
		fireDelay: 500,
		callback: function(){
			moreTweets();
		}
	});


});

function moreTweets() {
								   
		var before_id = $('.post:last').attr("id").substr(2);
		
		$.ajax({
			url: "ajax/moretweets.php?before_id="+before_id,
			cache: false,
			success: function(html){
				if (html.length > 0) {
					$("#.post:last").after(html);
				}
			}
		});
		
		return false;
		
	};