/* v0 */
(function(a){a.fn.swipe=function(c){if(!this){return false}var k={fingers:1,threshold:75,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,click:null,triggerOnTouchEnd:true,allowPageScroll:"auto"};var m="left";var l="right";var d="up";var s="down";var j="none";var u="horizontal";var q="vertical";var o="auto";var f="start";var i="move";var h="end";var n="cancel";var t="ontouchstart" in window,b=t?"touchstart":"mousedown",p=t?"touchmove":"mousemove",g=t?"touchend":"mouseup",r="touchcancel";var e="start";if(c.allowPageScroll==undefined&&(c.swipe!=undefined||c.swipeStatus!=undefined)){c.allowPageScroll=j}if(c){a.extend(k,c)}return this.each(function(){var D=this;var H=a(this);var E=null;var I=0;var x={x:0,y:0};var A={x:0,y:0};var K={x:0,y:0};function z(N){var M=t?N.touches[0]:N;e=f;if(t){I=N.touches.length}distance=0;direction=null;if(I==k.fingers||!t){x.x=A.x=M.pageX;x.y=A.y=M.pageY;if(k.swipeStatus){y(N,e)}}else{C(N)}D.addEventListener(p,J,false);D.addEventListener(g,L,false)}function J(N){if(e==h||e==n){return}var M=t?N.touches[0]:N;A.x=M.pageX;A.y=M.pageY;direction=v();if(t){I=N.touches.length}e=i;G(N,direction);if(I==k.fingers||!t){distance=B();if(k.swipeStatus){y(N,e,direction,distance)}if(!k.triggerOnTouchEnd){if(distance>=k.threshold){e=h;y(N,e);C(N)}}}else{e=n;y(N,e);C(N)}}function L(M){M.preventDefault();distance=B();direction=v();if(k.triggerOnTouchEnd){e=h;if((I==k.fingers||!t)&&A.x!=0){if(distance>=k.threshold){y(M,e);C(M)}else{e=n;y(M,e);C(M)}}else{e=n;y(M,e);C(M)}}else{if(e==i){e=n;y(M,e);C(M)}}D.removeEventListener(p,J,false);D.removeEventListener(g,L,false)}function C(M){I=0;x.x=0;x.y=0;A.x=0;A.y=0;K.x=0;K.y=0}function y(N,M){if(k.swipeStatus){k.swipeStatus.call(H,N,M,direction||null,distance||0)}if(M==n){if(k.click&&(I==1||!t)&&(isNaN(distance)||distance==0)){k.click.call(H,N,N.target)}}if(M==h){if(k.swipe){k.swipe.call(H,N,direction,distance)}switch(direction){case m:if(k.swipeLeft){k.swipeLeft.call(H,N,direction,distance)}break;case l:if(k.swipeRight){k.swipeRight.call(H,N,direction,distance)}break;case d:if(k.swipeUp){k.swipeUp.call(H,N,direction,distance)}break;case s:if(k.swipeDown){k.swipeDown.call(H,N,direction,distance)}break}}}function G(M,N){if(k.allowPageScroll==j){M.preventDefault()}else{var O=k.allowPageScroll==o;switch(N){case m:if((k.swipeLeft&&O)||(!O&&k.allowPageScroll!=u)){M.preventDefault()}break;case l:if((k.swipeRight&&O)||(!O&&k.allowPageScroll!=u)){M.preventDefault()}break;case d:if((k.swipeUp&&O)||(!O&&k.allowPageScroll!=q)){M.preventDefault()}break;case s:if((k.swipeDown&&O)||(!O&&k.allowPageScroll!=q)){M.preventDefault()}break}}}function B(){return Math.round(Math.sqrt(Math.pow(A.x-x.x,2)+Math.pow(A.y-x.y,2)))}function w(){var P=x.x-A.x;var O=A.y-x.y;var M=Math.atan2(O,P);var N=Math.round(M*180/Math.PI);if(N<0){N=360-Math.abs(N)}return N}function v(){var M=w();if((M<=45)&&(M>=0)){return m}else{if((M<=360)&&(M>=315)){return m}else{if((M>=135)&&(M<=225)){return l}else{if((M>45)&&(M<135)){return s}else{return d}}}}}try{this.addEventListener(b,z,false);this.addEventListener(r,C)}catch(F){}})}})(jQuery);(function(g,p,e,f){var q=g.levi||{};var r=function r(d){if(arguments.length>0){this.init(d)}};var h={swipeStatus:j,threshold:200,allowPageScroll:"vertical"};e(function(){e("#levi-lookbook-panels").swipe(h)});r.prototype={init:function k(d){var u;this.$container=e(d);this.$parentContainer=this.$container.parent();this.panelWidth=this.$container.get(0).offsetWidth;this.hasLandingPage=false;this.$panels=this.createPanels();this.totalPanels=this.$panels.length;this.panelIndex=0;this.setBoxWidth();this.boxPosition=this.updatePosition();this.speed=1000;this.easing="easeInOutCubic";if(this.hasLandingPage){this.$parentContainer.addClass("landing-page")}u=this.$container.children().first().attr("class").match(/\bautorotate-(\d+)\b/i);if(u&&u.length===2){this.autoRotate=true;this.rotateInterval=1000*u[1];this.rotate(this.rotateInterval)}this.addEvents()},rotate:function l(u){var d=this;this.rotateTimer=window.setTimeout(function(){d.rotate(u);d.movePanels(d.getPanel("next"))},u||12000)},addEvents:function i(){var d=this,A="#"+this.$parentContainer.attr("id");e(p).delegate(A+' a[href*="#"], '+A+' area[href*="#"]',"click",function(B){var C=e(this).attr("href");B.preventDefault();C=C.slice(C.indexOf("#")+1);d.movePanels(d.getPanel(C))});if(d.autoRotate){d.$parentContainer.delegate("a, area",{mouseenter:function(B){window.clearTimeout(d.rotateTimer)},mouseleave:function(B){window.clearTimeout(d.rotateTimer);d.rotate(d.rotateInterval)}})}e(p.body).delegate("a.cta",{mouseenter:function(B){e(B.target).closest("a").addClass("hover")},mouseleave:function(B){e(B.target).closest("a").removeClass("hover")}});e("#levi-lookbook-panels").delegate(".drawer-panel .drawer-link a","click",function(){findyourcurveCustomLinkTrack()});var w,y=false,x=false,z=false;function v(){if(y&&z){x=true;lookbookflyoutCustomLinkTrack()}}function u(){if(!y&&x){x=false;z=false}}e("#levi-lookbook-panels").delegate(".drawer-trigger, .drawer-panel",{mouseenter:function(B){clearTimeout(w);y=true;z=e(B.target).closest("a").is(".drawer-trigger")&&!x;overTime=setTimeout(v,300)},mouseleave:function(B){clearTimeout(w);y=false;w=setTimeout(u,300)}})},createPanels:function o(){var w=this.$container.children("div").addClass("panel"),A,z=[],y=!(this.$container.children().first().hasClass("nolanding")),u=w.length,v,x,d;while(u--){A=e(w[u]);A.data({lookbook:{offset:this.panelWidth*u,index:u}});d=A.attr("id");if(d===f||d===""){if(y){d="panel-"+(u||"landing")}else{d="panel-"+u}A.attr("id",d)}if(y&&d.toLowerCase().indexOf("landing")>=0){this.hasLandingPage=true}else{v='<li><a href="#'+A.attr("id")+'"';v+=(u===0)?'class="active"':"";v+=">&bull;</a></li>";z.push(v)}}x=w.length*22;e(".panel-pages ul").html(z.reverse().join("")).css({width:x});e(".panel-pages").css({"margin-left":function(){return((x+20)/2*-1)},width:x+10});return w},getPanel:function s(x){var w=this,v=x,d,u;if(this.panelAliases!==f){u=this.panelAliases}else{this.panelAliases=u={next:function(){return(w.panelIndex+1)%w.totalPanels},previous:function(){return(w.totalPanels+w.panelIndex-1)%w.totalPanels}}}if(u.hasOwnProperty(v)){if(typeof u[v]==="function"){return u[v]()}else{if(typeof u[v]==="number"){return u[v]}}}d=e("#"+v);if(d.length>0&&d.data("lookbook").index!==f){return this.panelAliases[v]=d.data("lookbook").index}return this.panelIndex},moveSwipe:function b(v,d,w){var u=this;if(d=="end"&&(w=="left"||w=="right")){if(w=="right"&&(this.panelIndex-1)>=0){u.movePanels(this.panelIndex-1);window.clearTimeout(u.rotateTimer)}else{if(w=="left"&&(this.panelIndex+1)<=this.totalPanels){u.movePanels(this.panelIndex+1);window.clearTimeout(u.rotateTimer)}}}},setBoxWidth:function c(){var d=this.$panels.length*this.panelWidth;this.$container.css("width",d);return this.$container},updatePosition:function a(){return this.$container.position().left},movePanels:function t(u){var v=this,d;if(typeof u==="number"){d=e(this.$panels[u])}else{d=e(u)}if(d.length>0&&d.data("lookbook").index!==this.panelIndex){this.$container.animate({left:d.data("lookbook").offset*-1},{duration:this.speed,easing:this.easing,queue:false,complete:function(){v.updatePanelArrows()}});v.panelIndex=d.data("lookbook").index;v.updatePanelNav()}},updatePanelArrows:function m(){var d=this.panelIndex;this.$parentContainer.removeClass("landing-page last-page");if(this.hasLandingPage){if(d===0){this.$parentContainer.addClass("landing-page")}else{if(d===this.totalPanels-1){this.$parentContainer.addClass("last-page")}}}},updatePanelNav:function n(){var u=this.panelIndex,y=e(this.$panels[u]),d=e(".panel-pages a"),w,x="";for(var v=d.length;v--;){w=e(d[v]);x=w.attr("href");x=x.substring((x.indexOf("#")+1));if(x!==y.attr("id")){w.removeClass("active")}else{w.addClass("active")}}}};if(e("#levi-lookbook-panels").length>0){q.lookbook=new r(e("#levi-lookbook-panels"))}function j(u,d,v,w){if(v=="right"||v=="left"){q.lookbook.moveSwipe(u,d,v)}}})(window,window.document,jQuery);
