var xhrInProgress = false;

jQuery(document).ready(function() {
    
	jQuery('.temoignages').jcarousel({
        auto: 5,
        wrap: 'circular',
        buttonNextHTML: null,
        buttonPrevHTML: null,
        scroll: 1,
        initCallback: initCarousel,
        itemVisibleInCallback: setCarouselVisibleItem
    });
	
});

function initCarousel(carousel)
{
    jQuery('.pager a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('href').replace('#','')));
        return false;
    });

    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    
}

function setCarouselVisibleItem(carousel, li, index, action) {
	num = index%jQuery(".pager a").size();
	if(num==0)
		num=jQuery(".pager a").size();
	
	jQuery(".pager a").each(function() { jQuery(this).removeClass("active"); });
    jQuery(".pager a[rel=" + num+"]").addClass('active');
}

