// redimensionne l'image par rapport à la taille de la fenêtre
$(document).ready(function(){
	// fonction qui redimensionne l'image principale
	$(window).load(function(){
		resizeImage();
	}).resize(function(){
		resizeImage();
	});

	// définition de la fonction
	function resizeImage() {
		// définition de la hauteur et de la largeur de la fenêtre
		var navWidth = $(window).width();
		var navHeight = $(window).height();
		var navRatio = navWidth / navHeight;
		
		// calcul de la taille et de la proportion de l'image
		if ($('#wrapper img').width() > 1) picWidth = $('#wrapper img').width();
		if ($('#wrapper img').height() > 1) picHeight = $('#wrapper img').height();
		picRatio = picWidth / picHeight;
		
		// calcul des résultats
		if (navRatio > picRatio) {
			// ajuste l'image à largeur
			var newHeight = (navWidth / picWidth) * picHeight;
			var newWidth = navWidth;
		} else {
			// ajuste l'image à hauteur
			var newHeight = navHeight;
			var newWidth = (navHeight / picHeight) * picWidth;
		}
		
		// centrer l'image
		newTop = 0 - ((newHeight - navHeight) / 2);
		newLeft =  0 - ((newWidth - navWidth) / 2);

		// définition de la nouvelle taille de l'image
		$('#wrapper img').css({height: newHeight, width: newWidth});
		// définition de la nouvelle position de l'image
		$('#wrapper').css({top: newTop, left: newLeft});
	};
});
