/* http://plugins.jquery.com/project/touchSwipe */
(function(n){n.fn.swipe=function(f){if(!this)return!1;var b={fingers:1,threshold:75,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,click:null,triggerOnTouchEnd:!0,allowPageScroll:"auto"},l="left",o="right",p="up",q="down",r="none",s="horizontal",t="vertical",x="auto",y="start",u="move",m="end",i="cancel",c="start";if(f.allowPageScroll==void 0&&(f.swipe!=void 0||f.swipeStatus!=void 0))f.allowPageScroll=r;f&&n.extend(b,f);return this.each(function(){function f(a){c=
y;g=a.touches.length;distance=0;direction=null;g==b.fingers?(d.x=e.x=a.touches[0].pageX,d.y=e.y=a.touches[0].pageY,b.swipeStatus&&j(a,c)):k(a)}function z(a){if(!(c==m||c==i)){e.x=a.touches[0].pageX;e.y=a.touches[0].pageY;direction=v();g=a.touches.length;c=u;var f=direction;if(b.allowPageScroll==r)a.preventDefault();else{var d=b.allowPageScroll==x;switch(f){case l:(b.swipeLeft&&d||!d&&b.allowPageScroll!=s)&&a.preventDefault();break;case o:(b.swipeRight&&d||!d&&b.allowPageScroll!=s)&&a.preventDefault();
break;case p:(b.swipeUp&&d||!d&&b.allowPageScroll!=t)&&a.preventDefault();break;case q:(b.swipeDown&&d||!d&&b.allowPageScroll!=t)&&a.preventDefault()}}g==b.fingers?(distance=w(),b.swipeStatus&&j(a,c,direction,distance),!b.triggerOnTouchEnd&&distance>=b.threshold&&(c=m,j(a,c),k(a))):(c=i,j(a,c),k(a))}}function A(a){a.preventDefault();distance=w();direction=v();b.triggerOnTouchEnd?(c=m,g==b.fingers&&e.x!=0?distance>=b.threshold||(c=i):c=i,j(a,c),k(a)):c==u&&(c=i,j(a,c),k(a))}function k(){g=0;d.x=0;
d.y=0;e.x=0;e.y=0}function j(a,c){b.swipeStatus&&b.swipeStatus.call(h,a,c,direction||null,distance||0);c==i&&b.click&&g==1&&(isNaN(distance)||distance==0)&&b.click.call(h,a,a.target);if(c==m)switch(b.swipe&&b.swipe.call(h,a,direction,distance),direction){case l:b.swipeLeft&&b.swipeLeft.call(h,a,direction,distance);break;case o:b.swipeRight&&b.swipeRight.call(h,a,direction,distance);break;case p:b.swipeUp&&b.swipeUp.call(h,a,direction,distance);break;case q:b.swipeDown&&b.swipeDown.call(h,a,direction,
distance)}}function w(){return Math.round(Math.sqrt(Math.pow(e.x-d.x,2)+Math.pow(e.y-d.y,2)))}function v(){var a;a=Math.round(Math.atan2(e.y-d.y,d.x-e.x)*180/Math.PI);a<0&&(a=360-Math.abs(a));return a<=45&&a>=0?l:a<=360&&a>=315?l:a>=135&&a<=225?o:a>45&&a<135?q:p}var h=n(this),g=0,d={x:0,y:0},e={x:0,y:0};try{this.addEventListener("touchstart",f,!1),this.addEventListener("touchmove",z,!1),this.addEventListener("touchend",A,!1),this.addEventListener("touchcancel",k,!1)}catch(B){}})}})(jQuery);
