// JavaScript Document

var map;

function initMap(){

	map = new GMap2(document.getElementById("gmap"));
	  	map.disableDoubleClickZoom();

	  	function TextualZoomInControl() {}
	  	function TextualZoomOutControl() {}
		TextualZoomInControl.prototype = new GControl();
		TextualZoomOutControl.prototype = new GControl();

		TextualZoomInControl.prototype.initialize = function(map)
		{
			var container = document.createElement("div");

			var zoomInDiv = document.createElement("div");
			this.setButtonStyle_(zoomInDiv);
			container.appendChild(zoomInDiv);
			zoomInDiv.appendChild(document.createTextNode("Zoom +"));
			GEvent.addDomListener(zoomInDiv, "click", function() {    map.zoomIn();  });

			map.getContainer().appendChild(container);
			return container;
		}

		TextualZoomOutControl.prototype.initialize = function(map)
		{
			var container = document.createElement("div");

			var zoomOutDiv = document.createElement("div");
			this.setButtonStyle_(zoomOutDiv);
			container.appendChild(zoomOutDiv);
			zoomOutDiv.appendChild(document.createTextNode("Zoom -"));
			GEvent.addDomListener(zoomOutDiv, "click", function() {    map.zoomOut();  });

			map.getContainer().appendChild(container);
			return container;
		}



		TextualZoomInControl.prototype.getDefaultPosition = function()
		{
			return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5, 5));
		}

		TextualZoomOutControl.prototype.getDefaultPosition = function()
		{
			return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5, 25));
		}

		TextualZoomInControl.prototype.setButtonStyle_ = function(button)
		{
			button.className = 'mapGIIPlus';
		}

		TextualZoomOutControl.prototype.setButtonStyle_ = function(button)
		{
			button.className = 'mapGIIMoins';
		}
	  	map.addControl(new TextualZoomInControl());
	  	map.addControl(new TextualZoomOutControl());
	
  var lat = document.getElementById('lat').value;
  var lng = document.getElementById('lng').value;

	map.setCenter(new GLatLng(lat, lng),12);
	
	var mapTypes = map.getMapTypes();
	for (var i=0; i<mapTypes.length; i++) {
         mapTypes[i].getMaximumResolution = function() {return 14;};
	}

  var ageIcon = new GIcon();
  ageIcon.image = document.getElementById('media_path').value+"images/pictos/icone_map_google_vierge2.png";
  ageIcon.infoWindowAnchor = new GPoint(0,0);
  ageIcon.iconSize = new GSize(25, 31);
  ageIcon.iconAnchor = new GPoint(11, 30);
  
  var marker =new GMarker(new GLatLng(lat, lng), {draggable:false, bouncy:false, dragCrossMove:true, icon:ageIcon});
  map.addOverlay(marker);
  
}

