/*jquery.als v.1.7 | (c) 2012, 2014 Federica Sibella musings(at)musings(dot)it | http://www.musings.it | MIT license.*/ !function(e){function t(e){if("string"==typeof e){var t=e.indexOf("_");-1!=t&&(e=e.substr(t+1))}return e}function i(i,o){i.preventDefault(),void 0===o&&(o=e(this));var r=t(o.attr("data-id")),s=n[r];s.next.off(),s.prev.off(),s.viewport.off("touchend"),"yes"===s.options.autoscroll&&e.fn.als("stop",r),e.fn.als("next",r),"yes"===s.options.autoscroll&&e.fn.als("start",r)}function o(i,o){i.preventDefault(),void 0===o&&(o=e(this));var r=t(o.attr("data-id")),s=n[r];s.prev.off(),s.next.off(),s.viewport.off("touchend"),"yes"===s.options.autoscroll&&e.fn.als("stop",r),e.fn.als("prev",r),"yes"===s.options.autoscroll&&e.fn.als("start",r)}var n=[],s=0,a={init:function(t){this.each(function(){var a={visible_items:3,scrolling_items:1,orientation:"horizontal",circular:"no",autoscroll:"no",interval:4e3,speed:600,easing:"swing",direction:"left",start_from:0},l=e(this),c=l.data("als"),m=e(),d=e(),u=e(),p=e(),h=e(),v=e(),f=0,w=0,T=0,g=0,_=0,y=0,x=0,k=0,b=0,E=0,q=0,H=0,W={};switch(W.swipeTreshold=100,W.allowedTime=300,m=e.extend(a,t),"no"==m.circular&&"yes"==m.autoscroll&&(m.circular="yes"),("linear"!=m.easing||"swing"!=m.easing)&&(m.easing="swing"),l.attr("id")&&""!=l.attr("id")||l.attr("id","als-container_"+s),l.attr("data-id","als-container_"+s),p=l.find(".als-viewport").attr("data-id","als-viewport_"+s),u=l.find(".als-wrapper").attr("data-id","als-wrapper_"+s),d=l.find(".als-item"),f=d.size(),m.visible_items>f&&(m.visible_items=f-1),m.scrolling_items>m.visible_items&&(m.visible_items>1?m.scrolling_items=m.visible_items-1:1===m.visible_items&&(m.scrolling_items=m.visible_items)),m.start_from>f-m.visible_items&&(m.start_from=0),h=l.find(".prev").attr("data-id","als-prev_"+s),v=l.find(".next").attr("data-id","next_"+s),m.orientation){case"horizontal":default:if(d.each(function(t){e(this).attr("id","als-item_"+s+"_"+t),T+=e(this).outerWidth(!0),e(this).outerHeight(!0)>x&&(x=e(this).outerHeight(!0)),b=m.start_from&&(w+=e(this).outerWidth(!0),b++)),0!=m.start_from&&(Ek&&(k=e(this).outerWidth(!0)),b=m.start_from&&(g+=e(this).outerHeight(!0),b++)),0!=m.start_from&&(EW.swipeTreshold&&W.endTime0)&&o(e,p):W.dy<-W.swipeTreshold&&W.endTimeW.swipeTreshold&&W.endTime0)&&o(e,p)}),l.data("als",{container:l,instance:s,options:m,viewport:p,wrapper:u,prev:h,next:v,item:d,num_items:f,wrapper_width:T,viewport_width:w,wrapper_height:_,viewport_height:g,current:q,timer:H,mm:W}),c=l.data("als"),n[s]=c,"yes"==m.autoscroll?(e.fn.als("start",s),u.hover(function(){e.fn.als("stop",e(this).attr("data-id"))},function(){e.fn.als("start",e(this).attr("data-id"))})):"no"==m.autoscroll&&e.fn.als("stop",s),s++,n})},next:function(e){e=t(e);var r=n[e],s=r.mm,a=0,l=0;switch(r.options.orientation){case"horizontal":default:var c=0,m=0;switch(r.options.circular){case"no":default:for(a=r.current;as.swipeTreshold&&s.endTime0&&o(e,r.viewport):s.dy<-s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime0&&o(e,r.viewport)})}),r.current>0&&r.prev.show(),r.current+r.options.visible_items>=r.num_items&&r.next.hide();break;case"yes":var d=0,u=[];for(a=r.current;a=r.num_items&&(p=a-r.num_items),c+=r.item.eq(p).outerWidth(!0),u[d]=p,d++}for(r.current+=r.options.scrolling_items,r.current>=r.num_items&&(r.current-=r.num_items),l=r.current;l=r.num_items&&(h=l-r.num_items),m+=r.item.eq(h).outerWidth(!0)}r.viewport.animate({width:m},r.options.speed,r.options.easing),r.item.animate({left:"-="+c},r.options.speed,r.options.easing),r.item.promise().done(function(){var e=r.item.last().position(),t=e.left+r.item.last().outerWidth(!0);for(k5=0;k5s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime0&&o(e,r.viewport):s.dy<-s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime0&&o(e,r.viewport)})}),r.current>0&&r.prev.show(),r.current+r.options.visible_items>=r.num_items&&r.next.hide();break;case"yes":var d=0,u=[];for(a=r.current;a=r.num_items&&(p=a-r.num_items),v+=r.item.eq(p).outerHeight(!0),u[d]=p,d++}for(r.current+=r.options.scrolling_items,r.current>=r.num_items&&(r.current-=r.num_items),l=r.current;l=r.num_items&&(h=l-r.num_items),f+=r.item.eq(h).outerHeight(!0)}r.viewport.animate({height:f}),r.item.animate({top:"-="+v}),r.item.promise().done(function(){var e=r.item.last().position(),t=e.top+r.item.last().outerHeight(!0);for(k5=0;k5s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime0&&o(e,r.viewport):s.dy<-s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime0&&o(e,r.viewport)})}),r.current<=0&&r.prev.hide(),r.current+r.options.visible_items=r.num_items&&(p=a-r.num_items),c+=r.item.eq(p).outerWidth(!0),u[d]=p,d++}for(l=r.current;l=r.num_items&&(h=l-r.num_items),m+=r.item.eq(h).outerWidth(!0)}var v=r.item.first().position(),f=v.left-r.wrapper_width;for(k5=0;k5k6;k6++)r.item.eq(u[k6]).css("left",T)}setTimeout(function(){r.viewport.animate({width:m}),r.item.animate({left:"+="+c},r.options.speed,r.options.easing),r.item.promise().done(function(){r.next.on("click touchstart touchend",i),r.prev.on("click touchstart touchend",o),r.viewport.on("touchend",function(e){if(void 0==e.originalEvent.touches)var t=e;else var t=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];s.dx=t.pageX-s.ox,s.dy=t.pageY-s.oy,s.endTime=(new Date).getTime()-s.startTime,"horizontal"==r.options.orientation?s.dx<-s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime0&&o(e,r.viewport):s.dy<-s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime0&&o(e,r.viewport)})}),r.current<=0&&r.prev.hide(),r.current+r.options.visible_items=r.num_items&&(p=a-r.num_items),g+=r.item.eq(p).outerHeight(!0),u[d]=p,d++}for(l=r.current;l=r.num_items&&(h=l-r.num_items),_+=r.item.eq(h).outerHeight(!0)}var v=r.item.first().position(),y=v.top-r.wrapper_height;for(k5=0;k5k6;k6++)r.item.eq(u[k6]).css("top",x)}setTimeout(function(){r.viewport.animate({height:_},r.options.speed,r.options.easing),r.item.animate({top:"+="+g},r.options.speed,r.options.easing),r.item.promise().done(function(){r.next.on("click touchstart touchend",i),r.prev.on("click touchstart touchend",o),r.viewport.on("touchend",function(e){if(void 0==e.originalEvent.touches)var t=e;else var t=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];s.dx=t.pageX-s.ox,s.dy=t.pageY-s.oy,s.endTime=(new Date).getTime()-s.startTime,"horizontal"==r.options.orientation?s.dx<-s.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTimes.swipeTreshold&&s.endTime