
  WF.Alert = (function() {

    Alert.prototype.MESSAGE_TYPES = ["success", "warning", "error"];

    function Alert(type, message) {
      this.m = $("<div class=\"message\"></div>");
      if ($.inArray(type, this.MESSAGE_TYPES) > -1) this.m.addClass(type);
      this.m.text(message);
      this.display();
    }

    Alert.prototype.display = function() {
      var target;
      target = ($("#message-wrapper").size() ? $("#message-wrapper") : $("#content"));
      target.prepend(this.m);
      this.m.bind("click", function(event) {
        if (this.fade_timeout) clearTimeout(this.fade_timeout);
        return this.destroy();
      });
      this.fadeOut(4);
      return this;
    };

    Alert.prototype.fadeOut = function(timeout) {
      var self;
      self = this;
      this.fade_timeout = setTimeout(function() {
        return self.destroy();
      }, timeout * 1000);
      return this;
    };

    Alert.prototype.destroy = function() {
      this.m.slideUp("fast");
      return this;
    };

    return Alert;

  })();

