var map = null;

function afficherVille(ville,distance){
	var geocoder = new google.maps.Geocoder();
	geocoder.geocode({address: ville + " France"},function(results,status){
		if(status == google.maps.GeocoderStatus.OK){
			map.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: map,
				position: results[0].geometry.location,
				draggable: false
			});

			var circle = new google.maps.Circle({
				map: map,
				radius: (distance * 1000),
				fillColor: '#9bd028',
				strokeColor: '#FFF',
				strokeWeight: 1
			});
			circle.bindTo('center',marker,'position');
		}
	});
}

var windowInfos = new Array();
var bounds = new google.maps.LatLngBounds();
function pointeurVille(ville,contenu){
	var geocoder = new google.maps.Geocoder();
	geocoder.geocode({address: ville + " France"},function(results,status){
		if(status == google.maps.GeocoderStatus.OK){
			map.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: map,
				position: results[0].geometry.location,
				draggable: false
			});
			bounds.extend(results[0].geometry.location);
			map.setCenter(bounds.getCenter());
			map.fitBounds(bounds); 
			
			var infowindow = new google.maps.InfoWindow({
				content: contenu
			});
			
			google.maps.event.addListener(marker,'click',function(e){
				infowindow.open(map,marker);
			});
		}
	});
}

/* Slider */
var sliderIdx = 0;
var sliderPhotos = 3;
var sliderLimite = null;
$(document).ready(function(){
	sliderLimite = $("#liste-photos").find("a.photo").length;
	$("#liste-photos").find("a.photo:gt("+(sliderPhotos-1)+")").hide();
});
function sliderPrecedent(){
	if(sliderIdx > (sliderLimite-1-sliderPhotos)){
		sliderIdx = (sliderLimite-1-sliderPhotos);
	}
	
	if(sliderIdx >= 0){
		$("#liste-photos").find("a.photo:eq("+sliderIdx+")").show();
		$("#liste-photos").find("a.photo:eq("+(sliderIdx+sliderPhotos)+")").hide();
		sliderIdx--;
	}
}
function sliderSuivant(){
	if(sliderIdx < 0){
		sliderIdx = 0;
	}
	
	if(sliderIdx <= (sliderLimite-1-sliderPhotos)){
		$("#liste-photos").find("a.photo:eq("+sliderIdx+")").hide();
		$("#liste-photos").find("a.photo:eq("+(sliderIdx+sliderPhotos)+")").show();
		sliderIdx++;
	}
}

