var indexSlideShow = new Array();
indexSlideShow[1] = "slideshow/riviere-fleurie.jpg";
indexSlideShow[2] = "slideshow/piscine.jpg";
indexSlideShow[3] = "slideshow/loggia.jpg";
indexSlideShow[4] = "slideshow/degustation.jpg";
indexSlideShow[5] = "slideshow/aqua-volley.jpg";
indexSlideShow[6] = "slideshow/soiree.jpg";
indexSlideShow[7] = "slideshow/hollandais.jpg";
indexSlideShow[8] = "slideshow/sanitaire.jpg";
indexSlideShow[9] = "slideshow/cabane-de-vignes.jpg";
indexSlideShow[10] = "slideshow/montaigne.jpg";
var previousDiapo = 0;
var currentDiapo = 1;
var currentLoad = 1;
var maxDiapo = 10;
var delayDiapo = 3000;
var delayReplay = 10000;
var delayTransition = 60;
var previousOpacity = 1;
var currentOpacity = 0;
var opacityStep = 0.1;
var timerTransition;
var timerSlideShow = setTimeout('sshowAnimate()',delayDiapo);
var timerLoadingImg = setTimeout('sshowLoadImg()',300);

function sshowLoadImg() {
    if (document.getElementById('diapo'+currentLoad).complete) {
	currentLoad++;
	if (currentLoad <= maxDiapo) {
	    document.getElementById('diapo'+currentLoad).src = indexSlideShow[currentLoad];
	    timerLoadingImg = setTimeout('sshowLoadImg()',300);
	}
    } else {
	timerLoadingImg = setTimeout('sshowLoadImg()',300);
    }
}


function makeTransition(delay) {
    if (previousDiapo > 0) {
	previousOpacity -= opacityStep;
	if (previousOpacity <= 0) {
	    previousOpacity = 0;
	    document.getElementById('diapo'+previousDiapo).style.visibility = 'hidden';
	}
	document.getElementById('diapo'+previousDiapo).style.opacity = previousOpacity;
    }
    if (document.getElementById('diapo'+currentDiapo).complete) {
	currentOpacity +=  opacityStep;
	if (currentOpacity >= 1) {
	    currentOpacity = 1;
	}
	document.getElementById('diapo'+currentDiapo).style.visibility = 'visible';
	document.getElementById('diapo'+currentDiapo).style.opacity = currentOpacity;
    }
    if ((previousOpacity == 0) && (currentOpacity == 1)) {
	timerSlideShow = setTimeout('sshowAnimate()',delay);
    } else {
	timerSlideShow = setTimeout('makeTransition('+delay+')',delayTransition);
    }
}

function changeDiapo(step,delay) {
    if (! document.getElementById('diapo'+currentDiapo).complete) {
	timerSlideShow = setTimeout('sshowAnimate()',delay);
	return;
    }
    previousDiapo = currentDiapo;
    currentDiapo += step;
    if (currentDiapo > maxDiapo) {
	currentDiapo = 1;
    }
    if (currentDiapo < 1) {
	currentDiapo = maxDiapo;
    }
    previousOpacity = 1;
    currentOpacity = 0;
    makeTransition(delay);
}

function sshowNext() {
    clearTimeout(timerSlideShow);
    changeDiapo(1, delayReplay);
}

function sshowPrev() {
    clearTimeout(timerSlideShow);
    changeDiapo(-1, delayReplay);
}

function sshowAnimate() {
    changeDiapo(1, delayDiapo);
}



