// source --> https://www.buserterkini.com/wp-content/themes/smart-mag/js/lazyload.js?ver=10.3.2 
/* @license lazysizes - v5.3.0 */
window.lazySizesConfig={init:!1,expand:10},function(e){var t=function(n,f,s){"use strict";var m,z;if(function(){var e,t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",fastLoadedClass:"ls-is-cached",iframeLoadMode:0,srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};for(e in z=n.lazySizesConfig||n.lazysizesConfig||{},t)e in z||(z[e]=t[e])}(),!f||!f.getElementsByClassName)return{init:function(){},cfg:z,noSupport:!0};function o(e,t){return de[t]||(de[t]=new RegExp("(\\s|^)"+t+"(\\s|$)")),de[t].test(e[ae]("class")||"")&&de[t]}function c(e,t){o(e,t)||e.setAttribute("class",(e[ae]("class")||"").trim()+" "+t)}function u(e,t){(t=o(e,t))&&e.setAttribute("class",(e[ae]("class")||"").replace(t," "))}function y(e,t,a,n,i){var s=f.createEvent("Event");return(a=a||{}).instance=m,s.initEvent(t,!n,!i),s.detail=a,e.dispatchEvent(s),s}function h(e,t){var a;!ee&&(a=n.picturefill||z.pf)?(t&&t.src&&!e[ae]("srcset")&&e.setAttribute("srcset",t.src),a({reevaluate:!0,elements:[e]})):t&&t.src&&(e.src=t.src)}function g(e,t){return(getComputedStyle(e,null)||{})[t]}function i(e,t,a){for(a=a||e.offsetWidth;a<z.minSize&&t&&!e._lazysizesWidth;)a=t.offsetWidth,t=t.parentNode;return a}function e(a,e){return e?function(){fe(a)}:function(){var e=this,t=arguments;fe(function(){a.apply(e,t)})}}function t(e){function t(){a=null,e()}var a,n,i=function(){var e=s.now()-n;e<99?ie(i,99-e):(oe||t)(t)};return function(){n=s.now(),a=a||ie(i,99)}}var a,r,l,p,v,C,b,d,A,E,_,w,M,N,L,x,S,W,B,T,F,R,D,k,H,O,P,$,q,I,U,j,G,J,K,Q,V,X,Y,Z=f.documentElement,ee=n.HTMLPictureElement,te="addEventListener",ae="getAttribute",ne=n[te].bind(n),ie=n.setTimeout,se=n.requestAnimationFrame||ie,oe=n.requestIdleCallback,re=/^picture$/i,le=["load","error","lazyincluded","_lazyloaded"],de={},ce=Array.prototype.forEach,ue=function(t,a,e){var n=e?te:"removeEventListener";e&&ue(t,a),le.forEach(function(e){t[n](e,a)})},fe=(X=[],Y=V=[],we._lsFlush=_e,we),me=(R=/^img$/i,D=/^iframe$/i,k="onscroll"in n&&!/(gle|ing)bot/.test(navigator.userAgent),P=-1,x=ve,W=O=H=0,B=z.throttleDelay,T=z.ricTimeout,F=oe&&49<T?function(){oe(Ce,{timeout:T}),T!==z.ricTimeout&&(T=z.ricTimeout)}:e(function(){ie(Ce)},!0),q=e(be),I=function(e){q({target:e.target})},U=e(function(t,e,a,n,i){var s,o,r,l,d;(r=y(t,"lazybeforeunveil",e)).defaultPrevented||(n&&(a?c(t,z.autosizesClass):t.setAttribute("sizes",n)),s=t[ae](z.srcsetAttr),a=t[ae](z.srcAttr),i&&(o=(d=t.parentNode)&&re.test(d.nodeName||"")),l=e.firesLoad||"src"in t&&(s||a||o),r={target:t},c(t,z.loadingClass),l&&(clearTimeout(C),C=ie(ge,2500),ue(t,I,!0)),o&&ce.call(d.getElementsByTagName("source"),Ae),s?t.setAttribute("srcset",s):a&&!o&&(D.test(t.nodeName)?(n=a,0==(d=(e=t).getAttribute("data-load-mode")||z.iframeLoadMode)?e.contentWindow.location.replace(n):1==d&&(e.src=n)):t.src=a),i&&(s||o)&&h(t,{src:a})),t._lazyRace&&delete t._lazyRace,u(t,z.lazyClass),fe(function(){var e=t.complete&&1<t.naturalWidth;l&&!e||(e&&c(t,z.fastLoadedClass),be(r),t._lazyCache=!0,ie(function(){"_lazyCache"in t&&delete t._lazyCache},9)),"lazy"==t.loading&&O--},!0)}),G=t(function(){z.loadMode=3,$()}),J=function(){v||(s.now()-d<999?ie(J,999):(v=!0,z.loadMode=3,$(),ne("scroll",Ee,!0)))},{_:function(){d=s.now(),m.elements=f.getElementsByClassName(z.lazyClass),p=f.getElementsByClassName(z.lazyClass+" "+z.preloadClass),ne("scroll",$,!0),ne("resize",$,!0),ne("pageshow",function(e){var t;!e.persisted||(t=f.querySelectorAll("."+z.loadingClass)).length&&t.forEach&&se(function(){t.forEach(function(e){e.complete&&j(e)})})}),n.MutationObserver?new MutationObserver($).observe(Z,{childList:!0,subtree:!0,attributes:!0}):(Z[te]("DOMNodeInserted",$,!0),Z[te]("DOMAttrModified",$,!0),setInterval($,999)),ne("hashchange",$,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(e){f[te](e,$,!0)}),/d$|^c/.test(f.readyState)?J():(ne("load",J),f[te]("DOMContentLoaded",$),ie(J,2e4)),m.elements.length?(ve(),fe._lsFlush()):$()},checkElems:$=function(e){var t;(e=!0===e)&&(T=33),S||(S=!0,(t=B-(s.now()-W))<0&&(t=0),e||t<9?F():ie(F,t))},unveil:j=function(e){var t,a,n,i;e._lazyRace||(!(i="auto"==(n=(a=R.test(e.nodeName))&&(e[ae](z.sizesAttr)||e[ae]("sizes"))))&&v||!a||!e[ae]("src")&&!e.srcset||e.complete||o(e,z.errorClass)||!o(e,z.lazyClass))&&(t=y(e,"lazyunveilread").detail,i&&ze.updateElem(e,!0,e.offsetWidth),e._lazyRace=!0,O++,U(e,t,i,n,a))},_aLSL:Ee}),ze=(r=e(function(e,t,a,n){var i,s,o;if(e._lazysizesWidth=n,n+="px",e.setAttribute("sizes",n),re.test(t.nodeName||""))for(s=0,o=(i=t.getElementsByTagName("source")).length;s<o;s++)i[s].setAttribute("sizes",n);a.detail.dataAttr||h(e,a.detail)}),{_:function(){a=f.getElementsByClassName(z.autosizesClass),ne("resize",l)},checkElems:l=t(function(){var e,t=a.length;if(t)for(e=0;e<t;e++)he(a[e])}),updateElem:he}),ye=function(){!ye.i&&f.getElementsByClassName&&(ye.i=!0,ze._(),me._())};function he(e,t,a){var n=e.parentNode;n&&(a=i(e,n,a),(t=y(e,"lazybeforesizes",{width:a,dataAttr:!!t})).defaultPrevented||(a=t.detail.width)&&a!==e._lazysizesWidth&&r(e,n,t,a))}function ge(e){O--,e&&!(O<0)&&e.target||(O=0)}function pe(e){return(L=null==L?"hidden"==g(f.body,"visibility"):L)||!("hidden"==g(e.parentNode,"visibility")&&"hidden"==g(e,"visibility"))}function ve(){var e,t,a,n,i,s,o,r,l,d,c,u=m.elements;if((b=z.loadMode)&&O<8&&(e=u.length)){for(t=0,P++;t<e;t++)if(u[t]&&!u[t]._lazyRace)if(!k||m.prematureUnveil&&m.prematureUnveil(u[t]))j(u[t]);else if((o=u[t][ae]("data-expand"))&&(i=+o)||(i=H),l||(l=!z.expand||z.expand<1?500<Z.clientHeight&&500<Z.clientWidth?500:370:z.expand,d=(m._defEx=l)*z.expFactor,c=z.hFac,L=null,H<d&&O<1&&2<P&&2<b&&!f.hidden?(H=d,P=0):H=1<b&&1<P&&O<6?l:0),r!==i&&(A=innerWidth+i*c,E=innerHeight+i,s=-1*i,r=i),d=u[t].getBoundingClientRect(),(N=d.bottom)>=s&&(_=d.top)<=E&&(M=d.right)>=s*c&&(w=d.left)<=A&&(N||M||w||_)&&(z.loadHidden||pe(u[t]))&&(v&&O<3&&!o&&(b<3||P<4)||function(e,t){var a,n=e,i=pe(e);for(_-=t,N+=t,w-=t,M+=t;i&&(n=n.offsetParent)&&n!=f.body&&n!=Z;)(i=0<(g(n,"opacity")||1))&&"visible"!=g(n,"overflow")&&(a=n.getBoundingClientRect(),i=M>a.left&&w<a.right&&N>a.top-1&&_<a.bottom+1);return i}(u[t],i))){if(j(u[t]),n=!0,9<O)break}else!n&&v&&!a&&O<4&&P<4&&2<b&&(p[0]||z.preloadAfterLoad)&&(p[0]||!o&&(N||M||w||_||"auto"!=u[t][ae](z.sizesAttr)))&&(a=p[0]||u[t]);a&&!n&&j(a)}}function Ce(){S=!1,W=s.now(),x()}function be(e){var t=e.target;t._lazyCache?delete t._lazyCache:(ge(e),c(t,z.loadedClass),u(t,z.loadingClass),ue(t,I),y(t,"lazyloaded"))}function Ae(e){var t,a=e[ae](z.srcsetAttr);(t=z.customMedia[e[ae]("data-media")||e[ae]("media")])&&e.setAttribute("media",t),a&&e.setAttribute("srcset",a)}function Ee(){3==z.loadMode&&(z.loadMode=2),G()}function _e(){var e=Y;for(Y=V.length?X:V,Q=!(K=!0);e.length;)e.shift()();K=!1}function we(e,t){K&&!t?e.apply(this,arguments):(Y.push(e),Q||(Q=!0,(f.hidden?ie:se)(_e)))}return ie(function(){z.init&&ye()}),m={cfg:z,autoSizer:ze,loader:me,init:ye,uP:h,aC:c,rC:u,hC:o,fire:y,gW:i,rAF:fe}}(e,e.document,Date);e.lazySizes=t,"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:{});
/**
 * ThemeSphere lazyload extend.
 * @copyright ThemeSphere
 * @preserve
 */
BunyadLazy.ext=(t=>{var e,a,l;lazyloadType=BunyadLazyConf.type,lazyloadType&&window.lazySizes?(addEventListener("lazybeforeunveil",e=>{var a=e.target;a.getAttribute("data-bgsrc")&&(e.detail.firesLoad=!0,t.bgLoad(a,function(){window.lazySizes.fire(a,"_lazyloaded",{},!0,!0)}))}),window.lazySizes.init(),"smart"!==lazyloadType||document.documentElement.clientWidth<1380||(e=e||requestAnimationFrame,a=()=>{document.querySelectorAll(".lazyload").forEach(e=>{lazySizes.loader.unveil(e)})},t.callOnLoad(()=>e(a,{timeout:500}))),t.callOnLoad(()=>window.lazySizesConfig.expand=null),l=()=>{document.querySelectorAll("script[data-type=lazy]").forEach(e=>{e.src=e.dataset.src,e.dataset.type=""})},setTimeout(l,4e3),t.callOnLoad(()=>{["mousemove","keydown","touchstart"].forEach(e=>document.addEventListener(e,l,{passive:!0,once:!0}))})):t.initBgImages(!0)})(BunyadLazy.load);
// source --> https://www.buserterkini.com/wp-content/themes/smart-mag/js/jquery.mfp-lightbox.js?ver=10.3.2 
/*! Magnific Popup - v1.1.0 - 2016-02-20
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2016 Dmitry Semenov; */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(b=new t,b.init(),a.magnificPopup.instance=b)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};t.prototype={constructor:t,init:function(){var c=navigator.appVersion;b.isLowIE=b.isIE8=document.all&&!document.addEventListener,b.isAndroid=/android/gi.test(c),b.isIOS=/iphone|ipad|ipod/gi.test(c),b.supportsTransition=B(),b.probablyMobile=b.isAndroid||b.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),d=a(document),b.popupsCache={}},open:function(c){var e;if(c.isObj===!1){b.items=c.items.toArray(),b.index=0;var g,h=c.items;for(e=0;e<h.length;e++)if(g=h[e],g.parsed&&(g=g.el[0]),g===c.el[0]){b.index=e;break}}else b.items=a.isArray(c.items)?c.items:[c.items],b.index=c.index||0;if(b.isOpen)return void b.updateItemHTML();b.types=[],f="",c.mainEl&&c.mainEl.length?b.ev=c.mainEl.eq(0):b.ev=d,c.key?(b.popupsCache[c.key]||(b.popupsCache[c.key]={}),b.currTemplate=b.popupsCache[c.key]):b.currTemplate={},b.st=a.extend(!0,{},a.magnificPopup.defaults,c),b.fixedContentPos="auto"===b.st.fixedContentPos?!b.probablyMobile:b.st.fixedContentPos,b.st.modal&&(b.st.closeOnContentClick=!1,b.st.closeOnBgClick=!1,b.st.showCloseBtn=!1,b.st.enableEscapeKey=!1),b.bgOverlay||(b.bgOverlay=x("bg").on("click"+p,function(){b.close()}),b.wrap=x("wrap").attr("tabindex",-1).on("click"+p,function(a){b._checkIfClose(a.target)&&b.close()}),b.container=x("container",b.wrap)),b.contentContainer=x("content"),b.st.preloader&&(b.preloader=x("preloader",b.container,b.st.tLoading));var i=a.magnificPopup.modules;for(e=0;e<i.length;e++){var j=i[e];j=j.charAt(0).toUpperCase()+j.slice(1),b["init"+j].call(b)}y("BeforeOpen"),b.st.showCloseBtn&&(b.st.closeBtnInside?(w(l,function(a,b,c,d){c.close_replaceWith=z(d.type)}),f+=" mfp-close-btn-in"):b.wrap.append(z())),b.st.alignTop&&(f+=" mfp-align-top"),b.fixedContentPos?b.wrap.css({overflow:b.st.overflowY,overflowX:"hidden",overflowY:b.st.overflowY}):b.wrap.css({top:v.scrollTop(),position:"absolute"}),(b.st.fixedBgPos===!1||"auto"===b.st.fixedBgPos&&!b.fixedContentPos)&&b.bgOverlay.css({height:d.height(),position:"absolute"}),b.st.enableEscapeKey&&d.on("keyup"+p,function(a){27===a.keyCode&&b.close()}),v.on("resize"+p,function(){b.updateSize()}),b.st.closeOnContentClick||(f+=" mfp-auto-cursor"),f&&b.wrap.addClass(f);var k=b.wH=v.height(),n={};if(b.fixedContentPos&&b._hasScrollBar(k)){var o=b._getScrollbarSize();o&&(n.marginRight=o)}b.fixedContentPos&&(b.isIE7?a("body, html").css("overflow","hidden"):n.overflow="hidden");var r=b.st.mainClass;return b.isIE7&&(r+=" mfp-ie7"),r&&b._addClassToMFP(r),b.updateItemHTML(),y("BuildControls"),a("html").css(n),b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo||a(document.body)),b._lastFocusedEl=document.activeElement,setTimeout(function(){b.content?(b._addClassToMFP(q),b._setFocus()):b.bgOverlay.addClass(q),d.on("focusin"+p,b._onFocusIn)},16),b.isOpen=!0,b.updateSize(k),y(m),c},close:function(){b.isOpen&&(y(i),b.isOpen=!1,b.st.removalDelay&&!b.isLowIE&&b.supportsTransition?(b._addClassToMFP(r),setTimeout(function(){b._close()},b.st.removalDelay)):b._close())},_close:function(){y(h);var c=r+" "+q+" ";if(b.bgOverlay.detach(),b.wrap.detach(),b.container.empty(),b.st.mainClass&&(c+=b.st.mainClass+" "),b._removeClassFromMFP(c),b.fixedContentPos){var e={marginRight:""};b.isIE7?a("body, html").css("overflow",""):e.overflow="",a("html").css(e)}d.off("keyup"+p+" focusin"+p),b.ev.off(p),b.wrap.attr("class","mfp-wrap").removeAttr("style"),b.bgOverlay.attr("class","mfp-bg"),b.container.attr("class","mfp-container"),!b.st.showCloseBtn||b.st.closeBtnInside&&b.currTemplate[b.currItem.type]!==!0||b.currTemplate.closeBtn&&b.currTemplate.closeBtn.detach(),b.st.autoFocusLast&&b._lastFocusedEl&&a(b._lastFocusedEl).focus(),b.currItem=null,b.content=null,b.currTemplate=null,b.prevHeight=0,y(j)},updateSize:function(a){if(b.isIOS){var c=document.documentElement.clientWidth/window.innerWidth,d=window.innerHeight*c;b.wrap.css("height",d),b.wH=d}else b.wH=a||v.height();b.fixedContentPos||b.wrap.css("height",b.wH),y("Resize")},updateItemHTML:function(){var c=b.items[b.index];b.contentContainer.detach(),b.content&&b.content.detach(),c.parsed||(c=b.parseEl(b.index));var d=c.type;if(y("BeforeChange",[b.currItem?b.currItem.type:"",d]),b.currItem=c,!b.currTemplate[d]){var f=b.st[d]?b.st[d].markup:!1;y("FirstMarkupParse",f),f?b.currTemplate[d]=a(f):b.currTemplate[d]=!0}e&&e!==c.type&&b.container.removeClass("mfp-"+e+"-holder");var g=b["get"+d.charAt(0).toUpperCase()+d.slice(1)](c,b.currTemplate[d]);b.appendContent(g,d),c.preloaded=!0,y(n,c),e=c.type,b.container.prepend(b.contentContainer),y("AfterChange")},appendContent:function(a,c){b.content=a,a?b.st.showCloseBtn&&b.st.closeBtnInside&&b.currTemplate[c]===!0?b.content.find(".mfp-close").length||b.content.append(z()):b.content=a:b.content="",y(k),b.container.addClass("mfp-"+c+"-holder"),b.contentContainer.append(b.content)},parseEl:function(c){var d,e=b.items[c];if(e.tagName?e={el:a(e)}:(d=e.type,e={data:e,src:e.src}),e.el){for(var f=b.types,g=0;g<f.length;g++)if(e.el.hasClass("mfp-"+f[g])){d=f[g];break}e.src=e.el.attr("data-mfp-src"),e.src||(e.src=e.el.attr("href"))}return e.type=d||b.st.type||"inline",e.index=c,e.parsed=!0,b.items[c]=e,y("ElementParse",e),b.items[c]},addGroup:function(a,c){var d=function(d){d.mfpEl=this,b._openClick(d,a,c)};c||(c={});var e="click.magnificPopup";c.mainEl=a,c.items?(c.isObj=!0,a.off(e).on(e,d)):(c.isObj=!1,c.delegate?a.off(e).on(e,c.delegate,d):(c.items=a,a.off(e).on(e,d)))},_openClick:function(c,d,e){var f=void 0!==e.midClick?e.midClick:a.magnificPopup.defaults.midClick;if(f||!(2===c.which||c.ctrlKey||c.metaKey||c.altKey||c.shiftKey)){var g=void 0!==e.disableOn?e.disableOn:a.magnificPopup.defaults.disableOn;if(g)if(a.isFunction(g)){if(!g.call(b))return!0}else if(v.width()<g)return!0;c.type&&(c.preventDefault(),b.isOpen&&c.stopPropagation()),e.el=a(c.mfpEl),e.delegate&&(e.items=d.find(e.delegate)),b.open(e)}},updateStatus:function(a,d){if(b.preloader){c!==a&&b.container.removeClass("mfp-s-"+c),d||"loading"!==a||(d=b.st.tLoading);var e={status:a,text:d};y("UpdateStatus",e),a=e.status,d=e.text,b.preloader.html(d),b.preloader.find("a").on("click",function(a){a.stopImmediatePropagation()}),b.container.addClass("mfp-s-"+a),c=a}},_checkIfClose:function(c){if(!a(c).hasClass(s)){var d=b.st.closeOnContentClick,e=b.st.closeOnBgClick;if(d&&e)return!0;if(!b.content||a(c).hasClass("mfp-close")||b.preloader&&c===b.preloader[0])return!0;if(c===b.content[0]||a.contains(b.content[0],c)){if(d)return!0}else if(e&&a.contains(document,c))return!0;return!1}},_addClassToMFP:function(a){b.bgOverlay.addClass(a),b.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),b.wrap.removeClass(a)},_hasScrollBar:function(a){return(b.isIE7?d.height():document.body.scrollHeight)>(a||v.height())},_setFocus:function(){(b.st.focus?b.content.find(b.st.focus).eq(0):b.wrap).focus()},_onFocusIn:function(c){return c.target===b.wrap[0]||a.contains(b.wrap[0],c.target)?void 0:(b._setFocus(),!1)},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(l,[b,c,d]),a.each(c,function(c,d){if(void 0===d||d===!1)return!0;if(e=c.split("_"),e.length>1){var f=b.find(p+"-"+e[0]);if(f.length>0){var g=e[1];"replaceWith"===g?f[0]!==d[0]&&f.replaceWith(d):"img"===g?f.is("img")?f.attr("src",d):f.replaceWith(a("<img>").attr("src",d).attr("class",f.attr("class"))):f.attr(e[1],d)}}else b.find(p+"-"+c).html(d)})},_getScrollbarSize:function(){if(void 0===b.scrollbarSize){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),b.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return b.scrollbarSize}},a.magnificPopup={instance:null,proto:t.prototype,modules:[],open:function(b,c){return A(),b=b?a.extend(!0,{},b):{},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">&#215;</button>',tClose:"Close (Esc)",tLoading:"Loading...",autoFocusLast:!0}},a.fn.magnificPopup=function(c){A();var d=a(this);if("string"==typeof c)if("open"===c){var e,f=u?d.data("magnificPopup"):d[0].magnificPopup,g=parseInt(arguments[1],10)||0;f.items?e=f.items[g]:(e=d,f.delegate&&(e=e.find(f.delegate)),e=e.eq(g)),b._openClick({mfpEl:e},d,f)}else b.isOpen&&b[c].apply(b,Array.prototype.slice.call(arguments,1));else c=a.extend(!0,{},c),u?d.data("magnificPopup",c):d[0].magnificPopup=c,b.addGroup(d,c);return d};var C,D,E,F="inline",G=function(){E&&(D.after(E.addClass(C)).detach(),E=null)};a.magnificPopup.registerModule(F,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){b.types.push(F),w(h+"."+F,function(){G()})},getInline:function(c,d){if(G(),c.src){var e=b.st.inline,f=a(c.src);if(f.length){var g=f[0].parentNode;g&&g.tagName&&(D||(C=e.hiddenClass,D=x(C),C="mfp-"+C),E=f.after(D).detach().removeClass(C)),b.updateStatus("ready")}else b.updateStatus("error",e.tNotFound),f=a("<div>");return c.inlineElement=f,f}return b.updateStatus("ready"),b._parseMarkup(d,{},c),d}}});var H,I="ajax",J=function(){H&&a(document.body).removeClass(H)},K=function(){J(),b.req&&b.req.abort()};a.magnificPopup.registerModule(I,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){b.types.push(I),H=b.st.ajax.cursor,w(h+"."+I,K),w("BeforeChange."+I,K)},getAjax:function(c){H&&a(document.body).addClass(H),b.updateStatus("loading");var d=a.extend({url:c.src,success:function(d,e,f){var g={data:d,xhr:f};y("ParseAjax",g),b.appendContent(a(g.data),I),c.finished=!0,J(),b._setFocus(),setTimeout(function(){b.wrap.addClass(q)},16),b.updateStatus("ready"),y("AjaxContentAdded")},error:function(){J(),c.finished=c.loadError=!0,b.updateStatus("error",b.st.ajax.tError.replace("%url%",c.src))}},b.st.ajax.settings);return b.req=a.ajax(d),""}}});var L,M=function(c){if(c.data&&void 0!==c.data.title)return c.data.title;var d=b.st.image.titleSrc;if(d){if(a.isFunction(d))return d.call(b,c);if(c.el)return c.el.attr(d)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var c=b.st.image,d=".image";b.types.push("image"),w(m+d,function(){"image"===b.currItem.type&&c.cursor&&a(document.body).addClass(c.cursor)}),w(h+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),v.off("resize"+p)}),w("Resize"+d,b.resizeImage),b.isLowIE&&w("AfterChange",b.resizeImage)},resizeImage:function(){var a=b.currItem;if(a&&a.img&&b.st.image.verticalFit){var c=0;b.isLowIE&&(c=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",b.wH-c)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,L&&clearInterval(L),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(b.content&&b.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var c=0,d=a.img[0],e=function(f){L&&clearInterval(L),L=setInterval(function(){return d.naturalWidth>0?void b._onImageHasSize(a):(c>200&&clearInterval(L),c++,void(3===c?e(10):40===c?e(50):100===c&&e(500)))},f)};e(1)},getImage:function(c,d){var e=0,f=function(){c&&(c.img[0].complete?(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("ready")),c.hasSize=!0,c.loaded=!0,y("ImageLoadComplete")):(e++,200>e?setTimeout(f,100):g()))},g=function(){c&&(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("error",h.tError.replace("%url%",c.src))),c.hasSize=!0,c.loaded=!0,c.loadError=!0)},h=b.st.image,i=d.find(".mfp-img");if(i.length){var j=document.createElement("img");j.className="mfp-img",c.el&&c.el.find("img").length&&(j.alt=c.el.find("img").attr("alt")),c.img=a(j).on("load.mfploader",f).on("error.mfploader",g),j.src=c.src,i.is("img")&&(c.img=c.img.clone()),j=c.img[0],j.naturalWidth>0?c.hasSize=!0:j.width||(c.hasSize=!1)}return b._parseMarkup(d,{title:M(c),img_replaceWith:c.img},c),b.resizeImage(),c.hasSize?(L&&clearInterval(L),c.loadError?(d.addClass("mfp-loading"),b.updateStatus("error",h.tError.replace("%url%",c.src))):(d.removeClass("mfp-loading"),b.updateStatus("ready")),d):(b.updateStatus("loading"),c.loading=!0,c.hasSize||(c.imgHidden=!0,d.addClass("mfp-loading"),b.findImageSize(c)),d)}}});var N,O=function(){return void 0===N&&(N=void 0!==document.createElement("p").style.MozTransform),N};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a,c=b.st.zoom,d=".zoom";if(c.enabled&&b.supportsTransition){var e,f,g=c.duration,j=function(a){var b=a.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+c.duration/1e3+"s "+c.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,b.css(e),b},k=function(){b.content.css("visibility","visible")};w("BuildControls"+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.content.css("visibility","hidden"),a=b._getItemToZoom(),!a)return void k();f=j(a),f.css(b._getOffset()),b.wrap.append(f),e=setTimeout(function(){f.css(b._getOffset(!0)),e=setTimeout(function(){k(),setTimeout(function(){f.remove(),a=f=null,y("ZoomAnimationEnded")},16)},g)},16)}}),w(i+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.st.removalDelay=g,!a){if(a=b._getItemToZoom(),!a)return;f=j(a)}f.css(b._getOffset(!0)),b.wrap.append(f),b.content.css("visibility","hidden"),setTimeout(function(){f.css(b._getOffset())},16)}}),w(h+d,function(){b._allowZoom()&&(k(),f&&f.remove(),a=null)})}},_allowZoom:function(){return"image"===b.currItem.type},_getItemToZoom:function(){return b.currItem.hasSize?b.currItem.img:!1},_getOffset:function(c){var d;d=c?b.currItem.img:b.st.zoom.opener(b.currItem.el||b.currItem);var e=d.offset(),f=parseInt(d.css("padding-top"),10),g=parseInt(d.css("padding-bottom"),10);e.top-=a(window).scrollTop()-f;var h={width:d.width(),height:(u?d.innerHeight():d[0].offsetHeight)-g-f};return O()?h["-moz-transform"]=h.transform="translate("+e.left+"px,"+e.top+"px)":(h.left=e.left,h.top=e.top),h}}});var P="iframe",Q="//about:blank",R=function(a){if(b.currTemplate[P]){var c=b.currTemplate[P].find("iframe");c.length&&(a||(c[0].src=Q),b.isIE8&&c.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(P,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){b.types.push(P),w("BeforeChange",function(a,b,c){b!==c&&(b===P?R():c===P&&R(!0))}),w(h+"."+P,function(){R()})},getIframe:function(c,d){var e=c.src,f=b.st.iframe;a.each(f.patterns,function(){return e.indexOf(this.index)>-1?(this.id&&(e="string"==typeof this.id?e.substr(e.lastIndexOf(this.id)+this.id.length,e.length):this.id.call(this,e)),e=this.src.replace("%id%",e),!1):void 0});var g={};return f.srcAction&&(g[f.srcAction]=e),b._parseMarkup(d,g,c),b.updateStatus("ready"),d}}});var S=function(a){var c=b.items.length;return a>c-1?a-c:0>a?c+a:a},T=function(a,b,c){return a.replace(/%curr%/gi,b+1).replace(/%total%/gi,c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var c=b.st.gallery,e=".mfp-gallery";return b.direction=!0,c&&c.enabled?(f+=" mfp-gallery",w(m+e,function(){c.navigateByImgClick&&b.wrap.on("click"+e,".mfp-img",function(){return b.items.length>1?(b.next(),!1):void 0}),d.on("keydown"+e,function(a){37===a.keyCode?b.prev():39===a.keyCode&&b.next()})}),w("UpdateStatus"+e,function(a,c){c.text&&(c.text=T(c.text,b.currItem.index,b.items.length))}),w(l+e,function(a,d,e,f){var g=b.items.length;e.counter=g>1?T(c.tCounter,f.index,g):""}),w("BuildControls"+e,function(){if(b.items.length>1&&c.arrows&&!b.arrowLeft){var d=c.arrowMarkup,e=b.arrowLeft=a(d.replace(/%title%/gi,c.tPrev).replace(/%dir%/gi,"left")).addClass(s),f=b.arrowRight=a(d.replace(/%title%/gi,c.tNext).replace(/%dir%/gi,"right")).addClass(s);e.click(function(){b.prev()}),f.click(function(){b.next()}),b.container.append(e.add(f))}}),w(n+e,function(){b._preloadTimeout&&clearTimeout(b._preloadTimeout),b._preloadTimeout=setTimeout(function(){b.preloadNearbyImages(),b._preloadTimeout=null},16)}),void w(h+e,function(){d.off(e),b.wrap.off("click"+e),b.arrowRight=b.arrowLeft=null})):!1},next:function(){b.direction=!0,b.index=S(b.index+1),b.updateItemHTML()},prev:function(){b.direction=!1,b.index=S(b.index-1),b.updateItemHTML()},goTo:function(a){b.direction=a>=b.index,b.index=a,b.updateItemHTML()},preloadNearbyImages:function(){var a,c=b.st.gallery.preload,d=Math.min(c[0],b.items.length),e=Math.min(c[1],b.items.length);for(a=1;a<=(b.direction?e:d);a++)b._preloadItem(b.index+a);for(a=1;a<=(b.direction?d:e);a++)b._preloadItem(b.index-a)},_preloadItem:function(c){if(c=S(c),!b.items[c].preloaded){var d=b.items[c];d.parsed||(d=b.parseEl(c)),y("LazyLoad",d),"image"===d.type&&(d.img=a('<img class="mfp-img" />').on("load.mfploader",function(){d.hasSize=!0}).on("error.mfploader",function(){d.hasSize=!0,d.loadError=!0,y("LazyLoadError",d)}).attr("src",d.src)),d.preloaded=!0}}}});var U="retina";a.magnificPopup.registerModule(U,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=b.st.retina,c=a.ratio;c=isNaN(c)?c():c,c>1&&(w("ImageHasSize."+U,function(a,b){b.img.css({"max-width":b.img[0].naturalWidth/c,width:"100%"})}),w("ElementParse."+U,function(b,d){d.src=a.replaceSrc(d,c)}))}}}}),A()});
// source --> https://www.buserterkini.com/wp-content/themes/smart-mag/js/jquery.sticky-sidebar.js?ver=10.3.2 
/*!
 * Theia Sticky Sidebar v1.7.0 (Modified by ThemeSphere)
 * https://github.com/WeCodePixels/theia-sticky-sidebar
 *
 * Glues your website's sidebars, making them permanently visible while scrolling.
 *
 * Copyright 2013-2016 WeCodePixels and other contributors
 * Released under the MIT license
 */

(function ($) {
	$.fn.theiaStickySidebar = function (options) {
		var defaults = {
			'containerSelector': '',
			'additionalMarginTop': 0,
			'additionalMarginBottom': 0,
			'updateSidebarHeight': true,
			'minWidth': 0,
			'disableOnResponsiveLayouts': true,
			'sidebarBehavior': 'modern',
			'defaultPosition': 'relative',
			'namespace': 'TSS'
		};
	
		options = $.extend(defaults, options);

		// Validate options
		options.additionalMarginTop = parseInt(options.additionalMarginTop) || 0;
		options.additionalMarginBottom = parseInt(options.additionalMarginBottom) || 0;

		tryInitOrHookIntoEvents(options, this);

		// Try doing init, otherwise hook into window.resize and document.scroll and try again then.
		function tryInitOrHookIntoEvents(options, $that) {
			var success = tryInit(options, $that);

			if (!success) {
				console.log('TSS: Body width smaller than options.minWidth. Init is delayed.');

				$(document).on('scroll.' + options.namespace, function (options, $that) {
					return function (evt) {
						var success = tryInit(options, $that);

						if (success) {
							$(this).unbind(evt);
						}
					};
				}(options, $that));
				$(window).on('resize.' + options.namespace, function (options, $that) {
					return function (evt) {
						var success = tryInit(options, $that);

						if (success) {
							$(this).unbind(evt);
						}
					};
				}(options, $that))
			}
		}

		// Try doing init if proper conditions are met.
		function tryInit(options, $that) {
			if (options.initialized === true) {
				return true;
			}

			if ($('body').width() < options.minWidth) {
				return false;
			}

			init(options, $that);

			return true;
		}

		// Init the sticky sidebar(s).
		function init(options, $that) {
			options.initialized = true;

			// Add CSS
			var existingStylesheet = $('#theia-sticky-sidebar-stylesheet-' + options.namespace);
			if (existingStylesheet.length === 0) {
				$('head').append($('<style id="theia-sticky-sidebar-stylesheet-' + options.namespace + '">.theiaStickySidebar:after {content: ""; display: table; clear: both;}</style>'));
			}

			$that.each(function () {
				var o = {};

				o.sidebar = $(this);

				// Save options
				o.options = options || {};
				
				// +EDIT: Options editable.
				o.sidebar.data('tss-options', o.options);

				// Get container
				o.container = $(o.options.containerSelector);
				if (o.container.length == 0) {
					o.container = o.sidebar.parent();
				}

				// Create sticky sidebar
				o.sidebar.parents().css('-webkit-transform', 'none'); // Fix for WebKit bug - https://code.google.com/p/chromium/issues/detail?id=20574
				o.sidebar.css({
					'position': o.options.defaultPosition,
					'overflow': 'visible',
					// The "box-sizing" must be set to "content-box" because we set a fixed height to this element when the sticky sidebar has a fixed position.
					'-webkit-box-sizing': 'border-box',
					'-moz-box-sizing': 'border-box',
					'box-sizing': 'border-box'
				});

				// Get the sticky sidebar element. If none has been found, then create one.
				o.stickySidebar = o.sidebar.find('.theiaStickySidebar');
				if (o.stickySidebar.length == 0) {
					// Remove <script> tags, otherwise they will be run again when added to the stickySidebar.
					var javaScriptMIMETypes = /(?:text|application)\/(?:x-)?(?:javascript|ecmascript)/i;
					o.sidebar.find('script').filter(function (index, script) {
						return script.type.length === 0 || script.type.match(javaScriptMIMETypes);
					}).remove();

					o.stickySidebar = $('<div>').addClass('theiaStickySidebar').append(o.sidebar.children());
					o.sidebar.append(o.stickySidebar);
				}

				// Get existing top and bottom margins and paddings
				o.marginBottom = parseInt(o.sidebar.css('margin-bottom'));
				o.paddingTop = parseInt(o.sidebar.css('padding-top'));
				o.paddingBottom = parseInt(o.sidebar.css('padding-bottom'));

				// Add a temporary padding rule to check for collapsable margins.
				var collapsedTopHeight = o.stickySidebar.offset().top;
				var collapsedBottomHeight = o.stickySidebar.outerHeight();
				o.stickySidebar.css('padding-top', 1);
				o.stickySidebar.css('padding-bottom', 1);
				collapsedTopHeight -= o.stickySidebar.offset().top;
				collapsedBottomHeight = o.stickySidebar.outerHeight() - collapsedBottomHeight - collapsedTopHeight;
				if (collapsedTopHeight == 0) {
					o.stickySidebar.css('padding-top', 0);
					o.stickySidebarPaddingTop = 0;
				}
				else {
					o.stickySidebarPaddingTop = 1;
				}

				if (collapsedBottomHeight == 0) {
					o.stickySidebar.css('padding-bottom', 0);
					o.stickySidebarPaddingBottom = 0;
				}
				else {
					o.stickySidebarPaddingBottom = 1;
				}

				// We use this to know whether the user is scrolling up or down.
				o.previousScrollTop = null;

				// Scroll top (value) when the sidebar has fixed position.
				o.fixedScrollTop = 0;

				// Set sidebar to default values.
				resetSidebar();

				o.onScroll = function (o) {
					// Stop if the sidebar isn't visible.
					if (!o.stickySidebar.is(":visible")) {
						return;
					}

					// Stop if the window is too small.
					if ($('body').width() < o.options.minWidth) {
						resetSidebar();
						return;
					}

					// Stop if the sidebar width is larger than the container width (e.g. the theme is responsive and the sidebar is now below the content)
					if (o.options.disableOnResponsiveLayouts) {
						var sidebarWidth = o.sidebar.outerWidth(o.sidebar.css('float') == 'none');

						if (sidebarWidth + 50 > o.container.width()) {
							resetSidebar();
							return;
						}
					}

					var scrollTop = $(document).scrollTop();
					var position = 'static';

					// If the user has scrolled down enough for the sidebar to be clipped at the top, then we can consider changing its position.
					if (scrollTop >= o.sidebar.offset().top + (o.paddingTop - o.options.additionalMarginTop)) {
						// The top and bottom offsets, used in various calculations.
						var offsetTop = o.paddingTop + options.additionalMarginTop;
						var offsetBottom = o.paddingBottom + o.marginBottom + options.additionalMarginBottom;

						// All top and bottom positions are relative to the window, not to the parent elemnts.
						var containerTop = o.sidebar.offset().top;
						var containerBottom = o.sidebar.offset().top + getClearedHeight(o.container);

						// The top and bottom offsets relative to the window screen top (zero) and bottom (window height).
						var windowOffsetTop = 0 + options.additionalMarginTop;
						var windowOffsetBottom;

						var sidebarSmallerThanWindow = (o.stickySidebar.outerHeight() + offsetTop + offsetBottom) < $(window).height();
						if (sidebarSmallerThanWindow) {
							windowOffsetBottom = windowOffsetTop + o.stickySidebar.outerHeight();
						}
						else {
							windowOffsetBottom = $(window).height() - o.marginBottom - o.paddingBottom - options.additionalMarginBottom;
						}

						var staticLimitTop = containerTop - scrollTop + o.paddingTop;
						var staticLimitBottom = containerBottom - scrollTop - o.paddingBottom - o.marginBottom;

						var top = o.stickySidebar.offset().top - scrollTop;
						var scrollTopDiff = o.previousScrollTop - scrollTop;

						// If the sidebar position is fixed, then it won't move up or down by itself. So, we manually adjust the top coordinate.
						if (o.stickySidebar.css('position') == 'fixed') {
							if (o.options.sidebarBehavior == 'modern') {
								top += scrollTopDiff;
							}
						}

						if (o.options.sidebarBehavior == 'stick-to-top') {
							top = options.additionalMarginTop;
						}

						if (o.options.sidebarBehavior == 'stick-to-bottom') {
							top = windowOffsetBottom - o.stickySidebar.outerHeight();
						}

						if (scrollTopDiff > 0) { // If the user is scrolling up.
							top = Math.min(top, windowOffsetTop);
						}
						else { // If the user is scrolling down.
							top = Math.max(top, windowOffsetBottom - o.stickySidebar.outerHeight());
						}

						top = Math.max(top, staticLimitTop);

						top = Math.min(top, staticLimitBottom - o.stickySidebar.outerHeight());

						// If the sidebar is the same height as the container, we won't use fixed positioning.
						var sidebarSameHeightAsContainer = o.container.height() == o.stickySidebar.outerHeight();

						if (!sidebarSameHeightAsContainer && top == windowOffsetTop) {
							position = 'fixed';
						}
						else if (!sidebarSameHeightAsContainer && top == windowOffsetBottom - o.stickySidebar.outerHeight()) {
							position = 'fixed';
						}
						else if (scrollTop + top - o.sidebar.offset().top - o.paddingTop <= options.additionalMarginTop) {
							// Stuck to the top of the page. No special behavior.
							position = 'static';
						}
						else {
							// Stuck to the bottom of the page.
							position = 'absolute';
						}
					}

					// +EDIT: Subpixel fix.
					const transY = window.devicePixelRatio < 1.6 ? Math.round : y => y;

					/*
					 * Performance notice: It's OK to set these CSS values at each resize/scroll, even if they don't change.
					 * It's way slower to first check if the values have changed.
					 */
					if (position == 'fixed') {
						var scrollLeft = $(document).scrollLeft();

						o.stickySidebar.css({
							'position': 'fixed',
							'width': getWidthForObject(o.stickySidebar) + 'px',
							// +EDIT: Subpixel fix.
							'transform': 'translateY(' + transY(top) + 'px)',
							'left': (o.sidebar.offset().left + parseInt(o.sidebar.css('padding-left')) + parseInt(o.sidebar.css('border-left')) - scrollLeft) + 'px',
							'top': '0px'
						});
					}
					else if (position == 'absolute') {
						var css = {};

						if (o.stickySidebar.css('position') != 'absolute') {
							css.position = 'absolute';
							// +EDIT: Subpixel fix.
							css.transform = 'translateY(' + transY(scrollTop + top - o.sidebar.offset().top - o.stickySidebarPaddingTop - o.stickySidebarPaddingBottom) + 'px)';
							css.top = '0px';
						}

						css.width = getWidthForObject(o.stickySidebar) + 'px';
						css.left = '';

						o.stickySidebar.css(css);
					}
					else if (position == 'static') {
						resetSidebar();
					}

					if (position != 'static') {
						if (o.options.updateSidebarHeight == true) {
							o.sidebar.css({
								'min-height': o.stickySidebar.outerHeight() + o.stickySidebar.offset().top - o.sidebar.offset().top + o.paddingBottom
							});
						}
					}

					o.previousScrollTop = scrollTop;
				};

				// Initialize the sidebar's position.
				o.onScroll(o);

				// Recalculate the sidebar's position on every scroll and resize.
				$(document).on('scroll.' + o.options.namespace, function (o) {
					return function () {
						o.onScroll(o);
					};
				}(o));
				$(window).on('resize.' + o.options.namespace, function (o) {
					return function () {
						o.stickySidebar.css({'position': 'static'});
						o.onScroll(o);
					};
				}(o));

				// Recalculate the sidebar's position every time the sidebar changes its size.
				if (typeof ResizeSensor !== 'undefined') {
					new ResizeSensor(o.stickySidebar[0], function (o) {
						return function () {
							o.onScroll(o);
						};
					}(o));
				}

				// Reset the sidebar to its default state
				function resetSidebar() {
					o.fixedScrollTop = 0;
					o.sidebar.css({
						'min-height': '1px'
					});
					o.stickySidebar.css({
						'position': 'static',
						'width': '',
						'transform': 'none'
					});
				}

				// Get the height of a div as if its floated children were cleared. Note that this function fails if the floats are more than one level deep.
				function getClearedHeight(e) {
					var height = e.height();

					e.children().each(function () {
						height = Math.max(height, $(this).height());
					});

					return height;
				}
			});
		}

		function getWidthForObject(object) {
			var width;

			try {
				width = object[0].getBoundingClientRect().width;
			}
			catch (err) {
			}

			if (typeof width === "undefined") {
				width = object.width();
			}

			return width;
		}

		return this;
	}
})(jQuery);
// source --> https://www.buserterkini.com/wp-content/themes/smart-mag/js/theme.js?ver=10.3.2 
/**
 * SmartMag Theme Frontend JS.
 * 
 * @copyright 2025 ThemeSphere.
 */
"use strict";

if (!Bunyad) {
	var Bunyad = {};
}

Bunyad.theme = (function($) {
	
	var hasTouch = false,
		responsiveMenu = false,
		isIframe = window.BunyadIsIframe || false,
		schemeKey = window.BunyadSchemeKey || 'bunyad-scheme';
		
	if (!window.requestIdleCallback) {
		window.requestIdleCallback = requestAnimationFrame;
	}
	
	// module
	var self = {
		init: function() {

			// Detect touch capability dynamically.
			$(window).on('touchstart', function() {
				// First touch.
				if (!hasTouch) {
					$('body').addClass('touch');
					self.touchNav();
				}

				hasTouch = true;
			});

			this.imageEffects();
			
			// Setup all sliders
			this.sliders();
			this.contentSlideshow();
			
			// Setup mobile header and navigation
			this.header();
			this.responsiveNav();
			this.megaMenus();
			
			// Start the news ticker
			this.newsTicker();
			
			// Setup the lightbox
			requestIdleCallback(this.lightbox);

			// Search modal
			this.searchModal();
			
			// Use sticky sidebar if enabled
			this.initStickySidebar();
			
			// User ratings
			this.userRatings();

			this.tabWidget();

			/**
			 * Woocommerce
			 */ 
			$('.woocommerce-ordering .drop li a').on('click', function(e) {
				var form = $(this).closest('form');
				form.find('[name=orderby]').val($(this).parent().data('value'));
				form.trigger('submit');
				
				e.preventDefault();
			});

			$(document).on('ts-ajax-pagination', e => {
				$(document).trigger('scroll.TSS');
				Bunyad.sliders();
			});

			// Lower priority.
			requestIdleCallback(() => {
				self.contextualBinds(document);

				// Nav icons class if missing
				$('.navigation i.only-icon').each(function() {	
					var el = $(this).closest('li');
					if (!el.hasClass('only-icon')) {
						el.addClass('only-icon');
					}
				});

				// Single show comments.
				$(document).on('click', '.ts-comments-show', function() {
					$(this).hide()
						.closest('.comments')
						.find('.ts-comments-hidden').show();
					return false;
				});
	
			}, {timeout: 1000});
		},

		/**
		 * @param {HTMLDocument|HTMLElement} context
		 */
		contextualBinds: function(context) {
			context = context || document;

			// Fit videos to container.
			requestAnimationFrame(() => {
				$('.featured-vid, .post-content', context).fitVids();
			});

			// Ratings
			$('.review-number', context).each(function() {
				var raw = $(this).find('span:not(.progress)').html(),
					progress = parseFloat(raw);
				
				$(this).find('.progress').css('width', (raw.search('%') === -1 ? (Math.round(progress / 10 * 100)) + '%' : progress));
			});

			$('.review-box ul li .bar', context).each(function() {
				$(this).data('width', $(this)[0].style.width).css('width', 0);
			});
		
			new Bunyad_InView(
				context.querySelectorAll('.review-box ul li'),
				entry => {
					const bar = $(entry.target).find('.bar');
					bar.addClass('appear').css('width', bar.data('width'));
				},
				{once: true}
			);

			// Single top social sharing view all buttons
			$('.post-share-b .show-more', context).on('click', function() {
				$(this).parent().addClass('all');
				return false;
			});

			$('.service.s-link', context).on('click', e => {
				// Temporary input copy trick as clipboard API only available over https.
				const temp = document.createElement('input');
				Object.assign(temp, {
					value: location.href,
					style: {position: 'absolute', left: '-200vw'}
				});
				document.body.prepend(temp);

				temp.select();
				document.execCommand('copy');
				temp.remove();

				let snackbar = document.querySelector('.ts-snackbar.copy-link');
				if (!snackbar) {
					snackbar = document.createElement('div');

					const message = e.currentTarget.querySelector('[data-message]').dataset.message;
					snackbar.className = 'ts-snackbar copy-link';
					snackbar.innerHTML = `<span>${message}</span><i class="tsi tsi-close"></i>`;
	
					document.body.append(snackbar);
				}

				if (snackbar.classList.contains('ts-snackbar-active')) {
					return false;
				}

				requestAnimationFrame(() => snackbar.classList.add('ts-snackbar-active'));

				const hideMessage = () => {
					snackbar.classList.remove('ts-snackbar-active');
					snackbar.hide();
					return false;
				}

				setTimeout(hideMessage, 5 * 1000);
				$(snackbar).on('click', '.tsi-close', hideMessage);

				return false;
			});

			// Go back handler for 404.
			$('.go-back').on('click', function() { 
				window.history.back();
				return false;
			});
		},

		/**
		 * Reinit common theme functionality, in a context, usually ALP feature.
		 * 
		 * @param {HTMLDocument|HTMLElement} context
		 */
		reInit: function(context) {

			// Only for elements.
			if (context !== document) {
				this.imageEffects(context.querySelectorAll('img'));
			}

			this.contextualBinds(context);
			this.lightbox();
			this.contentSlideshow();
			this.userRatings();

			setTimeout(this.stickySidebar, 50);

			Bunyad.sliders();
		},

		/**
		 * Image scroll animations.
		 */
		imageEffects: function(elements) {

			// Image effects - remove temp CSS when loaded.
			if (!$('body').hasClass('img-effects')) {
				return;
			}

			if (!elements) {
				elements = document.querySelectorAll('.main-wrap .wp-post-image, .post-content img');
			}

			elements.forEach(e => e.classList.add('no-display'));
			$('.bunyad-img-effects-css').remove();

			new Bunyad_InView(
				elements,
				entry => entry.target.classList.add('appear'),
				{once: true},
				() => $(elements).addClass('appear')
			);
		},
		
		newsTicker: function() {

			$('.trending-ticker').each(function() {

				if (!$(this).find('li.active').length) {
					$(this).find('li:first').addClass('active');
				}
				
				let ticker   = $(this);
				let interval = false;
				const delay  = parseInt(ticker.data('delay') || 5) * 1000;
				
				const setTick = () => {
					var active = ticker.find('li.active');
					active.fadeOut(function() {

						var next = active.next();
						if (!next.length) {
							next = ticker.find('li:first');
						}
						
						next.addClass('active').fadeIn();
						active.removeClass('active');
					});
				}
				
				const startTicker = () => {
					if (interval) {
						return;
					}

					interval = window.setInterval(setTick, delay);
				}

				startTicker();

				ticker.on('mouseenter', 'li', () => {
					clearInterval(interval);
					interval = false;
				});

				ticker.on('mouseleave', 'li', startTicker);
			});
		},
		
		header: function() {
			
			const toggleDarkMode = (scheme) => {
				const prevScheme = (scheme == 'dark' ? 'light' : 'dark');

				// Set initial scheme.
				const htmlClass = $('html').data('origClass');
				let initialScheme;
				if (htmlClass) {
					initialScheme = htmlClass.includes('s-dark') ? 'dark' : 'light';
				}

				if ($('html').data('autoDark')) {
					initialScheme = 'dark';
				}

				if (scheme !== initialScheme) {
					localStorage.setItem(schemeKey, scheme);
				}
				else {
					localStorage.removeItem(schemeKey);
				}
				
				$('html')
					.removeClass(`s-${prevScheme} site-s-${prevScheme}`)
					.addClass(`s-${scheme} site-s-${scheme}`);
			};
			
			$('.scheme-switcher .toggle').on('click', function() {
				const ele  = $(this);
				let scheme = ele.hasClass('toggle-dark') ? 'dark' : 'light';

				toggleDarkMode(scheme);

				// Notify auto-loaded posts.
				document.querySelectorAll('iframe.spc-auto-load-post').forEach(element => {
					element.contentWindow.postMessage({
						action: 'toggle-dark-mode',
						scheme
					}, '*');
				});

				return false;
			});

			// Listen and change in auto-loaded posts.
			if (isIframe) {
				window.addEventListener('message', e => {
					if (!e.data || e.data.action !== 'toggle-dark-mode') {
						return;
					}

					toggleDarkMode(e.data.scheme);
				});
			}
		},
		
		/**
		 * Setup the responsive nav events and markup
		 */
		responsiveNav: function() {
			this.initResponsiveNav();
		},

		initResponsiveNav: function() {
			
			if (responsiveMenu || !$('.off-canvas').length) {
				responsiveMenu = true;
				return;
			}
			
			// Set responsive initialized
			responsiveMenu = true;

			// Test for overlay/non-obstrusive scrollbar (MacOS).
			const hasOverlayScroll = () => {
				const ele = document.createElement("div");
				ele.setAttribute("style", "width:30px;height:30px;overflow:scroll;opacity:0");
				document.body.appendChild(ele);

				const result = ele.offsetWidth === ele.clientWidth;
				document.body.removeChild(ele);
				
				return result;
			}

			const setupScroll = () => {
				if (!hasTouch && !hasOverlayScroll()) {
					document.body.classList.add("has-scrollbar");
	
					// Reflow to fix scrollbars.
					const ele = $('.off-canvas-content');
					ele.css('display', 'block');
	
					requestAnimationFrame(function() {
						ele.css('display', 'flex');
					});
				}
			}

			const setupMenuHandlers = () => {
				// Setup mobile menu click handlers
				$('.mobile-menu li > a').each(function() {
					
					if ($(this).parent().children('ul').length) {
						$('<span class="chevron"><i class="tsi tsi-chevron-down"></i></span>').insertAfter($(this));
					}
				});
				
				$('.mobile-menu li .chevron').on('click', function() {
					$(this).closest('li').find('ul')
						.first()
						.parent()
						.toggleClass('active item-active');

					return false;
				});
			}

			const setupMobileMenu = () => {
				var container = $('.mobile-menu-container');

				// No items for mobile menu? Grab from others
				if (!container.find('.mobile-menu').children().length) {
					
					// Merge existing menus
					var mobileMenu = container.find('.mobile-menu'),
						mainMenu = $('.navigation-main .menu');
						
					if (!mainMenu.length) {
						return;
					}

					var menu = mainMenu.children().clone();
					
					// add category mega menu links
					menu.find('.mega-menu .sub-cats').each(function() {
						var container = $(this).closest('.menu-item');
						
						container.append($(this).find('.sub-nav'));
						container.find('.sub-nav').replaceWith(function() {
							return $('<ul />', {html: $(this).html()});
						});
						
						$(this).remove();
					});
					
					mobileMenu.append(menu);
				}
			}

			// Delayed setup.
			let isMenuSetup = false;
			const initSetup = () => {
				setupScroll();
				setupMobileMenu();
				setupMenuHandlers();
				
				isMenuSetup = true;
			};

			// Bunyad.util.onLoad(() => requestIdleCallback(initSetup, {timeout: 1000}));
			const showMenu = () => {
				if (!isMenuSetup) {
					initSetup();
				}
				
				$('html').toggleClass('off-canvas-active');
			}
		
			$('.mobile-head .menu-icon a, .smart-head .offcanvas-toggle')
				.on('click', function() {
					$(document).trigger('ts-sticky-bar-remove');
					showMenu();
				});

			// Off-canvas close
			$('.off-canvas .close').on('click', function() {
				showMenu();
				return false;
			});

			$('.off-canvas-backdrop').on('click', function() {
				$('.off-canvas .close').click();
				return false;
			})
		},

		megaMenus: function() {
			const media = window.matchMedia('(min-width: 940px)');
			const init  = e => {
				if (e.matches) {
					this.initMegaMenus();
				}
				media.removeListener(init);
			};

			init(media);
			media.addListener(init);
		},

		initMegaMenus: function() {
			// Bind events for mega menus
			$('.navigation .mega-menu-a').each(function() {
				
				var menu = $(this),
				    number = menu.find('.recent-posts').data('columns');
				
				// Init mega menus
				var default_mega_menu = function f() {
					menu.find('.posts').last().addClass('active');
					return f;
				}();

				// Mega-menu sub-cats handling.
				menu.find('.menu-item').on('mouseenter', function() {

					var id = parseInt( $(this).attr('class').match(/menu-cat-(\d+)/)[1] || 0 ),
					    menu = $(this).parents('.mega-menu'),
					    view_all = $(this).hasClass('view-all');
				
					if (!view_all && !id) {
						return;
					}
					
					// Remove other actives
					menu.find('.active, .current-menu-item').removeClass('active current-menu-item');

					// Activate current
					$(this).addClass('current-menu-item');
					var posts = menu.find('[data-id=' + id + ']').addClass('active');
					
					return false;
				});
				
				// Reset mega menu state on fresh hover
				menu.parent().on('mouseenter', function() {
					
					var menu = $(this).find('.mega-menu');
					
					// reset at beginning
					menu.find('.active, .current-menu-item')
						.removeClass('active current-menu-item');

					$(this)[0].offsetWidth; // reflow
					default_mega_menu();
				});
				
			});
		},
		
		/**
		 * Setup touch navigation for larger touch devices.
		 */
		touchNav: function() {
			
			var targets = $('.menu:not(.mobile-menu) a'),
				open_class = 'item-active',
				child_tag = 'ul, .mega-menu';
			
			targets.each(function() {
				
				var $this = $(this),
					$parent = $this.parent('li'),
					$siblings = $parent.siblings().find('a');
				
				$this.on('click', function(e) {

					var $this = $(this);
					e.stopPropagation();
					
					$siblings.parent('li').removeClass(open_class);
					
					// has a child? open the menu on tap
					if (!$this.parent().hasClass(open_class) && $this.next(child_tag).length > 0 && !$this.parents('.mega-menu.links').length) {
						e.preventDefault();
						$this.parent().addClass(open_class);
					}
				});
			});
			
			// close all menus
			$(document).on('click', function(e) {
				if (!$(e.target).is('.menu') && !$(e.target).parents('.menu').length) {
					targets.parent('li').removeClass(open_class);
				}
			});
		},

		initStickySidebar: function() {

			let hasInit  = false;
			const events = 'resize orientationchange scroll';
			const init = () => {
				if (hasInit) {
					return;
				}

				if (document.documentElement.clientWidth >= 940) {
					self.stickySidebar();
					hasInit = true;
					$(window).off(events, init);
				}
			}

			$(window).on(events, init);
			Bunyad.util.onLoad(init);
		},
		
		/**
		 * Setup sticky sidebar
		 */
		stickySidebar: function() {

			const stickyHeaderHeight = () => {
				const stickyHead = $('.smart-head-sticky');
				let addHeight = 0;
				if (stickyHead.length) {
					let height = window.getComputedStyle(stickyHead[0]).getPropertyValue('--head-h');
					addHeight = parseInt(height) || 0;
				}

				return addHeight;
			}

			const initNative = () => {
				if (!$('.ts-sticky-native').length) {
					return;
				}

				let baseTop = 20;
				if ($('.admin-bar').length) {
					baseTop += $('#wpadminbar').height();
				}
				
				const setTop = top => $('body').css('--ts-sticky-top', top + 'px');				

				$(document).on('sticky-bar-show', () => setTop(baseTop + stickyHeaderHeight()));
				$(document).on('sticky-bar-hide', () => setTop(baseTop));
			}

			const init = (addExtra) => {

				const sticky = $('.ts-sticky-col, .main-sidebar[data-sticky=1]');
				if (!sticky.length) {
					return;
				}
				
				let add = 20;
				if ($('.admin-bar').length) {
					add += $('#wpadminbar').height();
				}
				add += addExtra || 0;

				sticky.each(function() {

					var stickyCol = $(this);
					if (stickyCol.data('init') || stickyCol.hasClass('.ts-sticky-native')) {
						return;
					}

					stickyCol.data('init', 1);
					
					// Add wrapper class if missing
					if (!stickyCol.find('.theiaStickySidebar').length) {
						stickyCol.find('.elementor-widget-wrap').first().addClass('theiaStickySidebar');
						stickyCol.css({display: 'block'});
					}

					stickyCol.theiaStickySidebar({
						minWidth: 940, 
						updateSidebarHeight: false,
						additionalMarginTop: add,
						additionalMarginBottom: 20,
						disableOnResponsiveLayouts: false
					});
					
					// Update TSS internal options on sticky header on / off.
					const options = stickyCol.data('tss-options');

					if (!options) {
						return;
					}

					const stickyInner       = stickyCol.find('.theiaStickySidebar');
					const stickyColHeight   = stickyCol.outerHeight();
					const stickyInnerHeight = stickyInner.outerHeight();

					$(document).on('sticky-bar-show', () => {
						const newMarginTop = add + stickyHeaderHeight();

						// Do nothing if the height will exceed. This would cause a bug at bottom of sticky turning static.
						if (stickyInnerHeight + newMarginTop >= stickyColHeight) {
							return;
						}

						if (newMarginTop !== options.additionalMarginTop) {
							// Ignore unexpected negative transform of scrolling down.
							if (!sticky.css('transform').includes('-')) {
								options.additionalMarginTop = newMarginTop;
								setTimeout(() => $(window).trigger('scroll.TSS'), 300);
							}
						}
					});

					// Reset margins on sticky bar hide.
					$(document).on('sticky-bar-hide', () => {
						options.additionalMarginTop = add;
						setTimeout(() => $(window).trigger('scroll.TSS'), 300);
					});
				});
			};

			init();
			initNative();
			
			// for iframe loads in sidebar
			Bunyad.util.onLoad(() => setTimeout(() => {
				$(window).trigger('resize.TSS');
			}, 3500));
		},
		
		/**
		 * Setup legacy slider and slideshow.
		 */
		sliders: function() {

			if (!$.fn.flexslider) {
				return;
			}
			
			var is_rtl = ($('html').attr('dir') == 'rtl' ? true : false);
			
			// Classic / Legacy slider.
			var slider = $('.classic-slider');

			if (!slider.length) {
				return;
			}
			
			slider.find('.flexslider').flexslider({
				controlNav: true,
				animationSpeed: slider.data('animation-speed'),
				animation: slider.data('animation'),
				slideshowSpeed: slider.data('slide-delay'),
				manualControls: '.main-featured .flexslider .pages a',
				pauseOnHover: true,
				start: function() {
					$('.main-featured .slider').css('opacity', 1);
				},
				rtl: is_rtl
			});
			
			// Dynamic pagination - if not at default of 5
			var pages  = slider.find('.pages'),
				number = parseInt(pages.data('number'));
			
			if (number && number !== 5) {
				var width = (100 - ((number + 1) * 0.284900285)) / number;  // 100 - (slides + 1 * margin-left) / slides
				pages.find('a').css('width', width + '%');
			}
		},

		/**
		 * Post Content Slideshow: AJAX
		 */
		contentSlideshow: function() {

			var slideshow_cache = {},
				slideshow_wrap  = '.post-slideshow .post-pagination-large';
			
			if ($(slideshow_wrap).length && !$(slideshow_wrap).data('init') && $(slideshow_wrap).data('type') == 'ajax') {
			
				var processing;
				$(slideshow_wrap).data('init', true);

				$('.main-content').on('click', '.post-slideshow .post-pagination-large .links a', function() {
					
						// showing on home-page?
						if ($('body').hasClass('page')) {
							return;
						}
						
						// bottom links, scroll top
						var scroll;
						if ($(this).parents('.bottom').length) {
							scroll = true;
						}
						
						// abort existing request
						if (processing && processing.hasOwnProperty('abort')) {
							processing.abort();
						}
					
						var parent = $(this).closest('.post-slideshow'),
							url    = $(this).attr('href');
						
						parent.find('.content-page').removeClass('active').addClass('hidden previous');
					
						var show_slide = function(data) {
							
							// change browser url
							if (history.pushState) {
								history.pushState({}, '', url);
							}
							
							var page = $(data).find('.post-slideshow');
							
							if (page.length) {
								parent.find('.post-pagination-large').html(page.find('.post-pagination-large').html());
								parent.find('.content-page').after(page.find('.content-page').addClass('hidden loading'));
								
								setTimeout(function() {

									if (scroll) {
										$('html, body').animate({scrollTop: parent.offset().top - 50}, 200);
									}
									
									parent.find('.content-page.previous').remove();
									parent.find('.content-page.loading')
										.removeClass('previous hidden loading')
										.find('img').addClass('appear');
								}, 1);
							}
							
							processing = null;
							
						};
						
						// in cache?
						if (slideshow_cache[url]) {
							show_slide(slideshow_cache[url]);
						}
						else {
							
							// get via ajax
							processing = $.get(url, function(data) {
								slideshow_cache[url] = data;
								show_slide(data);
								
							});
						}
						
						return false;
				});
				
				// keyboard nav
				$(document).on('keyup', function(e) {				
						if (e.which == 37) {
							$(slideshow_wrap).find('.prev').parent().click();
						}
						else if (e.which == 39) {
							$(slideshow_wrap).find('.next').parent().click();
						}
				});
				
			}
		},
				
		/**
		 * User Ratings handling
		 */
		userRatings: function() {
			
			var compute_percent = function(e) {
				
				var offset = $(this).offset(),
				    position, percent;
				
				// count from right for RTL
				if ($('html').attr('dir') == 'rtl')  {
					offset.left = offset.left + $(this).outerWidth();
				}
				
				position = Math.abs(e.pageX - Math.max(0, offset.left));
				percent  = Math.min(100, Math.round(position / $(this).width() * 100));
				
				return percent;
			};

			// percent or points?
			var is_points = true,
				scale = parseInt($('.review-box .value-title').text()) || 10;
			
			if ($('.review-box .overall .percent').length) {
				is_points = false;
			}
			
			// update the bar and percent/points on hover
			$('.user-ratings .main-stars, .user-ratings .rating-bar').on('mousemove mouseenter mouseleave', 
				function(e) {
				
					// set main variables
					var bar = $(this).find('span'),
						user_ratings = $(this).closest('.user-ratings');
				
					bar.css('transition', 'none');
					
					if (user_ratings.hasClass('voted')) {
						return;
					}
				
					// hover over?
					if (e.type == 'mouseleave') {
						bar.css('width', bar.data('orig-width'));
						user_ratings.find('.hover-number').hide();
						user_ratings.find('.rating').show();
						return;
					}
					
					var percent = compute_percent.call(this, e);
					
					if (!bar.data('orig-width')) {
						bar.data('orig-width', bar[0].style.width);
					}
					
					bar.css('width', percent + '%');
					user_ratings.find('.rating').hide();
					user_ratings.find('.hover-number').show().text((is_points ? +parseFloat(percent / 100 * scale).toFixed(1) : percent + '%'));
				}
			);
			
			// add the rating
			$('.user-ratings .main-stars, .user-ratings .rating-bar').on('click', function(e) {
				
				// set main variables
				var bar = $(this).find('span'),
					user_ratings = $(this).closest('.user-ratings');
				
				if (user_ratings.hasClass('voted')) {
					return;
				}
				
				// setup ajax post data
				var post_data = {
						'action': 'bunyad_rate', 
						'id': user_ratings.data('post-id'), 
						'rating': compute_percent.call(this, e)
				};
				
				// get current votes
				var votes = user_ratings.find('.number'),
					cur_votes = parseInt(votes.text()) || 0;
				
				user_ratings.css('opacity', '0.3');
				bar.data('orig-width', bar[0].style.width);
				
				// add to votes and disable further voting 
				votes.text((cur_votes + 1).toString());
				
				$(this).trigger('mouseleave');
				user_ratings.addClass('voted');
				
				$.post(Bunyad.ajaxurl, post_data, function(data) {
					
					// update data
					if (data === Object(data)) {

						// change rating
						var cur_rating = user_ratings.find('.rating').text();
						user_ratings.find('.rating').text( cur_rating.search('%') !== -1 ? data.percent + ' %' : data.decimal );
						
						bar.css('width', data.percent + '%');
						bar.data('orig-width', data.percent);
					}
					
					user_ratings.hide().css('opacity', 1).fadeIn('slow');			
				}, 'json');
			});
		},
		
		tabWidget: function() {
			$(document).on('click', '.widget-tabbed .heading a', function() {
				
				var tab = $(this).data('tab'),
					tabs_data = $(this).closest('.widget-tabbed').find('.tabs-data'),
					parent = $(this).parent().parent(),
					active = parent.find('.active');
				
				if (!active.length) {
					active = parent.find('li:first-child');
				}

				active.removeClass('active').addClass('inactive');
				$(this).parent().addClass('active').removeClass('inactive');
				
				// hide current and show the clicked one
				var active_data = tabs_data.find('.tab-posts.active');
				if (!active_data.length) {
					active_data = tabs_data.find('.tab-posts:first-child');
				}
				
				active_data.hide();
				tabs_data.find('#recent-tab-' + tab).fadeIn().addClass('active').removeClass('inactive');

				return false;
			});
		},

		searchModal: function() {
			let isSetup = false;
			const target = $('.smart-head .search-icon');

			const setup = () => {
				if (isSetup || !$.fn.magnificPopup) {
					return;
				}

				isSetup = true;
				const scheme = $('.search-modal-wrap').data('scheme') == 'dark' ? ' s-dark' : '';

				// Search modal
				target.magnificPopup({
					items: {
						src: '.search-modal-wrap',
						type: 'inline'
					},
					removalDelay: 400,
					focus: 'input',
					closeBtnInside: false,
					closeOnBgClick: false,
					mainClass: 'search-modal' + scheme,
					midClick: true,
					fixedContentPos: true,
					autoFocusLast: false
				}); 
			};

			target.on('mouseover', setup);
			setTimeout(setup, 400);
		},

		/**
		 * Setup prettyPhoto
		 */
		lightbox: function() {
			
			// Can be disabled overall, or on mobile.
			if (
				!$.fn.magnificPopup 
				|| !$('body').hasClass('has-lb') 
				|| (!$('body').hasClass('has-lb-sm') && $(window).width() < 768)
			) {
				return;
			}

			if (isIframe) {
				return;
			}
			
			var mfpInit = {
				type: 'image',
				tLoading: '',
				mainClass: 'mfp-fade mfp-img-mobile',
				removalDelay: 300,
				callbacks: {
					afterClose: function() {
						if (this._lastFocusedEl) {
							$(this._lastFocusedEl).addClass('blur');
						}
					},
					open: () => $(document).trigger('ts-sticky-bar-remove')
				}
			};

			/**
			 * Filter to handle valid images only.
			 */
			var filterImages = function() {
				
				if (!$(this).attr('href')) {
					return false;
				}
				
				return $(this).attr('href').match(/\.(jpe?g|webp|avif|png|bmp|gif)($|\?.+?)/); 
			};
			
			/**
			 * Handle Galleries in post.
			 * 
			 * @param {HTMLElement} context
			 */
			var addGalleryLightbox = function(context) {
				var gal_selectors = '.gallery-slider .slick-slide:not(.slick-cloned), .post-content .gallery, .post-content .blocks-gallery-item, .post-content .tiled-gallery, .wp-block-gallery .wp-block-image, .tiled-gallery__gallery .tiled-gallery__item';
		
				// Filter to only tie valid images.
				$(gal_selectors, context)
					.find('a')
					.has('img, .img.bg-cover')
					.filter(filterImages)
					.addClass('lightbox-gallery-img');

				// Add WooCommerce support
				$('.woocommerce a[data-rel^="prettyPhoto"], a.zoom').addClass('lightbox-gallery-img');
				gal_selectors += ', .woocommerce .images';

				// Attach the lightbox as gallery
				$(gal_selectors, context).magnificPopup($.extend({}, mfpInit, {
					delegate: '.lightbox-gallery-img',
					gallery: {enabled: true},
					image: {
						titleSrc: function(item) {
							var image   = item.el.find('img'), 
								caption = item.el.find('.caption').html();
							
							return (caption || image.attr('title') || ' ');
						}
					}
				}));
			};
			
			/**
			 * Non-gallery images in posts.
			 * 
			 * @param {HTMLElement} context 
			 */
			var addLightboxImages = function(context) {

				var selector = 
					$('.post-content, .main .featured, .single-creative .featured', context)
						.find('a:not(.lightbox-gallery-img)')
						.has('img, .img');

				selector.add('.lightbox-img')
					.filter(filterImages)
					.magnificPopup(mfpInit);

			};

			addGalleryLightbox();
			addLightboxImages();

			$('iframe.spc-auto-load-post').each(function() {
				const iframe = $(this).get(0).contentDocument;
				addGalleryLightbox(iframe);
				addLightboxImages(iframe);
			});
			
		}
	};

	self.stickyBarPause = false;

	return self;
	
})(jQuery);
/**
 * Utility methods.
 */
Bunyad.util = {
	
	throttle(fn, delay = 150, trails = true) {

		let pause = false;
		let trail;
		let timeout = function() {
			if (trail) {
				fn.apply(trail[0], trail[1]);
				trail = null;
				setTimeout(timeout, delay);
			} else {
				pause = false;
			}
		};

		return function(...args) {
			if (!pause) {
				fn.apply(this, args);
				pause = true;
				setTimeout(timeout, delay);
			} else if (trails) {
				trail = [this, args];
			}
		};
	},

	writeRaf(fn, options) {
		var running, 
		    args, 
		    that;

		var run = function() {
			running = false;
			fn.apply(that, args);
		};

		if (!options) {
			options = {};
		}

		return function() {
			args = arguments;
			that = options.that || this;

			if (!running) {
				running = true;
				requestAnimationFrame(run);
			}
		};
	},

	onLoad(cb) {
		document.readyState === 'complete' ? cb() : window.addEventListener('load', cb);
	}
};

/**
 * Authentication modal.
 */
(function($) {

	/** @type {Boolean} */
	let isInitialized = false;

	function init() {

		if (!$('#auth-modal').length) {
			return;
		}

		$(document).on('click', 'a', e => {
			if (e.currentTarget.hash === '#auth-modal') {
				if (!window.MicroModal) {
					return;
				}
		
				initModal();
				MicroModal.show('auth-modal', {
					awaitCloseAnimation: true
				});

				e.preventDefault();
			}
		});
	}

	function initModal(e) {

		if (isInitialized) {
			return;
		}

		const modal  = $('#auth-modal');
		const toggle = e => {
			modal.find('.auth-modal-login, .auth-modal-register').toggle();
			e.preventDefault();
		}
		
		modal.on('click', '.register-link, .login-link', toggle);
		isInitialized = true;
	}

	Bunyad.authModal = init;

})(jQuery);
(function($) {

	const cache = [];

	function init() {
		$('.section-head .subcats a, .block-head .filters a').on('click', e => {
			doFilter(e.currentTarget);
			return false;
		});
	}

	function doFilter(ele) {

		if ($(this).hasClass('active')) {
			return false;
		}

		ele = $(ele);

		const block   = ele.closest('.block-wrap');
		const blockId = block.data('id');
		const termId  = ele.data('id');
		const content = block.find('.block-content');
		const curActive = ele.parents('.filters').find('a.active');
		
		// Store "All" in cache.
		if (!curActive.data('id')) {
			cache[`${blockId}-0`] = block[0].outerHTML;
		}

		// Filter links active
		ele.addClass('active');
		curActive.removeClass('active');

		// For pagination.
		block.data('filter-active', ele.data('id'));
		
		const cacheId = `${blockId}-${termId}`;
		content.removeClass('fade-in-up-lg')
			.addClass('loading');

		if (!cache[cacheId]) {

			const blockData = block.data('block') || {};
			blockData.props.filter = termId;

			// AJAX params
			const params =  {
				action: 'bunyad_block',
				block: blockData
			};

			$.post(
				Bunyad.ajaxurl,
				params,
				data => {
					cache[cacheId] = data;
					replaceContent(cache[cacheId], block, content);
				}
			);
		}
		else {
			replaceContent(cache[cacheId], block, content);
		}
	}

	function replaceContent(data, block, content) {
		const newHtml    = $(data);
		const newContent = newHtml.find('.block-content')
		newContent.find('img').addClass('no-display appear');

		// Race condition.
		newContent.find('.lazyloading').removeClass('lazyloading').addClass('lazyload');
		content.removeClass('fade-in-up-lg');

		requestAnimationFrame(() => {
			content.html(newContent.html())
				.removeClass('loading')
				.addClass('fade-in-up-lg')
				.addClass('ready');
		});
		
		// Set new block data.
		block.data('block', newHtml.data('block'));
	}

	Bunyad.blocksFilters = init;

})(jQuery);

(function($) {
	Bunyad.stickyHeader = function(header, options = {}) {
		var nav,
			isSmart = false,
			isSticky = false,
			stickyIsStatic = false,
			prevScroll = 0,
			curScroll  = 0,
			extraTop   = 0,
			stickyTop,
			hideAt,
			head,
			headHeight;

		let stickyBar;
		let stickyIsActive = false;
		let hasInitialized = false;
		
		/**
		 * Calculate header size.
		 */
		const calcHeadSize = Bunyad.util.writeRaf(() => {

			// Don't reset if it's stuck
			if (stickyIsActive) {
				return;
			}

			var new_height = head.css('min-height', 0).height();
			head.css('min-height', new_height);
			headHeight = new_height;
		});

		function setSize(skipCalc) {

			// Skip calculation if asked to and head height has been prev set
			if (skipCalc && headHeight) {
				return;
			}

			calcHeadSize();
		}

		/**
		 * Remove / disable sticky.
		 */
		function removeSticky(simpleHide) {
		
			// Check before dom modification 
			if (isSticky) {
				
				stickyIsActive = false;
				let visualHide = false;

				// Mainly for smart sticky. Simple hide by not unfixing completely.
				if (simpleHide) {
					if (!nav.hasClass('off')) {
						nav.addClass('off');
						visualHide = true;
					}
				}
				else {
					// isSticky already checks for presence of smart-head-sticky.
					nav.removeClass('smart-head-sticky off');
					visualHide = true;
				}
				
				if (visualHide) {
					setSize(true);
					$(document).trigger('sticky-bar-hide');
				}
			}
		}

		/**
		 * Make the bar sticky and setup handlers.
		 */
		function toggleSticky() {

			if (stickyIsStatic) {
				return;
			}

			curScroll = $(window).scrollTop();
			isSticky  = nav.hasClass('smart-head-sticky');

			// Check and apply sticky - separated writes
			const stickyWrites = Bunyad.util.writeRaf(() => {
				
				// Make it sticky when viewport is scrolled beyond the sticky bar.
				if (curScroll > stickyTop) {

					// For smart sticky, test for scroll change
					if (isSmart && (!prevScroll || curScroll > prevScroll)) {
						removeSticky(true);
					}
					else {
						stickyIsActive = true;
						
						if (!isSmart || curScroll < prevScroll-4 && !Bunyad.theme.stickyBarPause) {
							if (!nav.hasClass('smart-head-sticky') || nav.hasClass('off')) {
								nav.removeClass('off');
								nav.addClass('smart-head-sticky');

								$(document).trigger('sticky-bar-show');
							}
						}
					}
					
					prevScroll = curScroll;
					
				} else {
					
					// hide at a certain point
					if (curScroll <= hideAt) {
						prevScroll = 0;
						removeSticky();
					}
				}
			});
			
			stickyWrites();
		}

		/**
		 * Check if smart sticky is enabled.
		 */
		function checkSmart() {
			if (head.data('sticky-type') == 'smart') {
				isSmart = true;
			}
			
			if (isSmart && nav.length) {
				nav.addClass('is-smart');
			}
		}

		/**
		 * Setup calculations and DOM targets.
		 */
		function setup() {

			// Reset vars - might be a re-init
			stickyIsStatic = false;
			
			if ($('.admin-bar').length) {
				extraTop = $('#wpadminbar').height();
			}

			stickyBar = head.data('sticky');
			if (!stickyBar) {
				return;
			}

			// Auto detect.
			if (stickyBar === 'auto') {
				const menu = head.find('.navigation-main .menu');
				if (menu.length) {
					const match = menu.eq(0).closest('.smart-head-row').attr('class')
						.match(/smart-head-(top|mid|bot)/);

					if (!match || !match[1]) {
						return;
					}
					
					stickyBar = match[1];
				}
			}
		
			stickyBar = head.find('.smart-head-' + stickyBar);
			nav = stickyBar;

			if (!stickyBar.length) {
				return;
			}

			if (head.data('sticky-full')) {
				stickyBar.addClass('sticky-is-full');
			}
			
			stickyTop = nav.offset().top - extraTop;
			hideAt = stickyTop + 1;

			const isLast = head.find('.smart-head-row:last-child').is(stickyBar);
			
			// If not the last row, show late and hide early to prevent jumps for bottom row.
			if (!isLast) {
				stickyTop = head.offset().top + head.height();
				hideAt = stickyTop + 1;
				nav.addClass('animate');
			}
				
			checkSmart();

			// For smart, always animate.
			if (isSmart) {
				nav.addClass('animate');
			}

			// Android fix on addr bar hide
			if (isSmart && !stickyIsActive) {
				prevScroll = 0;
			}
		}

		/**
		 * Init it - called multiple times to test for init based on width.
		 */
		function initHandler() {

			if (hasInitialized) {
				return false;
			}
	
			if (
				(options.mobile && $(window).width() > 940)
				|| (!options.mobile && $(window).width() <= 940)
			) {
				return;
			}
	
			setup();
			if (!nav || !nav.length) {
				return;
			}
	
			// Setup sticky handler 
			toggleSticky();
	
			Bunyad.util.onLoad(calcHeadSize);
			$(window).on('scroll', toggleSticky);
			
			// Re-initialize on resize.
			$(window).on('resize orientationchange', () => {
				removeSticky();
				calcHeadSize();
				setup();
				toggleSticky();
			});

			hasInitialized = true;

			// Hooks.
			$(document).on('ts-sticky-bar-remove', removeSticky);
		}

		function init(header) {
			hasInitialized = false;
			head = $(header);

			if (!head.length) {
				return;
			}

			initHandler();
			$(window).on('resize orientationchange', initHandler);
		}

		init(header);

		return {
			init,
			getSticky: () => stickyBar,
		};
	};
})(jQuery);
/**
 * Minimal Element in-viewport handler.
 */
class Bunyad_InView {
	
	/**
	 * @param {NodeList} elements 
	 * @param {CallableFunction} callback 
	 * @param {Object} options 
	 * @param {CallableFunction} fallback
	 */
	constructor(elements = [], callback, options = {}, fallback) {

		this.elements = elements;
		this.callback = callback;
		this.options  = Object.assign({
			intersectOnly: true,
			observeOptions: {},
			once: false
		}, options);

		if (!this.callback) {
			return false;
		}

		if (!window.IntersectionObserver) {
			console.warn('Intersection observer missing.');
			fallback();
			return false;
		}

		// eslint-disable-next-line compat/compat
		this.observer = new IntersectionObserver(
			this.handleIntersection.bind(this), 
			this.options.observeOptions
		);

		elements.forEach(element => {
			this.observer.observe(element);
		});
	}

	handleIntersection(entries) {

		entries.forEach(entry => {
			if (this.options.intersectOnly && !entry.isIntersecting) {
				return;
			}

			this.callback.call(this, entry);

			if (this.options.once) {
				this.observer.unobserve(entry.target);
			}
		});
	}
}
(function($) {

	const cache = [];

	/**
	 * Setup pagination for blocks.
	 */
	function init() {

		// AJAX pagination handlers
		$('.main-wrap')
			.on('click', '.main-pagination .load-button, .pagination-numbers[data-type=numbers-ajax] a', e => {
				const target = e.currentTarget;

				if (target.dataset.processing) {
					return;
				}

				target.dataset.processing = true;

				ajaxPagination(target, () => {
					target.dataset.processing = false;
				});

				return false;
			});

		$('.main-pagination[data-type=infinite]').each(function() {
			infiniteLoad($(this).get(0));
		});
	}

	/**
	 * Infinite load handler.
	 * 
	 * @param {Element} pageEle Pagination element container.
	 * @param {Object} options 
	 */
	function infiniteLoad(pageEle, options) {
		const block = pageEle.closest('.block-wrap');
		pageEle._loads = 1;
		options = Object.assign({bottomDeduct: 30}, options);

		if (!block) {
			return;
		}

		const offset = {top: 0, bottom: 0};
		const compute = () => {
			const rect    = block.getBoundingClientRect();
			offset.top    = rect.top + window.scrollY;
			offset.bottom = offset.top + block.clientHeight - window.innerHeight;

			// Page element's height shouldn't be counted + extra deduction.
			offset.bottom -= pageEle.clientHeight + options.bottomDeduct;
		}

		compute();
		
		let isLoading = false;	
		const loadOnScroll = (e) => {

			if (isLoading || pageEle._loads > 5) {
				return;
			}

			if (window.scrollY > offset.bottom) {
				isLoading = true;
				pageEle._loads++;

				ajaxPagination(pageEle.querySelector('.load-button'), () => {
					compute();
					isLoading = false;
				});
			}
		};

		$(window).on('scroll', Bunyad.util.throttle(loadOnScroll, 150, false));
		$(window).on('resize', Bunyad.util.throttle(compute));
	}

	function ajaxPagination(ele, callback) {
		
		ele = $(ele);
			
		let block    = ele.closest('.block-wrap');
		let isBlock = true;
		let process  = processLoadMore;
		
		// Not a block, archives
		if (!block.length) {
			isBlock = false;
			block = ele.closest('.main-content');
		}

		// AJAX params
		const params =  {
			action: 'bunyad_block',
			block: block.data('block') || {},
			paged: (ele.data('page') || 0) + 1
		};

		// Type of pagination
		const type = ele.closest('.main-pagination').data('type');
		
		switch(type) {
		
			// Type: Load More
			case 'load-more':
			case 'infinite':
				ele.addClass('loading').find('.tsi').addClass('tsi-spin');
				process = processLoadMore;

				break;

			// Type: Numbered
			case 'numbers-ajax':

				block.find('.block-content').addClass('loading');
				
				// Change page number
				const permalink = ele.attr('href').match(/\/page\/(\d+)(\/|$)/);
				if (permalink !== null) {
					params.paged = permalink[1];
				}
				else {
					// Plain links
					const src = ele.attr('href').match(/(\?|&)paged?=(\d+)/);
					params.paged = src ? src[2] : 1;
				}
				
				// Set height
				block.css('height', block.height());
				process = processNumbered;

				break;
		}

		// Process block.
		if (isBlock) {
			
			// Home blocks AJAX
			const ajaxUrl = Bunyad.ajaxurl;

			const blockId = block.data('id');
			const cacheId = `${blockId}-${ block.data('filter-active') }-${params.paged}`;

			if (!cache[cacheId]) {
				$.post(
					ajaxUrl,
					params,
					data => {
						requestAnimationFrame(() => {
							process(data, block, ele);
							cache[cacheId] = data;
							!callback || callback();
						});
					}
				);
			}
			else {
				requestAnimationFrame(() => {
					process(cache[cacheId], block, ele);
					!callback || callback();
				});
			}
		}
	}

	/**
	 * Numbered Ajax callback.
	 */
	function processNumbered(data, block) {
		const blockContent = block.find('.block-content');
		
		blockContent
			.removeClass('fade-in-down-lg')
			.html($(data).find('.block-content').html());
		
		block.css('height', 'auto');
		blockContent.addClass('fade-in-down-lg').removeClass('loading');
		blockContent.on('animationend', e => blockContent.removeClass('fade-in-down-lg'));

		// Scroll to top, temporarily pausing sticky bar.
		Bunyad.theme.stickyBarPause = true;
		setTimeout(() => { Bunyad.theme.stickyBarPause = false; }, 300);
		$('html, body').animate({scrollTop: block.offset().top - 50}, 200);
		
		$(document).trigger('ts-ajax-pagination');		
	}

	/**
	 * Load More Ajax callback method.
	 */
	function processLoadMore(data, block, ele) {
		
		var content = $(data),
			posts;
		
		// Mixed blocks: News Focus, Highlights, Focus Grid.
		const isMixed = block.data('is-mixed');
		const wrap = isMixed ? block.find('.block-content') : block.find('.loop');
		const pagination = block.find('.main-pagination');
		
		posts = content.find('.loop').children().addClass('fade-in-up-lg');
		posts.each(function() {
			$(this).on('animationend', () => $(this).removeClass('fade-in-up-lg'));
		});

		if (isMixed) {
			pagination.remove();
			wrap.append(content.find('.block-content').children());
		}
		else {
			wrap.append(posts);
			
			const newPagination = content.find('.main-pagination');
			if (newPagination.length) {
				pagination.html(newPagination.html());
			}
			else {
				pagination.remove();
			}
		}

		// Masonry reload
		if (wrap.hasClass('masonry')) {
			// posts.removeClass('fade-in-up-lg');
			// Bunyad.theme.masonry(true, posts, wrap.find('.posts-wrap'));
		}
		
		$(document).trigger('ts-ajax-pagination');
		
		ele.removeClass('loading')
			.find('.tsi').removeClass('tsi-spin');
	}

	Bunyad.pagination = init;
})(jQuery);

/**
 * Live Search Handler
 */
(function($) {
	"use strict";
	
	var cache = {}, timer, element;
	
	const self = {
		
		init: function() {
			
			var search = $('.live-search-query');

			if (!search.length) {
				return;
			}
			
			// Turn off browser's own auto-complete
			$('.live-search-query').attr('autocomplete', 'off');
			
			// setup the live search on key press
			$('.live-search-query').on('keyup focus', function() {
				
				element = $(this).parent();
			
				var query = $(this).val(), result;

				// clear existing debounce
				clearTimeout(timer);
				
				// minimum of 1 character
				if (query.length < 1) {
					self.add_result('');
					return;
				}
				
				// debounce to prevent excessive ajax queries
				timer = setTimeout(function() {
					self.process(query);
				}, 250);
			});
			
			// setup hide 
			$(document).on('click', function(e) {
				
				var results = $('.live-search-results');
				
				if (results.is(':visible') && !$(e.target).closest('.search-form').length) {
					results.removeClass('fade-in');
					results.closest('form').removeClass('has-live-results');
				}
			});
		},
		
		/**
		 * Process the search query
		 */
		process: function(query) {

			// have it in cache?
			if (query in cache) {
				self.add_result(cache[query]);
			}
			else {
				$.get(Bunyad.ajaxurl, {action: 'bunyad_live_search', 'query': query}, function(data) {
					
					// add to cache and add results
					cache[query] = data;
					self.add_result(data);
				});
			}
		},
		
		/**
		 * Add live results to the container
		 */
		add_result: function(result) {
			
			if (!element.find('.live-search-results').length) {
				element.append($('<div class="live-search-results"></div>'));
			}
			
			var container = element.find('.live-search-results');

			if (!result) {
				container.removeClass('fade-in');
				return;
			}
			
			// add the html result
			container.html(result);
			
			requestAnimationFrame(function() {
				container.addClass('fade-in');
				container.closest('form').addClass('has-live-results');
			});
			
		}
	};

	Bunyad.liveSearch = self.init;
	
})(jQuery);

(function($) {
	/**
	 * Setup sliders.
	 */
	function init() {

		if (!$.fn.slick) {
			return;
		}

		// Setup all sliders
		$('.common-slider .slides:not(.loaded), .loop-carousel:not(.loaded), .gallery-slider:not(.loaded)').each(function() {

			const slider = $(this);
			if (slider.hasClass('loaded')) {
				return;
			}

			slider.one('init', function() {
				$(this).addClass('loaded');
			});
		
			// Common setting
			var vars = {
				rows: 0,
				prevArrow: '<a href="#" class="prev-arrow"><i class="tsi tsi-angle-left"></i></a>',
				nextArrow: '<a href="#" class="next-arrow"><i class="tsi tsi-angle-right"></i></a>',
				autoplay: slider.data('autoplay') ? true : false,
				autoplaySpeed: slider.data('speed') || 5000,
				fade: slider.data('animation') == 'fade' ? true : false,
				rtl: $('html').prop('dir') === 'rtl'
			};
				
			const sliderType = slider.data('slider');

			// First image load.
			if (vars.autoplay) {

				slider.on('init afterChange', function(e, slick) {				
					var ele     = $(this),
						current = ele.find('[data-slick-index="' + slick.currentSlide + '"]');

					var img = current.find('.wp-post-image').first();
					if (!img.length) {
						return;
					}					

					var loaded = img.hasClass('lazyloaded') || (img.is('img:not(.lazyload)') && img.prop('complete'));

					if (!loaded) {
						img.on('lazyloaded load', function(e) {
							slick.slickPlay();
						});
						
						slick.slickPause();
					}
				});
			}
			
			switch (sliderType) {
				case 'feat-grid':
					setupFeatGrid(slider, vars);
					break;
					
				case 'carousel':
					setupCarousel(slider, vars);
					break;

				case 'gallery':
					setupGallery(slider, vars);
					break;
			}

		});

		// Disable anchor jump on arrows
		$('.common-slider').on('click', '.slick-arrow', function(e) {
			e.preventDefault();
		});
	}

	/**
	 * For posts carousels.
	 */
	function setupCarousel(slider, vars) {

		const slidesNum = slider.data('slides') || 1;

		// If not defined, use columns - 1, min 2, max 4.
		const slidesNumMd = slider.data('slides-md') || (
			Math.min(4, Math.max(2, slidesNum - 1))
		);

		const slidesNumSm = slider.data('slides-sm') || 1;

		if (slider.data('arrows')) {
			// Set correct top for arrows on init.
			slider.on('init', (ele) => {
				const height = slider.find('.l-post:first-child .media-ratio').outerHeight();
				if (height) {
					slider[0].style.setProperty('--arrow-top', (height/2) + 'px');
				}
			});
		}

		slider.slick($.extend(vars, {
			arrows: slider.data('arrows') ? true : false,
			infinite: true,
			cssEase: 'ease-out',
			speed: 400,
			dots: slider.data('dots') ? true : false,
			dotsClass: 'nav-dots',
			adaptiveHeight: true,
			slidesToShow: slidesNum,
			slidesToScroll: slidesNum, 
			responsive: [
				{
					breakpoint: 940,
					settings: {slidesToShow: slidesNumMd, slidesToScroll: slidesNumMd}
				},
				{
					breakpoint: 540,
					settings: {slidesToShow: slidesNumSm, slidesToScroll: slidesNumSm}
				}
			]
		}));
	}

	/**
	 * Setup slider for featured grid.
	 */
	function setupFeatGrid(slider, vars) {

		const scrollNum = slider.data('scroll-num') || 1;
		let scrollNumMd = slider.data('scroll-num-md');
			
		if (!scrollNumMd) {
			scrollNumMd = Math.min(2, Math.max(1, scrollNum - 1));
		}

		slider.slick($.extend(vars, {
			arrows: true,
			infinite: true,
			cssEase: 'ease-out',
			speed: 500,
			slidesToShow: scrollNum,
			slidesToScroll: scrollNumMd, 
			responsive: [
				{
					breakpoint: 940,
					settings: {slidesToShow: scrollNumMd, slidesToScroll: scrollNumMd}
				},
				{
					breakpoint: 540,
					settings: {slidesToShow: 1, slidesToScroll: 1}
				}
			]
		}));
	}

	/**
	 * Setup gallery slider.
	 */
	function setupGallery(slider, vars) {
			
		vars = Object.assign(vars, {
			infinite: true,
			slidesToShow: 1,
			slidesToScroll: 1,
			adaptiveHeight: true
		});
		
		const init = () => {
			slider.slick(vars);
		};

		// slider.find('img').eq(0).imagesLoaded(init);
		init();
	}

	Bunyad.sliders = init;
})(jQuery);

// load when ready
jQuery(function($) {
		
	Bunyad.theme.init();
	Bunyad.pagination();
	Bunyad.sliders();
	Bunyad.blocksFilters();

	// Setup sticky headers as applicable.
	Bunyad.stickyHeaders = {
		main: Bunyad.stickyHeader('.smart-head-main', {mobile: false}),
		mobile: Bunyad.stickyHeader('.smart-head-mobile', {mobile: true})
	};

	Bunyad.liveSearch();
	Bunyad.authModal();
});
/**
 * Plugins and 3rd Party Libraries
 */

/*!
* FitVids 1.1
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
*/
;(function($){$.fn.fitVids=function(options){var settings={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var head=document.head||document.getElementsByTagName("head")[0];var css=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";var div=document.createElement("div");div.innerHTML='<p>x</p><style id="fit-vids-style">'+css+"</style>";head.appendChild(div.childNodes[1])}if(options){$.extend(settings,options)}return this.each(function(){var selectors=['iframe[src*="player.vimeo.com"]','iframe[src*="youtube.com"]','iframe[src*="youtube-nocookie.com"]','iframe[src*="kickstarter.com"][src*="video.html"]',"object","embed"];if(settings.customSelector){selectors.push(settings.customSelector)}var ignoreList=".fitvidsignore";if(settings.ignore){ignoreList=ignoreList+", "+settings.ignore}var $allVideos=$(this).find(selectors.join(","));$allVideos=$allVideos.not("object object");$allVideos=$allVideos.not(ignoreList);$allVideos.each(function(){var $this=$(this);if($this.parents(ignoreList).length>0){return}if(this.tagName.toLowerCase()==="embed"&&$this.parent("object").length||$this.parent(".fluid-width-video-wrapper").length){return}if((!$this.css("height")&&!$this.css("width"))&&(isNaN($this.attr("height"))||isNaN($this.attr("width")))){$this.attr("height",9);$this.attr("width",16)}var height=(this.tagName.toLowerCase()==="object"||($this.attr("height")&&!isNaN(parseInt($this.attr("height"),10))))?parseInt($this.attr("height"),10):$this.height(),width=!isNaN(parseInt($this.attr("width"),10))?parseInt($this.attr("width"),10):$this.width(),aspectRatio=height/width;if(!$this.attr("id")){var videoID="fitvid"+Math.floor(Math.random()*999999);$this.attr("id",videoID)}$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",(aspectRatio*100)+"%");$this.removeAttr("height").removeAttr("width")})})}})(window.jQuery||window.Zepto);

/**
 * Plus/minus polyfill for numbers - used in WooCommerce
 * 
 * Author Bryce Adams
 */
jQuery( function( $ ) {

	// Quantity buttons
	$( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' )
		.addClass( 'buttons_added' )
		.append( '<div class="vertical-buttons"><input type="button" value="+" class="plus" /><input type="button" value="-" class="minus" /></div>' );

	$( document ).on( 'click', '.plus, .minus', function() {

		// Get values
		var $qty		= $( this ).closest( '.quantity' ).find( '.qty' ),
			currentVal	= parseFloat( $qty.val() ),
			max			= parseFloat( $qty.attr( 'max' ) ),
			min			= parseFloat( $qty.attr( 'min' ) ),
			step		= $qty.attr( 'step' );

		// Format values
		if ( ! currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0;
		if ( max === '' || max === 'NaN' ) max = '';
		if ( min === '' || min === 'NaN' ) min = 0;
		if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) === 'NaN' ) step = 1;

		// Change the value
		if ( $( this ).is( '.plus' ) ) {

			if ( max && ( max == currentVal || currentVal > max ) ) {
				$qty.val( max );
			} else {
				$qty.val( currentVal + parseFloat( step ) );
			}

		} else {

			if ( min && ( min == currentVal || currentVal < min ) ) {
				$qty.val( min );
			} else if ( currentVal > 0 ) {
				$qty.val( currentVal - parseFloat( step ) );
			}

		}

		// Trigger change event
		$qty.trigger( 'change' );

	});

});
// source --> https://www.buserterkini.com/wp-content/themes/smart-mag/js/float-share.js?ver=10.3.2 
/**
 * Floating/Sticky Social Share.
 * @copyright ThemeSphere
 * @preserve
 */
"use strict";Bunyad.floatShare=function(d){function e(s){let a=0;if(!(d(window).width()<768)){if(!d(s).closest(".no-sidebar").length&&!d(s).closest(".the-post-modern").length){const t=d(s).closest(".the-post"),e=t.find(".the-post-header");a=e.length?e.position().top:0}var r=[];d([".the-post-modern .alignfull",".the-post-modern .alignwide",".the-post-modern .gallery:not(.aligncenter)",".the-post-modern .wp-block-gallery:not(.aligncenter)",".the-post-modern figure.alignnone",".the-post-modern img.alignnone"].join(",")).each(function(){r.push(this)}),d(window).on("scroll",function(){var t,e,n=!1,o=s.find("> .inner").get(0);if(d(window).scrollTop()<a)n=!0;else for(var i in r)if(t=o,e=r[i],t=t.getBoundingClientRect(),e=e.getBoundingClientRect(),!(t.top>e.bottom||t.right<e.left||t.bottom<e.top||t.left>e.right)){n=!0;break}requestAnimationFrame(()=>{n?s.addClass("is-hidden"):s.removeClass("is-hidden")})})}}return{init:function(){d(".post-share-float").length&&(d(window).on("resize load resize.TSS",this.sticky),document.addEventListener("spc-alp-loaded",this.sticky),"complete"!==document.readyState||this.sticky())},sticky:function(){if(window.innerWidth<768)return!1;var i=parseInt(window.getComputedStyle(document.documentElement).getPropertyValue("--main-width"));d(".has-share-float").each(function(){const t=d(this);let e=t.data("orig-pos");if(e||(e=t.hasClass("has-share-float-in")?"in":"out",t.data("orig-pos",e)),"in"!==e)if(i+110>document.documentElement.clientWidth)t.addClass("has-share-float-in");else{t.removeClass("has-share-float-in");var n=(window.innerWidth-i)/2;const o=t.find(".post-share-float");n<110?o.addClass("post-share-float-vp"):o.removeClass("post-share-float-vp")}});var o=25;o+=d(".admin-bar").length?32:0,d(".post-share-float").each(function(){if(!d(this).data("init")){d(this).data("init",!0),e(d(this));const n=d(this).find("> .inner");d(document).on("sticky-bar-show",()=>{var t=d(".smart-head-sticky");let e=0;t.length&&(t=window.getComputedStyle(t[0]).getPropertyValue("--head-h"),e=parseInt(t)-10),n.css("top",o+e+"px")});var t=()=>n.css("top",o+"px");d(document).on("sticky-bar-hide",t),t()}})}}}(jQuery),jQuery(function(t){t("body").hasClass("single-post")&&Bunyad.floatShare.init()});
// source --> https://www.buserterkini.com/wp-includes/js/comment-reply.min.js?ver=6.9.4 
/*! This file is auto-generated */
window.addComment=function(v){var I,C,h,E=v.document,b={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=v.MutationObserver||v.WebKitMutationObserver||v.MozMutationObserver,r="querySelector"in E&&"addEventListener"in v,n=!!E.documentElement.dataset;function t(){d(),e&&new e(o).observe(E.body,{childList:!0,subtree:!0})}function d(e){if(r&&(I=g(b.cancelReplyId),C=g(b.commentFormId),I)){I.addEventListener("touchstart",l),I.addEventListener("click",l);function t(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode&&"a"!==E.activeElement.tagName.toLowerCase())return C.removeEventListener("keydown",t),e.preventDefault(),C.submit.click(),!1}C&&C.addEventListener("keydown",t);for(var n,d=function(e){var t=b.commentReplyClass;e&&e.childNodes||(e=E);e=E.getElementsByClassName?e.getElementsByClassName(t):e.querySelectorAll("."+t);return e}(e),o=0,i=d.length;o<i;o++)(n=d[o]).addEventListener("touchstart",a),n.addEventListener("click",a)}}function l(e){var t,n,d=g(b.temporaryFormId);d&&h&&(g(b.parentIdFieldId).value="0",t=d.textContent,d.parentNode.replaceChild(h,d),this.style.display="none",n=(d=(d=g(b.commentReplyTitleId))&&d.firstChild)&&d.nextSibling,d&&d.nodeType===Node.TEXT_NODE&&t&&(n&&"A"===n.nodeName&&n.id!==b.cancelReplyId&&(n.style.display=""),d.textContent=t),e.preventDefault())}function a(e){var t=g(b.commentReplyTitleId),t=t&&t.firstChild.textContent,n=this,d=m(n,"belowelement"),o=m(n,"commentid"),i=m(n,"respondelement"),r=m(n,"postid"),n=m(n,"replyto")||t;d&&o&&i&&r&&!1===v.addComment.moveForm(d,o,i,r,n)&&e.preventDefault()}function o(e){for(var t=e.length;t--;)if(e[t].addedNodes.length)return void d()}function m(e,t){return n?e.dataset[t]:e.getAttribute("data-"+t)}function g(e){return E.getElementById(e)}return r&&"loading"!==E.readyState?t():r&&v.addEventListener("DOMContentLoaded",t,!1),{init:d,moveForm:function(e,t,n,d,o){var i,r,l,a,m,c,s,e=g(e),n=(h=g(n),g(b.parentIdFieldId)),y=g(b.postIdFieldId),p=g(b.commentReplyTitleId),u=(p=p&&p.firstChild)&&p.nextSibling;if(e&&h&&n){void 0===o&&(o=p&&p.textContent),a=h,m=b.temporaryFormId,c=g(m),s=(s=g(b.commentReplyTitleId))?s.firstChild.textContent:"",c||((c=E.createElement("div")).id=m,c.style.display="none",c.textContent=s,a.parentNode.insertBefore(c,a)),d&&y&&(y.value=d),n.value=t,I.style.display="",e.parentNode.insertBefore(h,e.nextSibling),p&&p.nodeType===Node.TEXT_NODE&&(u&&"A"===u.nodeName&&u.id!==b.cancelReplyId&&(u.style.display="none"),p.textContent=o),I.onclick=function(){return!1};try{for(var f=0;f<C.elements.length;f++)if(i=C.elements[f],r=!1,"getComputedStyle"in v?l=v.getComputedStyle(i):E.documentElement.currentStyle&&(l=i.currentStyle),(i.offsetWidth<=0&&i.offsetHeight<=0||"hidden"===l.visibility)&&(r=!0),"hidden"!==i.type&&!i.disabled&&!r){i.focus();break}}catch(e){}return!1}}}}(window);