		function mycarousel_itemLoadCallback(carousel, state)
		{
			for (var i = carousel.first; i <= carousel.last; i++) {
				if (carousel.has(i)) {
					continue;
				}

				if (i > mycarousel_itemList.length) {
					break;
				}

				carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
			}			
	
			jQuery('#mycarousel .jcarousel-item img').each(function() {					
				var hBox = jQuery(this).parent().parent().height();	
				var hImg = jQuery(this).height();
				if (hImg>10) {
					jQuery(this).css('padding-top', (hBox-hImg)/2);		
				};
			});
			
			jQuery('#mycarousel .jcarousel-item img').load(function () {
				var hBox = jQuery(this).parent().parent().height();	
				var hImg = jQuery(this).height();
				jQuery(this).css('padding-top', (hBox-hImg)/2);
			});	
			
		};	
		
		function mycarousel_getItemHTML(item)
		{
			return '<a href="'+item.url_full+'"><img src="' + item.url + '" alt="' + item.title + '" /></a>';
		};
		
		function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
			jQuery("#mycarousel-next .jcarousel-control").html(mycarousel_itemList.length-idx);
			jQuery("#mycarousel-prev .jcarousel-control").html(idx-1);
			jQuery("#mycarousel .url-title").html('<a href="' + mycarousel_itemList[idx-1].url_full + '">' + mycarousel_itemList[idx-1].title + '</a>');
		 }; 

		function mycarousel_initCallback(carousel)
		{
			// Disable autoscrolling if the user clicks the prev or next button.
			carousel.buttonNext.bind('click', function() {
				//carousel.startAuto(0);
			});

			carousel.buttonPrev.bind('click', function() {
				//carousel.startAuto(0);
			});

			// Pause autoscrolling if the user moves with the cursor over the clip.
			carousel.container.hover(function() {
				carousel.stopAuto();
			}, function() {
				carousel.startAuto();
			});
			
			// Scroll carousel pri mousewheel
			carousel.container.bind('mousewheel', function(event, delta) {
				carousel[ delta > 0 ? 'prev' : 'next']();
				return false;
			});

		};
	
		jQuery(document).ready(function() {
			if (jQuery('#mycarousel').length) {
				jQuery('#mycarousel').jcarousel({
					start: 1,
					scroll:1,
					visible:1,
					wrap: 'both',
					itemFirstInCallback: {
					  onBeforeAnimation: mycarousel_itemFirstInCallback
					},
					initCallback: mycarousel_initCallback,
					size: mycarousel_itemList.length,
					itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback},
					auto: 3,
					easing: 'easeOutBack',
					animation: 600,
					buttonNextHTML: null,
					buttonPrevHTML: null
				});			
			
				var w = jQuery('.gal-navigation').width() - jQuery('.gal-navigation li:first').width() - jQuery('.gal-navigation li:last').width();
				jQuery('.gal-navigation li:eq(1)').width(w);
			};
		
		});
