var curX;
var curY;
var objetdrag;

function getPositionCurseur(e){
 curX=0;
 curY=0;

if(!e) e = window.event;
  if(e.pageX) // selon le navigateur (ici pour firefox et peut-être autre...)
 {
 curX = e.pageX;
 curY = e.pageY;
 }
 else if(e.clientX) // (ici pour Internet Explorer et peut-être autre...)
 {
 curX = e.clientX;
 curY = e.clientY;
 }
 else // (ici pour Internet Explorer et peut-être autre...)
 {
 curX = e.x;
 curY = e.y;
 } 
 //window.status=curX+" "+curY;
}

function definiOpacite(elt,valopacite){

	if(elt){
		elt.style.opacity = valopacite/100;
		elt.style.filter = 'alpha(opacity=' + valopacite + ')';
	}

}

function retournePosTailleElement(elt){
var iLargeur="0";
if(elt.offsetWidth){
	iLargeur=elt.offsetWidth;
}
else{
	if(elt.clip){
		iLargeur=elt.clip.width; 
	}

}

var iHauteur="0";
if(elt.offsetHeight){
	iHauteur=elt.offsetHeight;
}
else{
	if(elt.clip){
		iHauteur=elt.clip.height; 
	}

}

var iDessus="0";
if(elt.offsetTop){
	iDessus=elt.offsetTop; 
}
else{
	if(elt.style){
		if(elt.style.top){
			iDessus=elt.style.top;
		}
		else{
			if(elt.style.pixelTop){
				iDessus=elt.style.pixelTop; 
			}

		}
	}
}

var iGauche="0";
if(elt.offsetLeft){
	iGauche=elt.offsetLeft; 
}
else{
	if(elt.style){
		if(elt.style.left){
			iGauche=elt.style.left;
		}
		else{
			if(elt.style.pixelLeft){
				iGauche=elt.style.pixelLeft; 
			}

		}
	}
}

var obj={'Gauche':iGauche,'Dessus':iDessus,'Hauteur':iHauteur,'Largeur':iLargeur};
return(obj);
}


function retournePosTailleElementFenetrePere(elt){
	var PosElt=retournePosTailleElement(elt);

	var posX = 0, posY = 0;
	var eltPcrt=elt;
    do
    {
        posX += eltPcrt.offsetLeft;
        posY += eltPcrt.offsetTop;
        eltPcrt = eltPcrt.offsetParent;
    }
    while( eltPcrt != null );

	PosElt.Gauche=posX+"px";
	PosElt.Dessus=posY+"px";
	
	return(PosElt);
}

function attenteDe(nMiliseconde,seccrt){
if(seccrt<nMiliseconde){
	var nvseccrt=seccrt+10;
	var cmd="attenteDe("+nMiliseconde+","+nvseccrt +")";
	setTimeout(cmd,10);
}
}

function retourneImageRatioRespecteEtCentre(lgContaineur,htContaineur,lgImage,htImage){
var lgMax=parseInt(lgContaineur);
var htMax=parseInt(htContaineur);
var iLargeur=parseInt(lgImage);
var iHauteur=parseInt(htImage);
if(iLargeur>lgMax){
	iHauteur=Math.round(lgMax/iLargeur*iHauteur);
	iLargeur=lgMax;
}
if(iHauteur>htMax){
	iLargeur=Math.round(htMax/iHauteur*iLargeur);
	iHauteur=htMax;
}

var iDessus=Math.round((htMax-iHauteur)/2);
var	iGauche=Math.round((lgMax-iLargeur)/2);
var Facteur=iLargeur/parseInt(lgImage);
	
var obj={'Gauche':iGauche,'Dessus':iDessus,'Hauteur':iHauteur,'Largeur':iLargeur,'Facteur':Facteur};
return(obj);
}



function retournePosTailleElementFenetrePere(elt){
	var PosElt=retournePosTailleElement(elt);
	var posX = 0, posY = 0;
	var eltPcrt=elt;
    do
    {
        posX += eltPcrt.offsetLeft;
        posY += eltPcrt.offsetTop;
        eltPcrt = eltPcrt.offsetParent;
    }
    while( eltPcrt != null );
 
	PosElt.Gauche=posX+"px";
	PosElt.Dessus=posY+"px";
	
	return(PosElt);
}

/******************************************************************************************
*
*
*                             Deplacer un objet en fct de la position de la souris
*
*
******************************************************************************************/
/* Positionne une info bulle en tenant en compte sa taille ainsi que la taille de l'ecran */
function positionneInfoBulleDansEcran(eltInfoBulle){

var posTailElt=retournePosTailleElement(eltInfoBulle);
var xtl,ytl,xbr,ybr;
xtl=curX+10;
ytl=curY+10;
xbr=xtl+posTailElt.Largeur;
ybr=ytl+posTailElt.Hauteur;
if(xbr>screen.width){
	xtl=xtl-(xbr-screen.width);
}
if(ybr>screen.height){
	ytl=ytl-(ybr-screen.height);
}

eltInfoBulle.style.left=xtl+"px";
eltInfoBulle.style.top=ytl+"px";
}

/******************************************************************************************
*
*
*                               ZONE D INTERACTION
*
*
******************************************************************************************/
ClasseZoneIntercation = function(x,y,lg,ht,action) {
	this.init(x,y,lg,ht,action);
}


ClasseZoneIntercation.prototype.init = function(x,y,lg,ht,action){
this.setX(x);
this.setY(y);
this.setLargeur(lg);
this.setHauteur(ht);
this.setAction(action);
this.setFacteur(1);
}

ClasseZoneIntercation.prototype.getX = function() {
	return this.x;
}
ClasseZoneIntercation.prototype.setX = function(val) {
	this.x = val;
}

ClasseZoneIntercation.prototype.getY = function() {
	return this.y;
}
ClasseZoneIntercation.prototype.setY = function(val) {
	this.y = val;
}

ClasseZoneIntercation.prototype.getLargeur = function() {
	return this.largeur;
}
ClasseZoneIntercation.prototype.setLargeur = function(val) {
	this.largeur = val;
}

ClasseZoneIntercation.prototype.getHauteur = function() {
	return this.hauteur;
}
ClasseZoneIntercation.prototype.setHauteur = function(val) {
	this.hauteur = val;
}

ClasseZoneIntercation.prototype.getAction = function() {
	return this.action;
}
ClasseZoneIntercation.prototype.setAction = function(val) {
	this.action = val;
}

ClasseZoneIntercation.prototype.getFacteur = function() {
	return this.fact;
}
ClasseZoneIntercation.prototype.setFacteur = function(val) {
	this.fact = val;
}

ClasseZoneIntercation.prototype.getElement = function() {
	return this.eltzi;
}
ClasseZoneIntercation.prototype.setElement = function(val) {
	this.eltzi = val;
}


ClasseZoneIntercation.prototype.definiTailleZone= function(Facteur){
	
	this.x=parseInt(Facteur*this.x);
	this.y=parseInt(Facteur*this.y);
	this.largeur=parseInt(Facteur*this.largeur);
	this.hauteur=parseInt(Facteur*this.hauteur);
}

ClasseZoneIntercation.prototype.afficheZone= function(){
var elt=this.getElement();
elt.style.top=parseInt(this.fact*this.y)+"px";
elt.style.left=parseInt(this.fact*this.x)+"px";
elt.style.width=parseInt(this.fact*this.largeur)+"px";
elt.style.height=parseInt(this.fact*this.hauteur)+"px";

}

/******************************************************************************************
*
*
*                               PHOTO POUR EFFET VISUEL
*
*
******************************************************************************************/
ClassePhotoFilm = function(id,chemin,action) {
	this.init(id,chemin,action);
}

ClassePhotoFilm.prototype.init = function(id,chemin,action){
this.setId(id);
this.setChemin(chemin);
//recuperation des dimensions de la photo pour recalculer sa taille
var imgcrt=new Image();
imgcrt.src=chemin;
var that=this;
imgcrt.onerror = function (evt) {
  that.setEnErreur(true);
}
this.setImage(imgcrt);
this.setOpacite(100);
this.setAAffiche(false);
this.setAction(action);
this.setPositionZ(1);
this.listezonesintercations=new Array();
this.setOnClick("");
this.setEnErreur(false);
}

ClassePhotoFilm.prototype.getId = function() {
	return this.id;
}
ClassePhotoFilm.prototype.setId = function(val) {
	this.id = val;
}

ClassePhotoFilm.prototype.getChemin = function() {
	return this.chemin;
}
ClassePhotoFilm.prototype.setChemin = function(val) {
	this.chemin = val;
}

ClassePhotoFilm.prototype.getAction = function() {
	return this.actioncrt;
}
ClassePhotoFilm.prototype.setAction = function(val) {
	this.actioncrt = val;
}

ClassePhotoFilm.prototype.executeAction = function() {
	var actionAexec=this.getAction();
	if(actionAexec!=""){
		eval(actionAexec);
	}
}

ClassePhotoFilm.prototype.getOpacite = function() {
	return this.opacite;
}
ClassePhotoFilm.prototype.setOpacite = function(val) {
	this.opacite = val;
}

ClassePhotoFilm.prototype.setOpaciteDelta= function(delta,dimbordure) {

	if(dimbordure==0){
		pctOpac=100;
	}
	else{
		var pctOpac=100+Math.round(delta*100/dimbordure);
		if(pctOpac>95) pctOpac=100;
	}
	this.opacite = pctOpac;
}

ClassePhotoFilm.prototype.getImage = function() {
	return this.image;
}
ClassePhotoFilm.prototype.setImage = function(val) {
	this.image = val;
}

ClassePhotoFilm.prototype.getX = function() {
	return this.x;
}
ClassePhotoFilm.prototype.setX = function(val) {
	this.x = val;
}

ClassePhotoFilm.prototype.getY = function() {
	return this.y;
}
ClassePhotoFilm.prototype.setY = function(val) {
	this.y = val;
}

ClassePhotoFilm.prototype.getAngle = function() {
	return this.angle;
}
ClassePhotoFilm.prototype.setAngle = function(val) {
	this.angle = val;
}

ClassePhotoFilm.prototype.getAAffiche = function() {
	return this.affiche;
}
ClassePhotoFilm.prototype.setAAffiche = function(val) {
	this.affiche = val;
	
}

ClassePhotoFilm.prototype.getHauteurImage = function() {
	return this.image.height;
}

ClassePhotoFilm.prototype.getLargeurImage = function() {
	return this.image.width;
}


ClassePhotoFilm.prototype.getHauteur = function() {
	return this.hauteur;
}

ClassePhotoFilm.prototype.setHauteur = function(val) {
	this.hauteur = val;
}

ClassePhotoFilm.prototype.getLargeur = function() {
	return this.largeur;
}

ClassePhotoFilm.prototype.setLargeur = function(val) {
	this.largeur = val;
}

ClassePhotoFilm.prototype.getHauteurAffichage = function() {
	return this.hauteuraff;
}

ClassePhotoFilm.prototype.setHauteurAffichage = function(val) {
	this.hauteuraff = val;
}

ClassePhotoFilm.prototype.getLargeurAffichage = function() {
	return this.largeuraff;
}

ClassePhotoFilm.prototype.setLargeurAffichage = function(val) {
	this.largeuraff = val;
}

ClassePhotoFilm.prototype.getElementImage = function() {
	return this.eltimage;
}
ClassePhotoFilm.prototype.setElementImage = function(val) {
	this.eltimage = val;
}

ClassePhotoFilm.prototype.getElementGroupe = function() {
	return this.eltgroupe;
}
ClassePhotoFilm.prototype.setElementGroupe = function(val) {
	this.eltgroupe = val;
}

ClassePhotoFilm.prototype.getPositionZ = function() {
	return this.positionz;
}

ClassePhotoFilm.prototype.setPositionZ = function(val) {
	this.positionz = val;
}

ClassePhotoFilm.prototype.getOnClick = function() {
	return this.onclick;
}

ClassePhotoFilm.prototype.setOnClick = function(val) {
	this.onclick = val;
}

ClassePhotoFilm.prototype.getAfficheCompletement = function() {
	return this.affichecompletement;
}

ClassePhotoFilm.prototype.setAfficheCompletement = function(val) {
	this.affichecompletement = val;
}

ClassePhotoFilm.prototype.setEnErreur = function(val) {
	this.erreurChrg = val;
}

ClassePhotoFilm.prototype.getEnErreur = function() {
	return this.erreurChrg;
}

ClassePhotoFilm.prototype.getZonesInteractions = function() {
	
	return this.listezonesintercations;
}

ClassePhotoFilm.prototype.ajouteZoneInteraction = function(x,y,lg,ht,action) {
	var MaZone= new ClasseZoneIntercation(x,y,lg,ht,action);
	this.listezonesintercations[this.listezonesintercations.length]=MaZone;
}


ClassePhotoFilm.prototype.definiTailleImage = function(Containeur) {
	var hImag=Containeur.getHauteurPhoto();
	var lImag=Containeur.getLargeurPhoto();
	
	var lIm=this.getLargeurImage();
	var hIm=this.getHauteurImage();
	
	var imgratio=retourneImageRatioRespecteEtCentre(lImag,hImag,lIm,hIm);

	this.setLargeur(imgratio.Largeur);
	this.setHauteur(imgratio.Hauteur);
	this.setLargeurAffichage(imgratio.Largeur);
	this.setHauteurAffichage(imgratio.Hauteur);
	this.setY(imgratio.Dessus);
	this.setX(imgratio.Gauche);
	
	var eltim=this.getElementImage();
	eltim.style.width=this.getLargeurAffichage()+"px";
	eltim.style.height=this.getHauteurAffichage()+"px";
	
	eltim=this.getElementGroupe();
	eltim.style.width=this.getLargeurAffichage()+"px";
	eltim.style.height=this.getHauteurAffichage()+"px";
	
	var leszonesinter=this.getZonesInteractions();
	for(var j=0;j<leszonesinter.length;j++){
		leszonesinter[j].definiTailleZone(imgratio.Facteur);
	}
	
}

ClassePhotoFilm.prototype.positionImageAOrigine= function(GestionairePhoto){
switch(GestionairePhoto.getTypeEnchainement()){
case GestionairePhoto.DEPLACEMENT:
	if(GestionairePhoto.sensDpctVertical()){
		if(GestionairePhoto.getPasDefilFctSens()>0){
			this.setY(-1*this.getHauteur()-5);
		}
		else{
			this.setY(GestionairePhoto.getHauteur()+5);
		}
	}
	else{
		if(GestionairePhoto.getPasDefilFctSens()>0){
			this.setX(-1*this.getLargeur()-5);
		}
		else{
			this.setX(GestionairePhoto.getLargeur()+5);
		}
	}
	this.setAfficheCompletement(false);
	break;
case GestionairePhoto.CLIGNOTEMENT:
case GestionairePhoto.FONDU:
	this.setOpacite(0);
	break;
}
this.afficheImage(GestionairePhoto);
}

ClassePhotoFilm.prototype.initialisePhoto= function(GestionairePhoto) {
	//Duplique l image pour conserver sa taille initiale
	this.getElementImage().src=this.getImage().src;
	this.definiTailleImage(GestionairePhoto);
	this.positionImageAOrigine(GestionairePhoto);
}



ClassePhotoFilm.prototype.afficheImage= function(GestionairePhoto){

var eltim=this.getElementImage();
var eltgrp=this.getElementGroupe();
eltgrp.style.top=this.getY()+"px";
eltgrp.style.left=this.getX()+"px";
eltgrp.style.width=this.getLargeurAffichage()+"px";
eltgrp.style.height=this.getHauteurAffichage()+"px";
eltim.style.width=this.getLargeurAffichage()+"px";
eltim.style.height=this.getHauteurAffichage()+"px";
eltgrp.style.zIndex =this.getPositionZ();
eltim.style.zIndex =this.getPositionZ();

if(this.getAAffiche()){
	eltgrp.style.visibility="visible";
	var leszonesinter=this.getZonesInteractions();
	for(var j=0;j<leszonesinter.length;j++){
		leszonesinter[j].afficheZone();
	}
}
else{
	eltgrp.style.visibility="hidden";
}	
	
definiOpacite(eltim,this.getOpacite());
}

ClassePhotoFilm.prototype.fonduImage= function(GestionairePhoto,Pas) {
var affichecompletement=0;
var Opacrt=this.getOpacite();
Opacrt=Opacrt+Pas;
if(Opacrt>100){
	Opacrt=100;
	affichecompletement=1;
}
if(Opacrt<0){
	Opacrt=0;
	affichecompletement=2;
}

this.setOpacite(Opacrt);
this.afficheImage(GestionairePhoto);
return(affichecompletement);
}

ClassePhotoFilm.prototype.clignoteImage= function(GestionairePhoto) {
var affichecompletement=0;
affichecompletement=this.fonduImage(GestionairePhoto,GestionairePhoto.getPasDefilFctSens());
if(affichecompletement==1){
	GestionairePhoto.setPasDefil(-1*GestionairePhoto.getPasDefilFctSens());
}
if(affichecompletement==2){
	GestionairePhoto.setPasDefil(-1*GestionairePhoto.getPasDefilFctSens());
}

return(affichecompletement);
}


ClassePhotoFilm.prototype.deplaceImage = function(GestionairePhoto,alalimiteseulement) {
var pos,posfin;
var dimcnt;
var affichecompletement=false;
var atteintbord=false;
var imageVisible=false;
var obj;

if(GestionairePhoto.sensDpctVertical()){
	//gestion de l opacite
	pos=this.getY();
	dimcnt=GestionairePhoto.getHauteur();

	pos=pos+GestionairePhoto.getPasDefilFctSens();
	this.setY(pos);
	posfin=pos+this.getHauteur();
}
else{
	pos=this.getX();
	dimcnt=GestionairePhoto.getLargeur();

	pos=pos+GestionairePhoto.getPasDefilFctSens();
	this.setX(pos);
	posfin=pos+this.getLargeur();
	
}


	
var delta=GestionairePhoto.getDimensionBordure()-pos;
if(Math.abs(delta)<=Math.abs(GestionairePhoto.getPasDefil())){
	this.executeAction();
}
if(GestionairePhoto.getPasDefilFctSens()>0){
	if(pos>=dimcnt){
		this.positionImageAOrigine(GestionairePhoto);
		
		this.setAAffiche(false);
	}
	if((!this.getAfficheCompletement())&&(this.getAAffiche())){
		if(alalimiteseulement){
			if(Math.abs(pos)<=Math.abs(GestionairePhoto.getPasDefil())){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
		else{
			if(pos>=0){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
	}
	if((posfin-dimcnt>=0)&&(Math.abs(posfin-dimcnt)<=Math.abs(GestionairePhoto.getPasDefil()))){
		atteintbord=true;
	}
}
else{
	if(posfin<=0){
		this.positionImageAOrigine(GestionairePhoto);
		
		this.setAAffiche(false);
	}
	if((!this.getAfficheCompletement())&&(this.getAAffiche())){
		if(alalimiteseulement){
			if(Math.abs(posfin-dimcnt)<=Math.abs(GestionairePhoto.getPasDefil())){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
		else{
			if(posfin<=dimcnt){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
	}
	if((pos<=0)&&(Math.abs(pos)<=Math.abs(GestionairePhoto.getPasDefil()))){
		atteintbord=true;
	}
}
this.afficheImage(GestionairePhoto);

obj={'affichecompletement':affichecompletement,'atteintbord':atteintbord};
return(obj);

}



ClassePhotoFilm.prototype.deplaceImageDiapo = function(GestionairePhoto,alalimiteseulement) {
var pos,posfin;
var dimcnt;
var dimphoto;
var affichecompletement=false;
var atteintbord=false;
var disparueCompletement=false;

var obj;

if(GestionairePhoto.sensDpctVertical()){
	//gestion de l opacite
	pos=this.getY();
	dimcnt=GestionairePhoto.getHauteur();
	dimphoto=this.getHauteur();

	pos=pos+GestionairePhoto.getPasDefilFctSens();
	this.setY(pos);
	posfin=pos+this.getHauteur();
}
else{
	pos=this.getX();
	dimcnt=GestionairePhoto.getLargeur();
	dimphoto=this.getLargeur();
	pos=pos+GestionairePhoto.getPasDefilFctSens();
	this.setX(pos);
	posfin=pos+this.getLargeur();
	
}
var affichePrec=this.getAAffiche();
var affact=((pos+dimphoto>0)&&(pos<dimcnt));
this.setAAffiche(affact);

if(affichePrec){
	disparueCompletement=((pos+dimphoto<0)||(pos>=dimcnt));
	if(disparueCompletement){
		this.setAfficheCompletement(false);
	}
}
	
var delta=GestionairePhoto.getDimensionBordure()-pos;
if(Math.abs(delta)<=Math.abs(GestionairePhoto.getPasDefil())){
	this.executeAction();
}
if(GestionairePhoto.getPasDefilFctSens()>0){
	if((!this.getAfficheCompletement())&&(this.getAAffiche())){
		if(alalimiteseulement){
			if(Math.abs(pos)<=Math.abs(GestionairePhoto.getPasDefil())){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
		else{
			if(pos>=0){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
	}
	if((posfin-dimcnt>=0)&&(Math.abs(posfin-dimcnt)<=Math.abs(GestionairePhoto.getPasDefil()))){
		atteintbord=true;
	}
}
else{
	if((!this.getAfficheCompletement())&&(this.getAAffiche())){
		if(alalimiteseulement){
			if(Math.abs(posfin-dimcnt)<=Math.abs(GestionairePhoto.getPasDefil())){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
		else{
			if(posfin<=dimcnt){
				affichecompletement=true;
				this.setAfficheCompletement(true);
			}
		}
	}
	if((pos<=0)&&(Math.abs(pos)<=Math.abs(GestionairePhoto.getPasDefil()))){
		atteintbord=true;
	}
}
this.afficheImage(GestionairePhoto);

obj={'affichecompletement':affichecompletement,'disparueCompletement' :disparueCompletement,'atteintbord':atteintbord};
return(obj);

}


ClassePhotoFilm.prototype.retourneOpaciteImageEllipse = function(GestionairePhoto,y) {
var Facteur=1;
var yR=GestionairePhoto.getYRellipse();
var a=-1/(2*yR-GestionairePhoto.getCorrectionYOpaciteEllipse());
var b=-a*(yR-GestionairePhoto.getCorrectionYOpaciteEllipse());
Facteur=a*y+b;
if(Facteur<0.3){
	Facteur=0.3;
}

return(Facteur);
}


ClassePhotoFilm.prototype.afficheImageSurEllipse = function(GestionairePhoto) {
var angle=Math.PI*this.getAngle()/180;

var xR=GestionairePhoto.getXRellipse();
var yR=GestionairePhoto.getYRellipse();

//calcul du rayon inutile si parametrique
//var exc=Math.sqrt(xR*xR-yR*yR);
//exc=exc/xR;
//var ray=Math.sqrt(yR*yR/(1-(exc*exc*Math.cos(angle)*Math.cos(angle))));
//var x=Math.round(ray*Math.cos(angle));
//var y=Math.round(ray*Math.sin(angle));

var x=Math.round(xR*Math.cos(angle));
var y=Math.round(yR*Math.sin(angle));

//Calcul ici du facteur de taille et d opacite
var Facteur=GestionairePhoto.retourneFacteurPhotoEllipse(y);
var dimXphoto=Math.round(this.getLargeur()*Facteur);
var dimYphoto=Math.round(this.getHauteur()*Facteur);
var posz=yR-y+1;
this.setPositionZ(posz);
this.setLargeurAffichage(dimXphoto);
this.setHauteurAffichage(dimYphoto);


Facteur= this.retourneOpaciteImageEllipse(GestionairePhoto,y);
this.setOpacite(Math.round(Facteur*100));

x=Math.round(x-dimXphoto/2);
//Positionnement dans le bon repere
x=Math.round(GestionairePhoto.getLargeur()/2+x);
//y=Math.round(GestionairePhoto.getHauteur()/2-y);
y=Math.round(yR-y);


this.setX(x);
this.setY(y);

var leszonesinter=this.getZonesInteractions();
for(var j=0;j<leszonesinter.length;j++){
	leszonesinter[j].setFacteur(Facteur);
}

this.afficheImage(GestionairePhoto);
}

ClassePhotoFilm.prototype.deplaceImageSurEllipse = function(GestionairePhoto) {
var angle;
var affichecompletement=false;

angle=this.getAngle()+GestionairePhoto.getPasDefilFctSens();
if(angle<0){
	angle=360+angle;
}
if(angle>360){
	angle=angle-360;
}
//L image se retouve au premier plan
if(Math.abs(270-angle)<Math.abs(GestionairePhoto.getPasDefil()/2)){
	affichecompletement=true;
	this.executeAction();
	//angle=270;
}
this.setAngle(angle);
this.afficheImageSurEllipse(GestionairePhoto);
return(affichecompletement);
}

/******************************************************************************************
*
*
*                               GESTION DE L ENSEMBLE DES PHOTOS POUR EFFET VISUEL
*
*
******************************************************************************************/

ClasseEnchainementPhotos = function(id,documentCrt,nomcontaineur) {
	this.init(id,documentCrt,nomcontaineur);
}

ClasseEnchainementPhotos.prototype.init = function(id,documentCrt,nomcontaineur) {
this.setDocumentCourant(documentCrt);
this.setLimiteChargement(0);
if(this.elementPresentHTML(nomcontaineur)){
	var eltcont=documentCrt.getElementById(nomcontaineur);
	this.setId(id);
	eltcont.style.overflow="hidden";
	
	this.setContaineur(eltcont);
	
	this.setDimensionBordure(0);
	this.listephotos=new Array();
	this.setIndicePhotoCourante(0);
	this.setNbPhotos(0);
	this.setTempsDefil(5);
	this.setEtatAttente(false);
	this.setTempsAttente(0);
	this.setTypeEnchainement(this.DEPLACEMENT);
	
	this.setPasDefil(1);
	this.setBtGaucheEllipse(null);
	this.setBtDroiteEllipse(null);
	//Pour determination automatique
	this.setXRellipse(-1);
	this.setYRellipse(-1);
	this.setOffsetBtEllipse(0);
	this.setEcartEntrePhotos(0);
	this.setCorrectionYOpaciteEllipse(0);
	this.setDeplacementContinue(true);
	
	
}
}

ClasseEnchainementPhotos.prototype.DEPLACEMENT=1;
ClasseEnchainementPhotos.prototype.CLIGNOTEMENT=2;
ClasseEnchainementPhotos.prototype.ELLIPSE=3;
ClasseEnchainementPhotos.prototype.FONDU=4;
ClasseEnchainementPhotos.prototype.DIAPORAMA=5;
ClasseEnchainementPhotos.prototype.BLOCPARBLOC=6;

ClasseEnchainementPhotos.prototype.SENSBASVERSHAUT=0;
ClasseEnchainementPhotos.prototype.SENSHAUTVERSBAS=1;
ClasseEnchainementPhotos.prototype.SENSDROITEVERSGAUCHE=2;
ClasseEnchainementPhotos.prototype.SENSGAUCHEVERSDROITE=3;

ClasseEnchainementPhotos.prototype.getId = function() {
	return this.id;
}
ClasseEnchainementPhotos.prototype.setId = function(val) {
	this.id = val;
}

ClasseEnchainementPhotos.prototype.getTypeEnchainement = function() {
	return this.typeenchainement;
}
ClasseEnchainementPhotos.prototype.setTypeEnchainement = function(val) {
	this.typeenchainement= val;
}


ClasseEnchainementPhotos.prototype.getSensDeplacement = function() {
	return this.sensdeplacement;
}
ClasseEnchainementPhotos.prototype.setSensDeplacement = function(val) {
	this.sensdeplacement= val;
}

ClasseEnchainementPhotos.prototype.getEcartEntrePhotos = function() {
	return this.ecartEntPhoto;
}
ClasseEnchainementPhotos.prototype.setEcartEntrePhotos = function(val) {
	this.ecartEntPhoto= val;
}


ClasseEnchainementPhotos.prototype.getDeplacementContinue = function() {
	return this.deplacementcontinue;
}
ClasseEnchainementPhotos.prototype.setDeplacementContinue = function(val) {
	this.deplacementcontinue= val;
}

ClasseEnchainementPhotos.prototype.sensDpctVertical = function() {
	var res=true;
	if((this.getSensDeplacement()==this.SENSDROITEVERSGAUCHE)||(this.getSensDeplacement()==this.SENSGAUCHEVERSDROITE)){
		res=false;
	}
	return(res);
}

ClasseEnchainementPhotos.prototype.getContaineur= function() {
	return this.containeur;
}
ClasseEnchainementPhotos.prototype.setContaineur = function(val) {
	this.containeur = val;
}


ClasseEnchainementPhotos.prototype.getDimensionBordure= function() {
	return this.dimensionbordure;
}
ClasseEnchainementPhotos.prototype.setDimensionBordure = function(val) {
	this.dimensionbordure = val;
}

ClasseEnchainementPhotos.prototype.getListePhotos= function() {
	return this.listephotos;
}

ClasseEnchainementPhotos.prototype.getNbPhotos= function() {
	return this.nbphotos;
}
ClasseEnchainementPhotos.prototype.setNbPhotos = function(val) {
	this.nbphotos = val;
}


ClasseEnchainementPhotos.prototype.getLargeur= function() {
	return this.largeur;
}
ClasseEnchainementPhotos.prototype.setLargeur = function(val) {
	this.largeur = val;
}

ClasseEnchainementPhotos.prototype.getHauteur= function() {
	return this.hauteur;
}
ClasseEnchainementPhotos.prototype.setHauteur = function(val) {
	this.hauteur = val;
}

ClasseEnchainementPhotos.prototype.getXRellipse= function() {
	return this.xRellipse;
}
ClasseEnchainementPhotos.prototype.setXRellipse = function(val) {
	this.xRellipse = val;
}
ClasseEnchainementPhotos.prototype.getYRellipse= function() {
	return this.yRellipse;
}
ClasseEnchainementPhotos.prototype.setYRellipse = function(val) {
	this.yRellipse = val;
}


ClasseEnchainementPhotos.prototype.getBtGaucheEllipse= function() {
	return this.btgauche;
}
ClasseEnchainementPhotos.prototype.setBtGaucheEllipse = function(val) {
	this.btgauche = val;
}

ClasseEnchainementPhotos.prototype.getBtDroiteEllipse= function() {
	return this.btdroit;
}
ClasseEnchainementPhotos.prototype.setBtDroiteEllipse = function(val) {
	this.btdroit = val;
}

ClasseEnchainementPhotos.prototype.getOffsetBtEllipse= function() {
	return this.offposbt;
}
ClasseEnchainementPhotos.prototype.setOffsetBtEllipse = function(val) {
	this.offposbt = val;
}


ClasseEnchainementPhotos.prototype.getCorrectionYOpaciteEllipse= function() {
	return this.coryopa;
}
ClasseEnchainementPhotos.prototype.setCorrectionYOpaciteEllipse = function(val) {
	this.coryopa = val;
}


ClasseEnchainementPhotos.prototype.getLargeurPhoto= function() {
	return this.largeurphoto;
}

ClasseEnchainementPhotos.prototype.setLargeurPhoto = function(val) {
	this.largeurphoto = val;
}

ClasseEnchainementPhotos.prototype.getHauteurPhoto= function() {
	return this.hauteurphoto;
}

ClasseEnchainementPhotos.prototype.setHauteurPhoto = function(val) {
	this.hauteurphoto = val;
}

ClasseEnchainementPhotos.prototype.getTempsDefil = function() {
	return this.tempsdefil;
}
ClasseEnchainementPhotos.prototype.setTempsDefil = function(val) {
	this.tempsdefil = val;
}

ClasseEnchainementPhotos.prototype.getTempsAttente = function() {
	return this.tempsattente;
}
ClasseEnchainementPhotos.prototype.setTempsAttente = function(val) {
	this.tempsattente = val;
}


ClasseEnchainementPhotos.prototype.getEtatAttente = function() {
	return this.etatattente;
}
ClasseEnchainementPhotos.prototype.setEtatAttente = function(val) {
	this.etatattente = val;
}

ClasseEnchainementPhotos.prototype.getTempsFonction = function() {
	var tps=this.getTempsDefil();
	if(this.getEtatAttente()){
		if(this.getTempsAttente()!=0){
			tps=this.getTempsAttente();
		}
		this.setEtatAttente(false);
	}
	return tps;
}

ClasseEnchainementPhotos.prototype.getPasDefil = function() {
	return this.pasdefil;
}
ClasseEnchainementPhotos.prototype.setPasDefil = function(val) {
	this.pasdefil = val;
}

ClasseEnchainementPhotos.prototype.getPasDefilFctSens= function() {
	var dPas=this.getPasDefil();
	if((this.getSensDeplacement()==this.SENSDROITEVERSGAUCHE)||(this.getSensDeplacement()==this.SENSBASVERSHAUT)){
		dPas=dPas*-1;
	}
	return(dPas);
}


ClasseEnchainementPhotos.prototype.getLimiteSup= function() {
	return this.limitesup;
}
ClasseEnchainementPhotos.prototype.setLimiteSup = function(val) {
	this.limitesup= val;
}

ClasseEnchainementPhotos.prototype.getEtiquetteProgression= function() {
	return this.etiquetteprog;
}
ClasseEnchainementPhotos.prototype.setEtiquetteProgression = function(val) {
	this.etiquetteprog = val;
}

ClasseEnchainementPhotos.prototype.getIndicePhotoCourante= function() {
	return this.indicephtcrt;
}
ClasseEnchainementPhotos.prototype.setIndicePhotoCourante = function(val) {
	this.indicephtcrt= val;
}

ClasseEnchainementPhotos.prototype.getTimer= function() {
	return this.timeranim;
}
ClasseEnchainementPhotos.prototype.setTimer = function(val) {
	this.timeranim= val;
}

ClasseEnchainementPhotos.prototype.getDocumentCourant= function() {
	return this.documentTravailCrt;
}
ClasseEnchainementPhotos.prototype.setDocumentCourant = function(val) {
	this.documentTravailCrt= val;
}

ClasseEnchainementPhotos.prototype.getLimiteChargement= function() {
	return this.limiteChg;
}
ClasseEnchainementPhotos.prototype.setLimiteChargement = function(val) {
	this.limiteChg= val;
}

ClasseEnchainementPhotos.prototype.retournIndicePhotoPrecedente = function(iIndiceCrt) {
	var indicephoto=iIndiceCrt-1;
	if(indicephoto<0){
		indicephoto=this.getListePhotos().length-1;
	}
	return indicephoto;
}
ClasseEnchainementPhotos.prototype.retournIndicePhotoSuivante = function(iIndiceCrt) {
	var indicephoto=iIndiceCrt+1;
	if(indicephoto>=this.getListePhotos().length){
		indicephoto=0;
	}
	return indicephoto;
}

ClasseEnchainementPhotos.prototype.retourneFacteurPhotoEllipse= function(y){
	var yR=this.getYRellipse();
	
	return(1-(yR+y)/(2*yR)*0.7);
}

ClasseEnchainementPhotos.prototype.retournPostionPlusBasseEllipse= function(){
	var pos=0;
	for(i=0;i<this.getNbPhotos();i++){
		var photoCrt=this.getListePhotos()[i];
		if(i==0){
			pos=photoCrt.getHauteur();
		}
		else{
			if(photoCrt.getHauteur()>pos){
				pos=photoCrt.getHauteur();
			}
		}
	
	}
	//Ajout de la position Y du bas de l ellipse
	pos=pos+2*this.getYRellipse()
	return(pos);
}


ClasseEnchainementPhotos.prototype.determineDimensionIdealeEllipse=function (){

if((this.getYRellipse()==-1)||(this.getXRellipse()==-1)){
	var lesDonneesPhoto=this.getListePhotos();
	var htmaxphoto=0;
	var lgmaxphoto=0;
	for(i=0;i<this.getNbPhotos();i++){
		//Hauteur max photo et largeur max
		var imgcrt=lesDonneesPhoto[i].getImage();
		if(imgcrt){
			if(imgcrt.height>htmaxphoto){
				htmaxphoto=imgcrt.height;
			}
			if(imgcrt.width>lgmaxphoto){
				lgmaxphoto=imgcrt.width;
			}
		}

	}
	var htcont=this.getHauteur();
	var lgcont=this.getLargeur();
	var dimXel,dimYel;
	if(lgmaxphoto>(lgcont/2)){
		dimXel=Math.round(lgcont/2)-20;
	}
	else{
		dimXel=lgmaxphoto-20;
	}
	dimXel=Math.round(dimXel/2);
	if(htmaxphoto>(htcont/2)){
		dimYel=Math.round(htcont/2);
	}
	else{
		dimYel=htmaxphoto;
	}
	dimYel=Math.round(dimYel/2);
	
	this.setXRellipse(dimXel);
	this.setYRellipse(dimYel);
}
}

ClasseEnchainementPhotos.prototype.initialiseDimension = function(){
	var initialisationOk=true;
	var postailelt=retournePosTailleElement(this.getContaineur());
	this.setLargeur(parseInt(postailelt.Largeur));
	this.setHauteur(parseInt(postailelt.Hauteur));
	
	//Correction bug IE on impose les dimension au containeur
	this.getContaineur().style.width=postailelt.Largeur+"px";
	this.getContaineur().style.height=postailelt.Hauteur+"px";
	switch(this.getTypeEnchainement()){
	case this.DEPLACEMENT:
	case this.CLIGNOTEMENT:
	case this.FONDU:
	case this.DIAPORAMA:
		if(this.sensDpctVertical()){
			this.setLargeurPhoto(this.getLargeur());
			this.setHauteurPhoto(this.getHauteur()-2*this.getDimensionBordure());
			this.setLimiteSup(this.getHauteur()-this.getDimensionBordure());
		}
		else{
			this.setLargeurPhoto(this.getLargeur()-2*this.getDimensionBordure());
			this.setHauteurPhoto(this.getHauteur());
			this.setLimiteSup(this.getLargeur()-this.getDimensionBordure());
		}
		break;
	case this.BLOCPARBLOC:
			
			this.setLargeurPhoto(this.getLargeur());
			this.setHauteurPhoto(this.getHauteur()-15);
	break;	
	case this.ELLIPSE:
		this.determineDimensionIdealeEllipse();
		var dim=this.getHauteur()-2*this.getYRellipse();
		if(dim<0) initialisationOk=false;
		this.setHauteurPhoto(dim);
		
		dim=this.getLargeur()-2*this.getXRellipse();
		//La photo est ici multiplie par un facteur d environ 0.5 on peut donc augmenter la taille de celle ci
		
		dim=dim*(2-this.retourneFacteurPhotoEllipse(0));
		if(dim<0) initialisationOk=false;
		this.setLargeurPhoto(dim);
	
	break;
	}
	return(initialisationOk);
}

ClasseEnchainementPhotos.prototype.ajoutePhotoEtActionAListe= function(chemin,action){
var idinceImg=this.getNbPhotos();
var nvImg=new ClassePhotoFilm(idinceImg,chemin,action);
this.getListePhotos()[idinceImg]=nvImg;
idinceImg++;
this.setNbPhotos(idinceImg);
return(nvImg);
}

ClasseEnchainementPhotos.prototype.ajoutePhotoAListe= function(chemin){
return(this.ajoutePhotoEtActionAListe(chemin,""));

}


ClasseEnchainementPhotos.prototype.ajoutComposantHTML = function(){
var sTexte="",sPhoto;
var i,j;
var eltpht;
var ie=(navigator.appName=='Microsoft Internet Explorer');
sTexte="<DIV id=\""+this.getId()+"progress\" name=\""+this.getId()+"progress\"  style=\"position:absolute;top:50%;left:50%\" ></DIV>";

for(i=0;i<this.getNbPhotos();i++){
	sTexte=sTexte+"<DIV id=\""+this.getId()+i+"group\" name=\""+this.getId()+i+"group\" style=\"position:absolute;visibility:hidden;\" ";
	eltpht=this.getListePhotos()[i];
	if(eltpht.getOnClick()!=""){
		sTexte=sTexte+"onclick=\""+eltpht.getOnClick()+"\"";
	}
	sTexte=sTexte+">";

	//sPhoto="<IMG id=\""+this.getId()+i+"\" src=\""+this.getListePhotos()[i].getChemin()+"\" style=\"position:absolute;visibility:hidden\">";
	if(ie){
		sPhoto="";
		//sPhoto="<v:group id=\""+this.getId()+i+"\" name=\""+this.getId()+i+"\" style=\"position:absolute;top:0px;left:0px;z-index:1;\" coordsize=\"100, 100\" coordorigin=\"0, 0\" >";
		//sPhoto=sPhoto+"<v:image  id=\""+this.getId()+i+"img\" name=\""+this.getId()+i+"img\" src=\""+this.getListePhotos()[i].getChemin()+"\" style=\"width:100; height: 100;position:relative;top:0;left:0\" ></v:image>";
		//sPhoto=sPhoto+"</v:group>";
		sPhoto=sPhoto+"<v:image  id=\""+this.getId()+i+"\" name=\""+this.getId()+i+"\" src=\"\" style=\"position:absolute;top:0px;left:0px;\" ></v:image>";
	}
	else{
		sPhoto="<IMG id=\""+this.getId()+i+"\" src=\"\" style=\"position:absolute;top:0px;left:0px;\" >";
	}
	sTexte=sTexte+sPhoto;

	sPhoto="";
	var ListeZoneInter=this.getListePhotos()[i].getZonesInteractions();
	for(j=0;j<ListeZoneInter.length;j++){
		var zonecrt=ListeZoneInter[j];
		//sPhoto=sPhoto+"<DIV id=\""+this.getId()+i+"zi"+j+"\" style=\"position:absolute;left:"+zonecrt.getX()+";top:"+zonecrt.getY()+";width:"+zonecrt.getLargeur()+";height:"+zonecrt.getHauteur()+";cursor:pointer;cursor:hand;z-index:100;visibility:visible\" onclick=\""+zonecrt.getAction()+"\" ></DIV>";
		sPhoto=sPhoto+"<input type=\"image\" value=\"\" src=\"./js/vide.gif\" id=\""+this.getId()+i+"zi"+j+"\" style=\"position:absolute;left:"+zonecrt.getX()+";top:"+zonecrt.getY()+";width:"+zonecrt.getLargeur()+";height:"+zonecrt.getHauteur()+";z-index:100\" onclick=\""+zonecrt.getAction()+"\" />";
	}
	sTexte=sTexte+sPhoto;
	if(this.getTypeEnchainement()==this.BLOCPARBLOC){
		j=i+1;
		if(j<10){
			j="0"+j;
		}
		sTexte=sTexte+"<DIV  style=\"width:100%;position:absolute;top:"+this.getHauteurPhoto()+"px;left:0px;\">";
		sTexte=sTexte+"<TABLE border=\"0\" width=\"100%\" height=\"100%\" cellpadding=\"0px\" cellspacing=\"0px\" >";
		sTexte=sTexte+"<tr><td id=\""+this.getId()+i+"txt\" name=\""+this.getId()+i+"txt\" align=\"center\" style=\"font-size:10px;color:#000000;\">Etape :"+j+"</td></tr></TABLE>";
		sTexte=sTexte+"</DIV>";
	}
	
	sTexte=sTexte+"</DIV>";
}
switch(this.getTypeEnchainement()){
case this.DEPLACEMENT:
	//On ajoute ici les div pour l opacite pour passer de 0 a 90 pct
	//On ajoute les zones qui vont contenir les differentes petites zones, car IE pose un problème si on les ajoute maintenant, il ne les affiche pas.
	//On renseignera ces zones une fois que l'ensemble des images seront chargées
	if(this.getDimensionBordure()>0){
		var sTDiv,sTDiv2;
		sTDiv="<DIV style=\"z-index:100;position:absolute;font-size:0px;";
		
		if(this.sensDpctVertical()){
			sTDiv=sTDiv+"width:100%;height:"+this.getDimensionBordure()+"px;left:0px;"
			sTDiv2=sTDiv;
			sTDiv=sTDiv+"top:0px;"
			sTDiv2=sTDiv2+"bottom:0px;"
		}
		else{
			sTDiv=sTDiv+"height:100%;width:"+this.getDimensionBordure()+"px;top:0px;"
			sTDiv2=sTDiv;
			sTDiv=sTDiv+"left:0px;"
			sTDiv2=sTDiv2+"right:0px;"
		}
		
		sTDiv=sTDiv+"\" id=\""+this.getId()+"degra1\" name=\""+this.getId()+"degra1\" ></DIV>";
		sTDiv2=sTDiv2+"\" id=\""+this.getId()+"degra2\" name=\""+this.getId()+"degra2\" ></DIV>";
		sTexte=sTexte+sTDiv+sTDiv2;
	}
	break;
case this.ELLIPSE:

	var btGc=this.getBtGaucheEllipse();
	var btDr=this.getBtDroiteEllipse();
	if((btDr!=null)||(btGc!=null)){
		sTexte=sTexte+"<table id=\""+this.getId()+"btncommande\" style=\"width:100%;position:absolute;left:0px;visibility:hidden\">";
		sTexte=sTexte+"<tr>";
		if(btGc){
			sTexte=sTexte+"<td align=\"left\">";
			sTexte=sTexte+"<input type=\"image\" value=\"<-\" src=\""+btGc.src+"\"  onclick=\""+this.getId()+".rotationEllipse(false)\">";
			sTexte=sTexte+"</td>";
		}
		
		if(btDr){
			sTexte=sTexte+"<td align=\"right\">";
			sTexte=sTexte+"<input type=\"image\" value=\"->\" src=\""+btDr.src+"\"  onclick=\""+this.getId()+".rotationEllipse(true)\">";
			sTexte=sTexte+"</td>";
		}
		
		sTexte=sTexte+"</tr>";
		sTexte=sTexte+"</table>";
	
	}

	break;
}


this.getContaineur().innerHTML=sTexte;
this.setLimiteChargement(0);

if(this.elementPresentHTML(this.getId()+"progress")){
	var elt;
	elt=this.getDocumentCourant().getElementById(this.getId()+"progress");
	if(elt){
		this.setEtiquetteProgression(elt);
	}
	
}

var idPhoto;
var lesDonneesPhoto=this.getListePhotos();
var htmaxphoto=0;
var lgmaxphoto=0;
for(i=0;i<this.getNbPhotos();i++){
		
	this.setLimiteChargement(0);
	if(this.elementPresentHTML(this.getId()+i)){
		idPhoto=this.getId()+i;
		
		elt=this.getDocumentCourant().getElementById(idPhoto);
	
		lesDonneesPhoto[i].setElementImage(elt);
	}
	
	this.setLimiteChargement(0);
	if(this.elementPresentHTML(this.getId()+i+"group")){
		elt=this.getDocumentCourant().getElementById(this.getId()+i+"group");
		lesDonneesPhoto[i].setElementGroupe(elt);
	}
	
	var ListeZoneInter=lesDonneesPhoto[i].getZonesInteractions();
	for(j=0;j<ListeZoneInter.length;j++){
		var zonecrt=ListeZoneInter[j];
		elt=this.getDocumentCourant().getElementById(this.getId()+i+"zi"+j);
		if(elt){
			zonecrt.setElement(elt);
		}
		
	}

}


}



//Permet d attendre que tout les element html soit bien defini avant de continuer 
ClasseEnchainementPhotos.prototype.elementPresentHTML= function(nomElt){

var elt;
var res=false;
var iLimite;
	var elt;
	elt=this.getDocumentCourant().getElementById(nomElt);
	if(elt){
		res=true;
	}
	else{
		iLimite=this.getLimiteChargement();
		if(iLimite<10){
			setTimeout(this.getId()+".elementPresentHTML("+nomElt+")",10);
			iLimite++;
			this.setLimiteChargement(iLimite);
		}
	}
return(res);
}

/******************************************
                          CLIGNOTEMENT
*******************************************/
ClasseEnchainementPhotos.prototype.clignoteLesPhotos= function(){
var IndicePhotoCrt=this.getIndicePhotoCourante();
var eltpht;
eltpht=this.getListePhotos()[IndicePhotoCrt];
affichagecomplet=eltpht.clignoteImage(this);
if(affichagecomplet==1){
	this.setEtatAttente(true);
}
if(affichagecomplet==2){
	eltpht.setAAffiche(false);
	IndicePhotoCrt++;
	if(IndicePhotoCrt>=this.getNbPhotos()){
		IndicePhotoCrt=0;
	}
	this.setIndicePhotoCourante(IndicePhotoCrt);
	eltpht=this.getListePhotos()[IndicePhotoCrt];
	eltpht.setAAffiche(true);
}
setTimeout(this.getId()+".clignoteLesPhotos()",this.getTempsFonction());

}

ClasseEnchainementPhotos.prototype.initialiseAffichagePhotoClignotement= function(){
var IndicePhotoCrt=this.getIndicePhotoCourante();
var eltpht;
eltpht=this.getListePhotos()[IndicePhotoCrt];
eltpht.setAAffiche(true);
}

ClasseEnchainementPhotos.prototype.fonduDesPhotos= function(){
var IndicePhotoCrt=this.getIndicePhotoCourante();
var eltpht,eltsuiv;
var IndicePhotoSvt=this.retournIndicePhotoSuivante(IndicePhotoCrt);

eltpht=this.getListePhotos()[IndicePhotoCrt];
eltsuiv=this.getListePhotos()[IndicePhotoSvt];
affichagecomplet=eltpht.fonduImage(this,-1*this.getPasDefil());
eltsuiv.setAAffiche(true);
affichagecompletsuivant=eltsuiv.fonduImage(this,this.getPasDefil());
if(affichagecompletsuivant==1){
	eltsuiv.setAAffiche(true);
	this.setEtatAttente(true);

	eltpht.setAAffiche(false);
	IndicePhotoCrt=this.retournIndicePhotoSuivante(IndicePhotoCrt);
	this.setIndicePhotoCourante(IndicePhotoCrt);
}

setTimeout(this.getId()+".fonduDesPhotos()",this.getTempsFonction());
}


/******************************************
                          FONDU
*******************************************/
ClasseEnchainementPhotos.prototype.initialiseAffichagePhotoFondu= function(){
var IndicePhotoCrt=this.getIndicePhotoCourante();
var eltpht;
eltpht=this.getListePhotos()[IndicePhotoCrt];
eltpht.setAAffiche(true);
eltpht.setOpacite(100);
this.setEtatAttente(true);
}


/******************************************
                          DEPLACEMENT
*******************************************/

/* Permet de derouler l ensemble des photos de facon continue ou image par image*/
ClasseEnchainementPhotos.prototype.derouleLesPhotos= function(){
var i;
var eltpht;
var affichagecomplet=false;

var obj;
for(i=0;i<this.getNbPhotos();i++){
	eltpht=this.getListePhotos()[i];
	if(affichagecomplet){
		eltpht.setAAffiche(true);
	}
	affichagecomplet=false;
	if(eltpht.getAAffiche()){
		obj=eltpht.deplaceImage(this,false);
		affichagecomplet=obj.affichecompletement;
	}
	if(affichagecomplet){
		this.setEtatAttente(true);
	}
}
if((affichagecomplet)&&(this.getNbPhotos()>0)){
	//On reaffiche la premiere image
	eltpht=this.getListePhotos()[0];
	eltpht.setAAffiche(true);
}

setTimeout(this.getId() + ".derouleLesPhotos()", this.getTempsFonction());

}

ClasseEnchainementPhotos.prototype.deplaceLesPhotos= function(gaucheversdroite){
if(gaucheversdroite){
	this.setSensDeplacement(this.SENSGAUCHEVERSDROITE);
}
else{
	this.setSensDeplacement(this.SENSDROITEVERSGAUCHE);
}
this.derouleLesPhotos();
}

ClasseEnchainementPhotos.prototype.initialiseAffichagePhotoDefilement= function(){
var i,pos=0,iLimite=0;
var eltpht;
var bContinuer=true;


		
if(this.getPasDefilFctSens()>0){
	
	if(this.sensDpctVertical()){
		iLimite=this.getHauteur();
		
	}
	else{
		iLimite=this.getLargeur();
		
	}
	pos=this.getDimensionBordure();
}
else{
	pos=this.getLimiteSup();

	iLimite=0;
	
}

i=0;
while((i<this.getNbPhotos())&&(bContinuer)){
	eltpht=this.getListePhotos()[i];
	eltpht.setAAffiche(true);
	eltpht.setAfficheCompletement(true);
	if(this.getPasDefilFctSens()>0){
		if(this.sensDpctVertical()){
			eltpht.setY(pos);
			pos=pos+eltpht.getHauteur()+this.getEcartEntrePhotos();
			
		}
		else{
			eltpht.setX(pos);
			pos=pos+eltpht.getLargeur()+this.getEcartEntrePhotos();
		}
		if(pos>iLimite){
			bContinuer=false;
		}
	}
	else{
		if(this.sensDpctVertical()){
			pos=pos-eltpht.getHauteur()-this.getEcartEntrePhotos();
			eltpht.setY(pos);
		}
		else{
			pos=pos-eltpht.getLargeur()-this.getEcartEntrePhotos();
			eltpht.setX(pos);
			
		}
		if(pos<iLimite){
			bContinuer=false;
		}
	
	}
	i++;
}
//On positionne la derniere image en dessus
i=this.getNbPhotos()-1;
if(i>=0){
	eltpht=this.getListePhotos()[i];
	eltpht.setAAffiche(true);
	if(this.getPasDefilFctSens()>0){
		if(this.sensDpctVertical()){
			pos=this.getDimensionBordure()-eltpht.getHauteur()-this.getEcartEntrePhotos();
			eltpht.setY(pos);
		}
		else{
			pos=this.getDimensionBordure()-eltpht.getLargeur()-this.getEcartEntrePhotos();
			eltpht.setX(pos);
		}
	}
	else{
		pos=this.getLimiteSup();
		if(this.sensDpctVertical()){
			eltpht.setY(pos);
		}
		else{
			eltpht.setX(pos);
		}
	}
}
//Ajout des degrades
var degrades1=this.getDocumentCourant().getElementById(this.getId()+"degra1");
var degrades2=this.getDocumentCourant().getElementById(this.getId()+"degra2");
if((degrades1)&&(degrades2)){
	var sTexte1="";
	var sTexte2="";
	var delta=90/this.getDimensionBordure()*this.getPasDefil();
	var nbDiv=Math.round(this.getDimensionBordure()/this.getPasDefil());
	var dimDiv=Math.round(this.getDimensionBordure()/nbDiv);
	var iDiv;
	var sTDiv,sTDiv2;
	var valOpa,pctOpa=90,d1=0;
	
	for(iDiv=0;iDiv<nbDiv;iDiv++){
		valOpa=pctOpa/100;
		sTDiv="<DIV  style=\"position:absolute;font-size:0px;background-color:#FFFFFF;opacity : "+valOpa+";filter : alpha(opacity="+pctOpa+");";
		
		if(this.sensDpctVertical()){
			sTDiv=sTDiv+"width:100%;height:"+dimDiv+"px;left:0px;"
			sTDiv2=sTDiv;
			sTDiv=sTDiv+"top:"+d1+"px;"
			sTDiv2=sTDiv2+"bottom:"+d1+"px;"
		}
		else{
			sTDiv=sTDiv+"height:100%;width:"+dimDiv+"px;top:0px;"
			sTDiv2=sTDiv;
			sTDiv=sTDiv+"left:"+d1+"px;"
			sTDiv2=sTDiv2+"right:"+d1+"px;"
		}
		sTDiv=sTDiv+"\" ></DIV>";
		sTDiv2=sTDiv2+"\" ></DIV>";
		d1=d1+dimDiv;
		pctOpa=pctOpa-delta;
		sTexte1=sTexte1+sTDiv;
		sTexte2=sTexte2+sTDiv2;
	}
	
	degrades1.innerHTML=sTexte1;
	degrades2.innerHTML=sTexte2;

}
}
/******************************************
                          DIAPORAMA

*******************************************/



ClasseEnchainementPhotos.prototype.getIndicePremiereImage= function() {
	return this.idpremiereimg;
}
ClasseEnchainementPhotos.prototype.setIndicePremiereImage = function(val) {
	this.idpremiereimg= val;
}

ClasseEnchainementPhotos.prototype.getIndiceDerniereImage= function() {
	return this.idderniereimg;
}
ClasseEnchainementPhotos.prototype.setIndiceDerniereImage = function(val) {
	this.idderniereimg= val;
}

ClasseEnchainementPhotos.prototype.repositionneImageDiaporama = function(){
var indicephoto;
var eltpht;
var eltref;

if(this.getPasDefilFctSens()>0){
	indicephoto=this.retournIndicePhotoPrecedente(this.getIndicePremiereImage());
	eltref=this.getListePhotos()[this.getIndicePremiereImage()];
	eltpht=this.getListePhotos()[indicephoto];
	if(this.sensDpctVertical()){
		eltpht.setY(eltref.getY()-eltpht.getHauteur()-this.getEcartEntrePhotos());
	}
	else{
		eltpht.setX(eltref.getX()-eltpht.getLargeur()-this.getEcartEntrePhotos());
	}
	eltpht.setAAffiche(false);
	eltpht.setAfficheCompletement(false);
}
else{
	indicephoto=this.retournIndicePhotoSuivante(this.getIndiceDerniereImage());
	
	eltref=this.getListePhotos()[this.getIndiceDerniereImage()];
	eltpht=this.getListePhotos()[indicephoto];

	if(this.sensDpctVertical()){
		eltpht.setY(eltref.getY()+eltref.getHauteur()+this.getEcartEntrePhotos());
	}
	else{
		eltpht.setX(eltref.getX()+eltref.getLargeur()+this.getEcartEntrePhotos());
	}
	eltpht.setAAffiche(false);
	eltpht.setAfficheCompletement(false);
}
//alert("repositionneImageDiaporama p"+this.getIndicePremiereImage()+" d "+this.getIndiceDerniereImage()+" id photo "+indicephoto);
}

ClasseEnchainementPhotos.prototype.derouleDiaporama= function(){
var i;
var eltpht;
var affichagecomplet=false;
var atteindsbordure=false;
var obj;
if(this.getNbPhotos()>1){
	for(i=0;i<this.getNbPhotos();i++){
		eltpht=this.getListePhotos()[i];
		
		obj=eltpht.deplaceImageDiapo(this,false);
		affichagecomplet=obj.affichecompletement;
		//alert(i+" Aff complet "+obj.affichecompletement+" atteind bordure "+obj.atteintbord+" disparue  "+obj.disparueCompletement);
		if(obj.affichecompletement){
			//L image courante est affiche completement il faut donc repositionne la suivante
			if(this.getPasDefilFctSens()>0){
				this.setIndicePremiereImage(i);
			}
			else{
				this.setIndiceDerniereImage(i);
			}
			this.repositionneImageDiaporama();
		}
		if(obj.disparueCompletement){
			if(this.getPasDefilFctSens()>0){
				this.setIndiceDerniereImage(this.retournIndicePhotoPrecedente(i));
			}
			else{
				this.setIndicePremiereImage(this.retournIndicePhotoSuivante(i));
			}
		}
		atteindsbordure=obj.atteintbord||atteindsbordure;
		
	}


	if(!atteindsbordure){
		setTimeout(this.getId()+".derouleDiaporama()",this.getTempsFonction());
	}
}	
}

ClasseEnchainementPhotos.prototype.passeLesDiapos= function(gaucheversdroite){
	if(this.getNbPhotos()>1){
		if(gaucheversdroite){
			this.setSensDeplacement(this.SENSGAUCHEVERSDROITE);
		}
		else{
			this.setSensDeplacement(this.SENSDROITEVERSGAUCHE);
		}
		//On positionne l image suivant ou precedente en fct du sens de deplacement
		this.repositionneImageDiaporama();
		this.derouleDiaporama();
	}
}

ClasseEnchainementPhotos.prototype.initialiseAffichagePhotoDiaporama= function(){

var i,pos=0,iLimite=0;
var eltpht;
var derposini=false;	
if(this.getPasDefilFctSens()>0){
	if(this.sensDpctVertical()){
		iLimite=this.getHauteur();
		
	}
	else{
		iLimite=this.getLargeur();
		
	}
	pos=0;
}
else{
	if(this.sensDpctVertical()){
		pos=this.getHauteur();
		
	}
	else{
		pos=this.getLargeur();
	}

	iLimite=0;
}
i=0;
this.setIndicePremiereImage(0);
while(i<this.getNbPhotos()){
	eltpht=this.getListePhotos()[i];
	eltpht.setAAffiche(!derposini);
	eltpht.setAfficheCompletement(!derposini);
	if(this.getPasDefilFctSens()>0){
		if(this.sensDpctVertical()){
			eltpht.setY(pos);
			pos=pos+eltpht.getHauteur()+this.getEcartEntrePhotos();
			
		}
		else{
			eltpht.setX(pos);
			pos=pos+eltpht.getLargeur()+this.getEcartEntrePhotos();
		}
		if((pos>iLimite)&&(!derposini)){
			this.setIndiceDerniereImage(i);
			derposini=true;
		}
	}
	else{
		if(this.sensDpctVertical()){
			pos=pos-eltpht.getHauteur()-this.getEcartEntrePhotos();
			eltpht.setY(pos);
		}
		else{
			pos=pos-eltpht.getLargeur()-this.getEcartEntrePhotos();
			eltpht.setX(pos);
			
		}
		if((pos<iLimite)&&(!derposini)){
			this.setIndiceDerniereImage(i);
			derposini=true;
		}
	
	}
	
	
	eltpht.afficheImage(this);
	i++;
}


}
/******************************************
                          BLOC PAR BLOC
*******************************************/
ClasseEnchainementPhotos.prototype.afficheAutreBloc= function(blocsuivant){
var iIndicePremImg=this.getIndicePremiereImage();
var iIndiceDerImg=this.getIndiceDerniereImage();
var iIndice=0;
if(blocsuivant){
	if(iIndiceDerImg+1<this.getNbPhotos()){
		this.EnleveBlocAffiche(iIndicePremImg,iIndiceDerImg);
		iIndice=iIndiceDerImg+1;
		this.affichePhotoBlocParBloc(iIndice);
	}
}
else{
	if(iIndicePremImg-1>0){
		this.EnleveBlocAffiche(iIndicePremImg,iIndiceDerImg);
		iIndice=this.RetourneIndPhotoBlocPrecedent(iIndicePremImg-1);
		this.affichePhotoBlocParBloc(iIndice);
	}


}


}

ClasseEnchainementPhotos.prototype.RetourneIndPhotoBlocPrecedent=function(iIndicePhoto){
var iIndice=0,dim=0,i,prochainedim;
var eltpht;
if(this.sensDpctVertical()){
	iLimite=this.getHauteur();
	
}
else{
	iLimite=this.getLargeur();
	
}

i=iIndicePhoto;
while(i>=0){
	eltpht=this.getListePhotos()[i];
	if(this.sensDpctVertical()){
		prochainedim=dim+eltpht.getHauteur();
	}
	else{
		prochainedim=dim+eltpht.getLargeur();
	}
	if(prochainedim>iLimite){
		break;
	}
	else{
		dim=prochainedim+this.getEcartEntrePhotos();
		iIndice=i;
		
	}
	i--;
}

return (iIndice);

}

ClasseEnchainementPhotos.prototype.RetourneIndPremierePhotoBlocContantImage=function(iIdPhoto){
var iIndicePremiereImg=0,dim=0,i,prochainedim;
var continuer=true;
var eltpht;
if(this.sensDpctVertical()){
	iLimite=this.getHauteur();
	
}
else{
	iLimite=this.getLargeur();
	
}
iIndicePremiereImg=0;
i=0;
while((i<this.getNbPhotos())&&(continuer)){
	eltpht=this.getListePhotos()[i];
	if(this.sensDpctVertical()){
		prochainedim=dim+eltpht.getHauteur();
	}
	else{
		prochainedim=dim+eltpht.getLargeur();
	}
	if(prochainedim>iLimite){
		iIndicePremiereImg=i;
		dim=0;
	}
	else{
		dim=prochainedim+this.getEcartEntrePhotos();
		
	}
	if(i==iIdPhoto){
		continuer=false;
	}
	i++;
}
return (iIndicePremiereImg);

}

ClasseEnchainementPhotos.prototype.afficheBlocContenantPhotoDid=function (iIdPhoto){
var iIndicePremImg=this.getIndicePremiereImage();
var iIndiceDerImg=this.getIndiceDerniereImage();

if((iIdPhoto<iIndicePremImg)||(iIdPhoto>iIndiceDerImg)){
	this.EnleveBlocAffiche(iIndicePremImg,iIndiceDerImg);
	var iIndice=this.RetourneIndPremierePhotoBlocContantImage(iIdPhoto);
	this.affichePhotoBlocParBloc(iIndice);
}
}

ClasseEnchainementPhotos.prototype.EnleveBlocAffiche=function(iIndicePremImg,iIndiceDerImg){
var i,iLimite=0;
i=iIndicePremImg;
var eltpht;
if(this.sensDpctVertical()){
	iLimite=this.getHauteur();
	
}
else{
	iLimite=this.getLargeur();
	
}
while(i<=iIndiceDerImg){
	eltpht=this.getListePhotos()[i];
	eltpht.setAAffiche(false);
	if(this.sensDpctVertical()){
		eltpht.setY(iLimite);
	}
	else{
		eltpht.setX(iLimite);
	}
	eltpht.afficheImage(this);
	i++;
}
}


ClasseEnchainementPhotos.prototype.affichePhotoBlocParBloc= function(iIndPhoto){
var i,pos=0,iLimite=0,prochainepos=0;
var eltpht;
var derposini=false;	

if(this.sensDpctVertical()){
	iLimite=this.getHauteur();
	
}
else{
	iLimite=this.getLargeur();
	
}

i=iIndPhoto;
this.setIndicePremiereImage(i);
while(i<this.getNbPhotos()){
	eltpht=this.getListePhotos()[i];
	if(this.sensDpctVertical()){
		prochainepos=pos+eltpht.getHauteur();
	}
	else{
		prochainepos=pos+eltpht.getLargeur();
	}
	if(prochainepos>iLimite){
		break;
	}
	else{
		if(this.sensDpctVertical()){
			eltpht.setY(pos);
		}
		else{
			eltpht.setX(pos);
		}
		pos=prochainepos+this.getEcartEntrePhotos();
		this.setIndiceDerniereImage(i);
		eltpht.setAAffiche(true);
		eltpht.afficheImage(this);
	}
	i++;
}

}

ClasseEnchainementPhotos.prototype.initialiseAffichagePhotoBlocParBloc= function(){
	this.affichePhotoBlocParBloc(0);

}

/******************************************
                          ELLIPSE
*******************************************/
ClasseEnchainementPhotos.prototype.initialiseAffichageDeplacementEllipse= function(){
var i,eltpht;
var AnglePos=270;
var dDeltaAngle=Math.round(360/this.getNbPhotos());
var dPas=Math.abs(this.getPasDefil());
//Angle au modulo du pas
dDeltaAngle=Math.round(dDeltaAngle/dPas)*dPas;
for(i=0;i<this.getNbPhotos();i++){
	eltpht=this.getListePhotos()[i];
	eltpht.setAngle(AnglePos);
	eltpht.setAAffiche(true);
	AnglePos=AnglePos+dDeltaAngle;
	if(AnglePos>360){
		AnglePos=AnglePos-360;
	}
}



var elt=this.getDocumentCourant().getElementById(this.getId()+"btncommande");
if(elt){
	var posBtn=this.retournPostionPlusBasseEllipse()+this.getOffsetBtEllipse();
	elt.style.top=posBtn+"px";
	elt.style.visibility="visible";
}
}

ClasseEnchainementPhotos.prototype.affichageEllipse= function(){
var i,eltpht;

for(i=0;i<this.getNbPhotos();i++){
	eltpht=this.getListePhotos()[i];
	eltpht.afficheImageSurEllipse(this);
}
}

ClasseEnchainementPhotos.prototype.deplacemntAutourEllipse= function(){
var i;
var eltpht;
var affichagecomplet=false;

for(i=0;i<this.getNbPhotos();i++){
	eltpht=this.getListePhotos()[i];
	//Attention bien laisser eltpht.deplaceImageSurEllipse(this) avant affichagecomplet, car si affichage complet passe a vrai
	//alors la fonction eltpht.deplaceImageSurEllipse(this)  n est pas effectue
	affichagecomplet=eltpht.deplaceImageSurEllipse(this)||affichagecomplet;
}
if(!affichagecomplet){
	setTimeout(this.getId()+".deplacemntAutourEllipse()",this.getTempsFonction());
}
}

ClasseEnchainementPhotos.prototype.rotationEllipse= function(gaucheversdroite){
if(gaucheversdroite){
	this.setSensDeplacement(this.SENSGAUCHEVERSDROITE);
}
else{
	this.setSensDeplacement(this.SENSDROITEVERSGAUCHE);
}
this.deplacemntAutourEllipse();
}


ClasseEnchainementPhotos.prototype.deplacemntContinueAutourEllipse= function(){
var i;
var eltpht;

for(i=0;i<this.getNbPhotos();i++){
	eltpht=this.getListePhotos()[i];
	eltpht.deplaceImageSurEllipse(this);
}

setTimeout(this.getId()+".deplacemntContinueAutourEllipse()",this.getTempsFonction());

}

/******************************************
                          CHARGEMENT DES PHOTOS
*******************************************/
ClasseEnchainementPhotos.prototype.attenteChargementeEnsPhotos= function(){
var bContinuer,eltpht;
var bCharge;
var i,iNbPhChg=0;

bContinuer=true;
for(i=0;i<this.getNbPhotos();i++){

	eltpht=this.getListePhotos()[i];

	bCharge=eltpht.getImage().complete||eltpht.getEnErreur();
	
	if(bCharge){
		iNbPhChg++;
	}
	bContinuer=bContinuer&&bCharge;
}
var pctChg=Math.round(iNbPhChg/this.getNbPhotos()*100);
var eltprog=this.getEtiquetteProgression();
eltprog.innerHTML=pctChg+" %";

//Initialisation des photos leurs taille et leur position
if(bContinuer){
	eltprog.style.display="none";
	//On initialise l ensemble des photos ainsi que leur dimensions
	for(i=0;i<this.getNbPhotos();i++){
		this.getListePhotos()[i].initialisePhoto(this);
	}
	this.deplacePhotosSuivantType();
}
else{
	setTimeout(this.getId()+".attenteChargementeEnsPhotos()",100);
}

}

/******************************************
                          GESTION EFFET MOUVEMENT
*******************************************/
ClasseEnchainementPhotos.prototype.deplacePhotosSuivantType= function(){
var typech=this.getTypeEnchainement();
var nomFct="";

switch(typech){
	case this.DEPLACEMENT:
		this.initialiseAffichagePhotoDefilement();
		
		this.derouleLesPhotos();
		
		break;
	case this.CLIGNOTEMENT:	
		this.initialiseAffichagePhotoClignotement();
		this.clignoteLesPhotos();
		break;
	case this.FONDU:
		this.initialiseAffichagePhotoFondu();
		this.fonduDesPhotos();
		break;
	case this.ELLIPSE:	
		this.initialiseAffichageDeplacementEllipse();
		this.affichageEllipse();
		if(this.getDeplacementContinue()){
			this.deplacemntContinueAutourEllipse();
		}
		break;	
	case this.DIAPORAMA:
		this.initialiseAffichagePhotoDiaporama();
		break;
		
	case this.BLOCPARBLOC:
		this.initialiseAffichagePhotoBlocParBloc();
		break;
		
}

}

ClasseEnchainementPhotos.prototype.enchaineLesPhotos= function(){
this.initialiseDimension();
this.ajoutComposantHTML();

this.attenteChargementeEnsPhotos();
}

ClasseEnchainementPhotos.prototype.stopEnchainement= function(){
	clearInterval(this.getTimer());
}


/******************************************************************************************
*
*
*                               BOITE DE ZOOM
*
*
******************************************************************************************/
ClassePhotoZoomBox = function(id,documentCrt,idcontaineurphotoreduite,idcontaineurphotoagrandie) {
	this.init(id,documentCrt,idcontaineurphotoreduite,idcontaineurphotoagrandie);
}


ClassePhotoZoomBox.prototype.init = function(id,documentCrt,idcontaineurphotoreduite,idcontaineurphotoagrandie){
this.setId("nofound");
var elt=documentCrt.getElementById(idcontaineurphotoreduite);
var elt2=documentCrt.getElementById(idcontaineurphotoagrandie);
if((elt)&&(elt2)){
	this.setId(id);
	this.setChemin("");
	this.setContaineurPhotoReduite(elt);
	this.setContaineurPhotoAgrandie(elt2);
	this.initialise(documentCrt);
	this.setAfficheZoom(false);
	this.setRatioMiniZoom(-1);
	documentCrt.onmousemove=documentDeplaceSouris;
	documentCrt.onmouseup=documentSourisEnHaut;
	documentCrt.onmousedown=documentSourisEnBas;
	documentCrt.onclick=documentSourisAppuyee;
}
}


ClassePhotoZoomBox.prototype.getId = function() {
	return this.id;
}
ClassePhotoZoomBox.prototype.setId = function(val) {
	this.id = val;
}

ClassePhotoZoomBox.prototype.getChemin = function() {
	return this.chemin;
}
ClassePhotoZoomBox.prototype.setChemin = function(val) {
	this.chemin = val;
}

ClassePhotoZoomBox.prototype.getContaineurPhotoReduite = function() {
	return this.contphotred;
}
ClassePhotoZoomBox.prototype.setContaineurPhotoReduite = function(val) {
	this.contphotred = val;
}

ClassePhotoZoomBox.prototype.getDessusContaineurPhotoReduite = function() {
	return this.dessuscontphotred;
}
ClassePhotoZoomBox.prototype.setDessusContaineurPhotoReduite = function(val) {
	this.dessuscontphotred = val;
}

ClassePhotoZoomBox.prototype.getGaucheContaineurPhotoReduite = function() {
	return this.gauchecontphotred;
}
ClassePhotoZoomBox.prototype.setGaucheContaineurPhotoReduite = function(val) {
	this.gauchecontphotred = val;
}


ClassePhotoZoomBox.prototype.getContaineurPhotoAgrandie = function() {
	return this.contphotagr;
}
ClassePhotoZoomBox.prototype.setContaineurPhotoAgrandie = function(val) {
	this.contphotagr = val;
}

ClassePhotoZoomBox.prototype.getImageReduite = function() {
	return this.imgred;
}
ClassePhotoZoomBox.prototype.setImageReduite = function(val) {
	this.imgred = val;
}

ClassePhotoZoomBox.prototype.getImageNonReduite = function() {
	return this.imgnonred;
}
ClassePhotoZoomBox.prototype.setImageNonReduite = function(val) {
	this.imgnonred = val;
}

ClassePhotoZoomBox.prototype.getMasquePhoto = function() {
	return this.lesmasques;
}
ClassePhotoZoomBox.prototype.setMasquePhoto = function(val) {
	this.lesmasques = val;
}

ClassePhotoZoomBox.prototype.getLargeurBoite = function() {
	return this.largboite;
}
ClassePhotoZoomBox.prototype.setLargeurBoite = function(val) {
	this.largboite = val;
}

ClassePhotoZoomBox.prototype.getHauteurBoite = function() {
	return this.hautboite;
}
ClassePhotoZoomBox.prototype.setHauteurBoite = function(val) {
	this.hautboite = val;
}

ClassePhotoZoomBox.prototype.getRatioX = function() {
	return this.ratioX;
}
ClassePhotoZoomBox.prototype.setRatioX = function(val) {
	this.ratioX = val;
}

ClassePhotoZoomBox.prototype.getRatioY = function() {
	return this.ratioY;
}
ClassePhotoZoomBox.prototype.setRatioY = function(val) {
	this.ratioY = val;
}


ClassePhotoZoomBox.prototype.getRatioMiniZoom = function() {
	return this.ratiominizoom;
}
ClassePhotoZoomBox.prototype.setRatioMiniZoom = function(val) {
	this.ratiominizoom = val;
}
ClassePhotoZoomBox.prototype.getEstDansPhotoReduit =function() {
	return this.estdansphoto;
}
ClassePhotoZoomBox.prototype.setEstDansPhotoReduit = function(val) {
	this.estdansphoto = val;
}

ClassePhotoZoomBox.prototype.getAfficheZoom = function() {
	return this.affichezoom;
}
ClassePhotoZoomBox.prototype.setAfficheZoom = function(val) {
	this.affichezoom = val;
}



ClassePhotoZoomBox.prototype.initialise = function(documentCrt){

var i;

var elt=this.getContaineurPhotoReduite();
var postailelt=retournePosTailleElement(elt);

var sTexte="";

sTexte=sTexte+"<IMG id=\""+this.getId()+"photored\" width=\""+postailelt.Largeur+"\" height=\""+postailelt.Hauteur+"\" class=\"edephotoreduite\" ";
sTexte=sTexte+" onmouseover=\""+this.getId()+".afficheSourisCacheMasque()\"";
//sTexte=sTexte+" onmouseout=\""+this.getId()+".afficheSourisCacheMasque(false,event)\"";
//sTexte=sTexte+" onmousemove=\""+this.getId()+".deplaceSourisBoite(event)\"";
sTexte=sTexte+" />";



for(i=0;i<4;i++){
	sTexte=sTexte+"<DIV id=\""+this.getId()+"mask"+i+"\" class=\"edemasquephoto\" ></DIV>";
}
sTexte=sTexte+"<DIV id=\""+this.getId()+"box\" class=\"edeboitephoto\" ></DIV>";
elt.innerHTML=sTexte;

elt=this.getContaineurPhotoAgrandie();
sTexte="<IMG id=\""+this.getId()+"photononred\"  />";
elt.innerHTML=sTexte;
//Utilisation de dom la place de inner htmlpour eviter les problemes de chargement plus d attente

//Initialisation des composant javascript
var eltdessus=new Array();
var i;
 var eltrech=documentCrt.getElementById(this.getId()+"photored");
 this.setImageReduite(eltrech);
 for(i=0;i<4;i++){
	eltrech=documentCrt.getElementById(this.getId()+"mask"+i);
	eltdessus[i]=eltrech;
}
eltrech=documentCrt.getElementById(this.getId()+"box");
eltdessus[4]=eltrech;

eltdessus[0].style.top="0px";
eltdessus[0].style.left="0px";

eltdessus[1].style.top="0px";
eltdessus[3].style.top="0px";

this.setMasquePhoto(eltdessus);
 //On soccupe maintenant du bloc non reduit
 eltrech=documentCrt.getElementById(this.getId()+"photononred");
 this.setImageNonReduite(eltrech);


}


ClassePhotoZoomBox.prototype.attenteChargementPhoto= function(){
var bCharge;



bCharge=this.getImageReduite().complete&&this.getImageNonReduite().complete;
//Initialisation des photos leurs taille et leur position
if(bCharge){
	
	this.definiAffichagePhotoEtBoite();
}
else{
	setTimeout(this.getId()+".attenteChargementPhoto()",100);
}

}


ClassePhotoZoomBox.prototype.definiPhoto = function(chemin) {
	this.setChemin(chemin);
	this.setAfficheZoom(false);
	
	
	this.getImageReduite().src=chemin;
	this.getImageNonReduite().src=chemin;
	this.attenteChargementPhoto();
}

ClassePhotoZoomBox.prototype.definiAffichagePhotoEtBoite = function() {

	var elt=this.getContaineurPhotoReduite();
	var postailelt=retournePosTailleElement(elt);
	//bug IE on est oblige de passe par un objet de type image
	//on  ne peut pas passser directement a l objet image dom
	var imgcrt=new Image();
	imgcrt.src=this.getChemin();
	var imgratio=retourneImageRatioRespecteEtCentre(postailelt.Largeur,postailelt.Hauteur,imgcrt.width,imgcrt.height);
	
	this.getImageReduite().width=imgratio.Largeur;
	this.getImageReduite().height=imgratio.Hauteur;
	//Calcul de la taille de la boite
	elt=this.getContaineurPhotoAgrandie();
	//il faut l afficher avant de calculer les tailles puis le cacher de nouveau
	elt.style.visibility="hidden";
	elt.style.display="block";
	
	var postailelt=retournePosTailleElement(elt);
	var val=parseInt(postailelt.Largeur)/parseInt(this.getImageNonReduite().width);
	if(val>1) val=1;
	var lg=Math.round(parseInt(this.getImageReduite().width)*val);
	val=parseInt(postailelt.Hauteur)/parseInt(this.getImageNonReduite().height);
	if(val>1) val=1;
	
	var ht=Math.round(parseInt(this.getImageReduite().height)*val);
	
	val=parseInt(this.getImageNonReduite().width)/parseInt(this.getImageReduite().width);
	this.setRatioX(val);
	val=parseInt(this.getImageNonReduite().height)/parseInt(this.getImageReduite().height);
	this.setRatioY(val);
	elt.style.display="none";
	elt.style.visibility="visible";
	
	this.setLargeurBoite(lg);
	this.setHauteurBoite(ht);
	var ratioMini=this.getRatioMiniZoom();
	this.setAfficheZoom(true);
	if(ratioMini!=-1){
		if((this.getRatioX()<ratioMini)||(this.getRatioY()<ratioMini)){
			this.setAfficheZoom(false);
		}
	}
}

ClassePhotoZoomBox.prototype.afficheCacheMasque= function(bAffiche){
var i;
if(this.getAfficheZoom()){
	var eltdessus=this.getMasquePhoto();
	 for(i=0;i<5;i++){
		if(bAffiche){
			eltdessus[i].style.visibility="visible";
		}
		else{
			eltdessus[i].style.visibility="hidden";
		}
	 }
	 var contimg=this.getContaineurPhotoAgrandie();

	 if(bAffiche){
		var postailelt=retournePosTailleElementFenetrePere(this.getContaineurPhotoReduite());
		
		this.setDessusContaineurPhotoReduite(parseInt(postailelt.Dessus));
		this.setGaucheContaineurPhotoReduite(parseInt(postailelt.Gauche));
		//on definie l objet global de drag comme etant l objet courant
		 objetdrag=this;
		 contimg.style.display="block";
	 }
	 else{
		contimg.style.display="none";
		objetdrag=null;
	 }
	 this.setEstDansPhotoReduit(bAffiche);
}
}

ClassePhotoZoomBox.prototype.deplaceBoite= function(x,y){
if(this.getAfficheZoom()){
	var limitelg=Math.round(this.getLargeurBoite()/2);
	var limiteht=Math.round(this.getHauteurBoite()/2);
	var x1,x2,y1,y2;

	if((x<0)||(y<0)||(x>this.getImageReduite().width)||(y>this.getImageReduite().height)){
		this.afficheCacheMasque(false);
	}
	else{
		var eltdessus=this.getMasquePhoto();
		if((x>=limitelg)&&(x<=this.getImageReduite().width-limitelg)){
			x1=x-limitelg;
			x2=x+limitelg;
		}
		else{
			if(x<limitelg){
				x1=0;
				x2=2*limitelg;
			}
			else{
				x2=this.getImageReduite().width;
				x1=x2-2*limitelg;
			}
		}
		if((y>=limiteht)&&(y<=this.getImageReduite().height-limiteht)){
			y1=y-limiteht;
			y2=y+limiteht;
		}
		else{
			if(y<limiteht){
				y1=0;
				y2=2*limiteht;
			}
			else{
				y2=this.getImageReduite().height;
				y1=y2-2*limiteht;
			}

		}
		
		//element 0
		eltdessus[0].style.width=x1+"px";
		eltdessus[0].style.height=parseInt(this.getImageReduite().height)+"px";
		//element 1
		eltdessus[1].style.left=x1+"px";
		eltdessus[1].style.height=y1+"px";

		var val=x2-x1;
		eltdessus[1].style.width=val+"px";
		
		

		eltdessus[2].style.width=val+"px";

		eltdessus[4].style.width=val+"px";
		//element 2
		eltdessus[2].style.left=x1+"px";
		eltdessus[2].style.top=y2+"px";
		var val=this.getImageReduite().height-y2;
		eltdessus[2].style.height=val+"px";

		//element 3
		eltdessus[3].style.left=x2+"px";
		var val=this.getImageReduite().width-x2;
		eltdessus[3].style.width=val+"px";
		eltdessus[3].style.height=parseInt(this.getImageReduite().height)+"px";
		//element 4
		//pour la taille des bordures
		val=y1-1;
		eltdessus[4].style.top=val+"px";
		val=x1-1;
		eltdessus[4].style.left=val+"px";
		var val=y2-y1;
		eltdessus[4].style.height=val+"px";
		
		//window.status=x+" "+y +" "+x1+" "+y1+" "+x2+" "+y2
		
		//deplacement de la photo
		var contimg=this.getContaineurPhotoAgrandie();
		var pos=Math.round(x1*this.getRatioX());
		contimg.scrollLeft=pos;
		pos=Math.round(y1*this.getRatioY());
		contimg.scrollTop=pos;
	}
}
}

ClassePhotoZoomBox.prototype.afficheSourisCacheMasque= function(ev){
this.afficheCacheMasque(true);
}

function documentDeplaceSouris(ev){
getPositionCurseur(ev);
if(objetdrag){
	if(objetdrag.getEstDansPhotoReduit()){
		
		var x=curX-objetdrag.getGaucheContaineurPhotoReduite();
		var y=curY-objetdrag.getDessusContaineurPhotoReduite();
		objetdrag.deplaceBoite(x,y);
	}
}
}

function documentSourisAppuyee(){
return true;
}

function documentSourisEnBas(){
return false;
}

function documentSourisEnHaut(){
return false;
}

