   )
 
 ;;------------------------------------------------------------------------------
+;; Show / Hide Tooltips
+;;------------------------------------------------------------------------------
+
+(def left-arrow-class "left-arr-42ea1")
+(def right-arrow-class "right-arr-d3345")
+(def arrow-classes (str left-arrow-class " " right-arrow-class))
+
+;; NOTE: this value needs to stay in sync with the .tooltip-53ddee class
+;; in /less/main.less
+(def max-tooltip-width 360)
+
+(defn- show-tooltip! [target-el tooltip-id]
+  (let [$target-el ($ target-el)
+        target-height (.height $target-el)
+        target-width (.width $target-el)
+        target-coords (.offset $target-el)
+        target-x (+ (aget target-coords "left") (/ target-width 2))
+        target-y (+ (aget target-coords "top") (/ target-height 2))
+        browser-width (.width ($ js/window))
+        $tooltip-el ($ (str "#" tooltip-id))
+        tooltip-width (.width $tooltip-el)
+        flip? (> (+ target-x max-tooltip-width 50) browser-width)]
+    (.removeClass $tooltip-el arrow-classes)
+    (if flip?
+      (.addClass $tooltip-el right-arrow-class)
+      (.addClass $tooltip-el left-arrow-class))
+    (.css $tooltip-el (js-obj
+      "display" ""
+      "left" target-x
+      "marginLeft" (if flip? (- 0 tooltip-width 30) 18)
+      "top" target-y ))))
+
+(def tooltip-sel ".tooltip-53dde")
+
+(defn- hide-all-tooltips! []
+  (.hide ($ tooltip-sel)))
+
+;;------------------------------------------------------------------------------
 ;; Events
 ;;------------------------------------------------------------------------------
 

  (if-let [tooltip-id (evt->tt-num js-evt)]
    (hide-el! tooltip-id)))

(defn- on-touchstart [js-evt]
  nil
  )

;;------------------------------------------------------------------------------
;; Init and Events

      (remove-pin! tooltip-id)
      (pin-down! tooltip-id))))

(defn- on-mouseenter [js-evt]
  (when-let [tooltip-id (evt->tt-num js-evt)]
    (show-tooltip! (aget js-evt "currentTarget") tooltip-id)))

;; TODO: IE fires the mouseleave event while the mouse cursor is still inside
;; the tooltip icon, causing a very distracting flicker effect.
