/*
* simplyscroll 2 - a scroll-tastic jquery plugin
*
* http://logicbox.net/jquery/simplyscroll/
*
* copyright (c) 2009-2012 will kelly - http://logicbox.net
*
* dual licensed under the mit and gpl licenses.
*
* version: 2.0.5 last revised: 10/05/2012
*
*/
(function(c,j,i){c.fn.simplyscroll=function(a){return this.each(function(){new c.simplyscroll(this,a)})};var h={customclass:"simply-scroll",framerate:24,speed:1,orientation:"horizontal",auto:!0,automode:"loop",manualmode:"end",direction:"forwards",pauseonhover:!0,pauseontouch:!0,pausebutton:!1,startonload:!1};c.simplyscroll=function(a,b){var g=this;this.o=c.extend({},h,b||{});this.isauto=!1!==this.o.auto&&null!==this.o.automode.match(/^loop|bounce$/);this.isrtl=(this.ishorizontal=null!==this.o.orientation.match(/^horizontal|vertical$/)&&
this.o.orientation==h.orientation)&&"rtl"==c("html").attr("dir");this.isforwards=!this.isauto||this.isauto&&(null!==this.o.direction.match(/^forwards|backwards$/)&&this.o.direction==h.direction)&&!this.isrtl;this.isloop=this.isauto&&"loop"==this.o.automode||!this.isauto&&"loop"==this.o.manualmode;this.events=(this.supportstouch="createtouch"in document)?{start:"touchstart moztouchdown",move:"touchmove moztouchmove",end:"touchend touchcancel moztouchrelease"}:{start:"mouseenter",end:"mouseleave"};
this.$list=c(a);var d=this.$list.children();this.$list.addclass("simply-scroll-list").wrap('
').parent().wrap('');this.isauto?this.o.pausebutton&&(this.$list.parent().parent().prepend(''),this.o.pauseonhover=!1):this.$list.parent().parent().prepend('').prepend('');
if(1").parent().addclass("simply-scroll-list"),this.ishorizontal?this.$list.children().css({"float":"left",width:e+"px"}):this.$list.children().css({height:e+"px"}))}this.o.startonload?c(j).load(function(){g.init()}):this.init()};c.simplyscroll.fn=
c.simplyscroll.prototype={};c.simplyscroll.fn.extend=c.simplyscroll.extend=c.extend;c.simplyscroll.fn.extend({init:function(){this.$items=this.$list.children();this.$clip=this.$list.parent();this.$container=this.$clip.parent();this.$btnback=c(".simply-scroll-back",this.$container);this.$btnforward=c(".simply-scroll-forward",this.$container);this.ishorizontal?(this.itemmax=this.$items.eq(0).outerwidth(!0),this.clipmax=this.$clip.width(),this.dimension="width",this.movebackclass="simply-scroll-btn-left",
this.moveforwardclass="simply-scroll-btn-right",this.scrollpos="left"):(this.itemmax=this.$items.eq(0).outerheight(!0),this.clipmax=this.$clip.height(),this.dimension="height",this.movebackclass="simply-scroll-btn-up",this.moveforwardclass="simply-scroll-btn-down",this.scrollpos="top");this.posmin=0;this.posmax=this.$items.length*this.itemmax;var a=math.ceil(this.clipmax/this.itemmax);if(this.isauto&&"loop"==this.o.automode)this.$list.css(this.dimension,this.posmax+this.itemmax*a+"px"),this.posmax+=
this.clipmax-this.o.speed,this.isforwards?(this.$items.slice(0,a).clone(!0).appendto(this.$list),this.resetposition=0):(this.$items.slice(-a).clone(!0).prependto(this.$list),this.resetposition=this.$items.length*this.itemmax,this.isrtl&&(this.$clip[0].dir="ltr",this.$items.css("float","right")));else if(!this.isauto&&"loop"==this.o.manualmode){this.posmax+=this.itemmax*a;this.$list.css(this.dimension,this.posmax+this.itemmax*a+"px");this.posmax+=this.clipmax-this.o.speed;this.$items.slice(0,a).clone(!0).appendto(this.$list);
this.$items.slice(-a).clone(!0).prependto(this.$list);this.resetpositionforwards=this.resetposition=a*this.itemmax;this.resetpositionbackwards=this.$items.length*this.itemmax;var b=this;this.$btnback.bind(this.events.start,function(){b.isforwards=false;b.resetposition=b.resetpositionbackwards});this.$btnforward.bind(this.events.start,function(){b.isforwards=true;b.resetposition=b.resetpositionforwards})}else this.$list.css(this.dimension,this.posmax+"px"),this.isforwards?this.resetposition=0:(this.resetposition=
this.$items.length*this.itemmax,this.isrtl&&(this.$clip[0].dir="ltr",this.$items.css("float","right")));this.resetpos();this.interval=null;this.intervaldelay=math.floor(1e3/this.o.framerate);if(this.isauto||"end"!=this.o.manualmode)for(;0!==this.itemmax%this.o.speed;)if(this.o.speed--,0===this.o.speed){this.o.speed=1;break}b=this;this.trigger=null;this.funcmoveback=function(a){a!==i&&a.preventdefault();b.trigger=!b.isauto&&b.o.manualmode=="end"?this:null;b.isauto?b.isforwards?b.moveback():b.moveforward():
b.moveback()};this.funcmoveforward=function(a){a!==i&&a.preventdefault();b.trigger=!b.isauto&&b.o.manualmode=="end"?this:null;b.isauto?b.isforwards?b.moveforward():b.moveback():b.moveforward()};this.funcmovepause=function(){b.movepause()};this.funcmovestop=function(){b.movestop()};this.funcmoveresume=function(){b.moveresume()};if(this.isauto){this.paused=!1;var g=function(){if(b.paused===false){b.paused=true;b.funcmovepause()}else{b.paused=false;b.funcmoveresume()}return b.paused};this.supportstouch&&
this.$items.find("a").length&&(this.supportstouch=!1);if(this.isauto&&this.o.pauseonhover&&!this.supportstouch)this.$clip.bind(this.events.start,this.funcmovepause).bind(this.events.end,this.funcmoveresume);else if(this.isauto&&this.o.pauseontouch&&!this.o.pausebutton&&this.supportstouch){var d,f;this.$clip.bind(this.events.start,function(a){g();var c=a.originalevent.touches[0];d=b.ishorizontal?c.pagex:c.pagey;f=b.$clip[0]["scroll"+b.scrollpos];a.stoppropagation();a.preventdefault()}).bind(this.events.move,
function(a){a.stoppropagation();a.preventdefault();a=a.originalevent.touches[0];a=d-(b.ishorizontal?a.pagex:a.pagey)+f;if(a<0)a=0;else if(a>b.posmax)a=b.posmax;b.$clip[0]["scroll"+b.scrollpos]=a;b.funcmovepause();b.paused=true})}else this.o.pausebutton&&(this.$btnpause=c(".simply-scroll-btn-pause",this.$container).bind("click",function(a){a.preventdefault();g()?c(this).addclass("active"):c(this).removeclass("active")}));this.funcmoveforward()}else this.$btnback.addclass("simply-scroll-btn "+this.movebackclass).bind(this.events.start,
this.funcmoveback).bind(this.events.end,this.funcmovestop),this.$btnforward.addclass("simply-scroll-btn "+this.moveforwardclass).bind(this.events.start,this.funcmoveforward).bind(this.events.end,this.funcmovestop),"end"==this.o.manualmode&&(!this.isrtl?this.$btnback.addclass("disabled"):this.$btnforward.addclass("disabled"))},moveforward:function(){var a=this;this.movement="forward";null!==this.trigger&&this.$btnback.removeclass("disabled");a.interval=setinterval(function(){a.$clip[0]["scroll"+a.scrollpos]<
a.posmax-a.clipmax?a.$clip[0]["scroll"+a.scrollpos]+=a.o.speed:a.isloop?a.resetpos():a.movestop(a.movement)},a.intervaldelay)},moveback:function(){var a=this;this.movement="back";null!==this.trigger&&this.$btnforward.removeclass("disabled");a.interval=setinterval(function(){a.$clip[0]["scroll"+a.scrollpos]>a.posmin?a.$clip[0]["scroll"+a.scrollpos]-=a.o.speed:a.isloop?a.resetpos():a.movestop(a.movement)},a.intervaldelay)},movepause:function(){clearinterval(this.interval)},movestop:function(a){this.movepause();
null!==this.trigger&&("undefined"!==typeof a&&c(this.trigger).addclass("disabled"),this.trigger=null);this.isauto&&"bounce"==this.o.automode&&("forward"==a?this.moveback():this.moveforward())},moveresume:function(){"forward"==this.movement?this.moveforward():this.moveback()},resetpos:function(){this.$clip[0]["scroll"+this.scrollpos]=this.resetposition}})})(jquery,window);