function carte() {
	var carte = document.getElementById('grande_carte');
	if(carte) {
		//	gestion du clic sur le lien "fermer"
		$('#grande_carte a').click(function() {
			$('#grande_carte').attr('style', 'display: none');
			$('#carte_virtualearth').remove();
			$('#petite_carte').attr('style', 'display: block');
			return false;
		});
		$('#grande_carte a').after('<div id="carte_virtualearth" style="width: 498px; height: 350px;"></div>');
		map = new VEMap('carte_virtualearth');
		//map.SetDashboardSize(VEDashboardSize.Tiny);
		//	On commence par parcourir la page à la recherche des infos de Latitude et Longitude
		var reg_longlat = /(-?[\.0-9]+)\|(-?[\.0-9]+)/;
		var tab = new Array();
		$('.numero').each(function() {
			reg_longlat.exec($(this).attr('title'));
			var reg1 = RegExp.$1;
			var reg2 = RegExp.$2;
			//	On récupère le parent
			var div_parent = $(this).parent().parent();
			var nom_hotel = $(div_parent).find('h3 a').text();
			var url_img = $(div_parent).find('.photo').attr('src');
			var etoiles = $(div_parent).parent().find('.etoiles').attr('src');
			var prix = $(div_parent).find('.prix span').text();
			var lieu = $(div_parent).find('em').text();
			var url = $(div_parent).find('h3 a').attr('href');
			//alert(nom_hotel);
			//var url_hotel = $(parent).find('h3 a').attr('href');
			var tmp = new Array(reg1, reg2, nom_hotel, url_img, etoiles, prix, lieu, url);
			tab.push(tmp);
		});
		var tab_map = new Array();
		for(var i = 0; i < tab.length; i++) {
			tab_map.push(new VELatLong(tab[i][0], tab[i][1]));
		}
		map.LoadMap(new VELatLong(tab[0][0], tab[0][1]), 10, VEMapStyle.Road);
		map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
		map.SetMapView(tab_map);
		for(var i = 0; i < tab.length; i++) {
			var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(tab[i][0], tab[i][1]));
			shape.SetCustomIcon('<span class="pushpin" title="'+tab[i][7]+'">'+(i+1)+'</span>');
			
			//	On récupère les infos de l'hôtel
			var infobox = '<div class="map_description">';
			if(tab[i][3] != undefined || tab[i][4] != undefined) {
				infobox += '<div class="photos">';
				if(tab[i][3] != undefined)
					infobox += '<a href="'+tab[i][7]+'"><img src="'+tab[i][3]+'" class="photo"></a>';
				if(tab[i][4] != undefined)
					infobox += '<a href="'+tab[i][7]+'"><img src="'+tab[i][4]+'" class="etoiles"></a>';
				infobox += '</div>';
			}
			infobox += '<div class="content">';
			infobox += '<h3><a href="'+tab[i][7]+'">'+tab[i][2]+'</a></h3>';
			if(tab[i][6] != undefined)
				infobox += '<em><a href="'+tab[i][7]+'">'+tab[i][6]+'</a></em><br>';
			infobox += '</div><hr class="clear">';
			infobox += '<a href="'+tab[i][7]+'">Prix chambre/nuit : <span>'+tab[i][5]+'</span></a>';
			infobox += '</div>';
			shape.SetDescription(infobox);
			map.AddShape(shape);
		}
		
		//	On rend les pushpin cliquables
		$('.pushpin').each(function() {
			href = $(this).attr('title');
			this.parentNode.setAttribute('onclick', 'document.location = \''+href+'\'');
		});
		
		//	Rétrécissement du menu supérieur de la nav
		$('#MSVE_navAction_container.notraffic').attr('style', 'width: 24.5em !important');
	}
}

function load_carte() {
	var latlong = $('#lat_long').text();
	var reg = /(-?[\.0-9]+)\|(-?[\.0-9]+)/;
	reg.exec(latlong);
	var latitude = RegExp.$1;
	var longitude = RegExp.$2;
	if(latitude != '' && longitude != '') {
		$('#carte').addClass('loading');
		$.getScript(
			'http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6',
			function() {
				var map = null;
				map = new VEMap('carte');
				//map.SetDashboardSize(VEDashboardSize.Tiny);
				$('#carte').removeClass('loading');
				map.LoadMap(new VELatLong(latitude, longitude), 12, VEMapStyle.Road);
				var zoom = map.GetZoomLevel();
				if(zoom < 14)
					map.SetZoomLevel(14);
				map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
				//	Ajout du picto
				var shape = new VEShape(VEShapeType.Pushpin, map.GetCenter());
				//Set the icon
				var rep_templates = getCookie('rep_templates');
				var icon = '<img src="templates/img/picto-hotel.gif">';
				shape.SetCustomIcon(icon);
				//Set the info box
				//map.ClearInfoBoxStyles();
				//shape.SetTitle("<h2><?php echo $Nom; ?></h2>");
				//shape.SetDescription(infobox);
				//Add the shape the the map
				map.AddShape(shape);
			}
		);
	}
}

jQuery.fn.extend({
   findPos : function() {
	   obj = $(this).get(0);
		var curleft = obj.offsetLeft || 0;
		var curtop = obj.offsetTop || 0;
		while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
		}
		return {x:curleft,y:curtop};
   }
});