var mycarousel_itemListNews;

$(function() {
	
	if(currentpage=='fotoreportages')
	{	
		$('.reportitem .photogallery').jcarousel();
		
		$(".reportitem a").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	}

	$("a.photorepo").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		},
		'itemArray' : mycarousel_itemListNews
	});
	
	if(mycarousel_itemListNews)
	{
	$('#gallerynews').jcarousel({
        size: mycarousel_itemListNews.length,
        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallbackNews}
    });		
	}

});

function mycarousel_itemLoadCallbackNews(carousel, state)
{
	var photoitems = [];
	
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemListNews.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML(mycarousel_itemListNews[i-1]));
    }
	
	
	 $("#gallerynews a").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		},
		'itemArray' : mycarousel_itemListNews
	});
	
};
