
object = new Array();
Tempo = 25;

VitesseZoom=10;
ImgLast = -1;
TailleMax=350;

ThumbLeftMax=320;


Tfinal=50;
Lfinal=450;

function StartAgrandir(ImgEnCours)
{
	object[ImgEnCours].img.cursor="crosshair";
	object[ImgEnCours].actif=true;
	object[ImgEnCours].deplaceLIn();
	object[ImgEnCours].deplaceTIn();
	object[ImgEnCours].Agrandir();
}

function StartReduire(ImgEnCours)
{
	object[ImgEnCours].img.cursor="pointer";
	object[ImgEnCours].Reduire();
	object[ImgEnCours].deplaceTOut();
	object[ImgEnCours].deplaceLOut();
}

function zyva(ImgEnCours)
{
	if(ImgEnCours!=ImgLast)
	{
		StartAgrandir(ImgEnCours);
		if (ImgLast!=-1)
		{
			object[ImgLast].actif=false;
			StartReduire(ImgLast);
		}
		ImgLast=ImgEnCours;
	}
}


function CObj(ImgEnCours,img,topinit,leftinit)
{
	this.T= topinit;
	this.L= leftinit;

	this.Tinit = topinit;
	this.Linit = leftinit;
	
	this.Tpas =(Tfinal-topinit)/5;
	this.Lpas =(Lfinal-leftinit)/50;

	this.img = img.style;

	this.W   =  parseInt(img.width);
	this.H   =  parseInt(img.height);

	this.Winit   = parseInt(img.width);
	this.Hinit   = parseInt(img.height);


	this.obj = "object["+ImgEnCours+"].";
	this.actif  = false;
	this.mainloop = function ()
	{
		with (this)
		{
			with(img)
			{
				top= Math.floor(T);
				left= Math.floor(L);			
				width= Math.floor(W);
				height= Math.floor(H);
			}
			setTimeout(obj+"mainloop();", Tempo);
		}
	}
	this.deplaceLIn  = function() 
	{
		with (this)
		{
			L=L+Lpas;
			if (actif)
			{
				if (L<Lfinal )
				{
					setTimeout(obj+"deplaceLIn();", Tempo);
				}
			}
		}
	}
	this.deplaceTIn  = function() 
	{
		with (this)
		{
			T=T+Tpas;
			if (actif)
			{
				if (((Tpas>0)&&(T<Tfinal))||((Tpas<0)&&(T>Tfinal)))
				{
					setTimeout(obj+"deplaceTIn();", Tempo);
				}
			}
		}
	}

	this.deplaceTOut  = function()
	{
		with (this)
		{

			T=T-Tpas;
			if (!actif)			
			if (((Tpas>0)&&(T>Tinit))||((Tpas<0)&&(T<Tinit)))
			{
				setTimeout(obj+"deplaceTOut();", Tempo);
			}
		}
	}

	this.deplaceLOut  = function()
	{
		with (this)
		{
			L=L-Lpas;
			if (!actif)			
			if (L>Linit)
			{
				setTimeout(obj+"deplaceLOut();", Tempo);
			}
		}
	}

	this.Agrandir  = function() 
	{
		with (this)
		{
			W += VitesseZoom;
			H += Hinit/Winit*VitesseZoom;
			if (actif)
			{
				if ((W<TailleMax )||(H<TailleMax))
				{
					setTimeout(obj+"Agrandir();", Tempo);
				}
			}
			
		}
	}
	this.Reduire  = function()
	{
		with (this)
		{
			W -= VitesseZoom;
			H -= Hinit/Winit*VitesseZoom;
			if (W>Winit)
			{
				setTimeout(obj+"Reduire();", Tempo);
			}
			else
			{
				actif=false;
			}
		}
	}
	this.mainloop();
}


function AlbumInit()
{
	Images =  document.getElementsByTagName("img");
	ImgCount= 0;
	imgtop=10;
	imgleft=10;
   
	for (i = 0; i < Images.length; i++)
	{
	     	className = Images[i].className;
		if ( className == "Picture" )
		{

			object[ImgCount] = new CObj(ImgCount,Images[i],imgtop,imgleft);
			ImgCount++;
			imgleft+=Images[i].width+10;
			if (imgleft>ThumbLeftMax) 
			{
				imgtop+=70;
				imgleft=10;
			}
		}

	}
DivPhotoCentrale=document.getElementById("AlbumPhoto");
DivPhotoCentrale.style.visibility='visible';
}

