
google.load("feeds", "1");

var maxStories = 4;

// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
  if (!result.error) {
    // Grab the container we will put the results into
    var container = document.getElementById("news");
    container.innerHTML = '';

    // Loop through the feeds, putting the titles onto the page.
    // Check out the result object for a list of properties returned in each entry.
    // http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
    var stories = Math.min(result.feed.entries.length, maxStories);
    
    for (var i = 0; i < stories; i++) {
      var entry = result.feed.entries[i];
      var div = $('<div class="newsitem alignleft"></div>')[0];
      
      var date = new Date(entry.publishedDate).toDateString().slice(3);
      
      div.appendChild($('<br/>')[0]);
      div.appendChild($('<b>' + entry.title + '</b>')[0]);
      div.appendChild($('<span style="color: #999"> - ' + date + '</span>')[0]);
      div.appendChild($('<br/>')[0]);
      
      var snippet = $("<span>" + entry.contentSnippet + " </span>")[0]
      div.appendChild(snippet);
      snippet.appendChild($('<a href="' + entry.link + '">Read More</a>')[0]);
      container.appendChild(div);
    }
  }
}

function OnLoad() {
  var feed = new google.feeds.Feed("http://blog.claveo.com/feed/");

  // Calling load sends the request off.  It requires a callback function.
  feed.load(feedLoaded);
}

google.setOnLoadCallback(OnLoad);


