 
     init_nav: () ->
         # <li role="presentation"><a href="#sage">Sage</a></li>
+        @nav.empty()
         nav_entries = [
             ["sage", "Sage"],
             ["python", "Python"],
             ["r", "R"],
             ["gap", "GAP"],
             ["cython", "Cython"]]
-        for entry, idx in nav_entries when data[entry[0]]?
-            @nav.append($("<li role='presentation'><a href='##{entry[0]}'>#{entry[1]}</a></li>"))
-            if @opts.lang == entry[0]
-                @set_active(@nav, @nav.children(idx))
-
-    init_lvl1: () ->
-        if @opts.lang?
-            @fill_list(@lvl1, data[@opts.lang])
+        for entry, idx in nav_entries when data[entry[0]]? && _.keys(data[entry[0]]).length > 0
+            nav_pill = $("<li role='presentation'><a href='##{entry[0]}'>#{entry[1]}</a></li>")
+            @nav.append(nav_pill)
 
     init_buttons: () ->
         @dialog.find(".btn-close").on "click", =>
-            @dialog.modal('hide')
+            @hide()
             return false
 
         @dialog.find(".btn-submit").on "click", =>


                new_doc = active[dirop]()
                if new_doc.length == 0
                    # we have to switch back one step in the lvl2 category
                    lvl2_active = @lvl2.find(".active")
                    new_lvl2 = lvl2_active[dirop]()
                    if new_lvl2.length == 0
                        lvl1_active = @lvl1.find(".active")
                        # now, we also have to step back in the highest lvl1 category
                        new_lvl1 = lvl1_active[dirop]()
                        if new_lvl1.length == 0
                            new_lvl1 = @lvl1.children()[carryop]()

    _list_sort: (a, b) ->
        # ordering operator, such that some entries are in front
        ord = (el) -> switch el
            when "Intro"    then -3
            when "Tutorial" then -2
            when "Help"     then -1
            else 0
        return ord(a) - ord(b) || a > b

    fill_list: (list, entries) ->
        # the three lists are the levels in the tree of documents. they change dynamically.
        # there is also a mutually recursive logic, to expand sublevels iff there is just one entry (saves stupid clicks)
        # fill_list call -> calls select_lvl1/2 -> which in turn calls fill_list again.
        list.empty()
        if entries?
            keys = _.keys(entries).sort(@_list_sort)
