//class pour gerer chaque diapo
//class cree par prototype
var Diapositive=Class.create();
Diapositive.prototype = {
	initialize: function(url,alt,index,cible){
		
		this.legend=alt;
		this.reference=null;
		this.src=url;
		this.id=index;
		this.im=new Image();
		//this.im.height="300px";
		this.status=0;
		this.left="";
		this.cible=cible;
		
		//creation de la resource
		var image=document.createElement("img");
		image.src="default.gif";
		image.className="diapositives";
		image.id="diapo"+this.id;
		image.style.display='none';
		
		//cible.appendChild(image);
		Insertion.Bottom(cible,image);
		this.reference=image;
		this.reference.style.position='relative';
		this.reference.style.display='none';
		delete image;
	},
	/*liste des method
	nomMethod:function() {
		
	},*/
	charge : function(){
		//document.getElementById('diapo'+this.id).src=this.src;
		if (this.status<1){
			this.im.src=this.src;
			
			//alert(this.im.width);
			if (this.status==0){this.status=1;}
			this.waitForIm();
		}
	},
	affiche : function(){
		
		new Effect.Appear(this.reference);
		
		//new Effect.Grow('diapo'+this.id);
		//new Effect.Move('diapo'+this.id,{x:40});
	},
	cache : function(){
		new Effect.Puff(this.reference);
	},
	waitForIm : function(){
		if (!this.im.complete) { setTimeout(getFcnRef(this,'waitForIm'), 100); return; }	
		this.status=2;
		this.reference.src=this.im.src;
		
		//ajustement des decalages
		
		//recuperer la taille du contenair pour ajuster la position eventuelement
		var larg=this.cible.getWidth();
		var haut=this.cible.getHeight();
		this.reference.style.height=this.im.height+"px";
		this.reference.style.width=this.im.width+"px";
		this.reference.style.left=Math.floor((larg - this.im.width)/2)+"px";
		this.reference.style.top=Math.floor((haut - this.im.height)/2)+"px"
		
	}
	
}

