(function($){var methods={init:function(options){var settings={'type':'vertical','height':100,'width':100,'direction':'normal','count':1,'duration':5000};return this.each(function(){if(options)$.extend(settings,options);var $this=$(this);data=$this.data('imagescroller');imagescroller={'type':settings.type,'direction':settings.direction,'count':settings.count,'counter':0,'width':settings.width,'height':settings.height,'duration':settings.duration};if(!data){$this.data('imagescroller',imagescroller);data=imagescroller}$this.addClass('imagescroller');$this.css({'height':settings.height?settings.height:'auto','width':settings.width?settings.width:'auto'}).append($('<div />').addClass('imagescroller-overlay'));if(settings.type=='vertical')if(settings.direction=='reverse')$this.children('img').css('bottom',0);else $this.children('img').css('top',0);else if(settings.direction=='reverse')$this.children('img').css('right',0);else $this.children('img').css('left',0);if($this.children('img').height()&&$this.children('img').width())methods.scroll($this);else $this.children('img').load(function(){methods.scroll($this)})})},scroll:function($this){data=$this.data('imagescroller');var animateProperties;var cssProperties;if(data.type=='vertical')if(data.direction=='reverse'){animateProperties={bottom:'-='+($this.children('img').height()-data.height)+'px'};cssProperties={'bottom':'auto','top':0}}else{animateProperties={top:'-='+($this.children('img').height()-data.height)+'px'};cssProperties={'top':'auto','bottom':0}}else if(data.direction=='reverse'){animateProperties={right:'-='+($this.children('img').width()-data.width)+'px'};cssProperties={'right':'auto','left':0}}else{animateProperties={left:'-='+($this.children('img').width()-data.width)+'px'};cssProperties={'left':'auto','right':0}}$this.children('img').animate(animateProperties,data.duration,function(){$(this).css(cssProperties);data.direction=(data.direction=='reverse')?'normal':'reverse';if(!data.count){$this.data('imagescroller',data);methods.scroll($this)}else{data.counter++;$this.data('imagescroller',data);if(data.counter<data.count)methods.scroll($this)}})}};$.fn.imagescroller=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments)}else{$.error('Method '+method+' does not exist on jQuery.imagesscroller')}}})(jQuery);
