(function(b){var c={y:0,scrollHeight:0,elastic:true,momentum:true,elasticDamp:0.6,elasticTime:50,reboundTime:400,momentumDamp:0.9,momentumTime:300,iPadMomentumDamp:0.95,iPadMomentumTime:1200};var a={init:function(d){return this.each(function(){var n=b(this),z=b.extend(c,d),C=-z.y,r=0,s=0,l=0,w=0,A=0,G=0,u=false,f=false,m=false,I,x=navigator.platform.indexOf("iPad")!==-1,k="WebKitCSSMatrix" in window,t=k&&"m11" in new WebKitCSSMatrix();var q=this.update=function(){w=n.height();G=z.scrollHeight||n.attr("scrollHeight");if(G<w){G=w}A=w-G;clearTimeout(I);y(false)};q();n.css({"-webkit-transition-property":"-webkit-transform","-webkit-transition-timing-function":"cubic-bezier(0, 0, 0.2, 1)","-webkit-transition-duration":"0","-webkit-transform":j(C)});window.addEventListener("onorientationchange" in window?"orientationchange":"resize",q,false);n.bind("touchstart.touchScroll",e);n.bind("touchmove.touchScroll",F);n.bind("touchend.touchScroll touchcancel.touchScroll",i);n.bind("webkitTransitionEnd.touchScroll",p);var h=this.setPosition=function(o){C=o;n.css("-webkit-transform",j(C))};function j(o){return"translate"+(t?"3d(0px, ":"(0px, ")+o+"px"+(t?", 0px)":")")}function v(o){o=o||"0";n.css("-webkit-transition-duration",o+"ms")}function H(){if(k){var o=new WebKitCSSMatrix(window.getComputedStyle(n[0]).webkitTransform);return o.f}return C}this.getPosition=function(){return H()};function B(){if(C>0){g(0,z.reboundTime)}else{if(C<A){g(A,z.reboundTime)}}}function p(){if(f){f=false;B()}clearTimeout(I)}function y(J){if(!k||f){return}var o=l;l=H();if(l>0){if(z.elastic){f=true;C=0;E(l-o,z.elasticDamp,1,w,z.elasticTime)}else{v(0);h(0)}}else{if(l<A){if(z.elastic){f=true;C=A;E(l-o,z.elasticDamp,1,w,z.elasticTime)}else{v(0);h(A)}}else{if(J){I=setTimeout(y,20,true)}}}}function g(o,J){if(o===C){return}m=true;v(J);h(o)}function E(O,K,J,M,L){var N=Math.abs(O),o=0;while(N>0.1){N*=K;o+=N}if(o>M){o=M}if(o>J){if(O<0){o=-o}g(C+Math.round(o),L)}y(true)}function D(o){if(o.originalEvent){if(o.originalEvent.touches&&o.originalEvent.touches.length){return o.originalEvent.touches}else{if(o.originalEvent.changedTouches&&o.originalEvent.changedTouches.length){return o.originalEvent.changedTouches}}}return o.touches}function e(J){J.preventDefault();J.stopPropagation();var o=D(J);u=true;m=false;s=0;clearTimeout(I);v(0);if(z.momentum){var K=H();if(K!==C){h(K);m=true}}r=o[0].pageY-C}function F(K){if(!u){return}var J=D(K),o=J[0].pageY-r;if(o>0){if(z.elastic){o/=2}else{o=0}}else{if(o<A){if(z.elastic){o=(o+A)/2}else{o=A}}}s=o-C;m=true;h(o)}function i(L){if(!u){return}u=false;var K=D(L);if(m){if(C>0||C<A){B()}else{if(z.momentum){E(s,x?z.iPadMomentumDamp:z.momentumDamp,40,2000,x?z.iPadMomentumTime:z.momentumTime)}}}else{var M=K[0],J=M.target,o=document.createEvent("MouseEvent");while(J.nodeType!==1){J=J.parentNode}o.initMouseEvent("click",true,true,M.view,1,M.screenX,M.screenY,M.clientX,M.clientY,false,false,false,false,0,null);J.dispatchEvent(o)}}})},update:function(){return this.each(function(){this.update()})},getPosition:function(){var d=[];this.each(function(){d.push(-this.getPosition())});return d},setPosition:function(d){return this.each(function(){this.setPosition(-d)})}};b.fn.touchScroll=function(d){if(a[d]){return a[d].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof d==="object"||!d){return a.init.apply(this,arguments)}else{b.error("Method "+d+" does not exist on jQuery.touchScroll")}}}})(jQuery);
