function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
	switchClasse(this.text);
	document.getElementById("cpt").value=this.text;
        return false;
    });

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

    jQuery('#mycarousel-next').bind('click', function() {
      if( document.getElementById("cpt").value < document.getElementById("cptTotal").value)
     document.getElementById("cpt").value++;
     cpt = document.getElementById("cpt").value;
     switchClasse(cpt);
     if( document.getElementById("cpt").value <= document.getElementById("cptTotal").value)
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
     if( (document.getElementById("cpt").value <= document.getElementById("cptTotal").value) && (document.getElementById("cpt").value > 1) )
     document.getElementById("cpt").value--;
     
     cpt = document.getElementById("cpt").value;
     switchClasse(cpt);
     if( (document.getElementById("cpt").value <= document.getElementById("cptTotal").value))
        carousel.prev();
        return false;
    });
    
     function switchClasse(toto)
    {
     var active = "#mark"+(toto)+" a";
     
      $('#marqueurs a').removeClass('active').addClass('normal');
       $(active).removeClass('normal').addClass('active');
    }
};

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel").jcarousel({
        scroll: 1,
	
        initCallback: mycarousel_initCallback,
	
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});
