/**
 * jCarousel Circular Autoscroll 
 *
 * our event listener receives the carousel
 * object, so we just check to see if it's 
 * turned itself off or not...
 */
function afterAnimation(carousel){
  if(carousel.autoStopped){
    carousel.startAuto()
  }
}
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(document).ready(function(){
  var options = {
    auto: 5,                               // delay between scrolling to the next slide
    scroll:1,                              // scroll this amount of slides
    wrap: 'circular',                      // wrap
    initCallback: mycarousel_initCallback, // stop animation on hover or prev/next 
    itemLastInCallback:{
      onAfterAnimation: afterAnimation     // restart animation if it has stopped
    }
  }
  jQuery('#mycarousel').jcarousel(options);
})


