 
 (def $ js/$)
 
+;; TODO: move this to a dom namespace
+(defn- by-id [id]
+  (.getElementById js/document id))
+
 ;;------------------------------------------------------------------------------
 ;; HTML
 ;;------------------------------------------------------------------------------

;; Events
;;------------------------------------------------------------------------------

(defn on-submit
  "Handle the submit event."
  []
  (let [input (.val ($ ".login-name"))]
    (store-login! input)
    (send-login!)
    (aset js/location "hash" "#/menu")))

;; Page Initialization
;;------------------------------------------------------------------------------

(defn init []

  ; Initialize page content
  (.html ($ "#main-container") (login-html))

  ; Populate username field.
  (.val ($ "#login") (get-username))

  ; Set username on button click.
  (.click ($ "#submit") on-submit)

  ; Put focus on username field.
  (.focus (by-id "login")))

(defn cleanup
  []
