$(document).ready(function() {  
    var username = 'MitchLandrieu';  
    $.getScript('http://twitter.com/statuses/user_timeline/' + username + '.json?callback=twitterCallback&count=4');
});  


function twitterCallback(twitters) {
	var results = '';
	$(twitters).each(function() {
		if (this.id == undefined) return;
		results += "<p class='tweet_result' id='tweet" + this.id + "'><a href='http://twitter.com/MitchLandrieu' class='tweet_user'><img width='16' height='16' alt='MitchLandrieu on Twitter' src='" + this.user.profile_image_url + "' /></a>" + linkify(this.text) + "</p>";
	});
	$("#twitter_results").prepend(results);
}

function linkify(text) {
    // modified from TwitterGitter by David Walsh (davidwalsh.name)
    // courtesy of Jeremy Parrish (rrish.org)
    return text.replace(/(https?:\/\/[\w\-:;?&=+.%#\/]+)/gi, '<a href="$1">$1</a>')
               .replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
               .replace(/(^|\W)#(\w+)/g, '$1#<a href="http://search.twitter.com/search?q=%23$2">$2</a>');
}
