var showM = {
	currentMarker:null,
	init: function (initLat,initLong){
		if (GBrowserIsCompatible()) {
	        showM.map = new GMap2(document.getElementById("map"));
			// showM.map.setMapType( G_NORMAL_MAP );
			showM.map.addControl(new GLargeMapControl(),
			new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(8, 8))
			);
			showM.map.addControl(new GMapTypeControl(),
			new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(8, 8))
			);			
			if(initLat!=0 && initLong!=0){
				var point=new GLatLng(parseFloat(initLat), parseFloat(initLong));
				showM.map.setCenter(point, 15, G_NORMAL_MAP);	
				showM.placearrow(point);
			} else {
				var point=new GLatLng(parseFloat(46.980252), parseFloat(2.15332));
				showM.map.setCenter(point, 5, G_NORMAL_MAP);
			}	
			showM.runBatch();
		}
		
	},//end init
		
	placearrow: function(point){
		showM.map.clearOverlays();
			
		// this defines the style of the marker
		var icon = new GIcon();
		icon.image = "http://maps.google.com/mapfiles/arrow.png";
		icon.shadow = "http://maps.google.com/mapfiles/arrowshadow.png";
		icon.iconSize = new GSize(39, 34);
		icon.shadowSize = new GSize(39, 34);
		icon.iconAnchor = new GPoint(11, 34);
		icon.infoWindowAnchor = new GPoint(9, 2);
		icon.infoShadowAnchor = new GPoint(18, 25);

  		var marker = new GMarker(point, icon);
		showM.map.addOverlay(marker);	
	}, //end placearrow
	
	addMarker: function(point, i){
		
		// Testing
		if ( point == null ){
			alert("Marqueur non placé : "+i);
		}
		
		// icones
		var icon = new GIcon();
		icon.image = "/img/marqueur.png";
		icon.iconSize = new GSize(40, 30);
		icon.shadowSize = new GSize(40, 30);
		icon.iconAnchor = new GPoint(15, 30);
		icon.infoWindowAnchor = new GPoint(10, 1);

		
		// Création marqueur
		var marker = new GMarker(point, {icon:icon, title:showM.aTitle[i] }); 
  		GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(showM.aPage[i]);});
		showM.map.addOverlay(marker);


	},//end addMarker
		
	runBatch: function() {
		
		  for (var i = 0; i < showM.aTitle.length; i++) {
			var point = new GLatLng(showM.aLat[i],showM.aLong[i]);
			showM.addMarker(point, i);	
		}
		
	}
}//end showM