// JavaScript Document
function next(whichOne){
	var from = whichOne;
	var to = whichOne - 1;
	fromDiv = "form" + from.toString();
	toDiv = "form" + to.toString();

	if($(fromDiv).fx){$(fromDiv).fx.stop();}
	if($(toDiv).fx){$(toDiv).fx.stop();}
	
	$(fromDiv).set('tween', {duration: '750'});
	$(toDiv).set('tween', {duration: '750'});	
	
	$(toDiv).setStyle('display','block');

	$(fromDiv).tween('opacity','0');
	$(toDiv).tween('opacity','1');
}

function prev(whichOne){
	var from = whichOne;
	var to = whichOne + 1;
	fromDiv = "form" + from.toString();
	toDiv = "form" + to.toString();
	
	if($(fromDiv).fx){$(fromDiv).fx.stop();}
	if($(toDiv).fx){$(toDiv).fx.stop();}
	
	$(fromDiv).set('tween', {duration: '750'});
	$(toDiv).set('tween', {duration: '750'});	
	
	$(toDiv).setStyle('display','block');

	$(fromDiv).tween('opacity','0');
	$(toDiv).tween('opacity','1');
}

function attachStyle(src) {
	var linker = new Element ('link');
	linker.setProperties({
		rel: 'stylesheet',
		type: 'text/css',
		media: 'all',
		href: src
	});
	linker.injectBefore($(document.head).getElement('script'));
}

window.addEvent('domready', function() {
	var aantalPics = $(document.body).getElements('div.image').length;
	
	attachStyle('css/fotos-js.css');	
	
	$(document.body).getElements('div.image').each(function(el, index){
		el.setStyle('display','none');
		el.param = index;
		if(index < (aantalPics-1)){
			el.addEvent('click', function(){
				next(aantalPics - index - 1);									  	
			});
		}
	});
	$('form'+(aantalPics-1)).setStyle('display','block');
});




