var oldMenu = '';

function changeMarker(num){
 
  $("#bt" + num).addClass("selected");
  
  if(oldMenu != ("#bt" + num)){
    $(oldMenu).removeClass("selected");
    oldMenu = "#bt" + num;
  }
}

function carousel_initCallback(carousel) {
    changeMarker(1);
    jQuery('.jcarousel-control a').bind('click', function() {
        var num = jQuery(this).text();
        carousel.scroll(jQuery.jcarousel.intval(num));
        changeMarker(num);
        carousel.stopAuto();
        var timer = setTimeout(function(){carousel.startAuto();}, 10000);
        return false;
    });
    
    // Pause autoscrolling if the user moves with the cursor over the clip.
        jQuery("#carousel ul").hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    
};

// Ride the carousel...
jQuery(document).ready(function() {
    $("#carousel").css('visibility','visible');
    jQuery("#carousel").jcarousel({
        scroll: 1,
        initCallback: carousel_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null,
        auto:3,
        wrap: 'last'
    });
});
