$(document).ready(function() {

	// laat eerst de slideshow beginnen

	bigImages=new Array();
	arrNr=0;
	
	thumbsNails=$("#thumbnails img");
	if (thumbsNails.length>0) {

		$("#thumbnails img").each(function(){
			src=$(this).attr('src');
			srcBig=src.replace(/_small_/,'');
			bigImages[arrNr++]={src:srcBig,smallSrc:src};
		}).css({cursor:'pointer'});
		startSlide(bigImages);
	
		// maak een click event aan elke thumbnail om dan opnieuw de slide te starten vanaf die foto
		$("#thumbnails img").click(function(){
			// welke?
			smallSrc=$(this).attr('src');
			// reorder bigImages
			arrLen=bigImages.length;
			while (bigImages[0].smallSrc!=smallSrc) {
				bigImages.push(bigImages.shift());
			}
			startSlide(bigImages);
		});

	}
	
	function startSlide(imgArray) {
		$('#bigimage').crossSlide({sleep:2,fade:1}, imgArray);
	}
	
});

