$(document).ready(function() {
	/**
	 * Google Maps
	 */
	
	// Set the correct options and creat the map
	var options = {
		zoom: 7,
		scrollwheel: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		mapTypeControl: true,
		mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
	};
	var map = new google.maps.Map($("#map")[0], options);
	map.setCenter(new google.maps.LatLng(50.503887,4.469936));
	
	// Create the icon
	var markerIcon = new google.maps.MarkerImage(
		"/design/images/layout/map_pointer.png",
		new google.maps.Size(30, 30), // Size
		new google.maps.Point(0,0),
		new google.maps.Point(15, 15) // Position of the marker
	);

	// Request all the markers
	$.ajax({
		url: baseUrl+'/shops/markers',
		dataType: 'json',
		success: function(data) {
			
			// Loop over each marker
			$.each(data, function(index, shop) {
				
				// Create a marker and add it to the map
				var marker = new google.maps.Marker({
			        position: new google.maps.LatLng(shop.latitude, shop.longitude),
			        map: map,
			        title: shop.title,
			        icon: markerIcon
			    });
				
				// Add a click-event of the marker
			    google.maps.event.addListener(marker, 'click', function() {
     				document.location = baseUrl+"/"+shopsRouting+"/"+shop.id+"/"+shop.quicklink;
			    });
				
			});
			
		}
	});
	
});
