 (defn click-toggle-meridian []
   (let [hours (+ (get-hours) 12)
         hours (if (>= 24 ) (- 24 hours) hours)]
-    (set-hours! hours)))
+    (set-hours! hours)
+    (show-closest-snapshot!)))
 
 (defn click-decrement-hour []
-  (set-hours! (dec (get-hours))))
+  (set-hours! (dec (get-hours)))
+  (show-closest-snapshot!))
 
 (defn click-increment-hour []
-  (set-hours! (inc (get-hours))))
+  (set-hours! (inc (get-hours)))
+  (show-closest-snapshot!))
 
 (defn click-decrement-Minute []
-  (set-minutes! (dec (get-minutes))))
+  (set-minutes! (dec (get-minutes)))
+  (show-closest-snapshot!))
 
 (defn click-increment-minute []
-  (set-minutes! (inc (get-minutes)))))
+  (set-minutes! (inc (get-minutes)))
+  (show-closest-snapshot!)))
 
 (defn click-later []
   (if (pos? @snapshot-index)
-    (use-index-time! (dec @snapshot-index))))
+    (do
+      (swap! snapshot-index dec)
+      (sync-time-with-snapshot!))))
 
 (defn click-earlier []
-  (if (>= @snapshot-index (count @snapshot-list)
-    (use-index-time! (inc @snapshot-index)))))
+  (if (>= @snapshot-index (count @snapshot-list))
+    (do
+      (swap! snapshot-index inc)
+      (sync-time-with-snapshot!))))
 
 (defn add-events []
   (aset js/window "onpopstate" on-popstate)

(defn set-minutes! [new-mins]
  (swap! selected-time doto (.setMinutes new-mins)))

(defn use-index-time! [index]
  (swap! selected-time #(-> (@snapshot-list index) :time Date.)))

;;------------------------------------------------------------------------------
;; Watchers
;;------------------------------------------------------------------------------

(defn )

; TODO: Find closest index
(defn on-selected-time-change [_ _ _ new-time]
  (let [hour (.getHours new-time)
        meridian (if (> 11 hour) "PM" "AM")

    (val ($ "#hour") (pad hour))
    (val ($ "#minute") (pad (.getMinutes new-time)))
    (val ($ "#meridian") meridian)
    (.datepicker ($ "#datepicker") "update" new-time)))

(add-watch timestamp :_ on-selected-time-change)

(defn on-snapshot-index-change [_ _ _ new-index]
  (let [snapshot (@snapshot-list new-index)
        time (Date. (:time snapshot))
        image (:image snapshot)
        time-display (str (.toDateString time) " " (.toLocaleTimeString time))]
    (attr ($ "#currentSnapshot") "src" image)
    (text ($ "#imageDateTime") time-display)
    (prop ($ "#earlier") "disabled" (= (inc new-index) (count @snapshot-list)))
    (prop ($ "#later") "disabled" (zero? new-index))
    ; delay updating the url in case user is rapidly switching times
    (js/clearTimeout @url-update-timeout)
    (swap! url-update-timeout #(js/setTimeout set-url time 200))))

(add-watch snapshot-index :_ on-snapshot-index-change)

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