
/* Script de chargement des images du Diaporama */
//function preload(length) {
function preload(PhotosLST) {
  img_load = new Array();
  for(var i=0; i<PhotosLST.length; i++) {
	  img_load[i]=new Image();
	  img_load[i].src = PhotosLST[i];
  }
  return img_load;
}	

/* Script d'animation du Diaporama */
function diapo_auto(NumDia) {
  if ((NumDia >= 0) & (NumDia < 4)) {
	  var CTRL = 0;
	  var j = Math.floor(Math.random() * img_diapo.length);
    //Resize la Photo qui va être affichée
		if (img_diapo[j].width > img_diapo[j].height) {
		  resizeHeight = Math.floor((img_diapo[j].height/img_diapo[j].width)*120);
			resizeWidth = 120;
		}	
		else {
		  resizeWidth = Math.floor((img_diapo[j].width/img_diapo[j].height)*120);
      resizeHeight = 120;
		}	
		//Check si la Photo sélectionnée n'est pas déjà affichée
	  for(var k=0; k<4; k++) {
	    if (document.images[k].src != img_diapo[j].src)
 	      CTRL++;
    }
	  if (CTRL == 4) {
	    document.images[NumDia].src = img_diapo[j].src;
			document.images[NumDia].style.width = resizeWidth + 'px';
      document.images[NumDia].style.height = resizeHeight + 'px';
		}	
	}
	setTimeout("diapo_auto(Math.floor(Math.random() * 4))", 2000);
}