$(document).ready(function() {
  
  // TABS
  
  // reset tabs
  $('.tab').hide()
  $('.tablinks li').removeClass('active')
  
  // show default tab
  $('.tab').first().show()
  $('.tablinks li').first().addClass('active')
  
  $('.tablinks').find('a').click(function(event) {
    // stop link action
    event.preventDefault()
    event.stopPropagation()
    
    // store target tab
    target = $(this).attr('href')
    
    // reset tabs
    $('.tab').hide()
    $('.tablinks li').removeClass('active')
    
    // find and show target tab
    $(this).parent().addClass('active')
    $(target).show()
  })
  
  // MAP
  
  $('.marker').hover(
    function() {
      target = $(this).attr('class').slice(7)
      $('.' + target).addClass('hover')
    },
    function() {
      target = $(this).attr('class').slice(7)
      $('.hover').removeClass('hover')
    }
  )
  $('.address').hover(
    function() {
      target = $(this).attr('class').slice(8)
      $('.' + target).addClass('hover')
    },
    function() {
      target = $(this).attr('class').slice(8)
      $('.hover').removeClass('hover')
    }
  )
  
  // COLLAPSIBLE ELEMENTS
  $('div.collapsible').hide()
  $('.tab').each(function() {
    $(this).children('.collapsible').first().show()
  })
  $('a.collapsible').click(function(event) {
    event.preventDefault()
    event.stopPropagation()
    
    target = $(this).attr('href')
    
    $('div.collapsible').slideUp()
    $(target).slideDown()
  })
  
})

