
/* Depends on jFeed, in js/jquery.jfeed.pack.js */

function displayFeed( jfeed ) {

    var html = '<h3>Lastest Posts</h3><ul>';    

    for ( var i = 0; i < jfeed.items.length && i < 5; i++ ) {

	var item = jfeed.items[i];

	html += '<li>'
	    + '<a href="'
	    + item.link
	    + '">'
	    + item.title
	    + '</a> <small>' + item.updated + '</small>'
	    + '</li>';
    }

    html += '</ul>'

    /* Completely replace the contents of the div */
    $('div#feed').html( html );

    /* And make it appear with a nice slow fade-in, so as not to
     * alarm the viewer :-) */
    $('div#feed').fadeIn('slow');
}

$(document).ready(function () {

    /* Makes an AJAX call and calls the callback function if it succeeds */
    jQuery.getFeed({
	url: 'feed.cgi',
	success: function( feed ) { displayFeed( feed ); }
    });
});

