﻿// najsDiaporama v0.0.1
// by Newton Applications - http://www.newtonapplications.com
// Create : 2009-06-12
// Last Change : 2009-06-14
// For more information on this script, visit: http://www.newtonapplications.com/
// Requirements : prototype.js (1.6.0) / scriptaculous.js (1.7.1)

var najsDiaporama = Class.create({
nameClass: 'najsDiaporama',version: '0.0.1',idInstance: '',
lastDate: '',
initialize: function(idOfInstance,idBaseDiapo,delay,images) { 
	this.idInstance=idOfInstance;
	this.images=images;
	this.idBaseDiapo=idBaseDiapo;
	this.delay=delay;
	this.layer='A';
	this.current=0;
	this.receiver=[];
	Event.observe(window, "load", this.start.bindAsEventListener(this));
},
start: function(){this.intervalle=new PeriodicalExecuter(this.next.bindAsEventListener(this), this.delay);},
stop: function(){this.intervalle.stop();},
next: function(){
	this.current++;
	if(this.images.length==this.current)this.current=0;
	this.imageFade=this.idBaseDiapo+this.layer;
	if(this.layer=='A')this.layer='B'; else this.layer='A';
	var newimage='<div class="zoneimage" id="'+this.idBaseDiapo+this.layer+'" style="position:absolute;top:0px;left:0px;"><a href="'+this.images[this.current].url+'"><img  id="'+this.idBaseDiapo+this.layer+'Image" src="'+this.images[this.current].image+'" /></a></div>';
	$(this.idBaseDiapo).insert({top:newimage});
	Event.observe($(this.idBaseDiapo+this.layer+"Image"), "load", this.imageok.bindAsEventListener(this));
	this.stop();
},
imageok:function(){
	Effect.Fade(this.imageFade);
	//Effect.Fade(this.imageFade+"Image");
	//Effect.Puff(this.imageFade+"Image");
	//Effect.Fold(this.imageFade+"Image");
	this.start();
}
});