var mapD;
var baseIconD;
var gmapoverlayD;
var latInitD = 48.951563;
var longInitD = 2.664972;

var map;
var baseIcon;
var latInit = 48.951563;
var longInit = 2.664972;
var latLizy = 49.028357;
var longLizy = 3.023543;
var latVillemomble = 48.88114;
var longVillemomble = 2.517110;
	
function loadGoogleMaps(langue) {
  var txtVillemomble;
  var txtLizy;
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.setCenter(new GLatLng(latInit,longInit), 10);
	
	if (langue == 'fr') {
		txtVillemomble = '<strong>Service commercial</strong><br />23 rue beausire<br />93250 Villemomble<br />France';
		txtLizy = '<strong>Unité de production</strong><br />Rue Gutenberg<br />Z.I. les carreaux<br />77440 Lizy sur Ourcq<br />France';
	}
	
	if (langue == 'an') {
		txtVillemomble = '<strong>Sales dept</strong><br />23 rue beausire<br />93250 Villemomble<br />France';
		txtLizy = '<strong>Manufacturing plant</strong><br />Rue Gutenberg<br />Z.I. les carreaux<br />77440 Lizy sur Ourcq<br />France';
	}
	
	baseIcon = new GIcon();
	baseIcon.shadow = "google_maps/rve_shadow.png";
	baseIcon.iconSize = new GSize(30, 45);
	baseIcon.shadowSize = new GSize(70, 45);
	baseIcon.iconAnchor = new GPoint(0, 45);
	baseIcon.infoWindowAnchor = new GPoint(9, 12);
	baseIcon.infoShadowAnchor = new GPoint(18, 25);
	
	var point = new GLatLng(latVillemomble,longVillemomble);
	map.addOverlay(createMarker(point, 1, txtVillemomble));
	
	point = new GLatLng(latLizy,longLizy);
	map.addOverlay(createMarker(point, 0, txtLizy));
  
  }
}

function reInit() {
	map.setCenter(new GLatLng(latInit,longInit), 10);
}

function zoomLizy() {
	map.setCenter(new GLatLng(latLizy,longLizy), 15);
}

function zoomVillemomble() {
	map.setCenter(new GLatLng(latVillemomble,longVillemomble), 15);
}


function createMarker(point, index, htmltext) {
	var letter = String.fromCharCode("A".charCodeAt(0) + index);
	var letteredIcon = new GIcon(baseIcon);
	letteredIcon.image = "google_maps/rve_30.png";

	markerOptions = { icon:letteredIcon };
	var marker = new GMarker(point, markerOptions);

	GEvent.addListener(marker, "click", function() {
    	marker.openInfoWindowHtml(htmltext);
  	});
	return marker;
}



function initGmapDistri() {
  if (GBrowserIsCompatible()) {
	mapD = new GMap2(document.getElementById("map"));
	mapD.addControl(new GSmallMapControl());
	mapD.setCenter(new GLatLng(latInitD,longInitD), 1);
	
	baseIconD = new GIcon();
	baseIconD.shadow = "./google_maps/rve_shadow.png";
	baseIconD.iconSize = new GSize(30, 45);
	baseIconD.shadowSize = new GSize(70, 45);
	baseIconD.iconAnchor = new GPoint(1, 45);

	
	var mapDiv = document.getElementById("map"); 
	var CopyrightDiv = mapDiv.firstChild.nextSibling; 
	CopyrightDiv.style.display = "none"; 
	
  }
}

function centerGmapDistri() {
	if (gmapoverlayD) {
		mapD.removeOverlay(gmapoverlayD);
  	}
	mapD.setCenter(new GLatLng(latInitD,longInitD), 1);
}

function zoomGmapDistri(dLat, dLon, textepoint) {
	
	if (gmapoverlayD) {
		mapD.removeOverlay(gmapoverlayD);
  	}

	mapD.setCenter(new GLatLng(dLat,dLon), 15);
	var point = new GLatLng(dLat,dLon);
	
	gmapoverlayD = createMarkerD(point, 1, textepoint);
	mapD.addOverlay(gmapoverlayD);
}


function createMarkerD(point, index, htmltext) {
	var letteredIcon = new GIcon(baseIconD);
	letteredIcon.image = "./google_maps/rve_30.png";

	markerOptions = { icon:letteredIcon };
	var marker = new GMarker(point, markerOptions);
	return marker;
}


