/*
*  How to load a feed via the Feeds API.
*/

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

// 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("rssContent");
	container.innerHTML = '';

	var entryText = '<br /><div class="rssFeed"><img src="assets/images/layout/drops/40px_01.png" alt="News" width="52" height="40" border="0" style="padding-right:10px;float:left;" /><h1>News</h1>';
	// 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
	
	for (var i = 0; i < result.feed.entries.length; i++) {
	  var entry = result.feed.entries[i];
	  entryText += '<div class="rssEntry">';
	  entryText += '<span class="rssTitle">' + entry.title + '</span>';
	  entryText += '<span class="rssDate"> (' + entry.publishedDate + ')</span><br />';
	  entryText += entry.content + "<br /><br />";	  
	  entryText += '</div>';
	}
	
	entryText += '</div>';
  container.innerHTML = entryText;
  }
}

function initializeFeed() {
  // Create a feed instance
  var feed = new google.feeds.Feed("http://www.abattoir-software.com/index.xml");

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

google.setOnLoadCallback(initializeFeed);

