         (om/transact! data #(assoc % :current-state :loading))
         (go (async-search @data ajax-chan))))))
 
+(defn async-window-resize [data]
+   (.addEventListener 
+     js/window "resize"
+     (fn []
+       (om/transact! data #(assoc % :window-width (.. js/window -innerWidth))))))
 
 (om/root
   (fn [data owner]

        ))))

; render ---

(defn render-select [data owner]
  (dom/div nil
           (dom/input #js {:type "checkbox" 
                           :checked (-> data :search-options :photo) 
                           :onClick (fn [e]
                                      (.preventDefault e)
                                      (om/transact! 
                                        data
                                        #(update-in % [:search-options :photo] not)))}
                      (str 
                        "Photo ("
                        (count (filter #(= (:type %) "photo") (:current-items data)))
                        " items)"))
           (dom/input #js {:type "checkbox" 
                           :checked (-> data :search-options :audio) 
                           :onClick (fn [e]
                                      (.preventDefault e)
                                      (om/transact! 
                                        data
                                        #(update-in % [:search-options :audio] not)))}
                      (str 
                        "Audio ("
                        (count (filter #(= (:type %) "audio") (:current-items data)))
                        " items)")
                      )))

(defn render-search [data owner]
  (reify

(enable-console-print!)



;; state ------------------------------------------

(def IMGSIZE 400)

(def initial-state 
  {:current-state :search
   :current-search ""
   :error ""
   :current-items []
   :before 0
   :window-width (.. js/window -innerWidth) 
   })

(defn reset-state [state]
  (merge state initial-state))

;; Search ------------------------------------------------

; ajax ---

