///////////////
// Klasse: Gallery
// Author: Markus Auer, ma@adwerba.at
// Benötigt prototype.js 
///////////////

var Gallery = Class.create();
Gallery.prototype = {
	initialize: function(params) {
		this.param = {
		  big:'id des grossen Bildes',
		  thumbs:['ids der thumbnails'],
		  images:['pfade zu den bildern'],
		  large: {x:400,y:300},
		  small: {x:80,y:60}
		}
		Object.extend(this.param, params || {});

		this.pos=0;
		this.show(0);
		this.paint();
	},

	show: function(nr) {
		$(this.param.big).src=this.thumb(this.param.large,this.param.images[this.pos+nr]);
	},

	paint: function() {
		var len=Math.min(this.param.thumbs.length,this.param.images.length);
		for(var i=0;i<len;i++) {
			$(this.param.thumbs[i]).src=this.thumb(this.param.small,this.param.images[this.pos+i]);
		}
	},

	next: function() {
		this.pos += Math.floor(this.param.thumbs.length/2);
		var max=Math.max(0,this.param.images.length-this.param.thumbs.length);
		if (this.pos>max) this.pos=max;
		this.paint();
	},

	prev: function() {
		this.pos -= Math.floor(this.param.thumbs.length/2);
		if (this.pos<0) this.pos=0;
		this.paint();
	},

	thumb: function(dim, img) {
	   return '/.thumb?src='+img+'&w='+dim.x+'&h='+dim.y+'&fltr[]=usm|80|0.8|1';
	}
}

