var veno = {
	twitter: null,
	
	linkCatch: /((((ht|f){1}(tp:[/][/]){1})|((www.){1}))[-a-zA-Z0-9@:%_\+.~#?&//=]+)/gm,
	usernameCatch: /@(\w+)/gm,

    original_email_address_text: null,
    original_email_message_text: null,

	replaceUrl: function(t) { return '<a href="'+t+'" title="'+t+'">' + t + '</a>'; },

    convertUrls: function(text) {
		text = text.replace(veno.linkCatch, function(t) { return veno.replaceUrl(t); });
		return text.replace(veno.usernameCatch, '<a href="http://twitter.com/$1" title="External Link">@$1</a>');
    }
};

$(document).ready(function() {
	veno.twitter = $("#twitter");

	$.ajax({	
		type: "GET",
		dataType: "jsonp",
		url: "http://twitter.com/statuses/user_timeline/ryanmcgrath.json",
		data: "count=8&page=1",
		success: function(tweets) {
			var tweetString = "";
			
			for(var i = 0; i < tweets.length; i++) tweetString += '<dd class="' + (i === tweets.length - 1 ? 'final' : '') + '">' + veno.convertUrls(tweets[i].text) + '</dd>';
			veno.twitter.append(tweetString).slideDown("slow");
		},
		error: function() {
			veno.twitter.append("<dd>Huh, looks like Twitter is down at the moment. This'll return when Twitter gets back up.</dd>");
		}
	});
});
