// Déclaration et initialisation des variables 
 
var tab_img = new Array;    //tableau contenant les images
var num=0;                  //numéro de l'image jouée
 
//Images stockées dans le tableau       
tab_img[0] = 'images/cuisine-marocaine/recettes-de-couscous.jpg'
tab_img[1] = 'images/cuisine-marocaine/epices-marocaines.jpg'
tab_img[2] = 'images/cuisine-marocaine/patisserie-orientale.jpg'
tab_img[3] = 'images/cuisine-marocaine/pastilla.jpg'
tab_img[4] = 'images/cuisine-marocaine/tajine-de-poulet.jpg'
        
 
//Ajout d'un compte à rebours afin de jouer le diaporama
var timer_diapo=setInterval("diaporama('boite_diapo','img_diapo',500)",4000);

/* Explication des paramètres 
 
'boite_diapo' : identifiant de la boite du diaporama. NE PAS MODIFIER
'img_diapo'   : identifiant de l'image contenu dans la boite diaporama. NE PAS MODIFIER.
500           : temps (en milliseconde) de l'effet fondu entre 2 images. 1 seconde = 1000 millisecondes.
7000          : interval de temps entre 2 images. 1 seconde = 1000 millisecondes.
        
*/
 
//Fonction qui permet de jouer le diaporama
function diaporama(divid, imageid, millisec) 
{ 
var speed = Math.round(millisec / 100);
var timer = 0;
document.getElementById(divid).style.backgroundImage = "url(" + tab_img[num] + ")"; 
 
changeOpac(0, imageid); 
 
if (num>(tab_img.length-2))
{num = -1;}
 
document.getElementById(imageid).style.backgroundImage = "url(" + tab_img[num+1] + ")"; 
           
for(i = 0; i <= 100; i++)
{ 
	setTimeout("changeOpac(" + i + ",'" + imageid+ "')",(timer * speed)); 
  timer++; 
} 
   
num++;
 
}
 
//Fonction qui attribue l'opacité à l'objet "image_diapo"
function changeOpac(opacity, id) 
{
	var object = document.getElementById(id).style;
  Object.opacity = (opacity / 100);
  Object.MozOpacity = (opacity / 100);
  Object.KhtmlOpacity = (opacity / 100);
  Object.filter = "alpha(opacity=" + opacity + ")";
}
