// Load RSS feeds.
jQuery(document).ready(function($) {
    // FLICKR
    $.jGFeed('http://api.flickr.com/services/feeds/photos_public.gne?id=30254301@N04',
        function(feeds){
            if(!feeds) return false;

            var str = [];
            $(feeds.entries).each(function(){
                var parts = this.content.match(/http:\/\/farm(\d)\.static.flickr.com(.*)\.jpg/gi)[0].split('_m');
                var content = [parts[0], '_s', parts[1]].join('');
                var url = this.content.match(/http:\/\/.*flickr.com\/photos\/(.*)\/"/gi)[0];
                str.push('<a href="', url, '><img src="', content, '" alt="', this.title, '" title="', this.title, '"></a>');
            });

            $('#flickr > .content').append(str.join(''));
        },
    10);

    // TWITTER
    $.jGFeed('http://twitter.com/statuses/user_timeline/karbassi.rss',
        function(feeds){
            if(!feeds) return false;

            var str = ['<ul>'];
            $(feeds.entries).each(function(){
                str.push('<li><a href="', this.link, '">', this.content.substring(10), '</a></li>');
            });
            str.push('</ul>');

            $('#twitter > .content').append(str.join(''));
        },
    5);

    // LAST.FM
    $.jGFeed('http://ws.audioscrobbler.com/1.0/user/mrWoot/recenttracks.rss',
        function(feeds){
            if(!feeds) return false;

            var str = ['<ul>'];
            $(feeds.entries).each(function(){
                str.push('<li><a href="', this.content,'">', this.title, '</a></li>');
            });
            str.push('</ul>');

            $('#lastfm > .content').append(str.join(''));
        },
    5);

    // DELICIOUS
    $.jGFeed('http://feeds.delicious.com/v2/rss/mrwoot?count=5',
        function(feeds){
            if(!feeds) return false;

            var str = ['<ul>'];
            $(feeds.entries).each(function(){
                str.push('<li><a href="', this.link,'">', this.title, '</a></li>');
            });
            str.push('</ul>');

            $('#delicious > .content').append(str.join(''));
        },
    5);

    // DIGG
    $.jGFeed('http://digg.com/users/mrWoot/history/diggs.rss',
        function(feeds){
            if(!feeds) return false;

            var str = ['<ul>'];
            $(feeds.entries).each(function(){
                str.push('<li><a href="', this.link,'">', this.title, '</a></li>');
            });
            str.push('</ul>');

            $('#digg > .content').append(str.join(''));
        },
    5);

    // FRIENDFEED
    $.jGFeed('http://friendfeed.com/karbassi?format=atom',
        function(feeds){
            if(!feeds) return false;

            var str = ['<ul>'];
            $(feeds.entries).each(function(){
                str.push('<li><a href="', this.link,'">', this.title, '</a></li>');
            });
            str.push('</ul>');
            

            $('#friendfeed > .content').append(str.join(''));
        },
    5);

    // googlereader
    $.jGFeed('http://www.google.com/reader/public/atom/user%2F07483848639058383105%2Fstate%2Fcom.google%2Fbroadcast',
        function(feeds){
            if(!feeds) return false;

            var str = ['<ul>'];
            $(feeds.entries).each(function(){
                str.push('<li><a href="', this.link,'">', this.title, '</a></li>');
            });
            str.push('</ul>');

            $('#googlereader > .content').append(str.join(''));
        },
    5);

    // Tech.karbassi.com
    $.jGFeed('http://feeds.feedburner.com/karbassi/tech/',
        function(feeds){
            if(!feeds) return false;
    
            var str = ['<ul>'];
            $(feeds.entries).each(function(){
                str.push('<li><a href="', this.link,'">', this.title, '</a></li>');
            });
            str.push('</ul>');
    
            $('#tech_karbassi_com > .content').append(str.join(''));
        },
    5);

});

/*
 * jGFeed 1.0 - Google Feed API abstraction plugin for jQuery
 * Copyright (c) 2009 jQuery HowTo
 * Licensed under the GPL license: http://www.gnu.org/licenses/gpl.html
 * URL: http://jquery-howto.blogspot.com
 * Author URL: http://me.boo.uz
 */
(function($){
  $.extend({
    jGFeed : function(url, fnk, num, key){
      // Make sure url to get is defined
      if(url == null) return false;
      // Build Google Feed API URL
      var gurl = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + url;
      if(num != null) gurl += "&num=" + num;
      if(key != null) gurl += "&key=" + key;
      // AJAX request the API
      $.getJSON(gurl, function(data){
        if(typeof fnk == 'function')
            fnk.call(this, data.responseData.feed);
        else
            return false;
      });
    }
  });
})(jQuery);

// HTML 5 Shivs
document.createElement('header');
document.createElement('footer');
document.createElement('section');
document.createElement('aside');
document.createElement('nav');
document.createElement('article'); 
document.createElement('figure');
document.createElement('time');