$.fn.tweet = function() {
  var $this = $(this)
  
  return this.each(function() {
    $.getJSON('http://twitter.com/statuses/user_timeline/formedfunction.json?count=1&callback=?', function(data) {
      var tweet = data[0].text
      if (tweet.search(/(https?:\/\/[-\w\.]+:?\/[\w\/_\.]*(\?\S+)?)/) > -1)
        tweet = tweet.replace(/(https?:\/\/[-\w\.]+:?\/[\w\/_\.]*(\?\S+)?)/, "<a href=\"$1\">$1</a>")
      $this.html(tweet)
    });  
  });
}

$(function() {
  $('a[rel=facebox]').facebox()
  $('#tweet').tweet()
});