var map;
var geocoder;
var page;
//__________________Épiceries santé
var epicerieAdrs = [
	{ville:"Montréal",
	adresse:"505, rue Rachel Est",
	tel:"514 524-0725",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=505,+rue+Rachel+Est+Montr%C3%A9al&sll=46.88016,-71.23285&sspn=0.01056,0.016222&ie=UTF8&z=16",
	LatLng:"45.522838,-73.577242"}
	,
	{ville:"Montréal",
	adresse:"2346, rue Beaubien Est",
	tel:"514 727-2327",
	map:"http://maps.google.ca/maps?f=q&source=s_q&hl=fr&geocode=&q=2346+Rue+Beaubien+Est,+Montr%C3%A9al&sll=45.547553,-73.592767&sspn=0.011346,0.027809&g=2346+Rue+Beaubien+Est,+Montr%C3%A9al,+Communaut%C3%A9-Urbaine-de-Montr%C3%A9al,+Qu%C3%A9bec&ie=UTF8&ll=45.547551,-73.592777&spn=0.011346,0.027809&z=16&iwloc=addr",
	LatLng:"45.547551,-73.592777"}
	,
	{ville:"Montréal",
	adresse:"4810, boul. St-Laurent ",
	tel:"514 849-4118",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=4810,+boul.+St-Laurent+&sll=45.549134,-73.591472&sspn=0.010819,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.521515,-73.58945"}
	,
	{ville:"Laurentide",
	adresse:"105-1 Guindon, St-Sauveur",
	tel:"450 227-3343",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=105-1+Guindon,+St-Sauveur&sll=45.521515,-73.58945&sspn=0.010825,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.892717,-74.14772"}
	,
	{ville:"Mont-Tremblant",
	adresse:"909 rue de St-Jovite",
	tel:"819-425-7777",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=909+Rue+de+St-Jovite&sll=46.118555,-74.592834&sspn=0.0224,0.055618&ie=UTF8&t=p&z=15&iwloc=addr",
	LatLng:"46.118555,-74.592834"}
	,
	{ville:"Québec",
	adresse:"2700, boul. Laurier",
	tel:"418-651-3262",
	map:"http://maps.google.ca/maps?f=q&source=s_q&hl=fr&geocode=&q=2700,+boul.+Laurier+quebec&sll=46.769623,-71.283902&sspn=0.005548,0.013905&ie=UTF8&z=16&iwloc=addr",
	LatLng:"46.769623,-71.283902"}
	,
	{ville:"Longueuil",
	adresse:"217, rue St-Charles Ouest",
	tel:"450-679-6472",
	map:"http://maps.google.ca/maps?f=q&source=s_q&hl=fr&geocode=&q=217,+rue+St-Charles+Ouest+Longueuil&sll=45.538026,-73.510169&sspn=0.011347,0.027809&g=217,+rue+St-Charles+Ouest+Longueuil&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.538026,-73.510169"}
	
	];


//__________________Boutiques santé
var boutiqueAdrs = [
	
	{ville:"Beauport",
	adresse:"969, rue Nordique",
	tel:"418 660-6284",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=969,+rue+Nordique+Beauport&sll=46.835914,-71.293653&sspn=0.010569,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"46.889574,-71.191015"}
	,
	{ville:"Châteauguay",
	adresse:"90, boul. Anjou",
	tel:"418 660-6284",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=90,+boul.+Anjou+Ch%C3%A2teauguay&sll=46.889574,-71.191015&sspn=0.168933,0.259552&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.360544,-73.733548"}
	,
	{ville:"Drummondville",
	adresse:"1910, boul. St-Joseph",
	tel:"819 478-6997",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=1910,+boul.+St-Joseph+Drummondville&sll=45.433029,-73.681573&sspn=0.010842,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.877714,-72.487333"}
	,
	{ville:"Île Perrot",
	adresse:"110, boul. Don-Quichotte",
	tel:"514 425-9128",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=110,+boul.+Don-Quichotte+%C3%AEle+perrot&sll=45.877714,-72.487333&sspn=1.376729,2.076416&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.387306,-73.960447"}
	,
	{ville:"Lachine",
	adresse:"480, 28e avenue",
	tel:"514 639-4108",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=480,+28e+avenue+lachine&sll=45.387306,-73.960447&sspn=0.01085,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.437423,-73.688689"}
	,
	{ville:"Laprairie",
	adresse:"975, boul. Taschereau",
	tel:"450 619-6441",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=975,+boul.+Taschereau&sll=45.437423,-73.688689&sspn=0.010841,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.40613,-73.49652"}
	,
	{ville:"Québec",
	adresse:"5005, boul. L'Ormière",
	tel:"418 877-5108",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=5005+boulevard+de+l'Ormiere&sll=46.81274,-71.21935&sspn=0.33835,0.519104&ie=UTF8&z=16&iwloc=addr",
	LatLng:"46.818264,-71.331218"}
	,
	{ville:"Québec",
	adresse:"5555, boul. des Gradins",
	tel:"418 622-5262",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=5555+Boulevard+Des+Gradins+quebec&sll=46.841334,-71.276192&sspn=0.010157,0.024419&ie=UTF8&z=16&iwloc=addr",
	LatLng:"46.841334,-71.276192"}
	,
	{ville:"Repentigny",
	adresse:"1315, boul. Iberville",
	tel:"450 582-3720",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=1315,+boul.+Iberville+repentigny&sll=46.818264,-71.331218&sspn=0.042289,0.064888&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.784247,-73.411891"}
	,
	{ville:"Rivière-du-Loup",
	adresse:"254, Hôtel de Ville",
	tel:"418 862-7861",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=254,+H%C3%B4tel+de+Ville+rivi%C3%A8re-du-loup&sll=45.73862,-73.45035&sspn=0.010783,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"47.827064,-69.549753"}
	,
	{ville:"Sherbrooke",
	adresse:"3950, rue King Ouest",
	tel:"819 569-8642",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=3950+Rue+King+Ouest,+Sherbrooke&sll=45.392402,-71.955465&sspn=0.011347,0.027809&ie=UTF8&z=16&iwloc=addr",
	LatLng:"45.392402,-71.955465"}
	,
	{ville:"Ste-Foy",
	adresse:"999 de Bourgogne",
	tel:"418 651-2362",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=999+de+Bourgogne+sainte-foy&sll=45.42249,-71.91971&sspn=0.010844,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"46.765534,-71.309921"}
	,
	{ville:"St-Romuald",
	adresse:"1060, boul. Rive-Sud",
	tel:"418 834-4009",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=1060,+boul.+Rive-Sud&sll=46.765534,-71.309921&sspn=0.010583,0.016222&ie=UTF8&z=16&iwloc=addr",
	LatLng:"46.732237,-71.269138"}
	,
	{ville:"Trois-Rivières",
	adresse:"645, boul. Thibeau",
	tel:"819 691-2619",
	map:"http://maps.google.ca/maps?f=q&hl=fr&geocode=&q=645,+boul.+Thibeau+trois-rivieres&sll=46.38227,-72.546214&sspn=0.17834,0.444946&ie=UTF8&t=p&z=15&iwloc=addr",
	LatLng:"46.38227,-72.546214"}
	,
	{ville:"Montréal",
	adresse:"865, rue Sainte-Catherine Est",
	tel:"514 845-7152",
	map:"http://maps.google.ca/maps?f=q&source=s_q&hl=fr&geocode=&q=865,+rue+Sainte-Catherine+Est+montreal&sll=45.515839,-73.558619&sspn=0.010405,0.024419&ie=UTF8&t=p&z=15&iwloc=addr",
	LatLng:"45.515839,-73.558619"}
	];



function loadGMap() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("mapByGoogle"));

    //map.setCenter(new GLatLng(45.618435,-73.587670), 11);
    map.enableDoubleClickZoom();
    map.enableContinuousZoom();
    map.enableScrollWheelZoom();
    
	map.addControl(new GSmallZoomControl());
	map.addControl(new GScaleControl());
   
    geocoder = new GClientGeocoder();
    geocoder.setBaseCountryCode("ca");
    
	centerAddress();
	populateMap((page == 'epiceries') ? epicerieAdrs : boutiqueAdrs);
	
  }
}
function populateMap (obj) {
//	alert(obj.length);
	for (var i=0; i < obj.length; i++) {
	  geocoder.getLatLng(
	    obj[i].LatLng,
	    function(point) {
	      if (!point) {
	        alert(obj[i].LatLng + " not found");
	      } else {
	        var marker = new GMarker(point);
	        map.addOverlay(marker);
	      }
	    }
	  );
		
	}
}

function centerAddress () {
var adr = "45.920587344733654,-72.5152587890625";
  geocoder.getLatLng(
    adr,
    function(point) {
      if (!point) {
        alert(adr + " not found");
      } else {
        map.setCenter(point, 7);
      }
    }
  );

}
function showAddress(obj) {
	
  geocoder.getLatLng(
    obj.LatLng,
    function(point) {
      if (!point) {
        alert(obj.LatLng + " not found");
      } else {
        map.setCenter(point, 14);
		map.openInfoWindowHtml(point,  "<span style=\'font-size:10px; color:#333;\'><b style=\'font-size:12px; color:#000;\'>Rachelle-Béry</b><br />"+obj.adresse+"<br />"+obj.ville+"<br />T: "+obj.tel+"</span>");
        //var marker = new GMarker(point);
        //map.addOverlay(marker);
      }
    }
  );
}

