(function(){window.visibly={b:null,q:document,p:undefined,prefixes:["webkit","ms"],props:["VisibilityState","visibilitychange","Hidden"],m:["focus","blur"],visibleCallbacks:[],hiddenCallbacks:[],_callbacks:[],onVisible:function(n){this.visibleCallbacks.push(n)},onHidden:function(n){this.hiddenCallbacks.push(n)},isSupported:function(){return this._supports(0)||this._supports(1)},_supports:function(n){return this.prefixes[n]+this.props[2]in this.q},runCallbacks:function(n){if(n){this._callbacks=n==1?this.visibleCallbacks:this.hiddenCallbacks;for(var t=0;t<this._callbacks.length;t++)this._callbacks[t]()}},_visible:function(){window.visibly.runCallbacks(1)},_hidden:function(){window.visibly.runCallbacks(2)},_nativeSwitch:function(){this.q[this.b+this.props[2]]===!0?this._hidden():this._visible()},listen:function(){try{this.isSupported()?(this.b=this._supports(0)==this.p?this.prefixes[1]:this.prefixes[0],this.q.addEventListener(this.b+this.props[1],function(){window.visibly._nativeSwitch.apply(window.visibly,arguments)},1)):document.addEventListener?(window.addEventListener(this.m[0],this._visible,1),window.addEventListener(this.m[1],this._hidden,1)):(this.q.attachEvent("onfocusin",this._visible),this.q.attachEvent("onfocusout",this._hidden))}catch(n){}},init:function(){this.listen()}};this.visibly.init()})(),function(n){n.fn.pinardRotator=function(t,i,r){function c(t,u){for(var f=null,o,s,h,e=0;e<i.length;e++)if(i[e].width===t&&i[e].height===u){f=i[e];break}return f!==null&&typeof f!="undefined"?(o=n('<ins class="adsbygoogle"><\/ins>').attr("data-ad-client",r).attr("data-ad-slot",f.adSlot[0]),f.adSlot.length>1&&f.adSlot.shift(),f.auto===!0?(o.attr("data-ad-format","auto"),o.css("display","block")):o.css("display","inline-block").css("width",t+"px").css("height",u+"px"),s=n("<script>                                (adsbygoogle = window.adsbygoogle || []).push({});                               <\/script>"),h=n("<div/>").append(o).append(s),h):null}function l(){for(var t=0;t<u.length;t++){var r=parseInt(n("div",u[t]).width()),f=parseInt(n("div",u[t]).height()),i=c(r,f);i!==null&&n("div",n(u[t])).empty().append(i)}setTimeout(function(){n(".nota-banner:visible > div").each(function(t,i){n(i).removeAttr("style")})},5e3)}function a(t,i){var r,u,f;if(i.empty(),r=n("<div/>"),u=(new Date).getTime(),t.ImpressionTag&&t.ImpressionTag!=="")t.ImpressionTag=t.ImpressionTag.replace("[timestamp]",u).replace("INSERT_RANDOM_NUMBER_HERE",u),r.append(t.ImpressionTag);else{if(f=n("<img>").attr("src",t.ImagenUri).attr("width",t.Width).attr("height",t.Height).attr("alt",t.ImagenUri),t.Url!=="")f.on("click",function(){t.Url.startsWith("http")||(t.Url="http://"+t.Url);var n=window.open(t.Url,"_blank");n.focus()});r.append(f)}i.append(r)}function s(t){for(var i=0;i<u.length;i++){var r=parseInt(n(u[i]).attr("data-codigo")),f=parseInt(n("div",u[i]).width()),e=parseInt(n("div",u[i]).height());if(r===t.CodigoUbicacion&&f===t.Width&&e===t.Height)return n(u[i])}return null}function v(t){var i=s(t);i!==null&&(a(t,i),n.ajax("/api/banners/view/"+t.Id,{method:"PUT"}))}function h(){var n,i,t;if(o)for(n=0;n<f.length;n++)(i=f[n].length-1,i<0)||(t=e[n],v(f[n][t]),e[n]=t+1>i?0:t+1)}var u=n(this),f=[],e=[],o=!0;visibly.onVisible(function(){o=!0});visibly.onHidden(function(){o=!1});return l(),n.ajax(t,{method:"POST"}).done(function(n){var i,t,r;for(f=[],e=[],i=0;i<14;i++)f[i]=[],e[i]=0;for(t=0;t<n.length;t++)s(n[t])!==null&&(r=parseInt(n[t].CodigoUbicacion),f[r-1].push(n[t]));f.length!==0&&(h(),setInterval(function(){h()},3e4))}),this}}(jQuery)