похоже я что-то не понял, у меня сейчас вообще перестал реагировать.
var carWidth=240;
var visibleSlide = 3;
var blockMargin = 10;
function makeSlider (a) {
$el = a;
$(function(){
$el.find('.blocks').width($('.blocks').children().size()*carWidth);
$('.next_car').click(function(){
nextCar();
});
$('.prev_car').click(function(){
prevCar();
});
});
function nextCar(){
var currentSlide=parseInt($el.find('.blocks').data('current'));
currentSlide++;
if(currentSlide>=visibleSlide)
{
$el.find('.blocks').css('left',-(currentSlide-2)*carWidth+blockMargin);
$el.find('.blocks').append(el.find$('.blocks').children().first().clone());
$el.find('.blocks').children().first().remove();
currentSlide--;
}
$el.find('.blocks').animate({left: -currentSlide*carWidth},300).data('current',currentSlide);
}
function prevCar(){
var currentSlide=parseInt($el.find('.blocks').data('current'));
currentSlide--;
if(currentSlide<0)
{
$el.find('.blocks').css('left',-(currentSlide+2)*carWidth-blockMargin);
$el.find('.blocks').prepend($el.find('.blocks').children().last().clone());
$el.find('.blocks').children().last().remove();
currentSlide++;
}
$el.find('.blocks').animate({left: -currentSlide*carWidth},300).data('current',currentSlide);
}
}
makeSlider('#carousel1');
makeSlider('#carousel2');