$(function() {
    $('.project').click(function() {
        var scroll_id = $(this).attr('scroll_id');
        var y = parseInt(scroll_id) * 354;
        $('.details .images').animate({top: -y}, 250)

        $('.project').css('background-color', '#000');
        $(this).css('background-color', '#353535');
    });

    $('.project:first').css('background-color', '#353535')

    $('.project img').each(function() {
        $(this).appendTo('.details .images');
    });
    
    var numFeeds = 15;
    
    $.jGFeed('http://buzz.googleapis.com/feeds/105164384981209237729/public/posted', function(feeds) {
        $(feeds.entries).each(function() { this['class'] = "buzz"; });
        window['feeds'] = feeds.entries;
        $.jGFeed('http://dasacc22.wordpress.com/feed/', function(feeds) {
            $(feeds.entries).each(function() { this['class'] = "wp"; });
            window['feeds'] = window['feeds'].concat(feeds.entries);
            $.jGFeed('http://github.com/dasacc22.atom', function(feeds) {
                $(feeds.entries).each(function() { this['class'] = "gh"; });
                window['feeds'] = window['feeds'].concat(feeds.entries);
                window['feeds'].sort(function(a, b) {
                    return Date.parse(b.publishedDate) - Date.parse(a.publishedDate);
                });
                for (var i=0; i<numFeeds; ++i) {
                    var f = window['feeds'][i];
                    $('<div class="block">').append('<h3 class="'+f['class']+'"><a href="'+f.link+'">'+f.title+'</a> '+f.publishedDate+'</h3>'+f.contentSnippet).appendTo('#rssfeeds #blocks');
                }
            }, numFeeds);
        }, numFeeds);
    }, numFeeds);
    /*
    // load feeds
    $.jGFeed('http://buzz.googleapis.com/feeds/105164384981209237729/public/posted', function(feeds) {
        for (var i=0; i<feeds.entries.length; ++i) {
            var f = feeds.entries[i];
            $('<div class="block">').append('<h3 class="buzz"><a href="'+f.link+'">Buzz</a> '+f.publishedDate+'</h3>'+f.content).appendTo('.rssfeeds .blocks');
        }
    });
    $.jGFeed('http://dasacc22.wordpress.com/feed/', function(feeds) {
        for (var i=0; i<feeds.entries.length; ++i) {
            var f = feeds.entries[i];
            $('<div class="block">').append('<h3 class="wp"><a href="'+f.link+'">'+f.title+'</a> '+f.publishedDate+'</h3>'+f.contentSnippet).appendTo('.rssfeeds .blocks');
        }
    });
    $.jGFeed('http://github.com/dasacc22.atom', function(feeds) {
        for (var i=0; i<feeds.entries.length; ++i) {
            var f = feeds.entries[i];
            $('<div class="block">').append('<h3 class="gh"><a href="'+f.link+'">'+f.title+'</a> '+f.publishedDate+'</h3>'+f.contentSnippet).appendTo('.rssfeeds .blocks');
        }
    });
    */
});

