// DIAPORAMA //
function objet() {
this.length = objet.arguments.length
for (var i = 0; i < this.length; i++) this[i+1] = objet.arguments[i]
}
var nom = new objet ("intro-groupe.jpg", "intro-agri.jpg", "intro-jardin.jpg", "intro-export.jpg");
var numero = 1;
function changer() {
document.image.src = "img/"+nom[numero];
numero += 1;
if (numero == nom.length + 1) numero = 1;
setTimeout("changer()", 2500);
}


// PRELOAD //
function prechargimg() {
var doc=document;
if(doc.images){ if(!doc.precharg) doc.precharg=new Array();
var i,j=doc.precharg.length,x=prechargimg.arguments; for(i=0; i<x.length; i++)
if (x[i].indexOf("#")!=0){ doc.precharg[j]=new Image; doc.precharg[j++].src=x[i];}}
}

// DIAPORAMA 2

tbimagea=new Array('intro-groupe','intro-agri','intro-jardin','intro-export'); //tableau des images
tbimageb=new Array('dd','de','df','dg','dh','di','dj','dk');
tbimagec=new Array('aa','ab','ac','ad','ae','af','ag','ah','ai','aj');
preImages=new Array;

function precharge(){
var tbg = tbimagea.concat(tbimageb,tbimagec); //tableau des tableau afin de precharger toutes les images en une fois preciser le nom de tous les tableaux
for (i = 0; i < tbg.length; i++){
preImages[i] = new Image();
preImages[i].src = 'img/'+tbg[i]+'.jpg';
}
d1=new fondu('animaccueil',tbimagea,1800); // preciser l'id du diapo , le nom du tableau contenant le nom des image ainsi que la duree d'attente avant transition du diapo concerne
d2=new fondu('animaccueil2',tbimageb,1800);
d3=new fondu('animaccueil3',tbimagec,1800);
}

function fondu(ctn,tb,tps){ //a partir d'ici il n'y a plus rien a faire

if(navigator.appName.substring(0,3)=="Mic"){
this.Imagea=document.getElementById(ctn).childNodes[0];
this.Imageb=document.getElementById(ctn).childNodes[2];
}
else{
this.Imagea=document.getElementById(ctn).childNodes[1];
this.Imageb=document.getElementById(ctn).childNodes[3];
}
this.Tableau=tb;
this.temp=tps;
this.compteur=1;
this.opaa=0;
this.opab=100;
this.oxo=0;
this.defilmage();
}

fondu.prototype.defilmage = function(){

if(this.compteur==this.Tableau.length-1){
this.compteur=-1;
}
if(this.oxo==1){
this.compteur++;
this.opaa=10;
this.Imagea.src="img/"+this.Tableau[this.compteur]+".jpg";
this.oxo=0;
}
this.opaa+=3;
this.opab-=4;
if(document.all && !window.opera){
this.Imagea.style.filter = 'alpha(opacity=' + this.opaa + ');';
this.Imageb.style.filter = 'alpha(opacity=' + this.opab + ');';
}
else{
this.Imagea.style.opacity = this.opaa/100;
this.Imageb.style.opacity = this.opab/100;
}
if(this.opaa>=100){
this.opaa=10;
this.opab=100;
var xcc=this.Imagea.src.length-4;
var cxx=this.Imagea.src.lastIndexOf("/")+1;
var nomimg=this.Imagea.src.substring(cxx,xcc);
this.Imageb.src='img/'+nomimg+'.jpg';
this.oxo=1;
var lui=this;
setTimeout(function() { lui.defilmage(); },this.temp);
return false;
}
var lui=this;
setTimeout( function() { lui.defilmage(); }, 25 );
}
if(navigator.appName.substring(0,3)=="Mic"){
attachEvent("onload",precharge);
}
else{
addEventListener("load", precharge, false);
} 


window.onload=prechargimg('img/intro-groupe.jpg','img/intro-agri.jpg','img/intro-jardin.jpg','img/intro-export.jpg');
window.onload=changer();