!function(a){"use strict";var e=a("body").attr("data-page-url"),t=document.title,n=window.History;function o(){a(".page__content").find("img:first").imagesLoaded(function(){a(".listing-wrap").imagesLoaded(function(){a(".listing-wrap").masonry({itemSelector:".listing-item",transitionDuration:0})}),a("body").removeClass("loading"),a("body").removeClass("menu--open")}),a(".active-link").removeClass("active-link"),a('a[href="'+e+'"]').addClass("active-link"),Waypoint.destroyAll();var t=0;a(".gallery").each(function(){var e=a(this),n="gallery-"+ ++t;e.attr("id",n);var o=e.attr("data-columns");e.append(''),e.children("img").each(function(){a(this).appendTo("#"+n+" .gallery__wrap")}),e.find(".gallery__wrap img").each(function(){var e=a(this).attr("src");a(this).wrapAll('').appendTo()}),e.imagesLoaded(function(){if("1"===o){e.addClass("gallery--carousel"),e.children(".gallery__wrap").addClass("owl-carousel"),e.children(".gallery__wrap").owlCarousel({items:1,loop:!0,mouseDrag:!1,touchDrag:!0,pullDrag:!1,dots:!0,autoplay:!1,autoplayTimeout:6e3,autoHeight:!0,animateOut:"fadeOut"});new Waypoint({element:document.getElementById(n),handler:function(a){"down"===a&&e.children(".gallery__wrap").trigger("stop.owl.autoplay"),"up"===a&&e.children(".gallery__wrap").trigger("play.owl.autoplay")},offset:"-100%"}),new Waypoint({element:document.getElementById(n),handler:function(a){"down"===a&&e.children(".gallery__wrap").trigger("play.owl.autoplay"),"up"===a&&e.children(".gallery__wrap").trigger("stop.owl.autoplay")},offset:"100%"})}else e.addClass("gallery--grid"),e.children(".gallery__wrap").masonry({itemSelector:".gallery__item",transitionDuration:0}),e.find(".gallery__item__link").fluidbox({loader:!0});e.addClass("gallery--on")})}),a(".single p > img").each(function(){var e=a(this).parent("p");a(this).insertAfter(e),a(this).wrapAll('
'),e.remove()}),a(".single iframe").each(function(){if(a(this).attr("src").indexOf("youtube")>=0||a(this).attr("src").indexOf("vimeo")>=0){var e=a(this).attr("width"),t=a(this).attr("height")/e*100;a(this).wrapAll('
')}}),a(".single table").each(function(){a(this).wrapAll('
')})}n.Adapter.bind(window,"statechange",function(){var l=n.getState();a("body").addClass("loading"),a(".page-loader").load(l.hash+" .page__content",function(){a("body, html").animate({scrollTop:0},300);setTimeout(function(){a(".page .page__content").remove(),a(".page-loader .page__content").appendTo(".page"),a("body").attr("data-page-url",window.location.pathname),e=a("body").attr("data-page-url"),t=a(".page__content").attr("data-page-title"),document.title=t,o()},400)})}),a("body").hasClass("ajax-loading")&&a(document).on("click","a",function(o){o.preventDefault();var l=a(this).attr("href");a(this).hasClass("js-no-ajax")||l.indexOf("#")>=0||l.indexOf("mailto:")>=0||l.indexOf("tel:")>=0?window.location=l:a(this).is(".gallery__item__link")||(l.indexOf("http")>=0?window.open(l,"_blank"):(e=l,n.pushState(null,t,l)))}),o(),a(document).on("click",".js-menu-toggle",function(){a("body").hasClass("menu--open")?a("body").removeClass("menu--open"):a("body").addClass("menu--open")}),a(document).on("click",".menu__list__item__link",function(){a(".menu").hasClass("menu--open")&&a(".menu").removeClass("menu--open")}),a(document).on("submit","#contact-form",function(e){a(".contact-form__item--error").removeClass("contact-form__item--error");var t=a('.contact-form__input[name="email"]'),n=a('.contact-form__input[name="name"]'),o=a('.contact-form__textarea[name="message"]'),l=a(".contact-form__gotcha");""===t.val()&&t.closest(".contact-form__item").addClass("contact-form__item--error"),""===n.val()&&n.closest(".contact-form__item").addClass("contact-form__item--error"),""===o.val()&&o.closest(".contact-form__item").addClass("contact-form__item--error"),""!==t.val()&&""!==n.val()&&""!==o.val()&&0===l.val().length||e.preventDefault()})}(jQuery);