 
   messagesCount: ->
     $("#messages tr").length - 1
+
+  updateMessagesCount: ->
+    title = $("head title")
+    title.text(title.text().replace(/^\(\d*\)/, "(#{@messagesCount()})"))
 
   tabs: ->
     $("#message ul").children(".tab")

              @loadMessage switchTo
            else
              @unselectMessage()

          error: ->
            alert "Error while removing message."

      .append($("<td/>").text(message.subject or "No subject").toggleClass("blank", !message.subject))
      .append($("<td/>").text(@formatDate(message.created_at)))
      .prependTo($("#messages tbody"))
    @updateMessagesCount()

  scrollToRow: (row) ->
    relativePosition = row.offset().top - $("#messages").offset().top
