function mycarousel_initCallback(carousel) {
    $('.slider_controls a').first().addClass("active");
    $('.slider_controls a').bind('click', function() {
        var index = $(this).attr("id").split("_");
        carousel.scroll(jQuery.jcarousel.intval(index[1]));
        $(".slider_controls a").removeClass("active");
        $(this).addClass("active");
        return false;
    });
    
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    }); 
    
    jQuery('.next_slide').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('.prev_slide').bind('click', function() {
        carousel.prev();
        return false;
    }); 
}
          
function add_active(carousel, obejctli,liindex,listate){
    jQuery('.slider_controls a:nth-child('+ liindex +')').attr("class","active");
}

function remove_active(carousel, obejctli,liindex,listate){
    jQuery('.slider_controls a:nth-child('+ liindex +')').removeAttr("class","active");
}


$(document).ready(function() {
    $('.slider_content').jcarousel({
        auto: 3,
        start: 1,
        wrap: 'both',
        easing: 'easeInOutQuint',
        scroll: 1,
        animation: 1000,
        initCallback: mycarousel_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null,
        itemVisibleInCallback:  add_active,
        itemVisibleOutCallback: remove_active
    });
});







