function getFlashMovie(movieName) {
  	var isIE = navigator.appName.indexOf("Microsoft") != -1;
  	return (isIE) ? window[movieName] : document[movieName];
}

function stopPlaying(id) { 
	getFlashMovie(id).stopSingleButtonPlayer();
}

function getObjectIdsandStopPlaying() {
    var idarray = $("#mainFeature").find("object").map(function() { return this.id; }).get();
    
    for(var i=0; i<idarray.length; i++)
    {
        stopPlaying(idarray[i]);
    }
}

function featureCarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        //getObjectIdsandStopPlaying();
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        //getObjectIdsandStopPlaying();
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.

    $('.jcarousel-container').hover(function() {
        carousel.stopAuto();
        carousel.buttonPrev.show();
        carousel.buttonNext.show();
    }, function() {
        //carousel.startAuto();
        carousel.buttonPrev.hide();
        carousel.buttonNext.hide();
    });

    carousel.buttonPrev.hide();
    carousel.buttonNext.hide();

};

jQuery(document).ready(function() {
    jQuery('#featureCarousel').jcarousel({
      wrap: 'both',
      animation:'fast',
      auto: 5,
      scroll:1,
      initCallback: featureCarousel_initCallback

    });
});