var coord	=	[];

function getCoords(map)
{
	var batch = [];
				
	// Create our "tiny" marker icon
	var tinyIcon = new GIcon();
	tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
	tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	tinyIcon.iconSize = new GSize(12, 20);
	tinyIcon.shadowSize = new GSize(22, 20);
	tinyIcon.iconAnchor = new GPoint(6, 20);
	tinyIcon.infoWindowAnchor = new GPoint(5, 1);
	
	// Create our "tiny" marker icon
	var tinyIcon2 = new GIcon();
	tinyIcon2.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
	tinyIcon2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	tinyIcon2.iconSize = new GSize(12, 20);
	tinyIcon2.shadowSize = new GSize(22, 20);
	tinyIcon2.iconAnchor = new GPoint(6, 20);
	tinyIcon2.infoWindowAnchor = new GPoint(5, 1);
	
	// Create our "tiny" marker icon
	var tinyIcon3 = new GIcon();
	tinyIcon3.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
	tinyIcon3.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	tinyIcon3.iconSize = new GSize(12, 20);
	tinyIcon3.shadowSize = new GSize(22, 20);
	tinyIcon3.iconAnchor = new GPoint(6, 20);
	tinyIcon3.infoWindowAnchor = new GPoint(5, 1);
	
		
	// Set up our GMarkerOptions object literal
	markerIcon = new Array(tinyIcon, tinyIcon2, tinyIcon3);

	
	jQuery.each(coord, function(){
		var LatLgn = new GLatLng(this[0], this[1]);
		var marker = new GMarker(LatLgn, {title: this[4], icon: markerIcon[this[3]]});
		var type_rep = this[3];
		var rep_id = this[2];
		
		GEvent.addListener(marker, 'click', function() {
			if(type_rep == 0 || type_rep == 1){
				var page = 'bretagne_demeures.php';
			}else{
				var page = 'bretagne_randos.php';
			}
			window.open(page+'?reportages_id='+rep_id,'_self'); 
		});
		batch.push(marker);
	});
	
	return batch
}

function initialize() {
	var map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.setCenter(new GLatLng(48.253941, -3.158569 ), 8);
  
	// Create our Zoom marker icon
	var ZoomIcon = new GIcon();
	ZoomIcon.image='skins/general/zoom.png';
	ZoomIcon.iconSize=new GSize(26, 29);
	ZoomIcon.iconAnchor=new GPoint(13, 14);
	
	var cluster=new ClusterMarker(map, { 
		markers:getCoords(map), 
		clusterMarkerIcon: ZoomIcon, 
		clusterMarkerTitle: "Cliquez pour zoomer et voir les %count sélections",
		intersectPadding : 5
	} );
	cluster.fitMapToMarkers();
}

$('document').ready(function(){
	if (GBrowserIsCompatible()) {
		$.getScript("google_map.php?u=2",function(){
			initialize();
		});
	}
});
