jQuery(document).ready(function($) {
	var elements = $('div.advertenties');
    elements.each(function(index, value) { 
		$(value).cycle({timeoutFn: calculateTimeout, random:  1  }); 
	});
	
	var aelements = $('a.ad');
	
	aelements.each(function(aindex, avalue) { 
		$(avalue).fancybox({'height' : 500, 'width' : 700, showNavArrows: false, onComplete: fbcomplete});
	});
	
	
	$('#fotorechts').cycle({timeout: 6000}); 
	$('.fotolist a').css('display', 'inline');
	
	$('.gallery-item .gallery-icon a').attr('rel', 'gallery');
	
	$('a[rel="gallery"]').fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Foto ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
	});
});

function calculateTimeout(currElement, nextElement, opts, isForward) {
    return parseInt(jQuery(currElement).attr('rel')) * 1000;
} 

function fbcomplete(){
	
}
