function Swipe(n,t){function b(){var t,f;for(e=r.children,c=new Array(e.length),u=n.getBoundingClientRect().width||n.offsetWidth,r.style.width=e.length*u+"px",t=e.length;t--;)f=e[t],f.style.width=u+"px",f.setAttribute("data-index",t),l.transitions&&(f.style.left=t*-u+"px",s(t,i>t?-u:i<t?u:0,0));l.transitions||(r.style.left=i*-u+"px");n.style.visibility="visible"}function rt(){i?y(i-1):t.continuous&&y(e.length-1)}function nt(){i<e.length-1?y(i+1):t.continuous&&y(0)}function y(n,r){if(i!=n){if(l.transitions){for(var f=Math.abs(i-n)-1,o=Math.abs(i-n)/(i-n);f--;)s((n>i?n:i)-f-1,u*o,0);s(i,u*o,r||h);s(n,0,r||h)}else ut(i*-u,n*-u,r||h);i=n;w(t.callback&&t.callback(i,e[i]))}}function s(n,t,i){p(n,t,i);c[n]=t}function p(n,t,i){var u=e[n],r=u&&u.style;r&&(r.webkitTransitionDuration=r.MozTransitionDuration=r.msTransitionDuration=r.OTransitionDuration=r.transitionDuration=i+"ms",r.webkitTransform="translate("+t+"px,0)translateZ(0)",r.msTransform=r.MozTransform=r.OTransform="translateX("+t+"px)")}function ut(n,u,f){if(!f){r.style.left=u+"px";return}var o=+new Date,s=setInterval(function(){var h=+new Date-o;if(h>f){r.style.left=u+"px";a&&g();t.transitionEnd&&t.transitionEnd.call(event,i,e[i]);clearInterval(s);return}r.style.left=(u-n)*(Math.floor(h/f*100)/100)+n+"px"},4)}function g(){tt=setTimeout(nt,a)}function k(){a=0;a=t.auto>0?t.auto:0;clearTimeout(tt)}var it=function(){},w=function(n){setTimeout(n||it,0)},l={addEventListener:!!window.addEventListener,touch:"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch,transitions:function(n){var t=["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"],i;for(i in t)if(n.style[t[i]]!==undefined)return!0;return!1}(document.createElement("swipe"))},r,e,c,u,i,h,a,tt;if(n){r=n.children[0];t=t||{};i=parseInt(t.startSlide,10)||0;h=t.speed||300;t.continuous=t.continuous?t.continuous:!0;a=t.auto||0;var d={},f={},v,o={handleEvent:function(n){switch(n.type){case"touchstart":this.start(n);break;case"touchmove":this.move(n);break;case"touchend":w(this.end(n));break;case"webkitTransitionEnd":case"msTransitionEnd":case"oTransitionEnd":case"otransitionend":case"transitionend":w(this.transitionEnd(n));break;case"resize":w(b.call())}t.stopPropagation&&n.stopPropagation()},start:function(n){var t=n.touches[0];d={x:t.pageX,y:t.pageY,time:+new Date};v=undefined;f={};r.addEventListener("touchmove",this,!1);r.addEventListener("touchend",this,!1)},move:function(n){if(!(n.touches.length>1)&&(!n.scale||n.scale===1)){t.disableScroll&&n.preventDefault();var r=n.touches[0];f={x:r.pageX-d.x,y:r.pageY-d.y};typeof v=="undefined"&&(v=!!(v||Math.abs(f.x)<Math.abs(f.y)));v||(n.preventDefault(),k(),f.x=f.x/(!i&&f.x>0||i==e.length-1&&f.x<0?Math.abs(f.x)/u+1:1),p(i-1,f.x+c[i-1],0),p(i,f.x+c[i],0),p(i+1,f.x+c[i+1],0))}},end:function(){var n=+new Date-d.time,l=Number(n)<250&&Math.abs(f.x)>20||Math.abs(f.x)>u/2,a=!i&&f.x>0||i==e.length-1&&f.x<0,y=f.x<0;v||(l&&!a?(y?(s(i-1,-u,0),s(i,c[i]-u,h),s(i+1,c[i+1]-u,h),i+=1):(s(i+1,u,0),s(i,c[i]+u,h),s(i-1,c[i-1]+u,h),i+=-1),t.callback&&t.callback(i,e[i])):(s(i-1,-u,h),s(i,0,h),s(i+1,u,h)));r.removeEventListener("touchmove",o,!1);r.removeEventListener("touchend",o,!1)},transitionEnd:function(n){parseInt(n.target.getAttribute("data-index"),10)==i&&(a&&g(),t.transitionEnd&&t.transitionEnd.call(n,i,e[i]))}};return b(),a&&g(),l.addEventListener?(l.touch&&r.addEventListener("touchstart",o,!1),l.transitions&&(r.addEventListener("webkitTransitionEnd",o,!1),r.addEventListener("msTransitionEnd",o,!1),r.addEventListener("oTransitionEnd",o,!1),r.addEventListener("otransitionend",o,!1),r.addEventListener("transitionend",o,!1)),window.addEventListener("resize",o,!1)):window.onresize=function(){b()},{setup:function(){b()},slide:function(n,t){y(n,t)},prev:function(){k();rt()},next:function(){k();nt()},getPos:function(){return i},kill:function(){var n,t;for(k(),r.style.width="auto",r.style.left=0,n=e.length;n--;)t=e[n],t.style.width="100%",t.style.left=0,l.transitions&&p(n,0,0);l.addEventListener?(r.removeEventListener("touchstart",o,!1),r.removeEventListener("webkitTransitionEnd",o,!1),r.removeEventListener("msTransitionEnd",o,!1),r.removeEventListener("oTransitionEnd",o,!1),r.removeEventListener("otransitionend",o,!1),r.removeEventListener("transitionend",o,!1),window.removeEventListener("resize",o,!1)):window.onresize=null}}}}(window.jQuery||window.Zepto)&&function(n){n.fn.Swipe=function(t){return this.each(function(){n(this).data("Swipe",new Swipe(n(this)[0],t))})}}(window.jQuery||window.Zepto)