﻿// Fichier JScript
//Variable Globales !!Attention aux majuscules!!
//Le test if(document.all) permet de de savoir de façon sûr si le navigateur est IE
var espace;
var r=false;
var nomImg=new String("a");
var invisible=false;
var FFOpacite = parseFloat(1);
var TimerDefil;
var TimerFondu;
var TimerDefilG;
var TimerDefilD;
var etat=10;
var Decalage;
var NomMaxImg=new String("test");
//--------------------------------------------------------------------------
function initialisation(NomPhotoMax)
{
    if (document.all)
    {
        var nbImage=document.images.length;
        nbImage=nbImage-9;
        //document.getElementById("Grand").src=document.getElementById("a").src;
        document.getElementById("FicheBien_Defilement").style.width="400px"
        document.images["Grand"].src=document.images[NomPhotoMax].src;
        document.images["Grand"].alt=document.images[NomPhotoMax].alt;
        document.images["Grand"].titre=document.images[NomPhotoMax].alt;
        Decalage=parseInt(((nbImage)*100));
        espace=0; 
        NomMaxImg=NomPhotoMax;
     }
     else
     {
        var nbImage=document.images.length;
        nbImage=nbImage-9;
        //document.getElementById("Grand").src=document.images['a'].src;
//      document.getElementById("Grand").src=document.getElementById("a").src;
        document.getElementById("FicheBien_Defilement").setAttribute("style","width:400px;"); 
        document.images["Grand"].src=document.images[NomPhotoMax].src;
        document.images["Grand"].alt=document.images[NomPhotoMax].alt;
        document.images["Grand"].titre=document.images[NomPhotoMax].alt;
        Decalage=parseInt(((nbImage)*100));
        espace=0; 
        NomMaxImg=NomPhotoMax;
     }    
}
//--------------------------------------------------------------------------
//Photo grand format à partir de la source d'une photo vignette
function recupGrandePhoto(nomphoto,a,b)
{
      var i=0
      while (i!=-1) {
         i=nomphoto.indexOf(a,i);
         if (i>=0) {
            nomphoto=nomphoto.substring(0,i)+b+nomphoto.substring(i+a.length);
            i+=b.length;
         }
      }
      return nomphoto
}
//--------------------------------------------------------------------------
//Attention!!! La fonction Defilement risque de ne pas fonctionner si vous utiliser l'attribut css 'text-align'.
//dans une balise concernée par le script. Utilisez l'attribut 'margin:auto;' dans la balise sous-jacente. 
function defilement()
{
    var retour = new Boolean(true)
    retour=r;
    //Script defilement pour Internet Explorer 5+ et Gecko (ne génère pas d'erreur pour les versions inférieures)
    var taille1=NomMaxImg.length;
    var taille2=3;
    if (taille1>taille2) 
    {
        if (document.all)
        {
            if(espace==400){espace=-800;}           
            espace++;
            document.getElementById("FicheBien_Defilement").style.marginLeft=espace+"px";  
            TimerDefil=setTimeout("defilement()",30);      
        } 
        else
        {
            if(espace==400){espace=-700;}
            espace++;   
            document.getElementById("FicheBien_Defilement").setAttribute("style","margin-left:"+espace+"px;"); 
            TimerDefil=setTimeout("defilement()", 30);   
        }
    }
             
}
//--------------------------------------------------------------------------
//Stopper le defilement
function stopDefilement()
{
        clearTimeout(TimerDefil);  
}
//--------------------------------------------------------------------------
//Defiler manuellement à gauche
function defilerGauche()
    {
        if (document.all)
        {
            if (espace>-Decalage)
            {
                espace--;
                FicheBien_Defilement.style.marginLeft=espace+"px";
                TimerDefilG=setTimeout("defilerGauche()",5); 
            }
        }
        else
        {
            if (espace>-Decalage)
            {
                espace--;
                document.getElementById("FicheBien_Defilement").setAttribute("style","margin-left:"+espace+"px;"); 
                TimerDefilG=setTimeout("defilerGauche()",5); 
            }           
        }
}
//--------------------------------------------------------------------------
//Defiler manuellement à droite
function defilerDroite()
{
    if (document.all)
    {
        if (espace<0)
        {
            espace++;
            FicheBien_Defilement.style.marginLeft=espace+"px";
            TimerDefilD=setTimeout("defilerDroite()",5); 
        }
    }
    else
    {
        if (espace<0)
        {
            espace++;
            document.getElementById("FicheBien_Defilement").setAttribute("style","margin-left:"+espace+"px;"); 
            TimerDefilD=setTimeout("defilerDroite()",5); 
        }
    }
}
//--------------------------------------------------------------------------
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["Grand"].filters.alpha.opacity--;}
        if (invisible==true){document.images["Grand"].filters.alpha.opacity++;}
        if(document.images["Grand"].filters.alpha.opacity==0)
        {
            var taille1=nomImg.length
            var taille2=NomMaxImg.length
            if (taille1>taille2){nomImg="a";}
            document.images["Grand"].src= recupGrandePhoto(document.images[nomImg].src,'Vignette','PhotoWeb');
            nomImg+="a";
            invisible=true;      
        } 
        if(document.images["Grand"].filters.alpha.opacity==100)
        {
            invisible=false;     
        }
        TimerFondu= setTimeout("fondu()",30);
    }
//Script Fondu Mozilla (fonctionne theoriquement sous Netscape et Opera)
    else
    {      
        if (invisible==false){FFOpacite-=parseFloat(0.01);document.getElementById("Grand").setAttribute("style","-moz-opacity:"+FFOpacite+";");}
        if (invisible==true){FFOpacite+=parseFloat(0.01); document.getElementById("Grand").setAttribute("style","-moz-opacity:"+FFOpacite+";");}
        if(FFOpacite<=0.05)
        {
            var taille1=nomImg.length
            var taille2=NomMaxImg.length
            if (taille1>taille2){nomImg="a";}
                document.getElementById("Grand").src=recupGrandePhoto(document.images[nomImg].src,'Vignette','PhotoWeb');
                nomImg =nomImg+"a";
                invisible=true ;        
        } 
        if(FFOpacite>=1)
        {
            FFOpacite=1;
            invisible=false;     
        }    
        TimerFondu=setTimeout("fondu()",30);   
    }
           
}
//--------------------------------------------------------------------------
//Stopper le fondu et afficher l'image grans format
function stopFondu()
{
    if (document.all)
    {
        clearTimeout(TimerFondu);
        document.images["Grand"].filters.alpha.opacity=100;
    }  
    else
    {
        clearTimeout(TimerFondu); 
        document.getElementById("Grand").setAttribute("style","-moz-opacity:1;");     
    }       
}
//--------------------------------------------------------------------------
//Applet Java
function JavaPanoramique(DivId,Code,Codebase,View,Image)
{
	var b = document.getElementById(DivId);
	var d = '<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"';
	d +=' width="240" height="200">';
	d +=' <param name="code" value="pmvr.class"/>';
	d +=' <param name="codebase" value="'+Codebase+'"/>';
	d +=' <param name="view" value="'+View+'"/>';
	d +=' <param name="image" value="'+Image+'"/>';
	d +=' <param name="auto" value="1"/>';
	d +=' <!--[if gte IE 7]> <!-->';
	d +=' <object classid="java:pmvr.class"';
	d +=' type="application/x-java-applet"';
	d +=' width="240" height="200">';
	d +=' <param name="code" value="pmvr"/>  ';
	d +=' <param name="JAVA_CODEBASE" value="'+Codebase+'"/>';
	d +=' <param name="view" value="'+View+'"/>';
	d +=' <param name="image" value="'+Image+'">';
	d +=' <param name="auto" value="1"/>';
	d +=' alt : <a href="pmvr.class">pmvr.class</a>';
	d +=' </object>';
	d +=' <!--<![endif]-->';
	d +=' <!--[if lt IE 7]>';
	d +=' alt : <a href="data/JitterText.class">JitterText.class</a>';
	d +=' <![endif]-->';
	d +=' </object>';
	
	b.innerHTML=d;
}




