$(document).ready( function() {

// On defini la taille prealable de l'image
		 var widthimg = 888;  
		 var heightimg= 532;
		 
// On defini le ratio de l'image
		var ratio = heightimg/widthimg;
		
// On declare la taille de la fenetre de navigateur
		var browserwidth = $(window).width();
		var browserheight = $(window).height();

// on redimentionne l'image
if ((browserheight/browserwidth) > ratio){
		    $("#fsdiapo img").height(browserheight);
		    $("div #fsdiapo img").width(browserheight / ratio);
		} else {
		    $("#fsdiapo img").width(browserwidth);
		    $("#fsdiapo img").height(browserwidth * ratio);
		}
		// On centre l'image
		$("#fsdiapo img").css('left', (browserwidth - $("img").width())/2);
		$("#fsdiapo img").css('top', (browserheight - $("img").height())/2);
		return this; 
}); 


$(window).bind("resize", function() {

// On defini la taille prealable de l'image
		var widthimg = 888;  
		 var heightimg= 532;
		 
// On defini le ratio de l'image
		var ratio = heightimg/widthimg;
		
// On declare la taille de la fenetre de navigateur
		var browserwidth = $(window).width();
		var browserheight = $(window).height();

// on redimentionne l'image
if ((browserheight/browserwidth) > ratio){
		    $("#fsdiapo img").height(browserheight);
		    $("#fsdiapo img").width(browserheight / ratio);
		} else {
		    $("#fsdiapo img").width(browserwidth);
		    $("#fsdiapo img").height(browserwidth * ratio);
		}
		// On centre l'image
		$("#fsdiapo img").css('left', (browserwidth - $("img").width())/2);
		$("#fsdiapo img").css('top', (browserheight - $("img").height())/2);
		return this; 
}); 




// la fonction pour le slide en 
function slideSwitch() {
    
    // la  partie image
    var $active = $('#fsdiapo img.active');
    
    if ( $active.length == 0 ) $active = $('#fsdiapo img:last');

    var $next =  $active.next().length ? $active.next() : $('#fsdiapo img:first');
    $active.removeClass('active').addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('last-active');
        });   
}

// on ecrie le document pur le changement des images
$(document).ready(function() {

// interval de time pour stopper avec clear
var timer = setInterval( "slideSwitch()", 3000 );    

});




