$(document).ready(function()
{
	$('img').each(function(i)
	{
		$(this).animate({ 'opacity':'1' }, 400);
	});
	
	
	getTweets("mediastation", 5, "json");
});

function getTweets(id, num, type)
{
	var query = "http://twitter.com/status/user_timeline/" + id + "." + type + "?count=" + num + "&trim_user=true";
	$.getJSON(query + '&callback=?', function(json)
	{
		$.each(json, function(i)
		{
			if(this['in_reply_to_screen_name'] == null)
			{
				$('#tweet').html(parseLinks(this['text']));
				return false;
			}
		});
	});
}

function parseLinks(tweet)
{
	var t = tweet.replace(/(^|\s)@(\w+)/g, '$1@<a href="http://www.twitter.com/$2">$2</a>');
	//return t.replace(/(^|\s)#(\w+)/g, '$1#<a href="http://search.twitter.com/search?q=%23$2">$2</a>');
	t = t.replace(/(^|\s)#(\w+)/g, '$1#<a href="http://search.twitter.com/search?q=%23$2">$2</a>');;
	return t.replace(/\s(\bhttp:\/\/[^ ]+\b)/g, ' <a href="$1">$1</a>');
}
