(function(a){a.fn.simplyScroll=function(c){return this.each(function(){new a.simplyScroll(this,c)})};var b={className:"costomer-slideshow-simply-scroll",frameRate:24,speed:1,horizontal:true,autoMode:"off",pauseOnHover:true,startOnLoad:false,localJsonSource:"",flickrFeed:"",jsonImgWidth:240,jsonImgHeight:180,variable:false,estimatedwidth:200};a.simplyScroll=function(d,e){var c=this;this.o=a.extend({},b,e||{});this.auto=this.o.autoMode!=="off"?true:false;this.$list=a(d);this.$list.addClass("costomer-slideshow-simply-scroll-list").wrap('<div class="costomer-slideshow-simply-scroll-clip"></div>').parent().wrap('<div class="'+this.o.className+' costomer-slideshow-simply-scroll-container"></div>');if(!this.o.auto){this.$list.parent().parent().prepend('<div class="costomer-slideshow-simply-scroll-forward"></div>').prepend('<div class="costomer-slideshow-simply-scroll-back"></div>')}if(this.o.flickrFeed){a.getJSON(this.o.flickrFeed+"&format=json&jsoncallback=?",function(f){json=[];a.each(f.items,function(g,h){json.push({src:h.media.m,title:h.title,link:h.link})});c.renderData(json)})}else{if(this.o.localJsonSource){a.getJSON(this.o.localJsonSource,function(f){c.renderData(f)})}else{if(!this.o.startOnLoad){this.init()}else{a(window).load(function(){c.init()})}}}};a.simplyScroll.fn=a.simplyScroll.prototype={};a.simplyScroll.fn.extend=a.simplyScroll.extend=a.extend;a.simplyScroll.fn.extend({init:function(){this.$items=this.$list.children();this.$clip=this.$list.parent();this.$container=this.$clip.parent();if(!this.o.horizontal){this.itemMax=this.$items.eq(0).outerHeight(true);this.clipMax=this.$clip.height();this.dimension="height";this.moveBackClass="simply-scroll-btn-up";this.moveForwardClass="costomer-slideshow-simply-scroll-btn-down"}else{this.itemMax=this.$items.eq(1).outerWidth(true);this.clipMax=this.$clip.width();this.dimension="width";this.moveBackClass="simply-scroll-btn-left";this.moveForwardClass="costomer-slideshow-simply-scroll-btn-right"}this.posMin=0;if(this.o.variable){this.itemMax=this.o.estimatedwidth}this.posMax=this.$items.length*this.itemMax;this.$list.css(this.dimension,this.posMax+"px");if(this.o.autoMode=="loop"){var d=Math.ceil(this.clipMax/this.itemMax);this.$items.slice(0,d).clone(true).appendTo(this.$list);this.posMax+=(this.clipMax-this.o.speed);this.$list.css(this.dimension,this.posMax+(this.itemMax*d)+"px")}this.interval=null;this.intervalDelay=Math.floor(1000/this.o.frameRate);while(this.itemMax%this.o.speed!==0){this.o.speed--;if(this.o.speed===0){this.o.speed=1;break}}var c=this;this.trigger=null;this.funcMoveBack=function(){c.trigger=this;c.moveBack()};this.funcMoveForward=function(){c.trigger=this;c.moveForward()};this.funcMoveStop=function(){c.moveStop()};this.funcMoveResume=function(){c.moveResume()};if(this.auto){if(this.o.pauseOnHover){this.$clip.hover(this.funcMoveStop,this.funcMoveResume)}this.moveForward()}else{this.$btnBack=a(".costomer-slideshow-simply-scroll-back",this.$container).addClass("costomer-slideshow-simply-scroll-btn "+this.moveBackClass+" disabled").hover(this.funcMoveBack,this.funcMoveStop);this.$btnForward=a(".costomer-slideshow-simply-scroll-forward",this.$container).addClass("costomer-slideshow-simply-scroll-btn "+this.moveForwardClass).hover(this.funcMoveForward,this.funcMoveStop)}},moveForward:function(){var c=this;this.movement="forward";if(this.trigger!==null){this.$btnBack.removeClass("disabled")}c.interval=setInterval(function(){if(!c.o.horizontal&&c.$clip[0].scrollTop<(c.posMax-c.clipMax)){c.$clip[0].scrollTop+=c.o.speed}else{if(c.o.horizontal&&c.$clip[0].scrollLeft<(c.posMax-c.clipMax)){c.$clip[0].scrollLeft+=c.o.speed}else{if(c.o.autoMode=="loop"){c.resetPos()}else{c.moveStop(c.movement)}}}},c.intervalDelay)},moveBack:function(){var c=this;this.movement="back";if(this.trigger!==null){this.$btnForward.removeClass("disabled")}c.interval=setInterval(function(){if(!c.o.horizontal&&c.$clip[0].scrollTop>0){c.$clip[0].scrollTop-=c.o.speed}else{if(c.o.horizontal&&c.$clip[0].scrollLeft>0){c.$clip[0].scrollLeft-=c.o.speed}else{if(c.o.autoMode=="loop"){c.resetPos()}else{c.moveStop(c.movement)}}}},c.intervalDelay)},moveStop:function(c){clearInterval(this.interval);if(this.trigger!==null){if(typeof c!="undefined"){a(this.trigger).addClass("disabled")}this.trigger=null}if(this.auto){if(this.o.autoMode=="bounce"){c=="forward"?this.moveBack():this.moveForward()}}},moveResume:function(){this.movement=="forward"?this.moveForward():this.moveBack()},resetPos:function(){if(!this.o.horizontal){this.$clip[0].scrollTop=0}else{this.$clip[0].scrollLeft=0}},renderData:function(d){if(d.length>0){var c=this;a.each(d,function(e,f){a("<img/>").attr({src:f.src,title:f.title,alt:f.title,width:c.o.jsonImgWidth,height:c.o.jsonImgHeight}).appendTo(c.$list)});this.init()}}})})(jQuery);