		/**
		 * We use the initCallback callback
		 * to assign functionality to the controls
		 */
		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.clip.hover(function() {
				carousel.stopAuto();
			}, function() {
				carousel.startAuto();
			});

		    jQuery('#mn-breakingnews .jcarousel-control a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			jQuery('#mn-breakingnews .jcarousel-control a').removeClass('current');
			carousel.startAuto(0);
			return false;
		    });

		    jQuery('.jcarousel-scroll select').bind('change', function() {
			carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
			return false;
		    });

		};

		function picsCarousel_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.clip.hover(function() {
				carousel.stopAuto();
			}, function() {
				carousel.startAuto();
			});

		    jQuery('#mn-photogalleries .jcarousel-control a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			jQuery('#mn-photogalleries .jcarousel-control a').removeClass('current');
			return false;
		    });

		    jQuery('.jcarousel-scroll select').bind('change', function() {
			carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
			return false;
		    });

		};
		
		function compsCarousel_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.clip.hover(function() {
				carousel.stopAuto();
			}, function() {
				carousel.startAuto();
			});

		    jQuery('#mn-competitions .jcarousel-control a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			jQuery('#mn-competitions .jcarousel-control a').removeClass('current');
			return false;
		    });

		    jQuery('.jcarousel-scroll select').bind('change', function() {
			carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
			return false;
		    });

		};		

		jQuery(document).ready(function() {
		    jQuery('#mycarousel').jcarousel({
				auto: 8,
                		wrap: 'last',
                		scroll: 1,
				initCallback: mycarousel_initCallback,
				itemVisibleInCallback: mycarousel_itemVisibleIn,
				itemVisibleOutCallback: mycarousel_itemVisibleOut
			});

		    jQuery('#pics-carousel').jcarousel({
				auto: 9,
				wrap: 'last',
				scroll: 1,
				initCallback: picsCarousel_initCallback,
				itemVisibleInCallback: picsCarousel_itemVisibleIn,
				itemVisibleOutCallback: picsCarousel_itemVisibleOut
			});	
			
		    jQuery('#comp-carousel').jcarousel({
				auto: 9,
				wrap: 'last',
				scroll: 1,
				initCallback: compsCarousel_initCallback,
				itemVisibleInCallback: compsCarousel_itemVisibleIn,
				itemVisibleOutCallback: compsCarousel_itemVisibleOut
			});				
			
			function mycarousel_itemVisibleIn(carousel, li, index, state){
				jQuery('#mn-breakingnews .jcarousel-control a').removeClass('current');
				jQuery('#mn-breakingnews .jcarousel-control a').eq(index-1).addClass('current');
			}
			
			function mycarousel_itemVisibleOut(carousel, li, index, state){
				jQuery('#mn-breakingnews .jcarousel-control a').eq(index-1).removeClass('current');
			}
			
			function picsCarousel_itemVisibleIn(carousel, li, index, state){
				jQuery('#mn-photogalleries .jcarousel-control a').removeClass('current');
				jQuery('#mn-photogalleries .jcarousel-control a').eq(index-1).addClass('current');
			}
			
			function picsCarousel_itemVisibleOut(carousel, li, index, state){
				jQuery('#mn-photogalleries .jcarousel-control a').eq(index-1).removeClass('current');
			}	
			
			function compsCarousel_itemVisibleIn(carousel, li, index, state){
				jQuery('#mn-competitions .jcarousel-control a').removeClass('current');
				jQuery('#mn-competitions .jcarousel-control a').eq(index-1).addClass('current');
			}
			
			function compsCarousel_itemVisibleOut(carousel, li, index, state){
				jQuery('#mn-competitions .jcarousel-control a').eq(index-1).removeClass('current');
			}					

		});

function videoCarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, videoCarousel_itemList.length);
    carousel.add(i, videoCarousel_getItemHTML(videoCarousel_itemList[idx - 1]));
	
	// This code checks if it is the final item and if so, sets up the tooltips for the newly generated images.
	if ((i%videoCarouselItemNumber) == 0) {
		jQuery('#video-carousel .jcarousel-item a img').tooltip({showURL: false, top: -60, left: -25, showBody: " - "});
	};
};

function videoCarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function videoCarousel_getItemHTML(item)
{
    return '<a href="' + item.link + '"><img src="' + item.url + '" width="100" height="75" alt="' + item.title + '" title="' + item.title + '" border="0" /></a>';
};

jQuery(document).ready(function() {

    jQuery('#video-carousel').jcarousel({
        wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: videoCarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: videoCarousel_itemVisibleOutCallback}
    });
	
});
