(function($) {
	
	var ratio = 0.175;
	
	function loadEntity(map, entity) {
		var title = '<strong>' + entity.title + '</strong>' + entity.address;
	    var x = Math.floor(entity.point[0] * ratio),
	        y = Math.floor(entity.point[1] * ratio);
	
	    $('<a>')
	       .addClass('pin')
	       .addClass(entity.band ? 'band' : 'member')
	       .attr('data-name', title)
	       .css('top', y)
	       .css('left', x)
	       .append($('<span class="ring">'))
	       .append($('<span class="point">'))
	       .appendTo(map)
	       .twipsy({ title: 'data-name', offset: -10, html: true, placement: 'right' });
	};

	$(function($) {
	  var map = $('#mega-map');
		var months = [ "January", "February", "March", "April", "May", "June",
    	"July", "August", "September", "October", "November", "December" ];

		var now = new Date();
		var status = months[now.getMonth()] + ' ' + now.getDate() + ': ' + mapStatus.label;
		
		$('#mega-map .status').text(status);

		$.each(mapData, function(i, e) {
			if ((mapStatus.touring && e.band) || (!mapStatus.touring && !e.band)) {
				loadEntity(map, e);
			}
		});
	});

})(jQuery);
