api.SlideShow = 
{
	interval : 10, // seconds
	preload : 4, // seconds
	counter : 0,
	starter : null, // time interval pointer
	photos : 10, // number of photos
	actuali : 0, // actual photo number
	width : 100,
	height : 100,
	nextimg : {},
	imgid : '',
	linkid : '',
	picture_paths : [],
	picture_urls : [],
	picture_names : [],
	crop : 4,
	exists_link : 1,
	
	Init : function (o)
	{
		o = o || {};
		this.photos = o.photos;
		this.width = o.width;
		this.height = o.height;
		this.imgid = o.imgid;
		this.linkid = o.linkid;
		this.picture_paths = o.picture_paths;
		this.picture_urls = o.picture_urls;
		this.picture_names = o.picture_names;
		this.interval = o.interval;
		this.preload = o.preload;
		this.crop = o.crop;
		this.exists_link = o.exists_link;
	},
	
	Start : function ()
	{
		this.starter = setInterval("api.SlideShow.Anim()", 1000);
	},
	
	Stop : function ()
	{
		clearInterval(this.starter);
	},
	
	Anim : function ()
	{
		this.counter++;
		// pre-load next image
		if (this.counter == (this.interval - this.preload))
		{
			this.actuali++;
			nextimg = new Image();
			nextimg.src = 'libs/file/Img.php?path=' + this.picture_paths[this.actuali] + '&width=' + this.width + '&height=' + this.height + '&create_method=' + this.crop;
			nextimg.alt = this.picture_names[this.actuali];
		}
		// preload image and clear counter
		if (this.counter == this.interval)
		{
			var i = api.e(this.imgid);
			i.src = nextimg.src;
			i.alt = nextimg.alt;
			if (this.exists_link) {
				var a = api.e(this.linkid);
				a.href = this.picture_urls[this.actuali];
				a.title = nextimg.alt;
			}
			this.counter = 0;
			// clear image rotation
			if (this.actuali == (this.photos - 1))
			{
				this.actuali = -1;
			}
		}
	}
}