$(function(){
       $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=51242766@N04&format=json&jsoncallback=?", function(data) {
               var target = "#flickr ul"; // Where is it going?
               for (i = 0; i <= 9; i = i + 1) { // Loop through the 10 most recent, [0-9]
                       var pic = data.items[i];
                       var liNumber = i + 1; // Add class to each LI (1-10)
                       $(target).append("<li class='flickr-image no-" + liNumber + "'><a title='" + pic.title + "' href='" + pic.link + "'><img src='" + pic.media.m + "' /></a></li>\n");
               }
       });
	   

	   $.getJSON("http://twitter.com/statuses/user_timeline/johanahlback.json?callback=?", function(data) {
		   for(var i = 0; i <= 4; i++){
			   
     			$("#twitter").append('<li class="tweet">' + data[i].text.linkify() + '</div>\n\n');
		   }
});
String.prototype.linkify = function() {
    		return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
    			return m.link(m);
    		});
    	};


});

$.fn.tweetify = function() {
        this.each(function() {
                $(this).html(
                        $(this).html()
                                .replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi,'<a href="$1">$1</a>')
                                .replace(/(^|\s)#(\w+)/g,'$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>')
                                .replace(/(^|\s)@(\w+)/g,'$1<a href="http://twitter.com/$2">@$2</a>')
                );
        });
        return $(this);
}
