$('#myCarousel').carousel({
interval: 3500
});
// This event fires immediately when the slide instance method is invoked.
$('#myCarousel').on('slide.bs.carousel', function (e) {
var id = $('.item.active').data('slide-number');
// Added a statement to make sure the carousel loops correct
if(e.direction == 'right'){
id = parseInt(id) - 1;
if(id == -1) id = 7;
} else{
id = parseInt(id) + 1;
if(id == $('[id^=carousel-thumb-]').length) id = 0;
}
$('[id^=carousel-thumb-]').removeClass('selected');
$('[id=carousel-thumb-' + id + ']').addClass('selected');
});
// Thumb control
$('[id^=carousel-thumb-]').click( function(){
var id_selector = $(this).attr("id");
var id = id_selector.substr(id_selector.length -1);
id = parseInt(id);
$('#myCarousel').carousel(id);
$('[id^=carousel-thumb-]').removeClass('selected');
$(this).addClass('selected');
});