$(document).ready(function(){
  
  $('#locations-main #locations-index-content').addClass('locations-list-scrollable');
  $('#locations-main #locations-index').attr('class', 'locations-index');
  $('#locations-main #map').attr('class', 'map');
    
  $('#locations-index-tabs li a').click(function() {
    $('#locations-index-tabs li.active').removeClass('active');
    $(this).parent().addClass('active');
    $('div.locations-list:visible').hide('normal', function() {
      $('div.locations-list-scrollable').scrollTop(0);
    });
    return false;
  });

  $('#locations-index-tabs li#all-link a').click(function() {
    $('div#all-locations').show('normal');
    jQuery.setMapCenter('Man');
  });
  
  $('#locations-index-tabs li#research-link a').click(function() {
    $('div#research').show('normal');
    jQuery.setMapCenter('Man');
  });
  
  $('#locations-index-tabs li#manhattan-link a').click(function() {
    $('div#manhattan').show('normal');
    jQuery.setMapCenter('Man');
  });
  
  $('#locations-index-tabs li#bronx-link a').click(function() {
    $('div#bronx').show('normal');
    jQuery.setMapCenter('Bx');
  });
  
  $('#locations-index-tabs li#statenisland-link a').click(function() {
    $('div#statenisland').show('normal');
    jQuery.setMapCenter('Sta');
  });
  
});

$(document).ready(function() {
  // Check IP and show or hide survey block
  if ($.cookie('showS') != null) { // get cookie
      var showS = $.cookie('showS');
    }
    else { // Do the AJAX call and set cookie
      var url = '/sites/all/themes/nypl_new/includes/ip_segments.php';
      var showS = $.ajax({ type: 'GET', url: url, async: false }).responseText;
      $.cookie('showS', showS, { path: '/', domain: 'nypl.org' });
    }
  if ($.cookie('showS') == 'b7S') {
    $('div#block-nypl_content-7').show();
  }
  else {
    $('div#block-nypl_content-7').show();
  }
});

