// Vitesse de changement : durée en millisecondes
var delay = 2000;
// créer un talbleau pour la galerie d'images
var listephotos = listephotos_text.split(',');
// alert(listephotos0[5]);
// listephotos = new Array("_1F60000017B99F0FDB0", "_26F000001D07C40DA8D", "_270000001D3AA478626", "_271000001D47AEA6393", "_271000001D551239B38", "_273000001D6758FDC9D", "_2AF00000301E74D4C42", "_2B20000032AFC5B415B", "_2E000000228F1C370BE", "_30000000240F513306B.JPG", "P2036107", "P2036108", "P2036109", "P2036111", "P2036112", "P2036113", "P2036114", "P2036115", "P2036116", "P2036117", "P2036118", "P2036119", "P2036120", "P2036121", "P2036122", "P2036123", "P2036124", "P2036125", "P2036126", "P2036127", "P2036128", "P2036129", "P2036130", "P2036131", "P2036132", "P2036133", "P2036134", "P2036135", "P2036136", "P2036137", "P2036138", "P2036139", "P2036140", "P2036141", "P2036142", "P2036143", "P2036144", "P2036147", "P2036148");
// variables de dossiers
var dossierphotos = "./galerie/photos/redim/";
var extphotos = "_redimensionner.JPG";
var dossierphotosgrandes = "./galerie/photos/";
var extphotosgrandes = ".JPG";
// nombre de place pour les photos et gestion des modifications récentes
var col = 5;
var recents_col = new Array();
for(var i = 0; i<col; i++){
	recents_col[i] = 0;
};
// numéros des photos et tableau de codage des numéros récemment utilisés
nn = listephotos.length;
var nn_recents = 10;
var recents = new Array();
for(var i = 0; i<nn; i++){
	recents[i] = 0;
};
// création des colonnes
// Création du tableau
var txt = '<table>\n<tbody>\n<tr>';
for(var i = 0; i<col; i++){
txt += '\n<td id="TD' + i + '"><a id="HREFPH' + i + '"><img id="PH' + i + '" style="border:none"></a></td>';
};
txt += "\n</tr>\n<tr>";
for(var i = 0; i<col; i++){
txt += '\n<td id="TD2' + i + '">&nbsp;</td>';
};
txt += "\n</tr>\n</tbody>\n</table>";
// Fonction de sélection de numéros de photos
listeactuelle = new Array(0,1,2,3,4);
// Choisir une des photos initiales aléatoirement
function initphotos(){
	for(var i = 0; i<col+3; i++){
		change();
		};
	/*
	for(var i = 0; i<col; i++){
		// ------------------------------------------------------------------------------------------
		num1 = Math.floor(Math.random() * nn);
		while(recents[num1]>0){
			num1 = Math.floor(Math.random() * nn);
			};
		for(var i = 0; i<nn; i++){
			if(recents[i] > 0){
				recents[i] = recents[i]-1;
				};
			};
		recents[num1] = nn_recents;
		// ------------------------------------------------------------------------------------------
		IDTD = "TD" + i;
		IDPH = "PH" + i;
		photo0 = listephotos[num1];
		photo = dossierphotos + photo0 + extphotos;
		document.getElementById(IDPH).src=photo;
		};
	*/
};
// fonction de changement toutes les x millisecondes 
var int=self.setInterval("change()",delay);
function change(){
	var t=new Date();
	place1 = Math.floor(Math.random() * col);
	// ------------------------------------------------------------------------------------------
	while(recents_col[place1]>0){
		place1 = Math.floor(Math.random() * col);
		};
	for(var i = 0; i<col; i++){
		if(recents_col[i] > 0){
			recents_col[i] = recents_col[i]-1;
			};
	};
	recents_col[place1] = 3;
	// ------------------------------------------------------------------------------------------
	num1 = Math.floor(Math.random() * nn);
	while(recents[num1]>0){
		num1 = Math.floor(Math.random() * n);
		};
	for(var i = 0; i<nn; i++){
		if(recents[i] > 0){
			recents[i] = recents[i]-1;
			};
		};
	recents[num1] = nn_recents;
	// ------------------------------------------------------------------------------------------
	IDTD = "TD" + place1;
	IDPH = "PH" + place1;
	HREFPH = "HREFPH" + place1;
	// alert(IDTD + " / " + IDPH);
	photo0 = listephotos[num1];
	photo = dossierphotos + photo0 + extphotos;
	photo1 = dossierphotosgrandes + photo0 + extphotosgrandes;
	// alert(photo);
	//document.getElementById(IDTD).innerHTML = photo0;
	document.getElementById(IDPH).src=photo;
	lien = document.getElementById(HREFPH);
	lien.href=photo1;
	// alert(document.getElementById(HREFPH).innerHTML);
};
