class window.AlertMessage

  constructor: (@category, message) ->
    @messages = []
    @container = $("#alert-list")

    if message
      @messages.push(message)

  addMessage: (message) ->
    @messages.push(message)

  show: ->
    flashDiv = $("<div class='alert alert-#{@category}'><button type='button' class='close' data-dismiss='alert'>&times;</button>")
    for message in @messages
      flashDiv.append("<span class='message'>#{message}</span><br/>")

    flashDiv.hide().appendTo(@container).fadeIn()
