// JavaScript Document
//formatta il testo con html;
function showBaloon(message){
	var opentag = "<font style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; font-weight:normal;'><br>";
	var closetag = "</font>";		
	message = opentag + message + closetag;
	return message;
}

//posiziona la mappa sul country
function findCountry(countrytofind) {
		
		geocoder.getLatLng(
			countrytofind,
			function(point) {
			  if (!point) {
				  
			  } else {
				map.setCenter(point, 5);				
			  }
			}
		  );
		
}

//posiziona la mappa sulla regione
function findRegione(regionetofind) {		
		//aggiunge il country selezionato alla regione 
		//(a volte google map non č preciso con poche informazioni)
		regionetofind = regionetofind + "," + currentcountry;
		geocoder.getLatLng(
			regionetofind,
			function(point) {
			  if (!point) {
				  
			  } else {
				map.setCenter(point, 8);				
			  }
			}
		  );
		
}

//posiziona la mappa sulla citta
function findCitta(cittatofind) {
		//aggiunge la regione selezionata alla cittā 
		//(a volte google map non č preciso con poche informazioni)		
		cittatofind = cittatofind + "," + currentregione;
		geocoder.getLatLng(
			cittatofind,
			function(point) {
			  if (!point) {
				  
			  } else {
				map.setCenter(point, 13);				
			  }
			}
		  );
}

//posiziona la mappa sulla provincia
function findProvincia(provinciatofind) {
		//aggiunge la citta alla provincia selezionata
		//(a volte google map non č preciso con poche informazioni)		
		//provinciatofind = provinciatofind + "," + current;
		geocoder.getLatLng(
			provinciatofind,
			function(point) {
			  if (!point) {
				  
			  } else {
				map.setCenter(point, 13);				
			  }
			}
		  );
}

//visualizza marker sulla mappa
function ShowMarkerOnMap(arrindex,addresstolocate,zoomlevel) {
		
		geocoder.getLatLng(
			addresstolocate,
			function(point) {
			  if (!point) {
				alert("Indirizzo non trovato " + addresstolocate);
			  } else {
				map.setCenter(point, zoomlevel);				
				var marker = new GMarker(point,getIcon());
					marker.address = addresstolocate;
					marker.index = arrindex;
				map.addOverlay(marker);
				
			  }
			}
		  );
}

function getIcon() {
   
	var icon = new GIcon();
	if(location.hostname == "10.110.5.105"){
		icon.image = "http://" + location.hostname + "/progetti/EON_VENDITA_NEW/E-ON_VENDITA/sito/img/red-marker.png";		
	}
	if(location.hostname.toLowerCase() == "web1.ogilvy.it"){
		icon.image = "http://" + location.hostname + "/eon/img/red-marker.png";			
	}	
	if(location.pathname.toLowerCase().indexOf("e-on_vendita",0) != -1){	
		icon.image = "http://" + location.hostname + "/E-ON_VENDITA/sito/img/red-marker.png";			
	}
	
	icon.iconSize = new GSize(12, 20);	
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);
	return icon;				
	
}
//
