var stack=function(){function t(t){return w-1>u&&u==d&&u>t?(p.deactivate.call(y[0][d],d),p.activate.call(y[0][--d],d),u-=.5-v/i/2,scrollTo(0,u*i),!0):void 0}function e(){v=(window.innerHeight-i)/2,f=1+v/i,d3.select(g).style("margin-top",v+"px").style("margin-bottom",v+"px").style("height",(w-.5)*i+v+"px")}function n(){var t=+location.hash.slice(1);isNaN(t)||t===d||h.position(t)}function a(){var t;switch(d3.event.keyCode){case 39:if(d3.event.metaKey)return;case 40:case 34:t=d3.event.metaKey?1/0:1;break;case 37:if(d3.event.metaKey)return;case 38:case 33:t=d3.event.metaKey?-1/0:-1;break;case 32:t=d3.event.shiftKey?-1:1;break;default:return}r&&(r=clearTimeout(r)),null==m&&(m=(t>0?Math.floor:Math.ceil)(u==d?d:u+(.5-v/i/2))),h.position(m=Math.max(0,Math.min(w-1,m+t))),d3.event.preventDefault()}function l(){g!==x&&x.scrollTop&&(g=x);var e=Math.max(0,g.scrollTop/i);if(e>=w-1.51+v/i&&(e=w-1),!t(e)){var n=Math.max(0,Math.floor(u=e)),a=Math.min(f,2*(u%1));d!=n&&(null!=d&&p.deactivate.call(y[0][d],d),p.activate.call(y[0][n],n),location.replace("#"+n),d=n),y.classed("active",!1),d3.select(y[0][d]).style("-webkit-transform",a?"translate3d(0,"+-a*i+"px,0)":null).style("-o-transform",a?"translate(0,"+-a*i+"px)":null).style("-moz-transform",a?"translate(0,"+-a*i+"px)":null).style("transform",a?"translate(0,"+-a*i+"px)":null).classed("active",a!=f),d3.select(y[0][d+1]).style("-webkit-transform",a?"translate3d(0,0,0)":null).style("-o-transform",a?"translate(0,0)":null).style("-moz-transform",a?"translate(0,0)":null).style("transform",a?"translate(0,0)":null).classed("active",a>0)}}function o(){var t=d3.event.clientY;if(t!==c&&(c=t,null==m)){var e=h.position(),n=Math.max(0,Math.round(e+.25));0>=e||e>=w-1.51+v/i||(n>e&&.5-v/i>n-e?scrollTo(0,n*i):n!==e&&h.position(n))}}function s(t){return function(){var e=d3.interpolateNumber(this.scrollTop,t*i);return function(t){scrollTo(0,e(t)),l()}}}var r,c,i,u,d,m,f,v,h={},p=d3.dispatch("activate","deactivate"),y=d3.selectAll("section"),k=d3.select(window),g=document.body,x=document.documentElement,M=250,b="cubic-in-out",w=y[0].length;return y.classed("stack",!0).style("z-index",function(t,e){return w-e}),y.classed("active",!0),i=y.node().getBoundingClientRect().height,y.classed("active",!1),h.position=function(e){var n=g.scrollTop/i;return arguments.length<1?n:(e>=w?e=w-1:0>e&&(e=Math.max(0,w+e)),e=Math.floor(e),n-e&&(k.on("scroll.stack",null),t(e),d3.select(g).transition().duration(M).ease(b).tween("scrollTop",s(m=e)).each("end",function(){m=null,k.on("scroll.stack",l)})),location.replace("#"+e),h)},y.style("display")!="block"?(k.on("keydown.stack",a).on("resize.stack",e).on("scroll.stack",l).on("mousemove.stack",o).on("hashchange.stack",n),e(),l(),n(),h.duration=function(t){return arguments.length?(M=t,h):M},h.ease=function(t){return arguments.length?(b=t,h):b},d3.rebind(h,p,"on"),h):void 0}();