// Google Maps API

function GoogleMapsLoad()
{
	if (GBrowserIsCompatible())
	{
		var map = new GMap2(document.getElementById("googlemap"));
		var geocoder = new GClientGeocoder();

		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl());
		map.setCenter(new GLatLng(45.53274,3.34417),5);
		map.enableScrollWheelZoom();
		
//		var MonPointeur = new GIcon(G_DEFAULT_ICON);
//			MonPointeur.image = "http://94.23.1.75/antiquites-catalogue/images/marqueur-salon.gif";
//			MonPointeur.shadow = "";

		function markerStyle(correspondant)
		{
			var MonPointeur = new GIcon(G_DEFAULT_ICON);
			if (correspondant == "Vrai" )
			{
					MonPointeur.image = "http://www.antiquites-catalogue.com/images/gmap-marker-red.png";
					MonPointeur.shadow = "";
			}
			else
			{
					MonPointeur.image = "http://www.antiquites-catalogue.com/images/gmap-marker-yellow.png";
					MonPointeur.shadow = "";
			}
			return MonPointeur;
		}

		function createMarker(marker,nom,correspondant,point,adresse,codepostal,ville,pays)
		{
			var marker = new GMarker(point,markerStyle(correspondant));
			if (correspondant == "Vrai" )
			{
				GEvent.addListener (marker, "click", function() { marker.openInfoWindowHtml("<strong style='color:#940506;'>" + nom + "</strong><br/> <strong class='correspondant'>Correspondant r&eacute;gional</strong> <br/>" + adresse + "<br/>" + codepostal + " " + ville+"<br/>"+pays ); });
			}
			else
			{
				GEvent.addListener (marker, "click", function() { marker.openInfoWindowHtml("<strong style='color:#940506;'>" + nom + "</strong><br/>" + adresse + "<br/>" + codepostal + " " + ville+"<br/>"+pays ); });
			}
		
			return marker;
		}
		
		GDownloadUrl("../_inc/antiquaire.asp", function(data, responseCode)
		{
			var xml = GXml.parse(data);			
			var antiquaires = xml.documentElement.getElementsByTagName("ant");					

			for (var i=0 ; i < antiquaires.length ; i++){
				 var identifiant = new String(antiquaires[i].getAttribute("identifiant"));		
				 var nom = new String(antiquaires[i].getAttribute("nom"));		
				 var correspondant = new String(antiquaires[i].getAttribute("correspondant"));		
				 var adresse = new String(antiquaires[i].getAttribute("adresse"));
				 var codepostal = new String(antiquaires[i].getAttribute("codepostal"));    
				 var ville = new String(antiquaires[i].getAttribute("ville"));
				 var latitude = new String(antiquaires[i].getAttribute("latitude"));
				 var longitude = new String(antiquaires[i].getAttribute("longitude"));				
				 var point = new GLatLng(parseFloat(latitude), parseFloat(longitude));
				 var lien = new String(antiquaires[i].getAttribute("pays"));	
				 				 
				 if ((latitude.length > 0) && (longitude.length > 0))
				 {								
					map.addOverlay(createMarker(identifiant,nom,correspondant,point,adresse,codepostal,ville,lien));
				 }
			}
		})
	}
}
function Initialisation()
{

}
