(function(){
  if(jQuery){
    jQuery.extend({
      link:function(text){
        return text.replace(/(href="|<a.*?>)?[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function($0, $1) {
          return $1 ? $0 : $0.link($0);
});
      }
    });

    jQuery.fn.extend({
      'link':function(){
        this.html(jQuery.link(this.html()));
      }
    });
  
  }
})();

$(document).ready(function(){
//		t('ProWebDevBlog',3,'t1');
	//	t('ENGADGET',3,'t2');
		t('jorgedonoso',5,'t3');
	});
	
	function t(tName,count,div){
		$.jTwitter(tName,count, function(data){
			$('#'+div).empty();
			$('#'+div).append("<div class='tTitle'><img src='"+data[0].user.profile_image_url+"'/> "+data[0].user.name+"</div>");
			var postText;
			$.each(data, function(i, post){
				postText = $.link(post.text);
				postText = postText.replace(/@\w+/g, function(username) {
					return '<a href="http://twitter.com/' + username.replace('@', '') + '">' + 
						username + '</a>';
				});
				$('#'+div).append(
					'<div class="post">'
					+' <div class="txt">'
					// See output-demo.js file for details
					+    postText
					+' </div>'
					+'</div>'
				);
			});
		});
	}
