$.extend($s, {
  scroller: {
    CSS_CONTAINER: "#scroller",
    CSS_MESSAGES: "#scroller .messages",
  
    messages: {},    
  
    init: function(){
      this.updateScroller();
    },
    
    keys: function(o){
      var myKeys = [];
      for(var key in o) {
          myKeys.push(key);
      }
      return myKeys;
    },
    
    updateScroller: function() {     
      if(this.keys(this.messages).length == 0) {
        $(this.CSS_CONTAINER).hide();
      }else{
        $(this.CSS_CONTAINER).show();
      }
    },
    
    addMessage: function(id, message, confirm){
      if(confirm != null) {
        message = message + " <button onclick='$s.scroller.removeMessage(\"" + id + "\");'>" + confirm + "</button>";
      }
      this.messages[id] = message;
      $(this.CSS_MESSAGES).append("<li id='" + id + "'>" + message + "</li>");
      this.updateScroller();
    },
    
    removeMessage: function(id){
      delete this.messages[id];
      var ref = this;
      $("#" + id).fadeOut(200, function(){
        $("#" + id).remove();
        ref.updateScroller();
      });
    }
  }

});