 Template.Search.events
   "click .tag-name": (event, template) ->
     event.preventDefault()
-    obj = Session.get("active_tags")
+    obj = active_tags.get()
     myname = this.name
     if myname of obj
       delete obj[myname]
     else
       # add item
       obj[myname] = true
-    Session.set("active_tags",obj)
+    active_tags.set(obj)
     update_url_bar()
 
 del = (obj, key) ->

Session.setDefault "comments_search_text", null
Session.setDefault "flycircuit_search_text", null
Session.setDefault "active_tags", {}

update_url_bar = ->
  q = {}

  cst = Session.get("comments_search_text")
  if cst?
    q['text'] = cst

  fst = Session.get("flycircuit_search_text")
  if fst?
    q['idid'] = fst

  taglist = Object.keys(Session.get("active_tags"))
  if taglist.length
    q['tags'] = JSON.stringify(taglist)


  if !@find("#comments-search-input")?
    return
  if @data.text?
    comments_search_text.set(@data.text)
  if @data.idid?
    flycircuit_search_text.set(@data.idid)
  if @data.tags?
    atl = JSON.parse(@data.tags)
    taglist = {}
    for tag in atl
      taglist[tag] = true
    active_tags.set(taglist)
  this.find("#comments-search-input").value = comments_search_text.get()
  this.find("#flycircuit-search-input").value = flycircuit_search_text.get()

Template.Search.helpers
  current_search: ->
