// JavaScript Document
function load() {
	if (GBrowserIsCompatible()) {
		GUnload();
		var baseIcon = new GIcon();
		baseIcon.iconSize=new GSize(20,20);
		baseIcon.shadowSize=new GSize(20,20);
		baseIcon.iconAnchor=new GPoint(10,20);
		baseIcon.infoWindowAnchor=new GPoint(5,1);
		var MonIcone = new GIcon(baseIcon, 'images/habillage/icongoogle.png', null, 'images/habillage/icongoogle.png');

		// Cr&eacute;ation de la Carte //
		var MaCarte = new GMap2(document.getElementById('EmplacementDeMacarte'));
		
		function ZOOMBoutonControl() {}
		ZOOMBoutonControl.prototype = new GControl();
		ZOOMBoutonControl.prototype.initialize = function(MaCarte) {
			var containerZOOM = document.createElement('div');
			var boutonZoomPlus = document.createElement('div');
			this.setButtonStyle_Zoom_(boutonZoomPlus);
			containerZOOM.appendChild(boutonZoomPlus);
			boutonZoomPlus.appendChild(document.createTextNode('Zoom +'));
			GEvent.addDomListener(boutonZoomPlus, 'click', function() {
				MaCarte.zoomIn();
			});
			GEvent.addDomListener(boutonZoomPlus, 'mouseover', function() {
				this.style.backgroundColor = '#eadf5b';
			});
			GEvent.addDomListener(boutonZoomPlus, 'mouseout', function() {
				this.style.backgroundColor = '#cebf02';
			});
			var boutonZoomMoins = document.createElement('div');
			this.setButtonStyle_Zoom_(boutonZoomMoins);
			containerZOOM.appendChild(boutonZoomMoins);
			boutonZoomMoins.appendChild(document.createTextNode('Zoom -'));
			GEvent.addDomListener(boutonZoomMoins, 'click', function() {
				MaCarte.zoomOut();
			});
			GEvent.addDomListener(boutonZoomMoins, 'mouseover', function() {
				this.style.backgroundColor = '#eadf5b';
			});
			GEvent.addDomListener(boutonZoomMoins, 'mouseout', function() {
				this.style.backgroundColor = '#cebf02';
			});
			
			  MaCarte.getContainer().appendChild(containerZOOM);
			  return containerZOOM;
		}
		ZOOMBoutonControl.prototype.setButtonStyle_Zoom_ = function(button) {
		  button.style.textDecoration = 'none';
		  button.style.color = '#FFFFFF';
		  //button.style.backgroundColor = '#cebf02';
		  //button.style.backgroundImage = 'images/bt-sat-fr.gif';
		  button.style.font = '13px Verdana';
		  button.style.border = '1px solid #FFFFFF';
		  button.style.padding = '2px';
		  button.style.marginBottom = '3px';
		  button.style.textAlign = 'center';
		  button.style.width = '100px';
		  button.style.cursor = 'pointer';
		}
		ZOOMBoutonControl.prototype.getDefaultPosition = function() {
			return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
		}
		function PSMBoutonControl() {}
		PSMBoutonControl.prototype = new GControl();
		PSMBoutonControl.prototype.initialize = function(MaCarte) {
			var containerPSM = document.createElement('div');
			var boutonPlan = document.createElement('div');

			this.setButtonStyle_PSM(boutonPlan);
			containerPSM.appendChild(boutonPlan);
			boutonPlan.appendChild(document.createTextNode('Plan'));
			GEvent.addDomListener(boutonPlan, 'click', function() {
				MaCarte.setMapType(G_NORMAL_MAP);
			});
			GEvent.addDomListener(boutonPlan, 'mouseover', function() {
				this.style.backgroundColor = '#eadf5b';
				this.style.border = '1px solid #FFFFFF';
			});
			GEvent.addDomListener(boutonPlan, 'mouseout', function() {
				this.style.backgroundColor = '#cebf02';
				this.style.border = '1px solid #FFFFFF';
			});
			var boutonSatellite = document.createElement('div');
			this.setButtonStyle_PSM(boutonSatellite);
			containerPSM.appendChild(boutonSatellite);
			boutonSatellite.appendChild(document.createTextNode('Satellite'));
			GEvent.addDomListener(boutonSatellite, 'click', function() {
				MaCarte.setMapType(G_SATELLITE_MAP);
			});
			GEvent.addDomListener(boutonSatellite, 'mouseover', function() {
				this.style.backgroundColor = '#eadf5b';
			});
			GEvent.addDomListener(boutonSatellite, 'mouseout', function() {
				this.style.backgroundColor = '#cebf02';
			});
			var boutonMixte = document.createElement('div');

			this.setButtonStyle_PSM(boutonMixte);
			containerPSM.appendChild(boutonMixte);
			boutonMixte.appendChild(document.createTextNode('Mixte'));
			GEvent.addDomListener(boutonMixte, 'click', function() {
				MaCarte.setMapType(G_HYBRID_MAP);
			});
			GEvent.addDomListener(boutonMixte, 'mouseover', function() {
				this.style.backgroundColor = '#eadf5b';
			});
			GEvent.addDomListener(boutonMixte, 'mouseout', function() {
				this.style.backgroundColor = '#cebf02';
			});
			
			  MaCarte.getContainer().appendChild(containerPSM);
			  return containerPSM;
		}
		PSMBoutonControl.prototype.setButtonStyle_PSM = function(button) {
	  	button.style.textDecoration = 'none';
		  button.style.color = '#FFFFFF';
		  button.style.backgroundColor = '#cebf02';
		  //button.style.backgroundImage = 'images/bt-sat-fr.gif';
		  button.style.font = '13px Verdana';
		  button.style.border = '1px solid #FFFFFF';
		  button.style.padding = '2px';
		  button.style.marginBottom = '3px';
		  button.style.textAlign = 'center';
		  button.style.width = '100px';
		  button.style.cursor = 'pointer';
		}
		PSMBoutonControl.prototype.getDefaultPosition = function() {
		  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
		}
		MaCarte.addControl(new ZOOMBoutonControl());
		MaCarte.addControl(new PSMBoutonControl());
		MaCarte.setCenter(new GLatLng(47.69497434186282, 4.98779296875), 5);



		function CreationDuMarqueur(point,html) {
			var marker = new GMarker(point,MonIcone);
			GEvent.addListener(marker, 'click', function() {
				MaCarte.setCenter(marker.getPoint(),15);
				marker.openInfoWindowHtml(html);
			});
			GEvent.addListener(marker, 'infowindowclose', function() {
				MaCarte.setCenter(new GLatLng(47.69497434186282, 4.98779296875), 5);
			});
			return marker;
		}

		
		GDownloadUrl('data-hotel.xml', function(data) {
			var xml = GXml.parse(data);
			var markers = xml.documentElement.getElementsByTagName('marker');
			for (var i = 0; i < markers.length; i++) {
				var point = new GLatLng(parseFloat(markers[i].getAttribute('lat')), parseFloat(markers[i].getAttribute('lng')));
				var nomhotel= markers[i].getAttribute('nom');
				var hotelid= markers[i].getAttribute('hotelid');
				var adresse1= markers[i].getAttribute('adresse1');
				var adresse2= markers[i].getAttribute('adresse2');
				var codepostal= markers[i].getAttribute('codepostal');
				var ville= markers[i].getAttribute('ville');
				var tel= markers[i].getAttribute('tel');
				var fax= markers[i].getAttribute('fax');
				var html ='<img src=\"images/habillage/logo-bb.png\" width=\"30\" height=\"30\" border=\"0\"><br><span class=\"Titre\">  H&ocirc;tel B&B ' + nomhotel + '</span><br><span class=\"Paragraph\">'+ adresse1 + ' - ' + adresse2 +'<br>' + codepostal + ' ' + ville + '<br><img src=\"images/habillage/logo-Phone.png\" width=\"25\" height=\"25\" border=\"0\" align=\"absmiddle\"> '+ tel+'<br><img src=\"images/habillage/logo-Fax.png\" width=\"25\" height=\"25\" border=\"0\" align=\"absmiddle\"> ' + fax + '<br><br><a href=\"https://www.hotel-bb.com/resa.cgi?hotelid=' + hotelid + '\"></span><img src=\"images/habillage/bt-tarif.gif\" width=\"140\" height=\"25\" border=\"0\"></a> <a href=\"../detailhotels.phtml?hotelid=' + hotelid + '\"></span><img src=\"images/habillage/bt-infos.gif\" width=\"140\" height=\"25\" border=\"0\"></a><br>';
				var marker = CreationDuMarqueur(point, html);
				MaCarte.addOverlay(marker);
			}
		});
	}else{
		alert('Desole mais votre navigateur nest pas compatible avec Google Maps');
	}
}
//]]>