(function($){var counter=0;var imgRotator=function(element,option){counter++;var o=option,that=this;this.element=element;this.$element=$(element);this.width=this.$element.outerWidth();this.height=this.$element.outerHeight();this.dim=this.$element.offset();this.detect=element.tagName=='IMG';this.arr=o.img.slice();this.$help=$('<div class="imgRorator'+counter+'"></div>').css({'position':'absolute','top':this.dim.top+'px','left':this.dim.left+'px','width':this.width+'px','height':this.height+'px'});this.rotate=function(i){var $img=$('<img />'),index=i;$img.bind('load',function(){that.$help.hide().css({'background':'url('+that.arr[index]+') 0 0 no-repeat'}).fadeIn(o.speed,function(){that.change(index);setTimeout(function(){that.rotate((++index)%that.length)},o.delay)})}).attr({'src':this.arr[index]})};if(this.detect){this.change=function(index){this.element.src=this.arr[index]}}else{this.change=function(index){this.$element.css('background-image','url('+this.arr[index]+')')}}this.length=this.arr.length;this.init=function(){$('body').append(this.$help);setTimeout(function(){that.rotate(o.start)},o.delay)};return this};$.fn.imgRotator=function(option){this.each(function(){var obj=new imgRotator(this,option);obj.init()});return this}})(jQuery);

$(document).ready(function(){
    $('.motive img').imgRotator({
        img: ['./img/motive.jpg', './img/motive-02.jpg', './img/motive-03.jpg', './img/motive-04.jpg', './img/motive-05.jpg', './img/motive-06.jpg', './img/motive-07.jpg', './img/motive-08.jpg', './img/motive-09.jpg', './img/motive-10.jpg', './img/motive-11.jpg', './img/motive-12.jpg', './img/motive-13.jpg']
        ,delay: 5000
        ,speed: 1000
        ,start: 1 
    });
});

