$(document).ready(function()
{
	var pageSize = 3;
	
	// Appends the new tweet to the UI
	var appendTweet = function(tweet) {
		var tcont = $("#twitter_marquee");
		tcont.append((tweet));
	};
	
	// Loads the next tweets
	var loadTweets = function() 
	{ 
		var url = "http://twitter.com/status/user_timeline/urbanoutreachuk.json?count="+pageSize+"&callback=?";
				
		$.getJSON(url,function(data) {
			$.each(data, function(i, post) {
					if(i>pageSize)
						return;
					if(i>0)
					{
						appendTweet("&bull; <a href=\"htt2p://twitter.com/urbanoutreachuk/status/"+post.id_str+"\">" + post.text+"</a>");
					}
					else
					{
						appendTweet("<a href=\"http://twitter.com/urbanoutreachuk/status/"+post.id_str+"\">" + post.text+"</a>");
					}
				}
			);
		});
	};
	
	// First time, directly load the tweets
	setTimeout(loadTweets, 1500);
});
