google.load("feeds", "1"); //Load Google Ajax Feed API (version 1)

function rssdisplayer(cssid, url, feedlimit, showoptions) {
  this.showoptions=showoptions || ""; //get string of options to show ("date" and/or "description")
  var feedpointer=new google.feeds.Feed(url); //create new instance of Google Ajax Feed API
  feedpointer.setNumEntries(feedlimit); //set number of items to display
  this.feedcontainer=document.getElementById(cssid);
  var displayer=this;
  feedpointer.load(function(r){displayer.formatoutput(r)}); //call Feed.load() to retrieve and output RSS feed
}

rssdisplayer.prototype.formatoutput=function(result) {
  if (!result.error) { //if RSS feed successfully fetched
    var thefeeds=result.feed.entries; //get all feed entries as a JSON array
    for (var i=0; i<thefeeds.length; i++) { //loop through entries
      if (thefeeds[i].link !="http://www.coveringyourads.com/") {
          var li = document.createElement("li");
	  var feedlink = document.createElement("a");
	  feedlink.setAttribute('href', thefeeds[i].link);
	  feedlink.appendChild(document.createTextNode(thefeeds[i].title));
	  li.appendChild(feedlink);
	  this.feedcontainer.appendChild(li);
       }
    }
  }
}
