
function
ForumPuff(container, data)
{
  this.div = container.firstChild;
  this.container = container;
  this.applyUpdate(data);
  var widget = this;
  // window.setInterval(function() {widget.requestUpdate();}, 1000 * 60 * 10);
}

ForumPuff.prototype.requestUpdate = function() {
  var widget = this;
  pbu.postJSON("/widgets/update.php", {"widget":"ForumPuff"}, function(json) {
    try {
      if (!json.success)
        return;
    }
    catch (e) {
      return;
    }
    widget.applyUpdate(json);
  });
}

ForumPuff.prototype.applyUpdate = function(json) {
  var ul = pbu.$(".forumlist", this.div)[0];
  pbu.$(ul).empty();
  for (var i = 0; i < json.topics.length; i++) {
    var li = pbu.$("<li><a href='/?page=forum_topic_show&amp;topic="+json.topics[i].id+"&amp;pagenr=0'></a> <span></span></li>")[0];
    pbu.$("a", li).text(json.topics[i].subject);
    pbu.$("span", li).text("("+json.topics[i].usr+")");
    if (json.topics[i].premium)
      pbu.$("span", li).addClass("premium");
    ul.appendChild(li);
  }
}

