function backgroundResize() {
	
	//Initialisation
	var min = {w:1024,h:768};
	var ratio = min.h/min.w;

	var sWidth = $(window).width();
	var sHeight = $(window).height();
	var img = $("#imgBgr, #imgBgr2");
	
	//Vérifier les minimums w/h
	/*
	if((sHeight < min.h) && (sWidth < min.w)) {
		img.css("width", min.w);
		img.css("height", min.h);
	}
	else {*/	
		//Brower plus haut
		if(sHeight > sWidth) {			
			imgHeight = sHeight;
			img.css("height", sHeight);
			imgWidth = sHeight / ratio;
			img.css("width", imgWidth);
			
			if(sWidth > imgWidth){
				imgWidth = sWidth;
				img.css("width", sWidth);
				imgHeight = sWidth * ratio;
				img.css("height", imgHeight);
			}			
		}
		
		//Browser plus large
		if(sWidth >= sHeight){
			imgWidth = sWidth;
			img.css("width", sWidth);
			imgHeight = sWidth * ratio;
			img.css("height", imgHeight);
			
			if(sHeight > imgHeight){
				imgHeight = sHeight;
				img.css("height", sHeight);
				imgWidth = sHeight / ratio;
				img.css("width", imgWidth);
			}
		}
	
	//}
	
	$('#imgBgr_container').css('width', sWidth);
	$('#imgBgr_container').css('height', sHeight);
	
	$('#imgBgTrame').css('height', sHeight);
	$('#imgBgTrame').css('width', sWidth);
}

var bgArray = [
	'assets/img/background1.jpg',
	'assets/img/background2.jpg',
	'assets/img/background3.jpg',
	'assets/img/background4.jpg',
	'assets/img/background5.jpg'
];


var bgIndex = 0;
var setBg = 1;

function switchBg(bg) {
	
	//Get next bg,
	if(bg) { bgIndex = bg; }
	else { bgIndex = bgIndex+1; }
	//Set bg,
	if(bgIndex >= bgArray.length) { bgIndex = 0; }
	
	if(setBg == 0) { $("#imgBgr").attr('src', bgArray[bgIndex]); }
	else { $("#imgBgr2").attr('src', bgArray[bgIndex]); }
	
	var afterFade = function() {
		//Set timer,
		timerBg = setTimeout("switchBg()", 12000);
		//timerBg = setTimeout("switchBg()", 4000);
		
		if(setBg == 0) { setBg = 1; }
		else { setBg = 0; }
	}
	
	if(setBg == 1) { $("#imgBgr2_container").fadeIn(1000, afterFade); }
	else { $("#imgBgr2_container").fadeOut(1000, afterFade); }
	
}





