(function(n){var i=function(){return typeof n.screen.systemXDPI!="undefined"&&n.screen.systemXDPI>=n.screen.logicalXDPI?n.screen.systemXDPI/n.screen.logicalXDPI:typeof n.devicePixelRatio!="undefined"?n.devicePixelRatio:1},r=function(){var r=!1,t=r==!1||n.screen.width>n.screen.height?n.screen.width:n.screen.height,u=r==!1||n.innerWidth>n.innerHeight?n.innerWidth:n.innerHeight;return u>t&&(t=u),t=t*i()},u=function(){return navigator.userAgent.toLowerCase().indexOf("webkit")>-1?document.documentElement.clientWidth:n.innerWidth},t=function(n){return n=n.substring(0,n.length-2),Number(n)},e=function(n){var o,e,s;if(n=$.trim(n),n.length>0)for(n=n.toLowerCase(),n=n.substring(1,n.length-1),o=n.split(") and ("),e=0,s=o.length;e<s;e++){var h=o[e].indexOf(":"),c=$.trim(o[e].substring(0,h)),f=$.trim(o[e].substring(h+1));switch(c){case"min-width":if(f=t(f),f>u())return!1;break;case"max-width":if(f=t(f),f<u())return!1;break;case"min-device-pixel-width":if(f=t(f),f>r())return!1;break;case"max-device-pixel-width":if(f=t(f),f<r())return!1;break;case"min-device-pixel-ratio":if(Number(f)>i())return!1;break;default:return!1}}return!0},f=function(t){var f,h,o,r,y,l,s,b,c,a,p,u,v,w;t.setAttribute("data-resolved","true"),f=$(t).find("div[data-src], div[data-srcset]").get();n:for(r=f.length-1;r>=0;r--)if(y=e(f[r].getAttribute("data-media")),y==!0)if(f[r].getAttribute("data-srcset")!==null){for(l=f[r].getAttribute("data-srcset").split(","),b=!1,c=l.length-1;c>=0;c--)if(s=$.trim(l[c]),a=s.lastIndexOf(" "),p=$.trim(s.substring(a+1,s.length-1)),Number(p)<=i()){h=$.trim(s.substring(0,a)),o=r;break n}}else{h=f[r].getAttribute("data-src"),o=r;break}if(typeof h!="undefined"){if(u=t.getElementsByTagName("img")[0],u){if(v=u.getAttribute("data-source-index"),t.getAttribute("data-dissable-swap-above")!==null&&v>=o||t.getAttribute("data-dissable-swap-below")!==null&&v<=o)return}else u=n.document.createElement("img"),u.alt=t.getAttribute("data-alt"),t.appendChild(u);u.src=h,u.setAttribute("data-source-index",o)}else u||(w=t.getElementsByTagName("noscript")[0],t.innerHTML=w.innerText)};n.picturePolyfill={},n.picturePolyfill.resolveLast=function(){var n=$("div[data-picture]:not([data-resolved],[data-defer])").last().get()[0];f(n)},n.picturePolyfill.init=function(n){var i,t,r;for(typeof n!="boolean"&&(n=!0),i=$("div[data-picture]").get(),t=0,r=i.length;t<r;t++)(i[t].getAttribute("data-resolved")===null||i[t].getAttribute("data-dissable-swap")===null)&&(n===!0||i[t].getAttribute("data-defer")===null)&&f(i[t])},n.addEventListener?(n.addEventListener("resize",n.picturePolyfill.init,!1),n.addEventListener("DOMContentLoaded",function(){n.picturePolyfill.init(!1)},!1),n.addEventListener("load",n.picturePolyfill.init,!1)):n.attachEvent&&n.attachEvent("onload",n.picturePolyfill.init)})(window)
