 (ns ^{:doc "main entry point for the cljs-nusmods project"}
   cljs-nusmods.main
   (:use [jayq.core :only [$ $deferred $when attr document-ready done hide is one
-                          parent prevent resolve show]])
+                          parent prevent resolve show unbind]])
   (:require [cljs-nusmods.module-array-repr     :as module-array-repr]
             [cljs-nusmods.aux-module-array-repr :as aux-module-array-repr]
             [cljs-nusmods.lesson-array-repr     :as lesson-array-repr]

       :private true}
  MODULE-FINDER-SCRIPTS-DLED? false)

(defn- initialize-exhibit3 [MODULES AUXMODULES]
  "Initialize Exhibit3 database and UI for Module Finder page"
  (if (and (not (aget js/window "Exhibit3_Initialized"))
           (aget js/window "Exhibit3_Loaded")
           MODULE-FINDER-SCRIPTS-DLED?
           (= (aget js/window "ActiveTab") MODULEFINDER-TAB-INDEX))
    (do
      (aux-module-array-repr/init!)
      (let [modulesArray (build-modules-array MODULES AUXMODULES)
            itemsArray   (add-aux-info-to-exhibit-items

                                                  "module-finder-sidebar")))

    (.click ($ :#timetable-builder-tab-link)
            timetable-builder-tab-click-handler)

    ; Add module lesson groups from the hash of the url
    (let [urlHash (aget (aget js/document "location") "hash")]
