// JavaScript Document


var map;
var myLatLng;

var imageNormale = new google.maps.MarkerImage('/wp-content/themes/septime/images/marker.png',
  // Taille du marqueur
  new google.maps.Size(19, 22),
  // Origine du marqueur
  new google.maps.Point(0, 0),
  // Ancrage du marqueur
  new google.maps.Point(19, 22)
  );
var imageActive = new google.maps.MarkerImage('/wp-content/themes/septime/images/markerActif.png',
  // Taille du marqueur
  new google.maps.Size(19, 22),
  // Origine du marqueur
  new google.maps.Point(0, 0),
  // Ancrage du marqueur
  new google.maps.Point(19, 22)
  );


function urldecode (str) {    
		return decodeURIComponent(str.replace(/\+/g, '%20'));
}

// permet l'ajout d'un point (=drapeau) sur une google map
function ajouterPoint(id,titre,latitude,longitude,estFiche) {
	myLatLng = new google.maps.LatLng(latitude, longitude);
	
	if (!estFiche) {
		var marker = new google.maps.Marker({
			position: myLatLng,
			map: map,
			icon: imageNormale
		});
		marker.setTitle(titre);
		attachSecretMessageList(id,titre,marker,0,myLatLng);
	} else {
		var marker = new google.maps.Marker({
			position: myLatLng,
			map: map,
			icon: imageActive
		});
	}
}


function attachSecretMessageList(id,titre,marker, number,latLng) {
	google.maps.event.addListener(marker, 'click', function() {
		document.location = "#bloc_"+id;
		marker.setIcon(imageActive);
	});
}
