function homeMarker(map, markerPosition){
		
	// suppression de l'ancien marker s'il existe
	if (config.homeMarker != null){
		config.homeMarker.setMap(null);
		config.homeMarker = null;
	}

	var image = new google.maps.MarkerImage(
	  config.homeMarkerImage,
	  new google.maps.Size(48,48),
	  new google.maps.Point(0,0),
	  new google.maps.Point(24,48)
	);
	
	var shadow = new google.maps.MarkerImage(
	  config.homeMarkerShadow,
	  new google.maps.Size(76,48),
	  new google.maps.Point(0,0),
	  new google.maps.Point(24,48)
	);
	
	var shape = {
	  coord: [15,0,15,1,16,2,16,3,17,4,17,5,17,6,17,7,18,8,18,9,19,10,19,11,20,12,20,13,21,14,21,15,22,16,22,17,22,18,23,19,23,20,24,21,24,22,25,23,25,24,26,25,26,26,25,27,25,28,24,29,24,30,23,31,23,32,22,33,30,34,31,35,32,36,33,37,33,38,33,39,33,40,31,41,28,42,27,43,27,44,27,45,28,46,27,47,20,47,18,46,13,45,10,44,9,43,9,42,10,41,12,40,15,39,16,38,15,37,14,36,13,35,12,34,11,33,10,32,9,31,8,30,7,29,6,28,6,27,7,26,7,25,8,24,8,23,9,22,9,21,10,20,11,19,11,18,11,17,12,16,12,15,12,14,13,13,13,12,14,11,14,10,15,9,15,8,15,7,14,6,14,5,14,4,14,3,14,2,14,1,14,0,15,0],
	  type: 'poly'
	};
	
	var marker = new google.maps.Marker({
	  icon: image,
	  shadow: shadow,
	  shape: shape,
	  map: map,
	  draggable: true, 
	  position: markerPosition
	});
	
	//google.maps.event.addListener(marker, 'dragend', function() {
      //marker.getPosition();
    //});
    
	return marker;
}

function callbackRechercherAdresse(homeMarker){
	var pos = homeMarker.position;
    config.bounds.extend(pos);
    fitBounds();
    //$('#nonalweb_lieubundle_lieutype_lat').val(pos.lat());
	//$('#nonalweb_lieubundle_lieutype_lng').val(pos.lng());
}

function callbackGeolocaliser(homeMarker){
	var pos = homeMarker.position;
	config.bounds.extend(pos);
    fitBounds();
	//$('#nonalweb_lieubundle_lieutype_lat').val(pos.lat());
	//$('#nonalweb_lieubundle_lieutype_lng').val(pos.lng());
}

function callbackItineraire(homeMarker){
	callbackGeolocaliser(homeMarker);
	processCalculItineraire();
}

function onSelectStar(value){
	if (config.starInitialized){
		if ($(this).parent().parent().parent().prev().attr('class') == "checkbox"){
			$(this).parent().parent().parent().prev().find('input').attr('checked', 'checked');
		}
	}
}

function calculerItineraire(){
	if (config.homeMarker == null){
		// on affiche d'abord le homeMarker
		geolocaliser(callbackItineraire);
	}else{
		processCalculItineraire();
	}
}

function processCalculItineraire(){
	$('#map_canvas').gmap('displayDirections', { 'origin': config.homeMarker.getPosition(), 'destination': latlng, 'travelMode': google.maps.DirectionsTravelMode.DRIVING }, { 'panel': document.getElementById('itineraireModalBody') }, function(result, status) {
        if ( status === 'OK' ) {
        	$('#btnAfficherItineraire').show();
        }
	});
}

function proposerVideo(url, lieuId){
	if (url != ""){
		var data = {url: url, lieuId: lieuId};
		$('.proposerVideoLoader').show();
		// l'envoyer au serveur
		$.ajax({
		    type: "POST",
		    url: config.urlProposerVideo,
		    contentType: 'application/json',
		    data: JSON.stringify(data),
		    cache: false,
		    dataType: "json",
		    success: function(data){
				$('.proposerVideoLoader').hide();
				$('#proposerVideoModal').find('input').val("");
				$('#proposerVideoModal').modal('hide');
				if (data.ok){
					$('#remerciementVideoModal').modal('show');
				}else{
					$('#echecVideoModal').modal('show');
				}
			}
		});
	}
	
	return false;
}