function ggl_creation_icone(nom)
{
	var icon = new GIcon();
	icon.image = "../ressources_communes/images/tourisme/google_" + nom + ".gif";
	icon.iconAnchor = new GPoint(17, 40);
	icon.infoWindowAnchor = new GPoint(20, 0);
	icon.iconSize = new GSize(40, 40);
//	icon.shadow = "../ressources_communes/images/tourisme/google_ombre.png"; 
//	icon.shadowSize = new GSize(60, 40);
	return icon;
}

function ggl_ajoute_tourisme(crt,latitude,longitude,indice,id_site,titre)
{
	if (GBrowserIsCompatible()) 
	{
		// Creation point site touristique 
		var site = new GLatLng(latitude, longitude);
		// Création de l'icone
		icone_site = ggl_creation_icone("site_" + indice);
		var mk_site = new GMarker(site, icone_site);
		crt.addOverlay(mk_site);
		mk_site.bindInfoWindowHtml('<font face="Arial" size="2"><div align="center">' + titre + '</div></font>');
	}
}

function ggl_carte_affiche_lieu(latitude,longitude,type,nom,intitule)
{
	if (GBrowserIsCompatible()) 
	{
		// Creation carte
		var map = new GMap2(document.getElementById("map"));
		// Ajout boutons de controle
		map.addControl(new GSmallMapControl ());
//		map.addControl(new GMapTypeControl());
		// Creation point location 
		var point = new GLatLng(latitude, longitude);
		// Centrage et taille carte
		map.setCenter(point, 10, G_PHYSICAL_MAP);
		// Création de l'icone
		icone_maison = ggl_creation_icone("home");
		icone_ville  = ggl_creation_icone("ville");
		icone_site  = ggl_creation_icone("site");
		// Creation marker sur point
		if (type == "location")
			var marker = new GMarker(point, icone_maison);
		else if (type == "ville")
			var marker = new GMarker(point, icone_ville);
		else
			var marker = new GMarker(point, icone_site);		
//		var marker2 = new GMarker(point);
		map.addOverlay(marker);
//		map.addOverlay(marker2);
		// Texte
		var txthtml = '<font face="Arial" size="2"><div align="center">';
		if (type == "location")
			txthtml += 'Location LC'+nom;
		else
			txthtml += nom;
		txthtml += '<br /><font face="Arial" size="1">Coordonnées GPS de la '+intitule+' :<br />'+latitude+'° Latitude Nord<br />'+longitude+'° Longitude Est</font></div></font>';
		marker.openInfoWindowHtml(txthtml);
		marker.bindInfoWindowHtml(txthtml);
		info = map.getInfoWindow();
	}
	return map;
}

function ggl_carte_affiche_tourisme(latitude,longitude)
{
	if (GBrowserIsCompatible()) 
	{
		// Creation carte
		var map = new GMap2(document.getElementById("map"));
		// Ajout boutons de controle
		map.addControl(new GSmallMapControl ());
//		map.addControl(new GMapTypeControl());
		// Centrage et taille carte
		var point = new GLatLng(latitude, longitude);
		map.setCenter(point, 8, G_NORMAL_MAP);
	}
	return map;
}

function ggl_carte_place_location(latitude,longitude)
{
	if (GBrowserIsCompatible()) 
	{
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl ());
		map.addControl(new GMapTypeControl());
		var point = new GLatLng(latitude, longitude);
		map.setCenter(point, 11, G_NORMAL_MAP);
		document.loc_gmap.lat.value = point.lat();
		document.loc_gmap.lng.value = point.lng();
		var selection = new GLatLng();
		var marker = new GMarker(point, {draggable: true});
		GEvent.addListener(marker, "dragstart", function() {
			map.closeInfoWindow();	
			});
		GEvent.addListener(marker, "dragend", function() {
			selection = marker.getPoint();
			document.loc_gmap.lat.value = selection.lat();
			document.loc_gmap.lng.value = selection.lng();
			marker.openInfoWindowHtml("<span class=\"normal\">Si ce positionnement convient, cliquez sur <br />\"Valider le placement\"<br />Sinon, déplacez le curseur à l'endroit choisi.</span>");
			});
		map.addOverlay(marker);
		marker.openInfoWindowHtml("<span class=\"normal\">Placez ce pointeur rouge au plus près de votre location.<br />Pour vous aidez vous pouvez :<ul><li>Effectuer un zoom avec la barre de gauche.</li><li>Changer le type de carte en haut à droite.<ul><li>\"Plan\" pour se déplacer efficacement</li><li>\"Satellite\" pour la localisation précise.</li></ul></li></ul></span>");
	}
}


function ggl_ajoute_polygone(crt, nom)
{
    var geoXml = new GGeoXml("http://www.gites-montagne.com/extensions/google-maps/" + nom + ".kml");
	if (nom == "savoie")
		var boundaries = new GLatLngBounds(new GLatLng(45.50,6.3), new GLatLng(45.55,6.6));
	else
		var boundaries = new GLatLngBounds(new GLatLng(46.00,6.05), new GLatLng(46.05,6.65));
	var Titre  = new GGroundOverlay("http://www.gites-montagne.com/ressources_communes/images/titre-" + nom + ".gif", boundaries);
	crt.addOverlay(geoXml);
	crt.addOverlay(Titre);

}
