
  $.ajax({
      type: 'GET',
      cache: false,
      dataType:'jsonp',
      success:function(data,textStatus,XHR){
        //console.log(data);
        var locations = [];

        $.each(data, function(i, item) {
          //$('#tourMap').append(item.formatted_location);
            //$('#tourMap').append(item.venue.latitude + '-' + item.venue.longitude);

            //move the center of the map to the next upcoming show
            if(i == 0){
              map.setCenter( new google.maps.LatLng(item.venue.latitude, item.venue.longitude));
            }

            //if the event has tickets available, add the HTML for it
            if(item.ticket_url){
              tickets = '<div style="margin-top:5px;"><a href="'+item.ticket_url+'" class="ticketsButton">tickets</a></div>';
            }
            else{
              tickets = '';
            }

            //add HTML to the locations array so that we can call it when a user clicks the markers
            locations.push("<div style='font-weight:bold;'>"+item.title+"</div>"+"<div>"+item.formatted_location+"</div><div class='timeOfShow'>"+item.formatted_datetime+"</div>"+tickets);

            //making the markers animate over time
            setTimeout(function() {

              marker = new google.maps.Marker({
              position: new google.maps.LatLng(item.venue.latitude, item.venue.longitude),
              map: map,
              icon: image,
              animation: google.maps.Animation.DROP
            });
              
            google.maps.event.addListener(marker, 'click', (function(marker, i) {

              return function() {
                
                  infowindow.setContent(locations[i]);
                  infowindow.open(map, marker);
                
              }
            })(marker, i));

          }, i * 100);

          });
        },
      url:'http://api.bandsintown.com/artists/TheWailers/events.json?artist_id=fbid_72852404808&api_version=2.0&app_id=wailers'

    });
