jQuery(document).ready(function() {

// home top stage
    $('.carousel .slide').cycle({
        fx: 'fade',
		timeout: 18000,
		speed: 400,
        before: onBefore,
        pager: '.menu-une',
        pagerAnchorBuilder: function(idx, slide) {
		idxNUM = idx + 1;
        return '<div class="inactif">' + idxNUM + '</div>';
        }
    });

	$('.carousel .menu-une .inactif').click(function(){
		$('.carousel .slide').cycle('stop');
	});

	// media slideshow base	
//	$('#media_cat .categoryList').cycle({ 
//		fx: 'scrollVert', 
//		timeout: 0,
//		next: '#media_cat .next', 
//		prev: '#media_cat .previous'
//	});	
//	

	

    //end setup of slideshow gallery

});

$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
    $(pager).find('div').removeClass('actif')
        .filter('div:eq(' + currSlideIndex + ')').addClass('actif');
};

function gallery_initCallback(carousel) {
	var listTotal = jQuery('#gallery li').length;

	jQuery('.mod-gallery954 #main_image').bind('img_change', function() {
	    var num = parseInt((jQuery('.mod-gallery954 .caption').text()).split(";", 1)[0]) - 3;
	    var location = parseInt(jQuery('.mod-gallery954 .caption').text().split(";", 2)[0]) + 1;

	    jQuery('.mod-gallery954 .caption').html(jQuery('.caption').text().split(";", 2)[1]);
	    jQuery('.mod-gallery954 .tracker').html(location + " of " + listTotal);

	    carousel.scroll(num);
	    return false;
	});
};

function onBefore() {
	$('.stghrimg').html($('.carousel-titre', this).html());
	$('.stghrtxt').html($('.slidecontent', this).html());
	$('.stgcredit').html($('.slidecredit', this).html());
}


