
/****************************************************************************
_____RECHERCHE DE L'IMAGE : cherche()
****************************************************************************/
function cherche(n){
	if (document.getElementById) {
		obj=document.getElementById(n);
	}
	else if(document.all) {
		obj=document.all[n];
	}
	return obj;
}
/****************************************************************************
_____ROLLOVER CLASSIQUE : rollover()
****************************************************************************/
function rollover(img,newSrc){
	document.images[img].src=newSrc;
}


/****************************************************************************
_____ROLLOVER AVEC DIMENSIONS VARIABLES : rollover2()
****************************************************************************/
function rollover2(img,newSrc){
	newImg= new Image();
	newImg.src=newSrc;
	document.images[img][0].src=newImg.src;
	document.images[img][0].width=newImg.width;
	document.images[img][0].height=newImg.height;
}


/****************************************************************************
_____IMAGE ALEATOIRE AU CHARGEMENT : aleat()
****************************************************************************/
function aleat(){
	aleatsrc=aleat.arguments[Math.floor(Math.random()*aleat.arguments.length)];
	document.write("<img src=\""+aleatsrc+"\">");
}







/****************************************************************************
_____PRECHARGEMENT D'IMAGES : preload()
****************************************************************************/
function preload(){
	imgload=new Array();
	for(var j=0;j<preload.arguments.length;j++){
		imgload[j]=new Image();
		imgload[j].src=preload.arguments[j][0];
	}
}

                   


timing=5000;
nomimg="diapo2";
a=0;
i=0;
/****************************************************************************  
_____PRECHARGEMENT D'IMAGES : startDiapoAuto()                                        
****************************************************************************/  

function startDiapoAuto(){ 
	if(a==0){
			
		a=1;
		newImg= new Image();
	        newImg.src="../images/fleches/picto_diapo_stop.gif";
		document.images[5].src=newImg.src;
		diapoauto();
		
		
	}else{
	stopDiapoAuto();
	
	}
}
/****************************************************************************  
stopDiapoAuto D'IMAGES : stopDiapoAuto()                                        
****************************************************************************/  

function stopDiapoAuto(){ 
a=0;
newImg= new Image();
newImg.src="../images/fleches/picto_diapo.gif";
document.images[5].src=newImg.src;
}
/****************************************************************************  
diapoauto D'IMAGES : diapoauto()                                        
****************************************************************************/  

function diapoauto(){
	
	
	image=cherche(nomimg);
	if(i<imgdiapo.length && a==1){
		image.src=imgdiapo[i][0];
                document.ekform.labelImage.value =imgdiapo2[i][1];  
		document.getElementById("diapo2").alt =imgdiapo2[i][1]; 
			
		setTimeout("diapoauto()",timing);
		i++;
		if(i==imgdiapo.length){
			i=0;
		}
	}
}



/****************************************************************************  
diapobouton D'IMAGES : diapobouton()                                        
****************************************************************************/  

nomimg2="diapo2";
labelImage="diapodg2";
plage=0;
compt=0;
label=1;

function diapobouton(sens){
	label=0;
	image=cherche(nomimg2);
	image00=cherche("diapo00");
	image01=cherche("diapo01");
	image02=cherche("diapo02");
	image03=cherche("diapo03");
	image04=cherche("diapo04");
	image05=cherche("diapo05");
	image06=cherche("diapo06");
	image07=cherche("diapo07");
	image08=cherche("diapo08");
	image09=cherche("diapo09");
	//alert("ceil="+ Math.ceil(compt/10));
	//	alert(modulo(10,compt));
	
	
	
	if(modulo(10,compt)==9 && sens==1){
	//alert("1 compt = "+compt);	
	sens=10;
	compt=compt-9;
	comptLabel=compt;
	}
	if(modulo(10,compt)==0 && sens==-1 && compt!=0){
	//alert("2");
	sens=-10;
	compt=compt+9;
	comptLabel=compt;
	}
	
	//if(modulo(10,compt)==0 && sens==1){
	//alert("3");
	//compt=compt+1;
	//}
	
	
	if(sens==1 && compt<(imgdiapo2.length-1)){
		//alert("4");
		 
		compt+=sens;
		image.src=imgdiapo2[compt][0];
		comptLabel=compt;
		
	}
	else if(sens==-1 && compt>0){
	//alert("5");
		compt+=sens;
		image.src=imgdiapo2[compt][0];
		comptLabel=compt;
	}else if(sens==10 ){//&& compt!=0
	//alert("6");
		//compt+=sens;
		compt=sens+plage;   
if((compt)<imgdiapo.length){ 
		image.src=imgdiapo2[compt][0];
 		image00.src=imgdiapo2[compt][0];
}if((compt+1)<imgdiapo.length){ 
		image01.src=imgdiapo2[compt+1][0];
}if((compt+2)<imgdiapo.length){ 
		image02.src=imgdiapo2[compt+2][0];
}if((compt+3)<imgdiapo.length){ 
		image03.src=imgdiapo2[compt+3][0];
}if((compt+4)<imgdiapo.length){ 
		image04.src=imgdiapo2[compt+4][0];
}if((compt+5)<imgdiapo.length){ 
		image05.src=imgdiapo2[compt+5][0];
}if((compt+6)<imgdiapo.length){ 
		image06.src=imgdiapo2[compt+6][0];
}if((compt+7)<imgdiapo.length){ 
		image07.src=imgdiapo2[compt+7][0];
}if((compt+8)<imgdiapo.length){ 
		image08.src=imgdiapo2[compt+8][0];
}if((compt+9)<imgdiapo.length){ 
		image09.src=imgdiapo2[compt+9][0];
}
		comptLabel=compt;
		label=1;  
		
	}else if(sens==-10 && compt!=0 && compt>10){
	//alert("7");
		//compt+=sens;
		compt=sens+plage;
	//alert("1 compt = "+compt);	
		compt=compt+9;
if((compt)<imgdiapo.length){ 
		image.src=imgdiapo2[compt][0];
}if((compt-9)<imgdiapo.length){ 
		image00.src=imgdiapo2[compt-9][0];  
}if((compt-8)<imgdiapo.length){ 
		image01.src=imgdiapo2[compt-8][0];  
}if((compt-7)<imgdiapo.length){ 
		image02.src=imgdiapo2[compt-7][0];  
}if((compt-6)<imgdiapo.length){ 
		image03.src=imgdiapo2[compt-6][0];  
}if((compt-5)<imgdiapo.length){ 
		image04.src=imgdiapo2[compt-5][0];  
}if((compt-4)<imgdiapo.length){ 
		image05.src=imgdiapo2[compt-4][0];  
}if((compt-3)<imgdiapo.length){ 
		image06.src=imgdiapo2[compt-3][0];  
}if((compt-2)<imgdiapo.length){ 
		image07.src=imgdiapo2[compt-2][0];  
}if((compt-1)<imgdiapo.length){ 
		image08.src=imgdiapo2[compt-1][0];  
}if((compt)<imgdiapo.length){ 
		image09.src=imgdiapo2[compt][0];   
}		
		//alert("c = " +compt);
		comptLabel=compt;
		label=-1;
		
		 
	}  else if(sens==-10 && compt!=0 && compt<11){
	
	
		compt=0;
		
		image.src=imgdiapo2[compt][0];
		image00.src=imgdiapo2[compt][0];  
		image01.src=imgdiapo2[compt+1][0];  
		image02.src=imgdiapo2[compt+2][0];  
		image03.src=imgdiapo2[compt+3][0];  
		image04.src=imgdiapo2[compt+4][0];  
		image05.src=imgdiapo2[compt+5][0];  
		image06.src=imgdiapo2[compt+6][0];  
		image07.src=imgdiapo2[compt+7][0];  
		image08.src=imgdiapo2[compt+8][0];  
		image09.src=imgdiapo2[compt+9][0]; 
		comptLabel=compt;   
	}  

	plage=getPlage(compt); 
	//alert(comptLabel);
if(label==1 || label==0){
addAlt(comptLabel);
}else if(label==-1){
subAlt(comptLabel); 
}

	
} 

/****************************************************************************
intialisation : init()
****************************************************************************/
function init(){
image=cherche(nomimg2);
	image00=cherche("diapo00");
	image01=cherche("diapo01");
	image02=cherche("diapo02");
	image03=cherche("diapo03");
	image04=cherche("diapo04");
	image05=cherche("diapo05");
	image06=cherche("diapo06");
	image07=cherche("diapo07");
	image08=cherche("diapo08");
	image09=cherche("diapo09");
	
		image.src=imgdiapo2[compt][0]; 
		labelImage=imgdiapo2[compt][1]; 
		image00.src=imgdiapo2[compt][0];
		image01.src=imgdiapo2[compt+1][0];
		image02.src=imgdiapo2[compt+2][0];
		image03.src=imgdiapo2[compt+3][0];
		image04.src=imgdiapo2[compt+4][0];
		image05.src=imgdiapo2[compt+5][0];
		image06.src=imgdiapo2[compt+6][0];
		image07.src=imgdiapo2[compt+7][0];
		image08.src=imgdiapo2[compt+8][0];
		image09.src=imgdiapo2[compt+9][0];
		plage=getPlage(compt); 
	//alert("plage="+plage+" compt="+compt);
	//alert ("compt="+compt);     
	
comptLabel=compt;

if(label==1){
addAlt(comptLabel);
}else{
subAlt(comptLabel); 
}
 
} 
/****************************************************************************
addAlt : addAlt()
****************************************************************************/
function addAlt(compteur){
	//	alert("compteur "+compteur);
if(comptLabel<imgdiapo.length){ 
	document.ekform.labelImage.value =imgdiapo2[comptLabel][1];  	
	document.getElementById("diapo2").alt =imgdiapo2[comptLabel][1]; 
	document.getElementById("diapo00").alt =imgdiapo2[comptLabel][1];  
}
if((comptLabel+1)<imgdiapo.length){ 
document.getElementById("diapo01").alt =imgdiapo2[comptLabel+1][1];  
}
if((comptLabel+2)<imgdiapo.length){ 
document.getElementById("diapo02").alt =imgdiapo2[comptLabel+2][1];  
}
if((comptLabel+3)<imgdiapo.length){
document.getElementById("diapo03").alt =imgdiapo2[comptLabel+3][1];  
}
if((comptLabel+4)<imgdiapo.length){
document.getElementById("diapo04").alt =imgdiapo2[comptLabel+4][1];  
}
if((comptLabel+5)<imgdiapo.length){
document.getElementById("diapo05").alt =imgdiapo2[comptLabel+5][1];  
}
if((comptLabel+6)<imgdiapo.length){
document.getElementById("diapo06").alt =imgdiapo2[comptLabel+6][1]; 
}
if((comptLabel+7)<imgdiapo.length){ 
document.getElementById("diapo07").alt =imgdiapo2[comptLabel+7][1];  
}
if((comptLabel+8)<imgdiapo.length){
document.getElementById("diapo08").alt =imgdiapo2[comptLabel+8][1]; 
}
if((comptLabel+9)<imgdiapo.length){ 
document.getElementById("diapo09").alt =imgdiapo2[comptLabel+9][1]; 
}

//alert("comptLabel= "+(comptLabel+9));
} 

function subAlt(compteur){
	
document.ekform.labelImage.value =imgdiapo2[comptLabel][1];  	

document.getElementById("diapo2").alt =imgdiapo2[comptLabel][1]; 
if(comptLabel!=0){
document.getElementById("diapo00").alt =imgdiapo2[comptLabel-9][1];  
document.getElementById("diapo01").alt =imgdiapo2[comptLabel-8][1];  
document.getElementById("diapo02").alt =imgdiapo2[comptLabel-7][1];  
document.getElementById("diapo03").alt =imgdiapo2[comptLabel-6][1];  
document.getElementById("diapo04").alt =imgdiapo2[comptLabel-5][1];  
document.getElementById("diapo05").alt =imgdiapo2[comptLabel-4][1];  
document.getElementById("diapo06").alt =imgdiapo2[comptLabel-3][1];  
document.getElementById("diapo07").alt =imgdiapo2[comptLabel-2][1];  
document.getElementById("diapo08").alt =imgdiapo2[comptLabel-1][1];  
}
document.getElementById("diapo09").alt =imgdiapo2[comptLabel][1]; 
//alert("comptLabel= "+(comptLabel));
} 
             
/****************************************************************************
_____DISPLAY : display()
****************************************************************************/
function display(newSrc, compteur){
	//alert(compteur);
plage=getPlage(compt); 
image0 =cherche(newSrc) ;

compt=plage+compteur;
//alert (compt+" "+imgdiapo2[compt]);
image = cherche("diapo2");
image.src=image0.src;    
document.ekform.labelImage.value =imgdiapo2[compt][1];      
document.getElementById("diapo2").alt =imgdiapo2[compt][1]; 	
} 

function getPlage(nbr){
nplage =10*(Math.floor(nbr/10));
return nplage;

} 
function modulo(m,x)	{
x=x%m;
return x;
}          

