       if not event.isImmediatePropagationStopped()
         tag_box = event.target.parentNode.getElementsByTagName(
           "textarea")[0]
-        tag_text = tag_box.value
-        #TODO: Encapsulate this code
-        if tag_text != "" #TODO: && not @my_tags[tag_text]?
-          #TODO: add to @my_tags not @tags
-          @tags[tag_text] ?= { users: [], weight: 0}
-          @tags[tag_text].users.push(Session.get('user_id'))
-          Posts.update(@_id, {$set: {tags: @tags}})
-          #clear textbox and update suggestion filter
-          tag_box.value = ''
-          Session.set("filter_text_#{ @_id }", '')
-          Session.get("context_#{@_id}").invalidate()
+        Template.tagbox.add_tag(@_id, @tags, [], tag_box.value, tag_box)
         event.stopImmediatePropagation()
         
     "click button[name='done_tagging']": (event) ->

        Session.set("tagging_#{ @_id }", false)
        event.stopImmediatePropagation()
  }
)

Handlebars.registerHelper('vis_tags', (context, object) ->
  @my_tags = {test: 0}          #TODO: REMOVE
  ret = ""
  for tag in context
    ret += "<div class='tag"

        
        switch event.keyCode
          when 13 #Enter
            Template.tagbox.add_tag(@_id, @tags, [], entered_text, event.target)
          when 37 #Left-arrow: ADD
            if suggested_tag?
              @tags[suggested_tag] ?= { users: [], weight: 0}
