    //<![CDATA[


function InfoWindowMarkers(map,point,myText) {

	// Creates a marker at the given point
	function createMarker(point, myText,icon2) {  
		var marker = new GMarker(point,icon2);  
		GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(myText); });  
		return marker;
	}

	// Setup Icon
    var icon2 = new GIcon();
    icon2.image='files/marker.png';
    icon2.iconSize = new GSize(100,54);
    icon2.iconAnchor = new GPoint(100/2,54);
    icon2.infoWindowAnchor = new GPoint(49,54);

	// Add markers
	map.addOverlay(createMarker(point,myText,icon2));

}







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
    
    //new! v2
    if (myControls[2]==1) map.removeMapType(G_HYBRID_MAP); //remove Hybrid views
    
}


    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

		//Place Icons on map
		if (myAction == '1') { AddIcon(map) } else { PopulateMap(map) };
	
		//new! v2	
		map.setMapType(G_SATELLITE_MAP) //select satellite view by default

      } //end GBrowserIsCompatible
    } //end load
    
    function load_old() {
      if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));

		map.setCenter(new GLatLng(myLat, myLong), myZoom);  

		//show controls on map
		RenderControls(map)

		//START: functions for tests
		if (myUserType==1) { OnClickShowCoord(map); }
		if (myUserType==2) { ShowPopup(map); OnClickShowCoord(map); PlaceIconsOnMap(map); }
		//END: functions for tests

		//Place Icons on map
		if (myAction == '1') { AddIcon(map) } else { PopulateMap(map) };
		
		//Custom Layers
 		var layer1=[G_NORMAL_MAP.getTileLayers()[0]]; 
		var layer2=[G_SATELLITE_MAP.getTileLayers()[0],G_HYBRID_MAP.getTileLayers()[1]]; 

		var custommap1 = new GMapType(layer1, G_SATELLITE_MAP.getProjection(), "Normal", G_SATELLITE_MAP);
		var custommap2 = new GMapType(layer2, G_SATELLITE_MAP.getProjection(), "Satélite", G_SATELLITE_MAP);
	      
 		map.getMapTypes().length = 0;
		map.addMapType(custommap1);
		map.addMapType(custommap2);
			
		map.setMapType(custommap2);

		
      } //end GBrowserIsCompatible
    } //end load
    
    //]]>


