﻿//Variables globales
var Img='';
var Sources=new String('');
var TabSources=new Array();
var TabImg=new Array();
var Invisible=false;
var Repertoire='';
var	Index=0;
var	FFOpacite=0;
var	FonduTimeOut;

//--------------------------------------------------------------------------
function Initialisation(pImage,pSources,pRepertoire)
{
    Img=pImage;
    Sources=pSources; 
    TabSources=Sources.split('|');
    Repertoire=pRepertoire;
	//--------------------------------------------------------------------------
   for(i=1; i<=TabSources.length-1; i++) 
	{
		preload_image_object = new Image();
		TabImg[i]=preload_image_object;
		TabImg[i].src = Repertoire+TabSources[i];	
	}
	//--------------------------------------------------------------------------
 }
//--------------------------------------------------------------------------
function Fondu()
{
//Script Fondu pour Internet Explorer 5+ et Gecko (ne génère pas d'erreur pour les versions inférieures)
    if (document.all)
    {
        if (Invisible==false){document.images[Img].filters.alpha.opacity--;}
        if (Invisible==true){document.images[Img].filters.alpha.opacity++;}
        if(document.images[Img].filters.alpha.opacity==5)
        {
            Invisible=true; 
            Index++;  
            if (Index>=(TabSources.length-1))
                {Index=0;}
            document.images[Img].src=Repertoire+TabSources[Index];
        } 
        if(document.images[Img].filters.alpha.opacity==100)
        {
            Invisible=false;     
        }
		 FonduTimeOut=setTimeout("Fondu()",30);   
    }
//Script Fondu Mozilla (fonctionne theoriquement sous Netscape et Opera)
    else
    {      
        if (Invisible==false){FFOpacite-=parseFloat(0.01);document.getElementById(Img).setAttribute("style","-moz-opacity:"+FFOpacite+";");}
        if (Invisible==true){FFOpacite+=parseFloat(0.01); document.getElementById(Img).setAttribute("style","-moz-opacity:"+FFOpacite+";");}
        if(FFOpacite<=0.05)
        {
            Invisible=true ; 
            Index++;
            if (Index>=(TabSources.length-1))
                {Index=0;}  
            document.getElementById(Img).src=Repertoire+TabSources[Index];     
        } 
        if(FFOpacite>=1)
        {
            FFOpacite=1;
            Invisible=false;     
        } 
		FonduTimeOut=setTimeout("Fondu()",5);   
    }          
}
//--------------------------------------------------------------------------
function StopFondu()
{
    clearTimeout(FonduTimeOut);
    if (document.all)
    {
        document.images[Img].filters.alpha.opacity=100;    
    }
    else
    {
        document.getElementById(Img).setAttribute("style","-moz-opacity:1;");
    }
}
//--------------------------------------------------------------------------







