    //<![CDATA[

function OnClickShowCoord(map) {
	// centrar mapa indicando Latitude e Longitude

	GEvent.addListener(map, "moveend", function() {
	  var center = map.getCenter();
	  document.getElementById("message").innerHTML = center.toString();
	});

}

function PlaceIconsOnMap(map) {
	//add and remove icon in maps

	GEvent.addListener(map, "click", function(marker, point) {
	  if (marker) {
	    map.removeOverlay(marker);
	  } else {
	    map.addOverlay(new GMarker(point));
	  }
	});
}

function ShowPopup(map) {
	//display window with text
	map.setCenter(new GLatLng(myLat, myLong));  
	map.openInfoWindow(map.getCenter(), document.createTextNode(myPopupText));
}

function AddIcon(map) {
	var icon = new GIcon();
	icon.image = myImg;
	icon.iconSize = new GSize(myImgWidth, myImgHeight);
	icon.iconAnchor = new GPoint(myImgWidth/2,myImgHeight);
	icon.infoWindowAnchor = new GPoint(9,2);

	var point = new GLatLng(myLat, myLong); 
	map.addOverlay(new GMarker(point,icon));
}


function RenderControls(map) {

	// myControls[0..3] = 1_Zoom,2_Small,3_Big / Scale / MapType / Overview

	if (myControls[0]==1) map.addControl(new GSmallZoomControl());	// +- zoom
	if (myControls[0]==2) map.addControl(new GSmallMapControl());	// pan and zoom (small)
	if (myControls[0]==3) map.addControl(new GLargeMapControl());	// pan and zoom (big)
		
	if (myControls[1]==1) map.addControl(new GScaleControl());		// escala
	if (myControls[2]==1) map.addControl(new GMapTypeControl()); 	// Map,Satellite,Hybrid views
	if (myControls[3]==1) map.addControl(new GOverviewMapControl()); 	// overview box

	//new!        
    if (myControls[2]==2) map.addControl(new GMapTypeControl(),new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(5, 5))); // coloca o MapType no canto inferior direito com 5 padding
}

    function load() {
      if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));

		//show controls on map
		RenderControls(map)

		map.setCenter(new GLatLng(myLat, myLong), myZoom);  

		//START: functions for tests
		if (myUserType==1) { OnClickShowCoord(map); }
		if (myUserType==2) { ShowPopup(map); OnClickShowCoord(map); PlaceIconsOnMap(map); }
		//END: functions for tests

		AddIcon(map)
		
      } //end GBrowserIsCompatible
    } //end load
    
    //]]>
