var prev = null
function nextPhoto() {
	
	var el = null;
	if (prev == null) {
		el = $('slideshow').getChildren('div')[0];
	}
	else {
		el = prev.getNext('div');
	}
	
	//overnieuw
	if (el == null) {
		el = $('slideshow').getChildren('div')[0];
	}

	try {
		el.setStyle('opacity','0')
		el.setStyle('display','block')
		
		//fade vorige uit
		if (prev != null) {
			prev.set('morph', {duration: 'long'});
			prev.morph({opacity: 0});
		}
		
		//fade huidige in
		el.set('morph', {duration: 'long'});
		el.morph({opacity: 1});
		
		
		
		prev = el;
	} catch (e) {}
}

function slideshow() {
	var timer = nextPhoto.periodical(7000);
}


function checkomschrijving() {
	var scrollheight = $('fotoomschrijving').getScrollSize().y;
	var height = $('fotoomschrijving').getSize().y
	
	if (scrollheight > height) {
		var aantalkeer = Math.ceil((scrollheight-50)/90)
		//console.log(aantalkeer)
		var newheight = 50+aantalkeer*90
		$('fotoomschrijving').setStyle('height',newheight)
		$('fototable').setStyle('top',(aantalkeer*90+90))
	}
	//console.log(scrollheight+" "+height)
}

window.addEvent('domready', function() {
    checkomschrijving()
});