// Implementation: Bledar Begaj

function mycarousel_initCallback(carousel) {

  jQuery('.front-left-top .vooter .ctrl').bind('click', function() {
    ctrl(jQuery(this));
    carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()), true);
    return false;
  });

  $('.view-content *').hover(function() {
    carousel.stopAuto();
  }, function() {
    carousel.startAuto();
  });
}


function ctrl(btn) {
  btn.siblings().removeClass("active");
  btn.addClass("active");
}

function change(c, l, i, s) {
  ctrl(jQuery(".vooter .ctrl:eq(" + ((i-1)%5) + ")"));
}

$(document).ready(function() {
  jQuery('#news-list-carousel').jcarousel({
    auto: 15,
    scroll: 1,
    offset: 1,
    animation: 1000,
    wrap: "circular",
    itemVisibleInCallback: change,
    initCallback: mycarousel_initCallback,
    buttonNextHTML: null,
    buttonPrevHTML: null,
    itemFallbackDimension: 405
  });
});


