 hasher.init()
 
 $ ->
+  $imagesContainer = $('#images')
+  $modalContainer = $('#gallery-modal')
+
+  $imagesContainer.on 'click', '.image a', (e) ->
+    loadSlide(this)
+    e.preventDefault()
+
   $('#toggle_selection').click (e) ->
     e.preventDefault()
     if $(this).hasClass('active')

window.tmpl = (id) ->
  if id is 'template-upload'
    return (data) -> JST['templates/file'](data)


  $modalContainer.data 'gallery', gallery

handleHashChange = (newHash) ->
  if imageId = newHash.match(/images\/(\d+)/)?[1]
    newIndex = $("#image_#{imageId}").index('.image a')
