// JavaScript Document

PhotoViewer=function(width)
{
	PhotoViewer.me=$('<div/>');
	PhotoViewer.me.attr('id' , 'PhotoViewer');

	PhotoViewer.adresse=ModeleInteraction.root+"elements/contenus/PhotoViewer/";
	this.me=PhotoViewer.me;
	// récupère la liste des images
	PhotoViewer.getListeImage=function(reponse , arg2)
	{
		$.each(reponse.images , PhotoViewer.envoieImageSWF);
	}
	
	PhotoViewer.envoieImageSWF=function(i , img)
	{
		PhotoViewer.declencheFonctionActionScript(img.url);
	}
	
	
	
	PhotoViewer.getImages=function()
	{
		$.getJSON(ModeleInteraction.root+"elements/contenus/PhotoViewer/parcours.php",
			  {album:'alb_17' , racine:ModeleInteraction.root},
			  PhotoViewer.getListeImage);
	}
	
	
	// graphique : 
	if (!width)
	{
		this.width=440;
		this.height=340;
	}
	else
	{
		this.width=width;
		this.height=this.width*340/440
	}
	
	// création de l'animation : 
	var animation = { movie:PhotoViewer.adresse+"PhotoViewer.swf", width:this.width , height:this.height,
     			 majorversion:"9", build:"40" , wmode:"transparent", allowScreenAccess:"always" , id:'monPhotoViewer' , name:'monPhotoViewer'}
	
	UFO.create(animation, 'PhotoViewer');
	
	
	
	PhotoViewer.recupAnimation=function( pAnim ) 
	{
		return (document.getElementById('monPhotoViewer'));
	} 
	
	PhotoViewer.declencheFonctionActionScript=function(imgURL) 
	{ 
		PhotoViewer.recupAnimation("monPhotoViewer").loadPhoto(imgURL); 
	}
	
	ModeleGraphique.allowDrag(PhotoViewer.me);
}