
var repJardin = "Image/";  // Répertoire des images du diaporama (vide si meme repertoire que le fichier html)
var numJardin = 0;
var myCounterJardin;
var next_imgJardin = new Image;
next_imgJardin.src = repJardin+"pixel_transparent.gif"; 
var wPopupJardin;
var tabImgJardin;
var tabImgSaveJardin;
var nb_imgJardin;
var pauseJardin = 5000;

tabImgSaveJardin = new Array(9);

tabImgSaveJardin[0] = 'Plaque1.JPG';
tabImgSaveJardin[1] = 'Plaque2.JPG';
tabImgSaveJardin[2] = 'Plaque3.JPG';
tabImgSaveJardin[3] = 'Plaque4.JPG';
tabImgSaveJardin[4] = 'Plaque5.JPG';
tabImgSaveJardin[5] = 'Plaque6.JPG';
tabImgSaveJardin[6] = 'Plaque7.JPG';
tabImgSaveJardin[7] = 'Jardin1.JPG';
tabImgSaveJardin[8] = 'Jardin2.JPG';
nb_imgJardin = tabImgSaveJardin.length;
	       
function nextJardin() {
	//setTimeout("other()",1000)
	// Est-ce que l'image suivante est réchargée ?
if(wPopupJardin){
	if(next_imgJardin.complete) {
		// Oui, alors après le temps de pauseJardin choisi par l'utilisateur, cette image remplacera l'actuelle
		launchAgainJardin();
	}
	else {
		// Non, alors on continue d'attendre qu'elle le soit
		setTimeout("nextJardin()", 100);
	}
 }
}

// Lance le slideshow
function launchJardin() {
	// Petite vérification de la temporisation choisie
	
	// Ordre normal ou aléatoire
	numJardin = 0;
	tabImgJardin = tabImgSaveJardin;
	
	// Avant de lancer le slideshow, on désactive tous les éléments du formulaire
	// et on active le bouton "Stopper"
	next_imgJardin.src = repJardin+tabImgJardin[0];
	//focusOnStop();
	
	wPopupJardin = window.open('', 'img_popup', 'width=50, height=50, top='+(screen.height-50)/2+', left='+(screen.width-50)/2+', status=no, directories=no, toolbar=no, location=no, menubar=no, scrollbars=no, resizable=yes');

	launchAgainJardin();
}

// Poursuit le slideshow
function launchAgainJardin() {
	// Si la fenêtre n'existe pas ou est fermée, on la réouvre
	//if(!wPopupJardin) {
	//	wPopupJardin = window.open('', 'img_popup', 'width=50, height=50, top='+(screen.height-50)/2+', left='+(screen.width-50)/2+', status=no, directories=no, toolbar=no, location=no, menubar=no, scrollbars=no, resizable=yes');
	//}
	
	if(wPopupJardin){
	// On écrit le contenu de la fenêtre popup
	wPopupJardin.document.clear();
	wPopupJardin.document.write("<HTML><HEAD><TITLE>Jardin : "+(numJardin+1)+"/"+nb_imgJardin+"</TITLE></HEAD>");

	// La fonction qui attend que l'image soit chargée et affichée pour redimensionner la fenêtre à la bonne taille
	wPopupJardin.document.write('<SCRIPT language="JavaScript">\nfunction checkSize() { if(document.images && document.images[0].complete) { w = document.images[0].width+50; h = document.images[0].height+100; window.resizeTo(w, h); window.moveTo((screen.width-w)/2, (screen.height-h)/2); document.images[0].style.visibility = "visible"; window.focus(); if(opener.next_imgJardin.src != opener.repJardin+opener.tabImgJardin[opener.numJardin]) { opener.next_imgJardin.src = opener.repJardin+opener.tabImgJardin[opener.numJardin]; } } else { setTimeout("checkSize()", 250); } }\n</'+'SCRIPT>');
	
	wPopupJardin.document.write('<BODY bgcolor="#FFFFFF" leftMargin="0" topMargin="0" marginWidth="0" marginHeight="0">');
	wPopupJardin.document.write('<table width="100%" height="100%" align="center" cellpadding="0" cellspacing="0"><tr valign="middle"><td align="center"><img src="'+next_imgJardin.src+'" border="2" onLoad="checkSize()"  onClick="window.opener.otherJardin()" style="visibility:hidden"></td></tr><tr valign="center=><td><a href="javascript:onClick=window.opener.otherJardin();"></a></td></tr></table>');
	//wPopupJardin.document.write('<div align="center"> <h1>Tout centré</h1> </div>');

	wPopupJardin.document.write('</BODY></HTML>');
	wPopupJardin.document.close();
	numJardin++;
	
	
	// Si "Répéter" n'est pas cochée, on stoppe le slideshow
	if(numJardin == nb_imgJardin) {
		setTimeout("stopJardin()", pauseJardin);
		return false;
	}
	

	myCounterJardin=setTimeout("nextJardin()",pauseJardin);
	}else{
	clearTimeout(myCounterJardin);
	numJardin = 0;
	}
}

// Stoppe le slideshow
function stopJardin() {
	clearTimeout(myCounterJardin);
	wPopupJardin.close();	
	// On réactive tous les éléments du formulaire
	// et on désactive le bouton "Stopper"
	//focusOnLaunch();
	
	numJardin = 0;
}

function otherJardin() {
	if(numJardin!=nb_imgJardin){
	clearTimeout(myCounterJardin);
	nextJardin();
	}else{
	stopJardin();
	}	
}


