       $('.details-title').text event.name
       $('.details-entry').text event.description
       selected_cell.addClass 'selected'
+
+    # hide details if the event's details are already open
     else
       selected_cell.removeClass 'selected'
       $('.details').slideUp 'slow', ->

        $('.col-details').addClass 'hidden'
    false

  $('#country-table').on 'click', '.city-entry', ->
    event_id = $(this).data 'event-id'
    event = getEventById event_id
    selected_cell = $(this)

    if $('.col-details').hasClass 'hidden'
      $('.details').attr 'data-event-id', event_id
      $('.details-title').text event.name

$ ->
  # retrieve info about event
  getEventById = (eventId) ->
    gon.events.find (el) ->
      el.id is eventId

  # open details column for event from latest column
  $('a.link-latest').click ->
    if $('.col-latest').hasClass 'hidden'
      $('.col-latest').removeClass 'hidden'
