var vPunti=[]
function addPoint(n,v,l,g) {
	vPunti[vPunti.length]=new Array(n,v,l,g.split(",")[0],g.split(",")[1])	
}
function loadMapPunti() {
	if (vPunti.length>1) {
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("mappa"));
			map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 10)));
        	map.setCenter(new GLatLng(vPunti[0][3],vPunti[0][4]), vPunti[0][2]);
			
			var baseIcon = new GIcon(G_DEFAULT_ICON);
	        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        	baseIcon.iconSize = new GSize(20, 34);
	        baseIcon.shadowSize = new GSize(37, 34);
    	    baseIcon.iconAnchor = new GPoint(9, 34);
        	baseIcon.infoWindowAnchor = new GPoint(9, 2);

        	function createMarker(point, index,testo) {
	        	var letter = String.fromCharCode("A".charCodeAt(0) + index);
	        	var letteredIcon = new GIcon(baseIcon);
          		letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
		        markerOptions = { icon:letteredIcon };
          		var marker = new GMarker(point, markerOptions);
				GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(testo);});
	          	return marker;
	        }
			var txt
			for (var i=1;i<vPunti.length;i++) {
				txt="<div><b>"+vPunti[i][0]+"</b><br/>"+vPunti[i][1]+"<br/>"+vPunti[i][2]+"<br/>"
				txt=txt+"<a href='http://maps.google.com/maps?daddr="+vPunti[i][1]+","+vPunti[i][2]+",italy&geocode=&saddr=ancona,italy&f=d&hl=it&sll="+vPunti[i][3]+","+vPunti[i][4]+"&sspn=0.349719,0.562363&ie=UTF8&z=10&om=1' target='_blank'>Come arrivarci</a></div>"
				map.addOverlay(createMarker(new GLatLng(vPunti[i][3],vPunti[i][4]), i-1,txt))
			}
		}
	}
}

