// JavaScript Document

var dominio = 'www.rpmproget.it';
function showAddress() {
	if (GBrowserIsCompatible()){
		var map = new GMap2(document.getElementById("mappa"));
		map.addControl(new TextualZoomControl());
		
		var geocoder = new GClientGeocoder();
		var address='Via Gregorio VII, 472 00165 Roma ';
		geocoder.getLatLng(address,
			function(point){
				if(!point) {
					alert(address + " not found");
				}else {     
					map.setCenter(point, 13);
					
					var icon = new GIcon();
					icon.image = "http://"+ dominio +"/images/GoogleMap/Google/google.png";
					icon.iconSize = new GSize(32, 32);
					icon.iconAnchor = new GPoint(16, 18);
					icon.infoWindowAnchor = new GPoint(3, -2);
					var marker = new GMarker(point,icon);
					map.addOverlay(marker);
					//map.panDirection(1, 0);
					marker.openInfoWindowHtml("<span class=\"txt_nero\"><img src=\"images/GoogleMap/Google/logo_small.jpg\" alt=\"Arredamento locali pubblici Roma\" title=\"Arredamento locali pubblici Roma\" /><br>   Via Gregorio VII, 472 00165 - Roma (RM)</span>");

				}
			}
		);
	}
}
	function TextualZoomControl() {
    }
    TextualZoomControl.prototype = new GControl();

    // Creates a one DIV for each of the buttons and places them in a container
    // DIV which is returned as our control element. We add the control to
    // to the map container and return the element for the map class to
    // position properly.
    TextualZoomControl.prototype.initialize = function(map) {
      var container = document.createElement("div");

      var zoomInDiv = document.createElement("div");
      this.setButtonStyleIn_(zoomInDiv);
      container.appendChild(zoomInDiv);
      zoomInDiv.appendChild(document.createTextNode(""));
      GEvent.addDomListener(zoomInDiv, "click", function() {
        map.zoomIn();
      });

      var zoomOutDiv = document.createElement("div");
      this.setButtonStyleOut_(zoomOutDiv);
      container.appendChild(zoomOutDiv);
      zoomOutDiv.appendChild(document.createTextNode(""));
      GEvent.addDomListener(zoomOutDiv, "click", function() {
        map.zoomOut();
      });
      
      var mapTypeSat = document.createElement("div");
      this.setButtonStyleSat_(mapTypeSat);
      container.appendChild(mapTypeSat);
      mapTypeSat.appendChild(document.createTextNode(""));
      GEvent.addDomListener(mapTypeSat, "click", function() {
        map.setMapType(G_SATELLITE_MAP);
      });
      
      var mapTypeNor = document.createElement("div");
      this.setButtonStyleNor_(mapTypeNor);
      container.appendChild(mapTypeNor);
      mapTypeNor.appendChild(document.createTextNode(""));
      GEvent.addDomListener(mapTypeNor, "click", function() {
        map.setMapType(G_NORMAL_MAP);
      });

      map.getContainer().appendChild(container);
      return container;
    }

    // By default, the control will appear in the top left corner of the
    // map with 7 pixels of padding.
    TextualZoomControl.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
    }

    // Sets the proper CSS for the given button element.
    TextualZoomControl.prototype.setButtonStyleIn_ = function(button) {
      button.style.backgroundImage		= "url('http://"+ dominio +"/images/GoogleMap/Google/piu.png')";
      button.style.marginBottom			= "3px";
      button.style.width				= "25px";
      button.style.height				= "25px";
      button.style.cursor				= "pointer";
	}   
	
    // Sets the proper CSS for the given button element.
    TextualZoomControl.prototype.setButtonStyleOut_ = function(button) {
      button.style.backgroundImage		= "url('http://"+ dominio +"/images/GoogleMap/Google/meno.png')";
      button.style.marginBottom			= "3px";
      button.style.width				= "25px";
      button.style.height				= "25px";
      button.style.cursor				= "pointer";
    }
    
    // Sets the proper CSS for the given button element.
    TextualZoomControl.prototype.setButtonStyleSat_ = function(button) {
      button.style.backgroundImage		= "url('http://"+ dominio +"/images/GoogleMap/Google/sat.png')";
      button.style.marginBottom			= "3px";
      button.style.width				= "25px";
      button.style.height				= "25px";
      button.style.cursor				= "pointer";
	}   
	
    // Sets the proper CSS for the given button element.
    TextualZoomControl.prototype.setButtonStyleNor_ = function(button) {
      button.style.backgroundImage		= "url('http://"+ dominio +"/images/GoogleMap/Google/map.png')";
      button.style.marginBottom			= "3px";
      button.style.width				= "25px";
      button.style.height				= "25px";
      button.style.cursor				= "pointer";
    }

