Y.use("node","squarespace-ui-base","yui-throttle","squarespace-gallery-ng",function(){window.Site=Singleton.create({PARALLAX_FACTOR:0.8,SCROLL_SPEED:0.6,IMAGE_VIEWPORT:null,INITIAL_WINDOW_HEIGHT:Y.config.win.innerHeight,pageOffsets:{},docHeight:0,ready:function(){Y.on("domready",this.initialize,this)},initialize:function(){this.parallaxImages=Y.all("#parallax-images .image-container");this.parallaxPages=Y.all(".parallax-item");this.scrollEl=Y.one(Y.UA.gecko||Y.UA.ie||navigator.userAgent.match(/Trident.*rv.11\./)? "html":"body");this.viewportH=Y.one("body").get("winHeight");this.isMobile=!Y.Lang.isUndefined(window.orientation)||0=Y.UA.ie;this.bindUI();this.syncUI();this.textShrink(".page-title",".page-title-wrapper");this.textShrink(".page-desc p \x3e strong",".page-desc p");this.textShrink(".collection-type-events.view-list .entry-title-wrapper h1.entry-title",".collection-type-events.view-list .entry-title-wrapper");this.textShrink(".collection-type-blog.view-list.blog-layout-columns .entry-title-wrapper h1.entry-title", ".collection-type-blog.view-list.blog-layout-columns .entry-title-wrapper");Y.one("body.collection-type-index")&&this.handleIndex();this.listenTweaks();Y.one("body").addClass("loaded");Y.UA.ie&&Y.one("html").addClass("ie"+Y.UA.ie);this.isMobile||Y.one("html").removeClass("touch")},mutationObserver:function(a,b,c){var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(e){var d=new e(c);d.observe(a,b);var i=Y.later(15E3,this,function(){d.disconnect();i.cancel()})}else c(null, null)},mutationCallback:function(a){if(a)for(var b=0;b=Y.UA.ie?Y.one(".title-desc-wrapper").setStyle("paddingTop",e?80+b:b):Y.one(".title-desc-wrapper").setStyle("paddingTop",b)):(Y.one("#content-wrapper").setStyle("marginTop",c?b:null),Y.all(".title-desc-wrapper").setStyle("paddingTop",c&&e?80+b:null),Y.one(".title-desc-wrapper")&&Y.one(".title-desc-wrapper").setStyle("paddingTop",null));var d=Y.Squarespace.Template.getTweakValue("index-image-height");this.IMAGE_VIEWPORT="Fullscreen"==d?1:"Half"==d?0.5:0.66;this.firstImageHeight= "true"===Y.Squarespace.Template.getTweakValue("first-index-image-fullscreen")?this.viewportH:parseInt(this.viewportH*this.IMAGE_VIEWPORT);this.restImageHeight=parseInt(this.viewportH*this.IMAGE_VIEWPORT);var i=new Y.NodeList;this.parallaxPages.each(function(a,d){if(!this.isMobile){var h=0===d?this.firstImageHeight-Y.one("#header").get("clientHeight"):this.restImageHeight;if(e){var j=c?b+160:160,h=Math.max(h,a.one(".title-desc-inner").height()+j),j=0===d?h+b:h;this.parallaxImages.item(d).setStyle("height", Math.max(this.viewportH,j)+"px")}if(j=this.parallaxImages.item(d).one("img"))a.one(".title-desc-wrapper").setStyle("height",h+"px"),i.push(j.removeAttribute("data-load"))}this.pageOffsets[a.getAttribute("data-url-id")]=0===d?0:Math.round(a.getXY()[1])},this);Y.Squarespace.GalleryManager.addImageQueue(i);this.parallaxImages.each(function(a){(a=a.one("img"))&&a.getAttribute("src")&&ImageLoader.load(a)},this);this.stickyCart()}else(d=Y.one(".banner-image img"))&&ImageLoader.load(d),Y.one(".sqs-cart-dropzone").setStyle("marginTop", b),this.stickyCart(),this.isMobile||Y.one("#header-wrapper").setStyle("paddingTop",c?b:null);this.isMobile||(Y.one(".collection-type-index.title--description-alignment-center.title--description-position-over-image")&&Y.all(".title-desc-wrapper.has-main-image").each(function(a){a.one(".title-desc-inner").setStyles({top:"50%",left:"50%",transform:"translatex(-50%) translatey(-50%)"})}),Y.one(".collection-type-index.title--description-alignment-left")&&Y.all(".title-desc-wrapper.over-image.has-main-image .title-desc-inner").setStyles({top:null, left:null,transform:"translatex(0) translatey(0)"}),Y.one("#parallax-nav")&&(d=Y.one("#parallax-nav").get("offsetHeight"),Y.one("#parallax-nav").setStyle("marginTop",-1*(d/2))));Y.one(".footer-wrapper .sqs-block")||Y.one(".footer-wrapper").addClass("empty");Y.one(".nav-wrapper")&&a.addClass("has-nav");this.headerBgOnScroll()},textShrink:function(a,b){Y.one(a)&&Y.one(a).ancestor(b)&&Y.all(a).each(function(a){a.plug(Y.Squarespace.TextShrink,{parentEl:a.ancestor(b)})})},setupMobileLayout:function(){var a= Y.config.win.innerHeight>Y.config.win.innerWidth?screen.height:screen.width,b=Y.Squarespace.Template.getTweakValue("index-image-height"),c=Y.one("#header").get("clientHeight"),e;switch(!0){case "Two Thirds"==b:e=0.66666*a;break;case "Fullscreen"==b:e=1*a;break;default:e=0.5*a}Y.all(".parallax-item").each(function(a,b){var f=a.one(".title-desc-wrapper"),g=a.one(".title-desc-inner"),h=a.one(".title-desc-image");f.hasClass("has-main-image")?(f.setStyles({height:0===b?this.INITIAL_WINDOW_HEIGHT-c:e,overflow:"hidden"}, this),h.setStyles({height:0===b?e-118:e})):f.setStyle({paddingTop:c});Y.one(".title--description-alignment-center")&&f.hasClass("has-main-image")&&(g.get("clientHeight")=Y.UA.ie?(0=Y.UA.ie?Y.one("body").addClass("crappy-ie-no-parallax"):Y.one("body").addClass("mobile-no-parallax"),Y.all(".title-desc-image").each(function(a,b){0===b&&a.setStyles({minHeight:a.ancestor(".title-desc-wrapper").get("clientHeight")+Y.one("#header").get("clientHeight")});a.one("img").removeAttribute("data-load");ImageLoader.load(a.one("img"), {mode:"fill"})})):(Y.one("body").addClass("mobile-parallax"),Y.all(".title-desc-image").each(function(b){b.setStyle("height",a);b.one("img").removeAttribute("data-load");ImageLoader.load(b.one("img"),{mode:"fill"})}))},setupMobileNav:function(){Y.one("#mobileMenu").on("click",function(){Y.one("body").hasClass("mobile-nav-open")?Y.one("body").removeClass("mobile-nav-open"):Y.one("body").addClass("mobile-nav-open")});Y.all("li.folder").each(function(a){a.on("click",function(){var b=a.siblings("li.folder.dropdown-open").item(0); b&&b.toggleClass("dropdown-open");a&&a.toggleClass("dropdown-open")})})},positionBackgroundImage:function(){var a=this.scrollEl.get("scrollTop"),b=Y.one(Y.config.win).get("region"),c=Y.one(".banner-image img");!this.parallaxOff&&(!this.isMobile&&c&&!(a>b.height))&&c.setStyle("transform","translate3d(0,"+parseInt(a*this.PARALLAX_FACTOR,10)+"px,0)")},onHashChange:function(a){Y.one(".mobile-nav-open")&&Y.one("body").removeClass("mobile-nav-open");if(Y.one('.parallax-item[data-url-id\x3d"'+a.newHash+ '"]')){var b=this.pageOffsets[a.newHash];a.quick?(this.scrollEl.set("scrollTop",b),this.updateActivePage()):(this.autoScrolling=!0,this.scrollEl.anim({},{to:{scroll:[0,b]},duration:this.SCROLL_SPEED,easing:Y.Easing.easeBoth}).run().on("end",function(){this.scrollEl.get("scrollTop")!==b&&this.scrollEl.set("scrollTop",b);this.autoScrolling=!1;this.updateActivePage()},this))}},getPageFromOffset:function(a){if(this.parallaxPages.item(0)){var b=this.parallaxPages.item(0).getAttribute("data-url-id"),c; for(c in this.pageOffsets)a>=this.pageOffsets[c]&&this.pageOffsets[c]>this.pageOffsets[b]&&(b=c);return b}},setScrollArrowColor:function(){var a=Y.one(".scroll-arrow"),b=Y.one(".parallax-item .title-desc-wrapper");b&&(b=b.getAttribute("data-color-suggested"),Y.Lang.isValue(a)&&Y.Lang.isValue(b)&&a.removeClass("color-weight-dark").removeClass("color-weight-light").addClass("color-weight-"+this._getLightness(b)))},updateActivePage:function(){if(!this.autoScrolling){var a=this.scrollEl.get("scrollTop"), b=this.getPageFromOffset(a);Y.one("#parallax-nav")&&(Y.one('#parallax-nav a[href\x3d"#'+b+'"]').get("parentNode").addClass("active").siblings().removeClass("active"),window.location.hash.replace("#","")!=b&&window.history&&window.history.replaceState&&window.history.replaceState({},"","#"+b));b=this.isMobile?Y.one('.parallax-item[data-url-id\x3d"'+b+'"] .title-desc-wrapper img'):Y.one('#parallax-images .image-container[data-url-id\x3d"'+b+'"] img');Y.Squarespace.GalleryManager.promoteImageQueue(new Y.NodeList(b)); if(!Y.one("body.hide-parallax-nav")){var b=this.getPageFromOffset(a+this.viewportH/2),c;if(a+this.viewportH/2<=this.pageOffsets[b]+(0===this.pageOffsets[b]?this.firstImageHeight:this.viewportH*this.IMAGE_VIEWPORT))c=Y.one('.parallax-item[data-url-id\x3d"'+b+'"] .title-desc-wrapper').getAttribute("data-color-suggested");if(!c||"#"===c)c=Y.Squarespace.Template.getTweakValue("contentBgColor"),(a=c.match(/rgba\((\d+),(\d+),(\d+),(\d+)/))&&(c=this._rgb2hex(a[1],a[2],a[3]));Y.one("#parallax-nav")&&Y.one("#parallax-nav").removeClass("color-weight-dark").removeClass("color-weight-light").addClass("color-weight-"+ this._getLightness(c))}}},_rgb2hex:function(a,b,c){a=[a,b,c];for(b=0;2>=b;++b)a[b]=parseInt(a[b],10).toString(16),1==a[b].length&&(a[b]="0"+a[b]);return"#"+a.join("")},_getLightness:function(a){return a&&0=a.length?(a=a.replace("#",""),8388607.5 c?Y.one("#header").setStyle("backgroundColor",e):b.setStyle("backgroundColor","transparent")}}},stickyCart:function(){if(this.isMobile)return!1;var a=Y.one(".sqs-cart-dropzone");Y.one("#header").get("clientHeight");var b;if(a&&a.one(".yui3-widget"))if(b=a.one(".yui3-widget").getY(),Y.one(window).on("resize",function(){b=a.getY()}),Y.one("body.fixed-header"))a.addClass("fixed-cart").setStyles({top:Y.one("#header").get("clientHeight")+10});else Y.one(window).on("scroll",function(){a.toggleClass("fixed-cart", Y.config.win.scrollY>=b)})}})});