
var Bladeraar = new Class({
	items: [],
	currentitem: null,
	lastcurrentitem: null,
	itemclass: null,
	currentshow: null,
	lastcurrentshow: null,
	
	initialize: function(itemclass) {
		this.itemclass = itemclass;
		this.items = $$(this.itemclass);
		this.items.each(function(element, itemindex) {
			element.setStyle('z-index', (1000-itemindex));
			element.addEvent('mouseenter', function(){this.bladerNaar(element)}.bind(this));
			element.addEvent('click', function(){this.updatecurrentshow(element)}.bind(this));
			}.bind(this));
	},
	
	updatecurrentshow: function(element) {
		this.lastcurrentshow = this.currentshow;
		this.currentshow = element;
		this.update();
		var ind = this.items.indexOf(element);
		evnGallery.goTo(ind);
		
	},
	
	bladerNaar: function(element) {
		if (this.currentitem == element) return;
		if (!element) return;
		if (this.currentitem) this.currentitem.removeClass('active');
		this.lastcurrentitem = this.currentitem;
		this.currentitem = element;
		if (this.currentitem) this.currentitem.addClass('active');
		this.update();
		var plaatje = $(element).getElement('img').src;
		if ((plaatje) && (plaatje.substring(plaatje.length-3, plaatje.length) == "gif")) {
			$(element).getElement('img').src = 'foto/minithumb/'+this.currentitem.id+'.jpg';
			}
	},
	

	update: function() {
		if(this.lastcurrentitem) {
			this.lastcurrentitem.morph({'margin-top':'-57px', 'margin-left':'0px'});
			this.lastcurrentitem.getElement('h4').setStyle('display','none');
			this.lastcurrentitem.getElement('h6').setStyle('display','block');
			}
		if(this.lastcurrentshow) this.lastcurrentshow.morph({'margin-top':'-57px', 'margin-left':'0px'});
		if(this.currentitem) {
			this.currentitem.morph({'margin-top':'-5px'});
			this.currentitem.getElement('h4').setStyle('display','block');
			this.currentitem.getElement('h6').setStyle('display','none');
			}
		if(this.currentshow) this.currentshow.morph({'margin-top':'-5px', 'margin-left':'4px'});
	}
	
});




