// plaatjes fader
function cycleFromDir(options) {
	
	var cycle = $(options.ImgHolder);
	
	$('img:first',$(options.ImgHolder))
	.addClass('first');
	
	// images list JSON
	$.get(options.XHRpath,options.XHRreq,function(data){
		
		var list = data.files;
		
		// image nodes maken (niet inladen; geen src maar alt)
		for (i=0; i<list.length; i++) {
			$('<img/>')
			.attr('alt',options.randDir+list[i])
			.addClass('slide')
			.appendTo( $(cycle) );
		}
		
		// cyclen
		$(cycle)
		.cycle({
			fx: 			'fade',
			slideExpr:		'.slide',
			startingSlide:	0,
			delay: 			options.delay, // additional delay (in ms) for first transition
			timeout: 		options.timeout,
			speed: 			options.speed,
			sync:			options.sync ? options.sync : 1,
			pause:			0,     // true to enable "pause on hover" 
			before:			alt2src,
			after:			after
		});
		
		// transfer alt of elem to src of elem
		function alt2src(){
			$(this)
			.filter("[alt^='http']")
			.attr('src',$(this).attr('alt'))
			.removeAttr('alt');
		}
		
		function after(){
			
			if( $('img.first',$(options.ImgHolder)).length ){
				setTimeout(removefirst,Math.abs(options.timeout));
			}
		}
		
		function removefirst(){
			
			if( $('img.first',$(options.ImgHolder)).length ){
				
				// remove first slide
				$('img.first',
					$(options.ImgHolder)
					//.css({
						//'backgroundImage':"url('"+$('img.first',$(options.ImgHolder)).attr('src')+"')"
					//})
				)
				.css({
					position:'absolute',zIndex:2998
				})
				.fadeOut(options.speed,function(){
					$(this).remove();
				});
				
				//window.console.log('removed first');
			}
		}
		
	
	},"json");
		
}