function Carousel($node) {
this.$pic = $node.find('.pic')
this.$picWidth = this.$pic.children().width()
this.picLength = this.$pic.children().length
this.$btnPrev = $node.find('.btn-prev')
this.$btnNext = $node.find('.btn-next')
this.$pageIndex = $node.find('.pageIndex')
var $picFirst = this.$pic.children().eq(0).clone(),
$picLast = this.$pic.children().eq(this.picLength - 1).clone()
this.$pic.prepend($picLast)
this.$pic.append($picFirst)
this.$pic.width(this.$picWidth * this.$pic.children().length)
for (var i = 0; i < this.picLength; i++) {
this.$pageIndex.append($li)
this.$pageIndex.children().eq(0).addClass('active')
'left': '-=' + this.$picWidth
if (_this.mark === _this.picLength) {
_this.$pic.css('left', -_this.$picWidth)
'left': '+=' + this.$picWidth
_this.$pic.css('left', -(_this.picLength * _this.$picWidth))
_this.mark = _this.picLength - 1
this.$pageIndex.children().removeClass('active')
this.$pageIndex.children().eq(this.mark).addClass('active')
this.$btnNext.on('click', function() {
this.$btnPrev.on('click', function() {
this.$pageIndex.on('click', 'li', function() {
_this.mark = _this.$pageIndex.children().index($(this))
'left': -(_this.mark + 1) * _this.$picWidth
timer = setInterval(function() {
this.$pic.mouseenter(function(){
this.$pic.mouseleave(function(){
new Carousel($('.window'))