function labFeed(feed, listElementID) {
  this.feed = feed;
  this.title = feed.title;
  this.link = feed.link;
  this.author = feed.author;
  this.description = feed.description;
  this.type = feed.type;
  this.entries = feed.entries;

  this.listElement = listElementID;
  this.entryElement = this.listElement;
  this.embedTarget = true;
  this.targetURL = document.location.href;
  this.useCachedItem = function() {
    return ((this.listElement != this.entryElement)
      && (this.targetURL == document.location.href));
  }
  this.displayOlderEntry = function(aLink) {
    // TODO: reload the feed with includeHistorical... and a high NumEntries
    document.location.href= aLink; // for now, go to feed source...
  }
  this.displayEntry = function (aID) {
    var aLink = decodeURIComponent(aID);
    if (this.entries) {
      for (var i = 0; i < this.entries.length; i++) {
        if (aLink == this.entries[i].link) {
          var html = '';
          html += '<h3> '+ this.entries[i].title + '</h3>';
          html += '<p>' + this.entries[i].content + '</p>';
          var element = document.getElementById(this.entryElement);
          if (element) element.innerHTML = html;
          return;
        }
      }
    }
    this.displayOlderEntry(aLink);
  }

  this.listEntries = function () {
    var html = '';
    for (var i = 0; i < this.entries.length; i++) {
      html += '<h3>';
      if (this.embedTarget) {
        var aLink = encodeURIComponent(this.entries[i].link);
        if (this.useCachedItem())
          html+= '<a href="#" onclick="displayEntry(\'' + aLink + '\');"';
        else
          html+= '<a href="' + this.targetURL + '?entryid=' + aLink
      } else
        html+= '<a target="_blank" href="' + this.entries[i].link;
      html += '">' + this.entries[i].title + '</a></h3>';
      html += '<p>' + this.entries[i].contentSnippet + '</p>';
    }
    var obj = document.getElementById(this.listElement);
    if (obj) obj.innerHTML = html;
  }
  return this;
}


