function find_locations(locations) {

  var geocoder = new GClientGeocoder();
  var location = locations.pop();

  geocoder.getLocations(location['address'], function(response) {

    $('#location_' + location['index'] + '.map-location a.map-link').html(location['name']);

    if (response && response.Status.code == 200) {
      var place = response.Placemark[0];
      var point = place.Point;
      var accuracy = place.AddressDetails.Accuracy;
      $('#location_' + location['index'] + '.map-location').attr('data','{ id: ' + location['index'] + ', point: { lat: ' + point.coordinates[1] + ', lng: ' + point.coordinates[0] + ' } }');
    }

    if ((accuracy && accuracy < 7) || !response || response.Status.code != 200) {
      $('#location_' + location['index']).removeClass('map-location');
      $('#location_' + location['index'] + ' a.map-link').html($('#location_' + location['index'] + ' a.map-link').html() + ' [No Map]');
      $('#location_' + location['index'] + '').click(function() {
        return(false);
      });
    }

    if (locations.length > 0)
      find_locations(locations);
    else
      $('#map').jMapping();
  });
}

$(document).bind('afterMapping.jMapping', function() {
  $('.info-box').css('display', 'block');
  $('#map-side-bar').css('display', 'block');
});

