//GOOGLE MAP TOOLS

    function loadMap() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(44.719996474721015, 8.279142379760742), 13);
				var point = new GLatLng(44.719996474721015,8.279142379760742);
				var marker = new GMarker(point);
  			GEvent.addListener(marker, "click", function() {
   				 marker.openInfoWindowHtml("<span class=TestoNero><b>Coppo S.r.l.</b><br>Via Alba 68 <br> 14053 Canelli (AT) Italia<br><hr>44°43'13,37'' N 8°16'53,31'' E - Google Earth</span>");
 				 });
  			map.addOverlay(marker);


      }
    }

function ViewPath2(partenza){
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

}
	function ViewPath(locPartenza){
		//alert("ViewPath: " + locPartenza);
		var points = [];
		var zoom;
		var panX = 0;
		var panY = 0;
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(44.719996474721015, 8.279142379760742), 13);
		
		var arrivo = new GLatLng(44.719996474721015,8.279142379760742);
		var partenza = new GLatLng(44.719996474721015,8.279142379760742);
		var centro = new GLatLng(0,0);
	
		if (locPartenza == 'torino'){
			var partenza = new GLatLng(45.046359, 7.662964);//point 29
			points.push(partenza);
			points.push(new GLatLng(44.999767, 7.668457));
			points.push(new GLatLng(44.986170, 7.695923));
			points.push(new GLatLng(44.966741, 7.706909));
			points.push(new GLatLng(44.947305, 7.959595));
			points.push(new GLatLng(44.906469, 8.052979));
			points.push(new GLatLng(44.906469, 8.096924));
			points.push(new GLatLng(44.902578, 8.129883));
			points.push(new GLatLng(44.906469, 8.182068));
			points.push(new GLatLng(44.875336, 8.212280));
			points.push(new GLatLng(44.832500, 8.171082));
			points.push(new GLatLng(44.813019, 8.253479));
			points.push(new GLatLng(44.779886, 8.275452));
			points.push(arrivo);
			zoom = 9;
		}
		else{
			if (locPartenza == 'milano'){
				var partenza = new GLatLng(45.465910, 9.181824);
				points.push(partenza);
				//points.push(new GLatLng(45.465910, 9.181824));
				points.push(new GLatLng(45.398450, 9.140625));
				points.push(new GLatLng(45.224612, 9.019775));
				points.push(new GLatLng(45.079339, 8.962097));
				points.push(new GLatLng(44.914249, 8.838501));
				points.push(new GLatLng(44.923974, 8.690186));
				points.push(new GLatLng(44.949249, 8.635254));
				points.push(new GLatLng(44.937585, 8.566589));
				points.push(new GLatLng(44.908414, 8.346863));
				points.push(new GLatLng(44.914249, 8.234253));
				points.push(new GLatLng(44.842238, 8.184814));
				points.push(new GLatLng(44.813019, 8.247986));
				points.push(new GLatLng(44.779886, 8.275452));
				points.push(arrivo);
				zoom = 8;
			}
			else{
				if (locPartenza == 'piacenza'){
					var partenza = new GLatLng(45.052181, 9.700928);
					points.push(partenza);
					points.push(new GLatLng(45.052181, 9.700928));
					points.push(new GLatLng(45.069641, 9.519653));
					points.push(new GLatLng(45.087096, 9.376831));
					points.push(new GLatLng(45.079339, 9.266968));
					points.push(new GLatLng(45.036656, 9.118652));
					points.push(new GLatLng(45.007535, 8.984070));
					points.push(new GLatLng(44.918139, 8.849487));
					points.push(new GLatLng(44.927863, 8.687439));
					points.push(new GLatLng(44.945361, 8.638000));
					points.push(new GLatLng(44.935641, 8.569336));
					points.push(new GLatLng(44.906469, 8.355103));
					points.push(new GLatLng(44.910359, 8.239746));
					points.push(new GLatLng(44.888958, 8.239746));
					points.push(new GLatLng(44.875336, 8.209534));
					points.push(new GLatLng(44.830552, 8.173828));
					points.push(new GLatLng(44.814967, 8.245239));
					points.push(new GLatLng(44.779886, 8.269958));
					points.push(new GLatLng(44.764287, 8.267212));
					points.push(new GLatLng(44.727223, 8.297424));
					points.push(arrivo);
					zoom = 8;
				}
				else
				{
					if (locPartenza == 'genova'){
						var partenza = new GLatLng(44.418088, 8.890686);
						points.push(new GLatLng(44.420050, 8.893433));
						points.push(new GLatLng(44.429857, 8.879700));
						points.push(new GLatLng(44.433780, 8.843994));
						points.push(new GLatLng(44.431819, 8.769836));
						points.push(new GLatLng(44.431819, 8.739624));
						points.push(new GLatLng(44.443585, 8.734131));
						points.push(new GLatLng(44.453389, 8.725891));
						points.push(new GLatLng(44.455349, 8.714905));
						points.push(new GLatLng(44.449468, 8.709412));
						points.push(new GLatLng(44.443585, 8.714905));
						points.push(new GLatLng(44.443585, 8.723145));
						points.push(new GLatLng(44.451428, 8.739624));
						points.push(new GLatLng(44.472991, 8.739624));
						points.push(new GLatLng(44.494546, 8.731384));
						points.push(new GLatLng(44.500423, 8.709412));
						points.push(new GLatLng(44.521968, 8.695679));
						points.push(new GLatLng(44.539590, 8.692932));
						points.push(new GLatLng(44.545463, 8.673706));
						points.push(new GLatLng(44.576774, 8.657227));
						points.push(new GLatLng(44.598290, 8.665466));
						points.push(new GLatLng(44.621754, 8.654480));
						points.push(new GLatLng(44.645208, 8.657227));
						points.push(new GLatLng(44.672559, 8.657227));
						points.push(new GLatLng(44.705754, 8.665466));
						points.push(new GLatLng(44.729174, 8.665466));
						points.push(new GLatLng(44.758436, 8.643494));
						points.push(new GLatLng(44.807173, 8.596802));
						points.push(new GLatLng(44.824708, 8.591309));
						points.push(new GLatLng(44.844186, 8.594055));
						points.push(new GLatLng(44.877282, 8.569336));
						points.push(new GLatLng(44.900633, 8.566589));
						points.push(new GLatLng(44.922029, 8.574829));
						points.push(new GLatLng(44.937585, 8.569336));
						points.push(new GLatLng(44.939529, 8.572083));
						points.push(new GLatLng(44.908414, 8.355103));
						points.push(new GLatLng(44.908414, 8.247986));
						points.push(new GLatLng(44.879228, 8.212280));
						points.push(new GLatLng(44.834448, 8.176575));
						points.push(new GLatLng(44.818864, 8.245239));
						points.push(new GLatLng(44.777936, 8.272705));
						points.push(new GLatLng(44.760386, 8.267212));
						points.push(arrivo);
						zoom = 9;
						panX = 0.1;
						panY = 0.1;
					}
				}
			}
		}
		

		map.addOverlay(new GPolyline(points));
		map.addOverlay(new GMarker(partenza));
		map.addOverlay(new GMarker(arrivo));
		//setta il nuovo centro della mappa
			var x, y ;
			//alert(partenza.x.toString() + " - " + arrivo.x.toString() + " = " + (partenza.x - arrivo.x).toString());
			if (5<1){ //(partenza.x<arrivo.x){
				x = ((arrivo.x - partenza.x)/2) + partenza.x;
			}
			else
			{
				x = (partenza.x - arrivo.x)/2 + arrivo.x;
				//alert(partenza.x.toString() + " - " + arrivo.x.toString() + " = " + (partenza.x - arrivo.x).toString());
			}
			if (partenza.y < arrivo.y){
				y = (arrivo.y - partenza.y)/2 + partenza.y;
			}
			else
			{
				y = (partenza.y - arrivo.y)/2 + arrivo.y;
			}
			map.setCenter(new GLatLng(y + panY, x + panX), zoom);
			
			var bounds = map.getBounds();
			var southWest = bounds.getSouthWest();
			var northEast = bounds.getNorthEast();
			var lngSpan = northEast.lng() - southWest.lng();
			var latSpan = northEast.lat() - southWest.lat();
			
			
	}

