$(function(){
var slider = $('.slider-inner'),
slides = $('.slide'),
dotes = $('.slider-dot');
$('.arrow-left').on('click', function(){
var slideNumber = slides.index($('.slide-active')),
slideWidth = slides.eq(slideNumber).width();
slides.eq(slideNumber).removeClass('slide-active');
dotes.eq(slideNumber).removeClass('dot-active');
if(slideNumber === 0) {
slides.eq(slides.length-1).addClass('slide-active');
dotes.eq(slides.length-1).addClass('dot-active');
slider.animate({marginLeft:-slideWidth*(slides.length-1) + "px"}, 600);
} else {
slides.eq(slideNumber-1).addClass('slide-active');
dotes.eq(slideNumber-1).addClass('dot-active');
slider.animate({marginLeft:-slideWidth*(slideNumber-1) + "px"}, 600);
}
});
$('.arrow-right').on('click', function(){
var slideNumber = slides.index($('.slide-active')),
slideWidth = slides.eq(slideNumber).width();
slides.eq(slideNumber).removeClass('slide-active');
dotes.eq(slideNumber).removeClass('dot-active');
if(slideNumber === (slides.length-1)) {
slides.eq(0).addClass('slide-active');
dotes.eq(0).addClass('dot-active');
slider.animate({marginLeft:"0px"}, 600);
} else if (slideNumber < (slides.length-1)) {
slides.eq(slideNumber+1).addClass('slide-active');
dotes.eq(slideNumber+1).addClass('dot-active');
slider.animate({marginLeft:-slideWidth*(slideNumber+1) + "px"}, 600);
}
});
dotes.on('click', function(){
var oldSlide = $('.slide-active'),
oldDote = $('.dot-active'),
dotNumber = dotes.index($(this)),
slideWidth = slides.eq(dotNumber).width();
oldSlide.removeClass('slide-active');
oldDote.removeClass('dot-active');
slides.eq(dotNumber).addClass('slide-active');
dotes.eq(dotNumber).addClass('dot-active');
slider.animate({marginLeft:-slideWidth*dotNumber + "px"}, 600);
})
});