$(document).ready(function() {
  	// Handler for .ready() called.
  	$.localScroll({
		duration:800
	});
	$.localScroll.hash({
		duration:800
	});
	
	function formatTitle(title,currentArray,currentIndex,currentOpts){
		var re = /\--/i;
		var ttl = "<span class=\"fb-title\">"+currentOpts.title.replace(re,"</span><br /><br />");
		var re2 =/\n/g;
		ttl = ttl.replace(re2,"<br />");
		
		var format='<span id="fancybox-title-over">';
		//console.log(currentOpts);
		format+='<table cellpadding"0" cellspacing="0" width="100%"><tr><td colspan="2" valign="bottom">';
		format+=ttl;
		format+='</td></tr><tr><td valign="top" style="padding-top:10px;" class="lightbox-sub">';
		//format+='<br/><span class="lightbox-sub"></span>';
		format+=(currentIndex+1)+'/'+currentArray.length;
		format+='</td><td align="right" valign="top" class="lightbox-sub" style="font-weight:normal;font-style:italic;padding-top:10px;">';
		format+='<a onclick="$.fancybox.prev();" style="cursor:pointer;">&laquo; vorige</a>&nbsp;&nbsp;&nbsp;';
		format+='<a onclick="$.fancybox.next();" style="cursor:pointer;">volgende &raquo;</a>';
		format+='</td></tr></table>';
		
		format+='</span>';
		return format;
		
		
		//function(title, currentArray, currentIndex, currentOpts) {
		//	return '<span id="fancybox-title-over"><span class="fb-title">'+title+'</span><span class="lightbox-sub" align="right" onclick="$.fancybox.close();">' + (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
	}
	
	function formatTitle2(title,currentArray,currentIndex,currentOpts){
		var re = /\--/i;
		var ttl = "<span class=\"fb-title\">"+currentOpts.title.replace(re,"</span><br /><br />");
		var re2 =/\n/g;
		ttl = ttl.replace(re2,"<br />");
		
		var format='<span id="fancybox-title-over">';
		//console.log(currentOpts);
		format+='<table cellpadding"0" cellspacing="0" width="100%"><tr><td colspan="2" valign="bottom">';
		format+=ttl;
		format+='</td></tr><tr><td valign="top" style="padding-top:10px;" class="lightbox-sub">';
		//format+='<br/><span class="lightbox-sub"></span>';
		format+=(currentIndex+1)+'/'+currentArray.length;
		format+='</td><td align="right" valign="top" class="lightbox-sub" style="font-weight:normal;font-style:italic;padding-top:10px;">';
		format+='<a onclick="$.fancybox.prev();" style="cursor:pointer;">&laquo; vorige</a>&nbsp;&nbsp;&nbsp;';
		format+='<a onclick="$.fancybox.next();" style="cursor:pointer;">volgende &raquo;</a>';
		format+='</td></tr></table>';
		
		format+='</span>';
		return format;
		
		
		//function(title, currentArray, currentIndex, currentOpts) {
		//	return '<span id="fancybox-title-over"><span class="fb-title">'+title+'</span><span class="lightbox-sub" align="right" onclick="$.fancybox.close();">' + (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
	}
	
	var c=0;
	while(c<30){
		c++;
	$("a[rel=grp"+c+"]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'ttl'				: 'BTMN',
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	}
	
	var c=0;
	while(c<30){
		c++;
	$("a[rel=grp2-"+c+"]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'ttl'				: 'BTMN',
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle2
	});
	}
	
	/*$("a[rel=grp2]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp3]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp4]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp5]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp6]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp7]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp8]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp9]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});
	$("a[rel=grp10]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'inside',
		'overlayOpacity'	: '0.7',
		'cyclic'			: true,
		'showNavArrows'		: false,
		'titleFormat'		: formatTitle
	});*/
	
});
