var Message = function(string, showNow) {
  this.string = string;
  this.fadeSpeed = 200;
  this.delay = 3000;
  this.timer = null;
  var self = this;
  if (showNow) {
    self.show();
  } else {
    $(function() { self.show(); });
  }
}
Message.prototype = {
  show: function() {
    var self = this;
    this.$message = $("<div class='message'></div>").html(this.string)
                                                    .appendTo(document.body)
                                                    .fadeIn(this.fadeSpeed, function() {
                                                      self.timer = setTimeout(function() { self.hide(); }, self.delay);
                                                    });
  },
  hide: function() {
    this.$message.fadeOut(this.fadeSpeed, function() {
      $(this).remove();
    });
  }
}

