//The following construct defines a function to be run as soon as the document DOM is ready
$(function() {
    if ($("#news-headlines").length > 0) {
        $.ajax({
          //url: "http://zepheira.com/news/atom/entries/",
          url: "/news/index.atom",
          //cache: false,
          success: function(atom){
            var count = 0;
            var entries = $(atom).find("entry");

//alert(entries.length);
            for (var i = 0; i < entries.length; i++) {
                if (1) {
                    var e = $(entries[i]);
                    var H = '<a href="' + e.find('link[rel="alternate"]').attr("href") +
                            '" class="title">' +
                            e.find('title').text() + 
                            '</a> ' +
                            '<span class="date">' + 
                            e.find('updated').text().substring(0, 10) + 
                            '</span>';
                    //$("#news-headlines").append(entries[i].find("title"));
                    $('<li></li>')
                        .html(H)
                        .appendTo('#news-headlines ul');
                    count++;
                    if (count == 5) {
                        //alert("Done");
                        break;
                    }
                }
            }
          }
        });
    };
});
