   (.close @socket 1000 "Close button clicked"))
 
 (defn onload []
-  (let [openBtn  (.getElementById js/document "open")
-        sendBtn  (.getElementById js/document "send")
-        closeBtn (.getElementById js/document "close")]
+  (let [openBtn  (element "open")
+        sendBtn  (element "send")
+        closeBtn (element "close")]
     (set! (.-onclick openBtn) oonclick)
     (set! (.-onclick sendBtn) sonclick)
     (set! (.-onclick closeBtn) conclick)))

(ns chatapp.core)

(defn output [style text]
  (let [messages         (.getElementById js/document "messages")
        current-messages (.-innerHTML messages)
        current-message  (str "<br/><span class='" style "'>" text "</span>")]
    (set! (.-innerHTML messages) (str current-messages current-message))))

    (reset! socket websocket)))

(defn sonclick [event]
  (let [input (element "input")
        text  (.-value input)]
    (.send @socket text)
    (output "sent" (str ">>> " text))))
