 popup = L.popup()
 
 opening_popup = false
-$(window).on "hashchange", ->
+hashchange = ->
   slug = document.location.hash.replace '#', ''
   if slug.length == 0
     map.closePopup()

      opening_popup = true
      popup.openOn map
      opening_popup = false

$(->
  map.on "popupclose", (e) ->

    $.ajax(squats_url).success (squats) ->
      window.squats = squats
      addSquat squat for squat in squats
      hashchange()

  $('#geocode').click (e) ->
    e.preventDefault()
