
/**  tweet linking  **/
String.prototype.tweetlink = function() {
	return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function(link) {
		return '<a href="' + link + '">' + link + '</a>';
	}).replace(/@[\w]+/g, function(twit) {
		return '<a href="http://twitter.com/' + twit.substr(1) + '">' + twit + '</a>';
	}).replace(/#[\w]+/g, function(hash) {
		return '<a href="http://search.twitter.com/search?q=%23' + hash.substr(1) + '">' + hash + '</a>';
	});
}

/**  tweet fetching  **/
$(function(){
	$.getJSON('http://twitter.com/status/user_timeline/jamesvg.json?count=4&callback=?', function(data){
		$.each(data, function(index, item){
			$('.twitter').append('<li>' + item.text.tweetlink() + '<\/li>');
		});
	});
});