		 var windowWidth;
		 var windowHeight;
		 // gestion du glissement des photos		 
		 function affphoto(showhide,ileft,itop) {	
          var largeurImage;		 
		  var imgLeft = 120;
		  if (arguments.length > 1) imgLeft = ileft;
		  imgTop = -1;
		  if (arguments.length > 2) imgTop = itop;
		  var timer;
		  var pas = 12;
		  if (showhide == 0) showhide = (this.style.display == 'block')? -1 : 1;
		  var objet = this;
		  var imgs = this.getElementsByTagName('img');
		  this.style.display = 'block';
		  var imgWidth = imgs[0].width;
		  var leftActuel = (showhide > 0)?  imgLeft -imgWidth : objet.style.left;
		  var leftFinal =  (showhide == -1)? imgLeft -imgWidth : imgLeft;
		  var divs = objet.getElementsByTagName('div');
		  largeurImage = imgWidth + imgs[0].border*2;
		  tbs = divs[0].getElementsByTagName('table');
		  tbs[0].width = largeurImage + 'px';
		  function glissement(sens) {
					pas = 12; 
					pasreel =pas * sens;
					if (sens>0) objet.style.display = 'block';					
					leftActuel += pasreel;						
					objet.style.left = leftActuel + 'px';
					if (imgTop > -1) objet.style.top = imgTop +'px';
					if ((sens > 0 && (leftActuel > leftFinal)) || ((sens < 0) && (leftActuel < leftFinal)))
					{		if (sens<0) clearInterval(timer);   //Arrête le timer
							objet.style.overflow    =   'inherit';
							objet.style.display = (sens > 0) ? 'block' : 'none';
							//objet.style.top = objet.style.top + (int)(Math.random()*100);
							if ((sens > 0) && (leftActuel > leftFinal + 3*pasreel/2)) {
								clearInterval(timer);
								timer = setInterval(rappel,8);
							}
					}
			};
			function rappel() { 
				leftActuel -= pas / 4 ;
				objet.style.left = leftActuel + 'px';
				if (leftActuel < leftFinal - pas) { clearInterval(timer);
													   timer = setInterval(rappel2,8);
													  }
			}
			function rappel2() {
			   leftActuel += pas/6;
			   objet.style.left = leftActuel+'px';
			   if (leftActuel >= leftFinal) clearInterval(timer);
			}
			var affiche = function() { glissement(1);};
			var cache =   function (){glissement(-1); };
			var leftActuel = (showhide == -1)?  imgLeft : -imgWidth; //objet.style.left;
			var leftFinal =  (showhide == -1)?  -imgWidth : imgLeft;
			this.style.left = leftActuel + 'px';
			var fct =    (showhide == 1) ? affiche : cache;   
			timer = setInterval(fct, 6);    //Toute les 40 ms*
		}		
		
// gestion de la pluie de feuilles;
		feuillesVolantes = new Array (ParamFeuilles.NbFeuilles);
		chatTombantes = new Array ();
		var nbChataignes = 0;
		var timerFeuilles;		
		function vieFeuilles() { 
			   // 1) faut-il créer une nouvelle feuille ?
			   creer = false;
			   nbFVivantes = 0;
			   for (i = 0; i < feuillesVolantes.length; i++) if (feuillesVolantes[i]['etat']) nbFVivantes += 1;
			   for (i = 0; i < feuillesVolantes.length; i++) {
			       if (!feuillesVolantes[i]['etat']) {  
								  creer = true;
								  acreer = i;
								  break;
					}
				}			
			 if (creer) { // On envisage de crééer mais il faut tirer la décisionn au sort
			  // pour une création moyenne toutes les 5 secondes, il faut tirer un dé à 500 faces
			    freq = ParamFeuilles['FreqCreation'] - 
				       Math.floor(ParamFeuilles.FreqCreation / 1.25 / ParamFeuilles.NbFeuilles) * (ParamFeuilles.NbFeuilles-nbFVivantes); 
			    if ( Math.floor(Math.random()*freq) == 1 ) { //ouiii c'est gagné !!				 
				    iImage = Math.floor(Math.random()*feuilles.length);
					feuillesVolantes[acreer]['etat'] = true;
					feuillesVolantes[acreer]['iImage'] = iImage;
					objHtml = document.getElementById('feuille'+((acreer <10)? '0':'')+acreer);
					feuillesVolantes[acreer]['obj'] = objHtml;
					objHtml.src = feuilles[iImage];					
					objHtml.style.top = -100+'px';	
					feuillesVolantes[acreer]['V'] = -100;
					ph = Math.floor(Math.random()*windowWidth) - objHtml.width;	
					objHtml.style.left = ph+'px';
					feuillesVolantes[acreer]['H'] = ph;
					feuillesVolantes[acreer]['tempsImage'] = Math.floor(Math.random()*ParamFeuilles.PerImage / 2);
					feuillesVolantes[acreer]['tempsDirH'] = ParamFeuilles['PerDelta'] + 1;
					feuillesVolantes[acreer]['tempsDirV'] = ParamFeuilles['PerDelta'] + 1;
				}
			  }
			  // va-t-on créer une nouvelle Châtaigne ?
			   
			  if (nbChataignes < ParamFeuilles.NbChataignes) {
				  freq = ParamFeuilles['FreqCreation'] * ParamFeuilles.DivFreq; //on divise la fréquence des feuilles par 4 pour avoir la fréquence des châtaignes
				  if (Math.floor(Math.random()*freq) == 2)  { // Ouiii on crée une châtaigne				  
					chatTombantes[nbChataignes] = new Array();
				    chatTombantes[nbChataignes]['etat'] = 1;
					objHtml = document.getElementById('chataigne'+((nbChataignes < 100)? '0':'') + ((nbChataignes < 10)? '0':'') + nbChataignes);
					objHtml.style.top = -100 + 'px';
					chatTombantes[nbChataignes]['V'] = -100;
					chatTombantes[nbChataignes]['H'] = Math.floor(Math.random()* (windowWidth-10)) - objHtml.width + 10;
					objHtml.style.left = chatTombantes[nbChataignes]['H'] + 'px';	
					chatTombantes[nbChataignes]['obj'] = objHtml;
					nbChataignes++;	
				  }
			  }
			  // gestion de la création terminée
			  // il faut maintenant faire évoluer les feuilles vivantes.
			  for (i = 0; i < feuillesVolantes.length; i++) if (feuillesVolantes[i]['etat']) {
				objHtml = feuillesVolantes[i]['obj'];
				//gestion du déplacement horizontal
				feuillesVolantes[i]['tempsDirH'] += 1;
				if (feuillesVolantes[i]['tempsDirH'] >= ParamFeuilles['PerDelta']) {
						feuillesVolantes[i]['deltaH'] = Math.floor(Math.random()*ParamFeuilles['ForceH']) - variationH1;
						feuillesVolantes[i]['tempsDirH'] = Math.floor(Math.random()*ParamFeuilles['PerDelta']/2);
				}
				newPosH = feuillesVolantes[i]['H'] + feuillesVolantes[i]['deltaH'];
				if ((newPosH + objHtml.width) > windowWidth) newPosH = windowWidth - objHtml.width;
				//gestion du déplacement vertcal
				feuillesVolantes[i]['tempsDirV'] += 1;
				if (feuillesVolantes[i]['tempsDirV'] >= ParamFeuilles['PerDelta']) {
						feuillesVolantes[i]['deltaV'] = Math.floor(Math.random()*ParamFeuilles['ForceV']) - variationV1;
						feuillesVolantes[i]['tempsDirV'] = Math.floor(Math.random()*ParamFeuilles['PerDelta']/2);
				}				
				newPosV = feuillesVolantes[i]['V'] + feuillesVolantes[i]['deltaV'];
		
				//choix de la nouvelle image de la feuille :
				feuillesVolantes[i]['tempsImage'] += 1;
				if (feuillesVolantes[i]['tempsImage'] >= ParamFeuilles['PerImage']) {
					delta = Math.floor(feuilles.length / 6);
					iImage = (Math.floor(Math.random()*2*delta) - delta) + feuillesVolantes[i]['iImage'];
					if (iImage < 0 ) iImage += feuilles.length;
					iImage = iImage % feuilles.length;
					feuillesVolantes[i]['iImage'] = iImage;
					feuillesVolantes[i]['tempsImage'] = Math.floor(Math.random()*ParamFeuilles['PerImage']/2);
				}
				objHtml.src = feuilles[iImage];	
				if  (((newPosH+objHtml.width+24) > windowWidth) || ((newPosV+objHtml.height+20) > windowHeight)) {
				   objHtml.style.left = -100+'px';
				   objHtml.style.top = -100+'px';
				   feuillesVolantes[i]['etat'] = false;				   
				} else {
					objHtml.style.left = newPosH + 'px';					
					feuillesVolantes[i]['H'] =  newPosH;
					objHtml.style.top = newPosV + 'px';
					feuillesVolantes[i]['V'] =  newPosV;
				}
			  }
			  // gestion des châtaignes tombantes
				divbas = document.getElementById('bas');
				hbas = divbas.offsetHeight;
				ausol = document.getElementById("chataigneAuSol001");
				topAuSol = hbas - ausol.offsetHeight;
			   for (iChat = 0; iChat < nbChataignes; iChat++) {
				   objHtml = chatTombantes[iChat]['obj'];
			       pv = chatTombantes[iChat]['V'];
				   ph = chatTombantes[iChat]['H'];
			       switch (chatTombantes[iChat]['etat']) {
       				   case  1 :					         
							 pv = pv + ParamFeuilles.VitesseDeChute;
							 if ((pv + objHtml.height) >  windowHeight) {
							        chatTombantes[iChat]['etat'] = 2;
									pv = windowHeight - objHtml.height;
									chatTombantes[iChat]['rebondV'] = pv - Math.floor(Math.random()*40);
									chatTombantes[iChat]['rebondH'] = Math.floor(Math.random()*10) - 5;
							 }						 
							objHtml.style.top = pv + 'px';
							chatTombantes[iChat]['V'] = pv;
							break;
						case 2 :							
							pv = pv - Math.floor(ParamFeuilles.VitesseDeChute / 4);
							ph = ph + chatTombantes[iChat]['rebondH'];
							if ((ph + objHtml.width) > windowWidth) ph = windowWidth - objHtml.width;
							if ( pv <= chatTombantes[iChat]['rebondV'] ) {
								chatTombantes[iChat]['etat'] = 3;
							}
							objHtml.style.top = pv + 'px';
							objHtml.style.left = ph + 'px';
							chatTombantes[iChat]['V'] = pv;
							chatTombantes[iChat]['H'] = ph; 
							break;
						case 3 :
							pv = pv + Math.floor(ParamFeuilles.VitesseDeChute / 2);
							ph = ph + chatTombantes[iChat]['rebondH'];
							if ((ph + objHtml.width) > windowWidth) ph = windowWidth - objHtml.width;
							if ((pv + objHtml.height) >  windowHeight) {	
								chatTombantes[iChat]['etat'] = 4;					
								pv = windowHeight - objHtml.height;	
								causol = document.getElementById('chataigneAuSol'+((iChat< 100)? '0':'') + ((iChat < 10)? '0':'') + iChat);
								causol.style.top = topAuSol+'px';
								causol.style.left = ph+'px';
								pv = -100;
								ph = -100;
							}
							objHtml.style.top = pv + 'px';
							objHtml.style.left = ph + 'px';
							chatTombantes[iChat]['V'] = pv;
							chatTombantes[iChat]['H'] = ph; 
							break;
				   }
			   }
			} // fin de vieFeuilles
			
        function pluieDeFeuilles() {			
		if (document.body) {
				//windowWidth = (document.body.clientWidth);
				//windowHeight = (document.body.clientHeight);
				windowWidth = 0;
				windowHeight = 0;
				if (windowHeight <100) windowHeight = document.documentElement.clientHeight;
				if (windowWidth <100) windowWidth = document.documentElement.clientWidth;
				var larg = (window.innerWidth);
				var haut = (window.innerHeight);
				if (haut > windowHeight) windowHeight = haut;
				if (larg > windowWidth) windowWidth = larg;
			}
		variationH1 = ParamFeuilles['ForceH'] * ParamFeuilles['Bourrasque'];
		variationV1 = ParamFeuilles['ForceV'] * ParamFeuilles['Bourrasque'];			   
			for (i = 0; i < ParamFeuilles.NbFeuilles; i++) {
			            feuillesVolantes[i] = new Array();
			            feuillesVolantes[i]['etat'] = false;  // false pour feuille inexistante.
			}			
            if (ParamFeuilles.Animation) timerFeuilles = setInterval(vieFeuilles, ParamFeuilles['PeriodeBase']);				
		}

		
		
