class window.FlashMessage

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

    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()
