define(["jquery","jquery-touchswipe"],function(e){return{expert_width:"100%",ruri:"",div:null,transition_end:null,init:function(t){var r=this;this.ruri=document.location.href+"",this.ruri.indexOf("#")>-1&&(this.ruri=this.ruri.substring(0,this.ruri.indexOf("#"))),this.div=document.createElement("div");var i={transition:"transitionend",MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",msTransition:"MSTransitionEnd"},n={};n.transition=this.getVendorPropertyName("transition"),this.transition_end=i[n.transition]||null,this.div=null,t.each(function(){r.experts_iterator.call(r,e(this))});var s=(window.location.hash+"").replace(/^#/,"");return/^ask\-the\-experts/i.test(s)&&(s=""),""!=s&&(next=e(".experts-viewport-slider ul li a[href=#"+(window.location.hash+"").substring(1)+"]"),next.length>0)?void next.trigger("click"):void 0},experts_iterator:function(t){var r=this,i=t.attr("id").replace(/^experts\-viewport\-/,"");/\/(edu|blog)\/([^\/]+)\/([\d]+)\//.test(this.ruri)&&(t.find(".experts-content-expert").prepend('<a href="#" class="btn blue">'+t.data("back-link-text")+"</a>"),e("#experts-arrows-"+i).show()),t.find(".experts-content-home ul li a").click(function(){return r.expert_click.call(r,e(this)),!1}),t.data("scroller.instance",i).bind("scroller.build",function(){r.build_scroller.call(r,t)}).trigger("scroller.build"),t.find(".experts-viewport-slider").swipe({triggerOnTouchEnd:!0,excludedElements:"",threshold:75,swipeStatus:function(e,t,i,n){r.swipe_status.call(r,this.parent(),e,t,i,n)},allowPageScroll:"vertical"}),e("#experts-arrows-"+i+" a").on("click",function(){return r.arrow_click.call(r,e(this)),!1})},build_scroller:function(t){var r,i,n,s,a=this,o=t.find(".experts-viewport-slider"),l=t.data("scroller.instance"),d=t.find(".experts-pool"),p=t.find(".experts-content").length,c="data-page",u=".experts-content",f="expert-current",h="expert-next",g="expert-prev";d.hide(),t.css("overflow","hidden"),5>p&&e("#experts-arrows-"+l+" a").css("top",150),n=t.data("scroller.page"),"undefined"==typeof n?(r=d.find(u+":first"),r.addClass(h).appendTo(o),i=d.find(u+":last"),i.addClass(g).prependTo(o),n=1):(o.find(u+"["+c+"!="+n+"]").appendTo(d),t.find(u).removeClass(h+" "+g+" "+f),o.find(u).addClass(f),o.css({left:0,"-webkit-transition-duration":"0s","-webkit-transform":"none","transition-duration":"0s",transform:"none"}),s=o.find(u).attr("data-exp-id"),"undefined"==typeof s?window.history.pushState(null,null,"#"):window.history.pushState(null,null,"#"+s),r=d.find(u+"["+c+"="+(n+1)+"]"),0==r.length&&(r=d.find(u+"["+c+"=1]")),r.length>0&&r.addClass(h).appendTo(o),i=d.find(u+"["+c+"="+(n-1)+"]"),0==i.length&&(i=d.find(u+"["+c+"="+p+"]")),i.length>0&&i.addClass(g).prependTo(o)),o.height(o.find(".experts-content:eq(1)").outerHeight()),t.one("scroller.hide-unused-pages",function(){t.find("."+g+",."+h).removeClass(g+" "+h).appendTo(d)}).on("click",".experts-content-expert a.btn",function(){return a.back_click.call(a,t),!1}),o.off("scroller.scroll").on("scroller.scroll",function(e,t,r){/%$/.test(t)===!1&&(t+="px");var i="translate3d("+t+", 0, 0)",n="cubic-bezier(0.86, 0, 0.07, 1)";n="ease-out",o.css({"-webkit-transform":i,"-webkit-transition-duration":r,"-webkit-transition-timing-function":n,transform:i,"transition-duration":r,"transition-timing-function":n})}),t.data("scroller.page",n)},scroll_page:function(e,t,r,i,n){var s=this,a=e.find(".experts-viewport-slider");"undefined"==typeof i&&(i="0.3s"),n=!!n,n&&a.one(this.transition_end,function(){s.scroll_end.call(s,e,r)}),a.trigger("scroller.scroll",[t,i])},scroll_end:function(t,r){var i=t.data("scroller.instance");t.data("scroller.page",parseInt(r)).trigger("scroller.build"),this.is_mobile()&&(e("#experts-dots-"+i+" div").removeClass("selected"),e("#experts-dots-"+i+" div:eq("+(r-1)+")").addClass("selected"))},swipe_status:function(e,t,r,i,n){var s=this,a=e.find(".experts-content").length,o=e.data("scroller.page");"move"!=r||"left"!=i&&"right"!=i?"cancel"==r?s.scroll_page.apply(s,[e,0,o]):"end"==r&&("right"==i?(1==o?o=a:o-=1,s.scroll_page.apply(s,[e,n,o,"0.3s",!0])):"left"==i&&(o==a?o=1:o+=1,s.scroll_page.apply(s,[e,-n,o,"0.3s",!0]))):"left"==i?o==a?s.scroll_page.apply(s,[e,-n,1]):s.scroll_page.apply(s,[e,-n,o+1]):"right"==i&&(1==o?s.scroll_page.apply(s,[e,n,a]):s.scroll_page.apply(s,[e,n,o-1]))},arrow_click:function(t){var r=t.closest(".experts-arrows").attr("id").replace(/^experts\-arrows\-/,""),i=0,n=1,s=this.expert_width;t.hasClass("arrowleft")?n=-1:s="-"+s,t=e("#experts-viewport-"+r),i=t.find(".experts-content").length,e("html,body").animate({scrollTop:t.offset().top-50},200),page=t.data("scroller.page")+n,0==page&&(page=i),page>i&&(page=1),this.scroll_page.apply(this,[t,s,page,"0.3s",!0])},back_click:function(e){var t,r=e.find(".experts-viewport-slider");e.trigger("scroller.hide-unused-pages"),t=e.find(".experts-pool .experts-content[data-page=1]"),t.addClass("expert-prev").prependTo(r),this.scroll_page.apply(this,[e,this.expert_width,1,"0.3s",!0])},expert_click:function(t){var r,i,n=t.attr("href").replace(/^#/,"");return t=t.closest(".experts-viewport"),r=t.find(".experts-viewport-slider"),t.trigger("scroller.hide-unused-pages"),e("html,body").animate({scrollTop:t.offset().top-50},200),i=t.find(".experts-content[data-exp-id="+n+"]"),0==i.length?!1:(i.addClass("expert-next").appendTo(r),void this.scroll_page.apply(this,[t,"-"+this.expert_width,i.attr("data-page"),"0.3s",!0]))},getVendorPropertyName:function(e){if(e in this.div.style)return e;for(var t=["Moz","Webkit","O","ms"],r=e.charAt(0).toUpperCase()+e.substr(1),i=0;i<t.length;++i){var n=t[i]+r;if(n in this.div.style)return n}},is_mobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},is_safari:function(){return/safari/i.test(navigator.userAgent)},is_idevice:function(){return/iPhone|iPad|iPod/i.test(navigator.userAgent)||this.is_safari()}}});