(function(){var t=function(){function t(t,i){var e=this;e.settings=$.extend($.fn.rollerblade.defaults,i),e.container=$(t),e.image=e.container.find("img"),e.oldX=0,e.oldDiff=null,e.lastMove="none",e.lastMoveConstant="none",e.previousX=0,e.i=0,e.iAuto=0,e.sensitivity=e.settings.sensitivity,e.mobileRate=e.settings.sensitivity/3,e.images=e.settings.imageArray,e.preloadImages=[],e.timer=null,e.touchOnThis=!1,e.init()}return t.prototype.init=function(){var t=this;t.settings.auto===!0?t.auto(t.sensitivity):/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?t.touchIsMoving():t.settings.drag===!0?(t.drag(),t.image.addClass("rollerblade-drag")):t.settings.drag===!1&&t.mouseIsMoving(),t.preload(t.images)},t.prototype.preload=function(t){var i=this;i.preloadImages.list||(i.preloadImages.list=[]);for(var e=0;e<t.length;e++){var o=new Image;o.onload=function(){var t=i.preloadImages.list.indexOf(this);-1!==t&&i.preloadImages.splice(t,1)},i.preloadImages.list.push(o),o.src=t[e]}},t.prototype.increment=function(){var t=this;t.iAuto++,t.iAuto>=t.images.length&&(t.iAuto=0),t.image.attr("src",t.images[t.iAuto])},t.prototype.decrement=function(){var t=this;t.iAuto--,t.iAuto<0&&(t.iAuto=t.images.length-1),t.image.attr("src",t.images[t.iAuto])},t.prototype.auto=function(t){var i=this;i.timer=setInterval(function(){i.iAuto++,i.iAuto>=i.images.length&&(i.iAuto=0),i.image.attr("src",i.images[i.iAuto])},t)},t.prototype.autoStop=function(){var t=this;clearInterval(t.timer)},t.prototype.drag=function(){var t=this,i=!1;document.ondragstart=function(){return!1},t.image.mousedown(function(t){t.preventDefault,i||(i=!0)}),$("body").mousemove(function(e){if(e.preventDefault,i){var o=e.clientX;t.changeLogic(o,t.sensitivity)}}),$("body").mouseup(function(t){t.preventDefault,i&&(i=!1)})},t.prototype.mouseIsMoving=function(){var t=this;$("body").mousemove(function(i){var e=i.pageX,o=t.sensitivity;t.changeLogic(e,o)})},t.prototype.touchIsMoving=function(){var t=this;t.container.on("touchstart",function(){t.touchOnThis=!0}),$(window).on("touchmove",function(i){var e=i.originalEvent,o=e.pageX,n=t.mobileRate;t.touchOnThis&&t.changeLogic(o,n)}),$(window).on("touchend",function(){t.touchOnThis=!1})},t.prototype.changeLogic=function(t,i){var e=this;null===e.oldDiff&&(e.oldDiff=t,e.rotate(t)),t>e.oldDiff?e.lastMoveConstant="right":t<e.oldDiff&&(e.lastMoveConstant="left"),t>e.previousX&&"left"===e.lastMoveConstant?(e.oldDiff=t,e.i++):t<e.previousX&&"right"===e.lastMoveConstant&&(e.oldDiff=t,e.i--),Math.abs(t-e.oldDiff)>i&&(e.rotate(t),e.oldDiff=t),e.previousX=t},t.prototype.rotate=function(t){var i=this;t>i.oldX?("left"===i.lastMove&&i.i++,i.i>i.images.length&&(i.i=i.settings.edgeStop?i.images.length:0),i.image.attr("src",i.images[i.i]),i.i>=i.images.length?i.i=i.settings.edgeStop?i.images.length:0:i.i++,i.lastMove="right"):t<i.oldX&&("right"===i.lastMove&&i.i--,i.i<0&&(i.i=i.settings.edgeStop?0:i.images.length),i.image.attr("src",i.images[i.i]),i.i<=0?i.i=i.settings.edgeStop?0:i.images.length:i.i--,i.lastMove="left"),i.oldX=t},t}();$.fn.rollerblade=function(i){var e;return(e=this.data("rollerblade"))?i===!0?e:("string"===$.type(i)&&e[i](),this):this.each(function(){return $(this).data("rollerblade",new t(this,i))})},$.fn.rollerblade.defaults={imageArray:[],sensitivity:35,drag:!0,auto:!1,edgeStop:!1}}).call(this);