(function () {window._dt_dynad_5550010343_16486833894321372711402='';window._tp_dynad_5550010343_16486833894321372711402={};if(typeof JSON!=="object"){JSON={};JSON.parse=JSON.parse||function(o){return eval('('+o+')')};JSON.stringify=JSON.stringify||function(o){var n;var a;var t=typeof(o);var json=[];if(t!='object'||o===null){if(t=="string"){o='"'+o+'"'}return String(o)}else{a=(o&&o.constructor==Array);for(var key in o){n=o[key];t=typeof(n);if(t=="string"){n='"'+n.replace(/["]/g,"\\\"")+'"'}else if(t=="object"&&n!==null){n=JSON.stringify(n)}json.push((a?"":'"'+key+'":')+String(n))}return(a?"[":"{")+String(json)+(a?"]":"}")}}}
function DADB(t){return DADB.inst instanceof DADB?DADB.inst._rs=t(DADB.inst):(this._if=null,this._ok=!1,this._db=(typeof window['_dynad_tag_protocol_']!=='undefined'?window['_dynad_tag_protocol_']:("http:"!=window.location.protocol?"https://":"http://"))+"s.dynad.net",this._pt="/stack/KMA9C2O70iP6CHSgXk0LGaQ8ML9m6vJE4RIi1Rf61p4.html?v69",this._qu=[],this._rq={},this._id=(new Date).getTime()+Math.floor(1e4*Math.random()),this._ls=this._dg()==this._db,this._rs="",DADB.inst=this,void this.init(function(){"function"==typeof t&&(DADB.inst._rs=t(DADB.inst))}))}"object"!=typeof JSON&&(JSON={},JSON.parse=JSON.parse||function(o){return eval("("+o+")")},JSON.stringify=JSON.stringify||function(t){var i,e,s=typeof t,n=[];if("object"!=s||null===t)return"string"==s&&(t='"'+t+'"'),t+"";e=t&&t.constructor==Array;for(var o in t)i=t[o],s=typeof i,"string"==s?i='"'+i.replace(/["]/g,'\\"')+'"':"object"==s&&null!==i&&(i=JSON.stringify(i)),n.push((e?"":'"'+o+'":')+(i+""));return(e?"[":"{")+(n+"")+(e?"]":"}")}),DADB.prototype={constructor:DADB,init:function(t){var i=this;this._ls||this._if||(this._if=document.createElement("iframe"),this._if.style.cssText="position:absolute;width:1px;height:1px;left:-9999px;",(document.body||document.documentElement||document.getElementsByTagName('body')[0]).appendChild(this._if),window.addEventListener?(this._if.addEventListener("load",function(){i._ild()},!1),window.addEventListener("message",function(t){i._hm(t)},!1)):this._if.attachEvent&&(this._if.attachEvent("onload",function(){i._ild()},!1),window.attachEvent("onmessage",function(t){i._hm(t)})),this._if.src=this._db+this._pt),"function"==typeof t&&t()},getResult:function(){return this._rs},getCk:function(t,i){var e={request:{id:++this._id,type:"gc",key:t},callback:i};this._s(e)},setCk:function(t,i,e,s){"function"==typeof e&&(s=e,e=2592e3);var n={request:{id:++this._id,type:"sc",key:t,value:i,ttl:e},callback:s};this._s(n)},setNav:function(t,i,e,s,n){var o={request:{id:++this._id,type:"snav",key:t,value:i+"|"+e+"|"+s},callback:n};this._s(o)},getNav:function(t,i){var e={request:{id:++this._id,type:"nav",key:t},callback:i};this._s(e)},getItem:function(t,i){if(this._ls)return localStorage[t];var e=this,s={request:{id:++e._id,type:"get",key:t},callback:i};e._s(s)},setItem:function(t,i,e){if(this._ls)return void(localStorage[t]=i);var s=this,n={request:{id:++s._id,type:"set",key:t,value:i},callback:e};s._s(n)},delItem:function(t){if(this._ls)return delete localStorage[t];var i={request:{id:++this._id,type:"unset",key:t}};this._s(i)},_s:function(t){this._ok?this._if&&(this._rq[t.request.id]=t,this._if.contentWindow.postMessage(JSON.stringify(t.request),this._db)):this._qu.push(t)},_ild:function(){if(this._ok=!0,this._qu.length){for(var t=0,i=this._qu.length;i>t;t++)this._s(this._qu[t]);this._qu=[]}},_hm:function(t){if(!/\{.*(\"id\")+.*(\"key\")+.*\}/.test(t.data)||!/s.dynad.net/.test(t.origin)) return;try{if(t.origin==this._db){var i=JSON.parse(t.data);void 0!==this._rq[i.id].deferred&&this._rq[i.id].deferred.resolve(i.value);void 0!==this._rq[i.id]&&"function"==typeof this._rq[i.id].callback&&(this._rs=this._rq[i.id].callback(i.key,i.value)),delete this._rq[i.id]}}catch(t){}},_dg:function(){var t=window.location.href,i=document.createElement("a");return i.href=t,i.hostname}};
window._DADB_5550010343_16486833894321372711402=DADB;
function DAFIFO(e,t,n,r,i){this.s=e;this.t=t;this.db=n;this.it=[];this.ttl=r;this._rs="";var s=this;s.db.getItem(s.t,function(e,t){s.init(e,t);if(typeof i=="function"){s._rs=i(s)}})}DAFIFO.prototype={constructor:DAFIFO,init:function(e,t){if(t==null||t==""){this.it={}}else{this.it=JSON.parse(t)}},commit:function(e){var t=this;var n=0;this.db.setItem(this.t,JSON.stringify(this.it));if(typeof e=="function"){e(n)}},getResult:function(){return this._rs},push:function(e,t){var n=0;if(this.it!=null&&typeof e==="string"&&e!=""){this.it=this._vd();var r=[];r[r.length]={v:e,t:parseInt((new Date).getTime()/1e3)};var i=1;for(k in this.it){if(i++<this.s&&typeof this.it[k]==="object"&&typeof this.it[k]["v"]==="string"&&typeof this.it[k]["t"]==="number"&&this.it[k]["v"]!=e&&this.it[k]["v"]!=""){r[r.length]=this.it[k]}}n=1;this.it=r;if(typeof t=="function"){t(n)}}return n},pop:function(e){var t=null;if(this.it!=null){this.it=this._vd();var n=[];var r=0;for(k in this.it){if(r++>0){n[n.length]=this.it[k]}else{t=this.it[k]["v"]}}this.it=n;if(typeof e=="function"){e(t)}}return t},remove:function(e,t){var n=[];if(this.it!=null){var r=0;var i=[];for(k in this.it){if(this._ia(k)&&this.it[k]["v"]!=e){i[r++]=this.it[k]}}this.it=i;if(typeof t=="function"){t(n)}}return n},list:function(e,t,n){var f=[];if("function"==typeof e&&void 0==t&&(n=e,t=!1,e=this.it.length),"function"==typeof t&&void 0==n&&(n=t,t=!1),null!=this.it){var o=-1;for(k in this.it)if(this._ia(k)){if(++o>=this.s||o>=e)break;f[o]=t?this.it[k]:this.it[k].v}"function"==typeof n&&n(f)}return f},clear:function(e){this.it=[];if(typeof e=="function"){e()}},_vd:function(){var e=[];for(k in this.it){if(this._ia(k))e[k]=this.it[k]}return e},_ct:function(){var e=0;for(k in this.it)e++;return e},_ia:function(e){return(new Date).getTime()/1e3-this.it[e]["t"]<this.ttl}};
window._DAFIFO_5550010343_16486833894321372711402=DAFIFO;
new DADB(function(db){db.getCk('optout',function(k,v){if(v!=='1'){(function(customerId, placementId, campaignId, creativeId, timestamp, lookBackWindow, action){setTimeout(function(){new DADB(function(a){"I"==action?new DAFIFO(100,"d"+customerId+"W",a,15552e3,function(a){a.push(placementId+"|"+campaignId+"|"+creativeId+"|"+timestamp+"|"+(timestamp+24*lookBackWindow*3600),function(){a.commit(function(){a.list(function(b){for(var c in b){var d=b[c].split("|");d[d.length-1]<timestamp&&a.remove(b[c],function(){a.commit()})}})})})}):"D"==action?new DAFIFO(100,"d"+customerId+"W",a,15552e3,function(a){a.list(function(b){for(var c in b)els[els.length-1]<timestamp&&a.remove(b[c],function(){a.commit()}),b[c].indexOf(placementId+"|"+campaignId+"|"+creativeId+"|")>-1&&a.remove(b[c],function(){a.commit()})})}):"R"==action&&new DAFIFO(100,"d"+customerId+"W",a,15552e3,function(a){a.list(function(b){var c="";for(var d in b)c+=(""==c?"":";")+b[d];a.clear(function(){a.commit(function(){callback(c)})})})})});},0,customerId,placementId,campaignId,creativeId,timestamp,lookBackWindow,action);})(20160221,5550010343,5000003610,4000039770,1648683392,30,'I');}else{db.setCk('uid','',0)}})});
var ele=document.createElement("div");ele.setAttribute("id","_dynad_c_I5550010343_16486833894321372711402");ele.setAttribute("style","border:0; z-index:1; margin:0; visibility:visible; display:block; transition:all 1s; background-color:white; overflow:hidden; -webkit-transition:all 1s; width:100%; -o-transition:all 1s; height:0px; -moz-transition:all 1s; ");var target=(function(isIE){try {
  if (typeof window['DYNAD_TV_IMPLEMENTATION'] !== 'undefined') {
      if (console && console.log)
          console.log('[dynad.tv] - canceled inarticle impression (detected another active instance in current context)');
      return null;
  }
  window['DYNAD_TV_IMPLEMENTATION'] = 'INARTICLE';
} catch (exCyberCook) {}


try { 
  if( typeof navigator.userAgent === 'string' && navigator.userAgent.toUpperCase().indexOf('ANDROID') && navigator.userAgent.toUpperCase().indexOf(' SM-J7') > -1 )
      return null;
} catch(exBlockJ7){}


try {
  var container = document.querySelector('.player_dynad_tv')
  if (container) {
    return [container.parentNode, container]
  } else if( document.location.hostname.indexOf('telepadi.folha.uol.com.br') != -1 ) {
      var dynadTVContainer = document.querySelectorAll('.materia > .texto > .post > p');
      if (dynadTVContainer && dynadTVContainer.length >= 4 )
          return [ dynadTVContainer[0].parentNode, dynadTVContainer[3] ];
      if (dynadTVContainer && dynadTVContainer.length >= 2 )
      return [ dynadTVContainer[0].parentNode, dynadTVContainer[ dynadTVContainer.length - 1 ] ];
  } else if( document.location.hostname.indexOf('ruf.folha.uol.com.br') != -1 ) {
      var dynadTVContainer = document.querySelectorAll('[itemprop="articleBody"] > p');
      if (dynadTVContainer && dynadTVContainer.length >= 4 )
          return [ dynadTVContainer[0].parentNode, dynadTVContainer[3] ];
      if (dynadTVContainer && dynadTVContainer.length >= 2 )
      return [ dynadTVContainer[0].parentNode, dynadTVContainer[ dynadTVContainer.length - 1 ] ];
  } else if( document.location.hostname.indexOf('f5.folha.uol.com.br') != -1 ) {
      var dynadTVContainer = document.querySelectorAll('.news > .news__content > p');
      if (dynadTVContainer && dynadTVContainer.length >= 4 )
          return [ dynadTVContainer[0].parentNode, dynadTVContainer[3] ];
      if (dynadTVContainer && dynadTVContainer.length >= 2 )
      return [ dynadTVContainer[0].parentNode, dynadTVContainer[ dynadTVContainer.length - 1 ] ];
  } else if( document.location.hostname.indexOf('guia.folha.uol.com.br') != -1 ) {
      var dynadTVContainer = document.querySelectorAll('[itemprop="articleBody"] > p');
      if (dynadTVContainer && dynadTVContainer.length >= 4 )
          return [ dynadTVContainer[0].parentNode, dynadTVContainer[3] ];
      if (dynadTVContainer && dynadTVContainer.length >= 2 )
      return [ dynadTVContainer[0].parentNode, dynadTVContainer[ dynadTVContainer.length - 1 ] ];
  } else if(document.location.hostname.indexOf('agora.folha.uol.com.br') != -1 && window.innerWidth < 767 ){
      var dynadTVContainer = document.querySelectorAll('.c-news .c-news__body > p');
      return [ dynadTVContainer[0].parentNode, dynadTVContainer[2] ];
          
  }else {
    var widgetContainer = document.querySelectorAll(".js-gallery-widget")[0];
    var folhaContainers = ['.c-news .c-news__body p', '.c-news .c-news__content p', '.news .news__content p'];
    var dynadTVContainer = null;
    for(var index = 0; index < folhaContainers.length; index++){
      dynadTVContainer = document.querySelectorAll(folhaContainers[index]);
      if(dynadTVContainer.length){
        break;
      }
    }
    if(!dynadTVContainer.length){
      return null;
    }
    if (widgetContainer) {
      var desiredPosition = widgetContainer.parentElement.nextElementSibling.nextElementSibling;
      return [dynadTVContainer[0].parentNode, desiredPosition];  
    }
    if (dynadTVContainer && dynadTVContainer.length >= 4 )
        return [ dynadTVContainer[0].parentNode, dynadTVContainer[3] ];
    if (dynadTVContainer && dynadTVContainer.length >= 2 )
    return [ dynadTVContainer[0].parentNode, dynadTVContainer[ dynadTVContainer.length - 1 ] ];
  }
} catch (e) {}

return null;})(false);if(typeof target==='undefined'||target==null||(target.length!=1&&target.length!=2))return;else{try{if(target.length==1)target[0].insertBefore(ele);else target[0].insertBefore(ele,target[1]);}catch(e){if(typeof console!=='undefined'&&typeof console.log!=='undefined')console.log(e);}}var tagParameters=window._tp_dynad_5550010343_16486833894321372711402;var dt_dynad=window._dt_dynad_5550010343_16486833894321372711402;var divAppender=function(s){var n='';var r=s.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){n+=arguments[1]+'\n';return '';});document.getElementById('_dynad_c_I5550010343_16486833894321372711402').innerHTML=r;if(window.execScript&&n!='') window.execScript(n); else if(n!='')eval(n);};try{
var _rp16486833894321372711402=(function(reqid,type,step,containerId,placementId){try{var APPLY_PLAYER_SIZE_POLICY = function(desired_width) {
    var MIN_WIDTH = 256,
        MIN_HEIGHT = 144;
    var initial_area = (window.innerWidth * window.innerHeight);
    var window_ratio = (initial_area / (window.innerHeight * window.innerHeight));
    var part_window_ratio = window_ratio/0.3
    var base_width = Math.sqrt(initial_area/part_window_ratio)
    var base_height = base_width * window_ratio;

    var final_area = base_width * base_height;
    var expected_ratio = 9/16;
    var final_width = Math.floor(Math.sqrt(final_area/expected_ratio));
    if(window.DYNAD_TV.config && window.DYNAD_TV.config.width
        && final_width > (window.DYNAD_TV.config.width)) {
        final_width = window.DYNAD_TV.config.width;
    }
    if(desired_width && desired_width < final_width) {
        if(desired_width < MIN_WIDTH) {
            desired_width = MIN_WIDTH;    
        }
        final_width = desired_width;
    }
    var final_height =  Math.floor(expected_ratio * final_width);
    if(final_width < MIN_WIDTH || final_height < MIN_HEIGHT) {
        return false;
    }
    
    return {width: final_width, height: final_height};
};

if (step == 1) {
    if(!APPLY_PLAYER_SIZE_POLICY(null)) {
        return false;
    }
    window['_is_mobile_dynadtv_'] = {
        Android: function() {
            return navigator.userAgent.match(/Android/i);
        },
        BlackBerry: function() {
            return navigator.userAgent.match(/BlackBerry/i);
        },
        iOS: function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
        },
        Opera: function() {
            return navigator.userAgent.match(/Opera Mini/i);
        },
        Windows: function() {
            return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
        },
        any: function() {
            return (window['_is_mobile_dynadtv_'].Android() || window['_is_mobile_dynadtv_'].BlackBerry() || window['_is_mobile_dynadtv_'].iOS() || window['_is_mobile_dynadtv_'].Opera() || window['_is_mobile_dynadtv_'].Windows());
        }
    };

    if (window['_is_mobile_dynadtv_'].any()) {

        if (window['_is_mobile_dynadtv_'].iOS()) {
            console.log('[dynad-tv] - iOS nao e suportado');
            return false;
        } else if (window['_is_mobile_dynadtv_'].Android()) {
        } else {
            if (console && console.log)
                console.log('[dynad-tv] - plataforma movel nao suportada.');
            return false;
        }
    }
}

if (step == 2) {
    if (typeof window.DYNAD_TV === 'undefined')
        window.DYNAD_TV = {
            'config': {
                'URL_VAST': 'https://pubads.g.doubleclick.net/gampad/ads?slotname=/8804/teste/inread&sz=640x480&ciu_szs=&url=%5Breferrer_url%5D&unviewed_position_start=1&output=xml_vast3&impl=s&env=vp&gdfp_req=1&ad_rule=0&video_url_to_fetch=%5Bdescription_url%5D&vad_type=linear&vpos=preroll&pod=1&min_ad_duration=0&max_ad_duration=999999000&ppos=1&lip=true&correlator=' + new Date().getTime() + Math.random()
            }
        };

    function DynAdTvKeeper(container) {
        var idTimeout = null;
        var STATUS = {
            INITIALIZED: 0,
            LOADED: 1,
            PLAYING: 2,
            PAUSED: 3,
            CLOSED: 5,
            TIMEOUT: 4
        };

        var status = STATUS.INITIALIZED,
            height = 0,
            width = 0,
            vHeight = 0,
            vWidth = 0;
        var isMouseOverIfrm = false,
            isInVitrineMode = false,
            isVitrineExpanded = false;

        var idAdSystem = "",
            idCreativeId = "",
            idAdId = "";
            
        function dispatchEventListener(eventName, eventData) {
            if (status === STATUS.CLOSED)
                return;
                
            if (typeof window.DYNAD_TV !== 'undefined' && typeof window.DYNAD_TV.eventListener !== 'undefined') {
                if (typeof eventData !== 'undefined')
                    window.DYNAD_TV.eventListener(eventName, eventData);
                else
                    window.DYNAD_TV.eventListener(eventName);
            }
            if (eventName == 'nodata') {
                status = STATUS.CLOSED;
                /*
                if (window['_is_mobile_dynadtv_'].any()) {
                    divContainer.innerHTML = '';
                    divContainer.setAttribute('id', 'banner-300x250-outstream-area');
                    divContainer.style.height = "250px";
                    divContainer.style.width = "100%";
                    divContainer.style.textAlign = "center";
                    divContainer.style.overflow = "visible";
                    divContainer.style.position = "relative";
                    divContainer.style.marginBottom = "1rem";
                    
                    try {
                        window.UOLPD.TagManager.DfpAsync.addRenderingCallback('banner-300x250-outstream-area', function () {
                            var divC = document.getElementById('banner-300x250-outstream-area');
                            var cw = divC.getBoundingClientRect().width;
                            var gw = divC.querySelector('div').getBoundingClientRect().width;
                            if( typeof gw === 'number' && typeof cw === 'number' ) {
                                var bc = document.createElement('div');
                                bc.setAttribute('id', 'inarticle_parceiros_bt_close_dynadtv_unique');
                                bc.setAttribute('style', "width: 30px; text-align: right; line-height:17px; height:17px; position:absolute; top:-17px; left:"+( (gw - 30) + ((cw - gw) / 2))+"px; cursor:pointer; z-index:10; color: black; font-size: 12px; display: block");
                                bc.setAttribute("onclick", "var o = document.getElementById('banner-300x250-outstream-area'); o.parentNode.removeChild(o); ");
                                bc.innerHTML = '[ x ]';
                                document.getElementById('banner-300x250-outstream-area').appendChild(bc);
                            }    
                        });
                    } catch ( e ){}
                    
                    window.uolads&&window.uolads.push({id:'banner-300x250-outstream-area'});

                    dispose();
                    
                    return;
                }    
                */
                dispose();                   
                return;
            }
            if (eventName == 'closed') {
                status = STATUS.CLOSED;
            }
        }

        function getPrebidVastURL(adUnit) {
            return pbjs.adServers.dfp.buildVideoUrl({
                adUnit: adUnit,
                params: {
                    iu: window.DYNAD_TV.config.pathDFP ? window.DYNAD_TV.config.pathDFP : '/8804/teste/inread',
                    cust_params: {
                        videoplayertype: 'dynad_in-article',
                        keyword: 'video-auto-play'
                    },
                    output: 'xml_vast4',
                    ad_rule: '0'
                }
            });
        }

        function checkForVideoBids(cb) {
            try {
                var videoBids = window.UOLPD.TagManager.Prebid.videoBids;
                if (videoBids && typeof videoBids === 'object' && videoBids.constructor === Array) {
                    if(videoBids.length) {
                        window.DYNAD_TV.config.URL_VAST = getPrebidVastURL(videoBids[0]);
                    }
                    cb();
                } else {
                    window.DYNAD_TV.config.bidTimeout = window.DYNAD_TV.config.bidTimeout * 1000 || (window.innerWidth <= 767 ? 6500 : 4500);
                    window.UOLPD.TagManager.Prebid.attachVideoListener(reqid, function(adUnit){
                        window.DYNAD_TV.config.timeoutId && clearTimeout(window.DYNAD_TV.config.timeoutId);
                        window.DYNAD_TV.config.URL_VAST = getPrebidVastURL(adUnit);
                        cb();
                    });
                    window.DYNAD_TV.config.timeoutId = setTimeout(function() {
                        window.UOLPD.TagManager.Prebid.detachVideoListener(reqid);
                        cb();
                    }, window.DYNAD_TV.config.bidTimeout);
                }
            } catch (ex) {
                window.DYNAD_TV.config.timeoutId && clearTimeout(window.DYNAD_TV.config.timeoutId);
                window.UOLPD.TagManager.Prebid && window.UOLPD.TagManager.Prebid.detachListener(reqid);
                cb();
            }
        }

        function handle(e) {
            if (typeof e.data === 'undefined' || e.data == null || typeof e.data !== 'string'  )
                return;

            if (e.data.indexOf('dynad-tv') == -1 || status == STATUS.TIMEOUT || status == STATUS.CLOSED)
                return;

            if (window.console)
                console.log('dynad.tv - core:', e.data);

            if (e.data.indexOf('dynad-tv-protocol/loaded/') == 0) { // player foi carregado
                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}

                var dm = e.data.substr('dynad-tv-protocol/loaded/'.length).split('/');
                var avWidth = divContainer.parentNode.offsetWidth,
                    avHeight = (document.documentElement.clientHeight * 0.6);

                height = parseInt(dm[1]),
                    width = parseInt(dm[0]);
                if ((dm[0] == '' || dm[0] == 'undefined' || dm[0] == null || dm[0] == 'null') || isNaN(width) || width <= 0 || width < avWidth) {
                    width = avWidth;
                    height = Math.round(avWidth * 0.5625); //16x9
                }

                try {
                    dispatchEventListener('loaded', {
                        'w': width,
                        'h': height
                    });
                } catch (exEvent) {}

                status = STATUS.LOADED;
                resize();
                follow();
            } else if (e.data.indexOf('dynad-tv-protocol/click/') == 0) {
                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}
                try {
                    dispatchEventListener('click');
                } catch (exEvent) {}
            } else if (e.data.indexOf('dynad-tv-protocol/no_data/') == 0) { // player nao contem data
                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}
                var m = e.data.substr('dynad-tv-protocol/no_data/'.length).split('/');
                container.parentNode.style.display = "none";
                try {
                    dispatchEventListener('nodata', m);
                } catch (exEvent) {}
            } else if (e.data == 'dynad-tv-protocol/close') {
                divContainer.style.marginBottom = "0";
                try {
                    dispatchEventListener('closed');
                } catch (exEvent) {}

                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}

                divContainer.style.height = '0px';
                divContainer.style.width = '0%';
                divContainer.height = '0px';
                container.parentNode.style.display = "none";
                setTimeout(function() {
                    container.parentNode.removeChild(container);
                }, 1000);

                dispose();
            } else if (e.data == 'dynad-tv-protocol/init') {
                checkForVideoBids(function () { 
                    sendLoadMessage();
                    sendActiveViewMessage(isElementVisible(container, vHeight, vWidth));
                });
            } else if (e.data == 'dynad-tv-protocol/user_close') {
                container.contentWindow.postMessage('dynad-tv-protocol/force_close_linear', '*');
            } else if (e.data.indexOf('dynad-tv-protocol/impression_data/') == 0) {
                var op = e.data.substr(('dynad-tv-protocol/impression_data/').length).split('/');
                idAdSystem = op[1], idCreativeId = op[0], idAdId = op[2];
                try {
                    if (op.length > 3) {
                        adVideoDuration = Number(op[3]) * 1000;
                        if (adVideoDuration < 15000)
                            adVideoDuration = 15000
                    }
                } catch (exTimer) {}
            } else if (e.data == 'dynad-tv-protocol/dispatch_timeout_mobile') {
                startTimeoutCounter();                
            } else if (e.data == 'dynad-tv-protocol/state_skip') {
                var op = e.data.substr('dynad-tv-protocol/state_skip/'.length);
                divContainer.setAttribute('state_skip', (op == 'true' ? 'none' : 'block'));
            } else if (e.data == 'dynad-tv-protocol/expand') {
                divContainer.style.width = '100%';
                divContainer.style.marginBottom = "1rem";
                container.style.height = (vHeight + 20) + 'px';
                container.height = (vHeight + 20) + 'px';
                divContainer.style.animationDuration = "1s";
                divContainer.style.WebkitTransitionDuration = "1s";
                divContainer.style.WebkitTransition = "1s";
                divContainer.style.MozTransition = "1s";
                divContainer.style.height = (vHeight + 20) + 'px';
                divContainer.height = (vHeight + 20) + 'px';
                sendStartCounterMessage();
                try {
                    dispatchEventListener('expanded', {
                        'w': vWidth,
                        'h': vHeight
                    });
                } catch (exEvent) {}

                //DESLIGADO EM 23/08 a pedido do Andre
                var bc = document.createElement('div');
                bc.setAttribute('id', 'inarticle_parceiros_bt_close_dynadtv_unique');
                bc.setAttribute('style', "width:30px; text-align: right; line-height:17px; height:17px; position:absolute; top:0px; right:0px; cursor:pointer; z-index:10; color: black; font-size: 12px; display: block");
                bc.setAttribute("onclick", "window.postMessage('dynad-tv-protocol/user_close', '*');");
                bc.innerHTML = '[ x ]';
                divContainer.style.position = 'relative';
                divContainer.appendChild(bc);
            }
        }

        function resize() {
            if( width == 0 || height == 0 )
                return;
                
            var avWidth = divContainer.parentNode.offsetWidth,
                avHeight = (document.documentElement.clientHeight * 0.6);
            if (Math.abs(width - avWidth) < Math.abs(height - avHeight) || width > avWidth) {
                var ratio = width / avWidth;
                vWidth = Math.round(width / ratio);
                vHeight = Math.round(height / ratio);
            } else {
                var ratio = height / avHeight;
                vWidth = Math.round(width / ratio);
                vHeight = Math.round(height / ratio);
            }
            if (vWidth > avWidth) {
                var ratio = vWidth / avWidth;
                vWidth = Math.round(vWidth / ratio);
                vHeight = Math.round(vHeight / ratio);
            }
            if (vHeight > avHeight) {
                var ratio = vHeight / avHeight;
                vWidth = Math.round(vWidth / ratio);
                vHeight = Math.round(vHeight / ratio);
            }
            var sizing = APPLY_PLAYER_SIZE_POLICY(vWidth);
            if(sizing) {
                vWidth = sizing.width;
                vHeight = sizing.height;
                container.contentWindow.postMessage('dynad-tv-protocol/resize/' + vWidth + '/' + vHeight, '*');
            } else {
                window.postMessage('dynad-tv-protocol/close', '*');
            }
        }

        function isElementVisible(el, vdHeight, vdWidth) {
            if( isNaN(vdHeight) ) vdHeight = 0;
			if( isNaN(vdWidth) ) vdWidth = 0;
            var rect = el.getBoundingClientRect();
            var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
            var vertInView = ( (rect.top + (vdHeight * 0.1)) <= windowHeight ) && ( (rect.top + (vdHeight * 0.1)) >= 0 );
            return (vertInView);
        }
        
        function getExposedElementVisible () {
            return function () {
                return isElementVisible(container, vHeight, vWidth);
            }
        }
        
        window['DYNAD_TV_ElementWatcher'] = getExposedElementVisible();

        //
        // acompanha evento de scroll
        //
        function follow() {
            if (isElementVisible(container, vHeight, vWidth)) {
                sendActiveViewMessage(true);
                if (status == STATUS.INITIALIZED) {} else if (status == STATUS.LOADED) {
                    status = STATUS.PLAYING;
                    sendPlayMessage();
                } else if (status == STATUS.PAUSED) {
                    status = STATUS.PLAYING;
                    sendPlayMessage();
                }
            } else {
                sendActiveViewMessage(false);
                if (status == STATUS.PLAYING) {
                    status = STATUS.PAUSED;
                    sendPauseMessage();
                }
            }
        }

        function dispose() {
            if (window.addEventListener) {
                removeEventListener("scroll", follow);
                removeEventListener("touchstart", follow);
                removeEventListener("touchend", follow);
                removeEventListener("resize", resize);
                removeEventListener("focus", sendFocusMessage);
                removeEventListener("blur", sendBlurMessage);
            } else {
                detachEvent("onscroll", follow);
                detachEvent("ontouchstart", follow);
                detachEvent("ontouchend", follow);
                detachEvent("onresize", resize);
                detachEvent("onfocus", sendFocusMessage);
                detachEvent("onblur", sendBlurMessage);
            }
        }

        function sendStartCounterMessage() {
            container.contentWindow.postMessage('dynad-tv-protocol/start-counter', '*');
            try {
                dispatchEventListener('counting');
            } catch (exEvent) {}
        }

        function sendLoadMessage() {
            //var pattern = new RegExp('(\\?|\\&)(sz=).*?(&|$)');
            //DYNAD_TV.config.URL_VAST = DYNAD_TV.config.URL_VAST.replace(pattern,'$1$2480x360$3');
            var params = '&videoplayertype=dynad_in-article&keyword=video-auto-play';
            if (typeof UOLPD !== 'undefined' && typeof UOLPD.dataLayer !== 'undefined') {
                try {
                    for (var key in UOLPD.dataLayer) {
                        params += '&' + key + '=' + UOLPD.dataLayer[key];
                    }
                } catch (exDL) {
                    if (typeof UOLPD.dataLayer.tt_age !== 'undefined') params += '&tt_age=' + UOLPD.dataLayer.tt_age;
                    if (typeof UOLPD.dataLayer.tt_cluster !== 'undefined') params += '&tt_cluster=' + UOLPD.dataLayer.tt_cluster;
                    if (typeof UOLPD.dataLayer.tt_customaudience !== 'undefined') params += '&tt_customaudience=' + UOLPD.dataLayer.tt_customaudience;
                    if (typeof UOLPD.dataLayer.tt_gender !== 'undefined') params += '&tt_gender=' + UOLPD.dataLayer.tt_gender;
                    if (typeof UOLPD.dataLayer.tt_lists !== 'undefined') params += '&tt_lists=' + UOLPD.dataLayer.tt_lists;
                    if (typeof UOLPD.dataLayer.tt_microsegments !== 'undefined') params += '&tt_microsegments=' + UOLPD.dataLayer.tt_microsegments;
                    if (typeof UOLPD.dataLayer.tt_socialclass !== 'undefined') params += '&tt_socialclass=' + UOLPD.dataLayer.tt_socialclass;
                    if (typeof UOLPD.dataLayer.tt_subjects !== 'undefined') params += '&tt_subjects=' + UOLPD.dataLayer.tt_subjects;
                    if (typeof UOLPD.dataLayer.tt_team !== 'undefined') params += '&tt_team=' + UOLPD.dataLayer.tt_team;
                }
            }
            
            if (params != '') {
                if (window.DYNAD_TV.config.URL_VAST.indexOf('&cust_params=') > -1) {
                    var temp = window.DYNAD_TV.config.URL_VAST.split('&cust_params=');
                    window.DYNAD_TV.config.URL_VAST = temp[0] + '&cust_params=' + encodeURIComponent(params.substr(1) + "&") + temp[1];
                } else
                    window.DYNAD_TV.config.URL_VAST += '&cust_params=' + encodeURIComponent(params.substr(1));
            }

            try {
                var vast_updated_url = window.DYNAD_TV.config.URL_VAST;
                var requiredParams = {
                    impl: "impl=s",
                    env: "env=vp",
                    gdfp_req: "gdfp_req=1",
                    ad_rule: "ad_rule=0",
                    vad_type: "vad_type=linear",
                    vpos: "vpos=preroll",
                    pod: "pod=1",
                    min_ad_duration: "min_ad_duration=0",
                    max_ad_duration: "max_ad_duration=999999000",
                    ppos: "ppos=1",
                    lip: "lip=true",
                    'video_url_to_fetch': 'video_url_to_fetch=' + encodeURIComponent(window.location.href)
                };
            
                var paramKeys = Object.keys(requiredParams);
                for(var index = 0; index < paramKeys.length; index++) {
                    if (vast_updated_url.indexOf(paramKeys[index]) == -1){
                        vast_updated_url += "&" + requiredParams[paramKeys[index]];
                    }
                }
                window.DYNAD_TV.config.URL_VAST = vast_updated_url;
            }catch(ex){ }
            
            if( typeof window.DYNAD_TV.config.settings === 'undefined' )
                window.DYNAD_TV.config.settings = new Array();
            window.DYNAD_TV.config.settings.push( {"key": "containerId", "value": containerId} ); 

            if (typeof window.DYNAD_TV.config.settings !== 'undefined') {
                var st = '';
                for (var x = 0; x < window.DYNAD_TV.config.settings.length; x++) {
                    st += (st != '' ? '/' : '') + window.DYNAD_TV.config.settings[x].key + '=' + window.DYNAD_TV.config.settings[x].value;
                }
                if (st != '')
                    container.contentWindow.postMessage('dynad-tv-protocol/settings/' + st, '*');
            }
            container.contentWindow.postMessage('dynad-tv-protocol/load/' + window.DYNAD_TV.config.URL_VAST, '*');
        }

        function sendActiveViewMessage(status) {
            if( status != STATUS.CLOSED && typeof container !== 'undefined' && typeof container.contentWindow !== 'undefined' )
                container.contentWindow.postMessage('dynad-tv-protocol/active_display/' + status, '*');
        }

        function sendFocusMessage() {
            if (status == STATUS.PLAYING && typeof container !== 'undefined' && typeof container.contentWindow !== 'undefined')
                container.contentWindow.postMessage('dynad-tv-protocol/win-focus', '*');
        }

        function sendBlurMessage() {
            console.log('will dispatch blur:', status);
            if (status == STATUS.PLAYING && typeof container !== 'undefined' && typeof container.contentWindow !== 'undefined')
                container.contentWindow.postMessage('dynad-tv-protocol/win-blur', '*');
        }

        function sendPlayMessage() {
            container.contentWindow.postMessage('dynad-tv-protocol/play', '*');
        }

        function sendPauseMessage() {
            container.contentWindow.postMessage('dynad-tv-protocol/pause', '*');
        }
        
        var hidden, visibilityChange;
        try {
            if (typeof document.hidden !== "undefined") {
                hidden = "hidden";
                visibilityChange = "visibilitychange";
            } else if (typeof document.mozHidden !== "undefined") {
                hidden = "mozHidden";
                visibilityChange = "mozvisibilitychange";
            } else if (typeof document.msHidden !== "undefined") {
                hidden = "msHidden";
                visibilityChange = "msvisibilitychange";
            } else if (typeof document.webkitHidden !== "undefined") {
                hidden = "webkitHidden";
                visibilityChange = "webkitvisibilitychange";
            }
        } catch (e) {}

        var idTimerBlur = null;
        if (window.addEventListener) {
            addEventListener("scroll", follow, false);
            addEventListener("touchstart", follow, false);
            addEventListener("touchend", follow, false);
            addEventListener("resize", resize, false);
            addEventListener("message", handle, false);
            
            document.addEventListener(visibilityChange, function() {
                if (document[hidden]) {
                    sendBlurMessage();
                } else {
 
                    sendFocusMessage();
                }
            });
            
            addEventListener("focus", function () {                
                sendFocusMessage();
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
            }, false);
            
            addEventListener("blur", function() {                
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
                idTimerBlur = setTimeout( function () {
                    if ( isMouseOverIfrm === false ) {
                        if ( !(document.activeElement instanceof HTMLIFrameElement) || (document.activeElement instanceof HTMLIFrameElement && document.activeElement.id != container.id) ) {
                            sendBlurMessage();
                        }
                    }
                }, 5);
            }, false);

            container.addEventListener("mouseenter", function(e) {
                isMouseOverIfrm = true;
            }, false);
            container.addEventListener("mouseleave", function(e) {
                isMouseOverIfrm = false;
            }, false);
        } else {
            attachEvent("onscroll", follow);
            attachEvent("ontouchstart", follow, false);
            attachEvent("ontouchend", follow, false);
            attachEvent("onresize", resize, false);
            attachEvent("onmessage", handle);
            
            document.attachEvent('on' + visibilityChange, function() {
                if (document[hidden]) {
                    sendBlurMessage();
                } else {
 
                    sendFocusMessage();
                }
            });
            
            attachEvent("onfocus", function () {                
                sendFocusMessage();
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
            }, false);
            
            attachEvent("onblur", function() {
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
                idTimerBlur = setTimeout( function () {
                    if ( isMouseOverIfrm === false ) {
                        if ( !(document.activeElement instanceof HTMLIFrameElement) || (document.activeElement instanceof HTMLIFrameElement && document.activeElement.id != container.id) ) {
                            sendBlurMessage();
                        }
                    }
                }, 5);
            }, false);
            
            container.attachEvent("onmouseenter", function(e) {
                isMouseOverIfrm = true;
            }, false);
            
            container.attachEvent("onmouseleave", function(e) {
                isMouseOverIfrm = false;
            }, false);
        }

        follow();

        function startTimeoutCounter() {
            if (idTimeout != null)
                return;

            idTimeout = setTimeout(function() {
                //change status for timeout
                status = STATUS.TIMEOUT;
                setTimeout(function() {
                    //remove container
                    try {
                        divContainer.parentNode.removeChild(divContainer);
                    } catch (e) {}
                }, 1000);
                //dispatch nodata event
                dispatchEventListener('nodata', 'timeout operation');
                //dispose listeners
                dispose();
                //add event counter
            }, window.DYNAD_TV.config.timeout || 8000);

            if (window.addEventListener)
                removeEventListener("touchstart", startTimeoutCounter, false);
            else
                detachEvent("ontouchstart", startTimeoutCounter, false);
        }

        /**** if( !window['_is_mobile_dynadtv_'].any() ) startTimeoutCounter(); ****/
    }

    var divContainer = document.getElementById(containerId),
        ifrm = document.getElementById(reqid.replace('I', 'IF'));
    try {
        try {
            divContainer.style.width = '0%';
            ifrm.style.width = '100%';
            ifrm.width = '100%';

            divContainer.style.height = '0px';
            ifrm.style.height = '0px';
            ifrm.height = 0;
        } catch (e) {
            return false;
        }
        DynAdTvKeeper(ifrm);
    } catch (e) {
        return false;
    }
}
return true;}catch(e){if(typeof console!=='undefined'&&typeof console.log!=='undefined'){console.log('DynAd Error:');console.log(e);}}})('I5550010343_16486833894321372711402', 'H', 1,'_dynad_c_I5550010343_16486833894321372711402','5550010343');if(_rp16486833894321372711402==true||typeof _rp16486833894321372711402==='undefined'){divAppender("<iframe id='IF5550010343_16486833894321372711402' name='I5550010343_16486833894321372711402' src='https://s.dynad.net/stack/928W5r5IndTfocT3VdUV-AB8UVlc0JbnGWyFZsei5gU.html' style='border:0; visibility:visible; -webkit-transition:all 1s; width:100%; -o-transition:all 1s; transition:all 1s; height:0px; -moz-transition:all 1s; ' marginwidth='0' marginwidth='0' width='88' height='31' marginheight='0' align='top' scrolling='No' bordercolor='#000000' frameborder='0' hspace='0' vspace='0'></iframe>");(function(){var theIframe=document.getElementById('IF5550010343_16486833894321372711402');var dyndata=(function(){var t=dt_dynad;if(typeof t==="object")return JSON.stringify(t);else if(typeof t==="undefined"||t==null||t=="")return"{}";else return (function(e){var t=function(e){var t="";for(var n=e.length-1;n>=0;n--)if(e[n]>="0"&&e[n]<="9")t+=e[n];else break;return[e.substring(0,n+1),t]};var n=e.replace(/"/g,"'").split(/&(?!([#a-z0-9]{1,4})(;))/gi);var r="";var i="";var s="";for(var o=0;o<n.length;o++){if(typeof n[o]==="undefined")continue;var u=n[o].split("=");if(u[0]=="_nofobjs"||u[0]=="_dyn_hash_"||u.length!=2)continue;var a=t(u[0]);if(a[1]!=r&&i!=""){s+=(s==""?"":",")+"{"+i+"}";i=""}if(a[0]!=""){r=a[1];i+=(i==""?"":",")+'"'+a[0]+'":"'+decodeURIComponent(u[1])+'"'}}s+=(s==""?"":",")+"{"+i+"}";return"["+s+"]"})(t.toString())})();var data='{"target":"_blank","clickTAG":"https://t.dynad.net/c/?dc=5550010343;ct=1;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE6;bid=;iid=MTBEQ0E1RjhFQkMzRThDObrrGr1n3zOoLF5Q1mAtKAM8lXJcEokica1PQJY3pug/cNo8T9vkG1k8+p8SkQdQZpWG192ygu2ZmjG0lR63IfQ=;;","clickTAG2":"https://t.dynad.net/c/?dc=5550010343;ct=2;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE6;bid=;iid=MTBEQ0E1RjhFQkMzRThDObrrGr1n3zOoLF5Q1mAtKAM8lXJcEokica1PQJY3pug/cNo8T9vkG1k8+p8SkQdQZpWG192ygu2ZmjG0lR63IfQ=;;","clickTAG3":"https://t.dynad.net/c/?dc=5550010343;ct=3;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE6;bid=;iid=MTBEQ0E1RjhFQkMzRThDObrrGr1n3zOoLF5Q1mAtKAM8lXJcEokica1PQJY3pug/cNo8T9vkG1k8+p8SkQdQZpWG192ygu2ZmjG0lR63IfQ=;;","clickTAG4":"https://t.dynad.net/c/?dc=5550010343;ct=4;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE6;bid=;iid=MTBEQ0E1RjhFQkMzRThDObrrGr1n3zOoLF5Q1mAtKAM8lXJcEokica1PQJY3pug/cNo8T9vkG1k8+p8SkQdQZpWG192ygu2ZmjG0lR63IfQ=;;","clickTAG5":"https://t.dynad.net/c/?dc=5550010343;ct=5;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE6;bid=;iid=MTBEQ0E1RjhFQkMzRThDObrrGr1n3zOoLF5Q1mAtKAM8lXJcEokica1PQJY3pug/cNo8T9vkG1k8+p8SkQdQZpWG192ygu2ZmjG0lR63IfQ=;;","_d_site_id":"3000000127","_d_placement_id":"5550010343","_d_campaign_id":"5000003610","_d_creative_id":"4000039770","eventsMap":{},"domain":"https://t.dynad.net","tagParameters":'+JSON.stringify(tagParameters)+',"data":'+dyndata+'}';if(window.addEventListener){
theIframe.addEventListener('load',function(){theIframe.contentWindow.postMessage(JSON.stringify((function(dynamicData){return dynamicData;})(JSON.parse(data))),'https://s.dynad.net')});}else{theIframe.attachEvent('onload', function(){theIframe.contentWindow.postMessage(JSON.stringify((function(dynamicData){return dynamicData;})(JSON.parse(data))),'https://s.dynad.net')});}window._dd_st_vl_16486833894321372711402=JSON.parse(data);})();(function(reqid,type,step,containerId,placementId,siteId,campaignId,creativeId,dynamicData){try{var APPLY_PLAYER_SIZE_POLICY = function(desired_width) {
    var MIN_WIDTH = 256,
        MIN_HEIGHT = 144;
    var initial_area = (window.innerWidth * window.innerHeight);
    var window_ratio = (initial_area / (window.innerHeight * window.innerHeight));
    var part_window_ratio = window_ratio/0.3
    var base_width = Math.sqrt(initial_area/part_window_ratio)
    var base_height = base_width * window_ratio;

    var final_area = base_width * base_height;
    var expected_ratio = 9/16;
    var final_width = Math.floor(Math.sqrt(final_area/expected_ratio));
    if(window.DYNAD_TV.config && window.DYNAD_TV.config.width
        && final_width > (window.DYNAD_TV.config.width)) {
        final_width = window.DYNAD_TV.config.width;
    }
    if(desired_width && desired_width < final_width) {
        if(desired_width < MIN_WIDTH) {
            desired_width = MIN_WIDTH;    
        }
        final_width = desired_width;
    }
    var final_height =  Math.floor(expected_ratio * final_width);
    if(final_width < MIN_WIDTH || final_height < MIN_HEIGHT) {
        return false;
    }
    
    return {width: final_width, height: final_height};
};

if (step == 1) {
    if(!APPLY_PLAYER_SIZE_POLICY(null)) {
        return false;
    }
    window['_is_mobile_dynadtv_'] = {
        Android: function() {
            return navigator.userAgent.match(/Android/i);
        },
        BlackBerry: function() {
            return navigator.userAgent.match(/BlackBerry/i);
        },
        iOS: function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
        },
        Opera: function() {
            return navigator.userAgent.match(/Opera Mini/i);
        },
        Windows: function() {
            return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
        },
        any: function() {
            return (window['_is_mobile_dynadtv_'].Android() || window['_is_mobile_dynadtv_'].BlackBerry() || window['_is_mobile_dynadtv_'].iOS() || window['_is_mobile_dynadtv_'].Opera() || window['_is_mobile_dynadtv_'].Windows());
        }
    };

    if (window['_is_mobile_dynadtv_'].any()) {

        if (window['_is_mobile_dynadtv_'].iOS()) {
            console.log('[dynad-tv] - iOS nao e suportado');
            return false;
        } else if (window['_is_mobile_dynadtv_'].Android()) {
        } else {
            if (console && console.log)
                console.log('[dynad-tv] - plataforma movel nao suportada.');
            return false;
        }
    }
}

if (step == 2) {
    if (typeof window.DYNAD_TV === 'undefined')
        window.DYNAD_TV = {
            'config': {
                'URL_VAST': 'https://pubads.g.doubleclick.net/gampad/ads?slotname=/8804/teste/inread&sz=640x480&ciu_szs=&url=%5Breferrer_url%5D&unviewed_position_start=1&output=xml_vast3&impl=s&env=vp&gdfp_req=1&ad_rule=0&video_url_to_fetch=%5Bdescription_url%5D&vad_type=linear&vpos=preroll&pod=1&min_ad_duration=0&max_ad_duration=999999000&ppos=1&lip=true&correlator=' + new Date().getTime() + Math.random()
            }
        };

    function DynAdTvKeeper(container) {
        var idTimeout = null;
        var STATUS = {
            INITIALIZED: 0,
            LOADED: 1,
            PLAYING: 2,
            PAUSED: 3,
            CLOSED: 5,
            TIMEOUT: 4
        };

        var status = STATUS.INITIALIZED,
            height = 0,
            width = 0,
            vHeight = 0,
            vWidth = 0;
        var isMouseOverIfrm = false,
            isInVitrineMode = false,
            isVitrineExpanded = false;

        var idAdSystem = "",
            idCreativeId = "",
            idAdId = "";
            
        function dispatchEventListener(eventName, eventData) {
            if (status === STATUS.CLOSED)
                return;
                
            if (typeof window.DYNAD_TV !== 'undefined' && typeof window.DYNAD_TV.eventListener !== 'undefined') {
                if (typeof eventData !== 'undefined')
                    window.DYNAD_TV.eventListener(eventName, eventData);
                else
                    window.DYNAD_TV.eventListener(eventName);
            }
            if (eventName == 'nodata') {
                status = STATUS.CLOSED;
                /*
                if (window['_is_mobile_dynadtv_'].any()) {
                    divContainer.innerHTML = '';
                    divContainer.setAttribute('id', 'banner-300x250-outstream-area');
                    divContainer.style.height = "250px";
                    divContainer.style.width = "100%";
                    divContainer.style.textAlign = "center";
                    divContainer.style.overflow = "visible";
                    divContainer.style.position = "relative";
                    divContainer.style.marginBottom = "1rem";
                    
                    try {
                        window.UOLPD.TagManager.DfpAsync.addRenderingCallback('banner-300x250-outstream-area', function () {
                            var divC = document.getElementById('banner-300x250-outstream-area');
                            var cw = divC.getBoundingClientRect().width;
                            var gw = divC.querySelector('div').getBoundingClientRect().width;
                            if( typeof gw === 'number' && typeof cw === 'number' ) {
                                var bc = document.createElement('div');
                                bc.setAttribute('id', 'inarticle_parceiros_bt_close_dynadtv_unique');
                                bc.setAttribute('style', "width: 30px; text-align: right; line-height:17px; height:17px; position:absolute; top:-17px; left:"+( (gw - 30) + ((cw - gw) / 2))+"px; cursor:pointer; z-index:10; color: black; font-size: 12px; display: block");
                                bc.setAttribute("onclick", "var o = document.getElementById('banner-300x250-outstream-area'); o.parentNode.removeChild(o); ");
                                bc.innerHTML = '[ x ]';
                                document.getElementById('banner-300x250-outstream-area').appendChild(bc);
                            }    
                        });
                    } catch ( e ){}
                    
                    window.uolads&&window.uolads.push({id:'banner-300x250-outstream-area'});

                    dispose();
                    
                    return;
                }    
                */
                dispose();                   
                return;
            }
            if (eventName == 'closed') {
                status = STATUS.CLOSED;
            }
        }

        function getPrebidVastURL(adUnit) {
            return pbjs.adServers.dfp.buildVideoUrl({
                adUnit: adUnit,
                params: {
                    iu: window.DYNAD_TV.config.pathDFP ? window.DYNAD_TV.config.pathDFP : '/8804/teste/inread',
                    cust_params: {
                        videoplayertype: 'dynad_in-article',
                        keyword: 'video-auto-play'
                    },
                    output: 'xml_vast4',
                    ad_rule: '0'
                }
            });
        }

        function checkForVideoBids(cb) {
            try {
                var videoBids = window.UOLPD.TagManager.Prebid.videoBids;
                if (videoBids && typeof videoBids === 'object' && videoBids.constructor === Array) {
                    if(videoBids.length) {
                        window.DYNAD_TV.config.URL_VAST = getPrebidVastURL(videoBids[0]);
                    }
                    cb();
                } else {
                    window.DYNAD_TV.config.bidTimeout = window.DYNAD_TV.config.bidTimeout * 1000 || (window.innerWidth <= 767 ? 6500 : 4500);
                    window.UOLPD.TagManager.Prebid.attachVideoListener(reqid, function(adUnit){
                        window.DYNAD_TV.config.timeoutId && clearTimeout(window.DYNAD_TV.config.timeoutId);
                        window.DYNAD_TV.config.URL_VAST = getPrebidVastURL(adUnit);
                        cb();
                    });
                    window.DYNAD_TV.config.timeoutId = setTimeout(function() {
                        window.UOLPD.TagManager.Prebid.detachVideoListener(reqid);
                        cb();
                    }, window.DYNAD_TV.config.bidTimeout);
                }
            } catch (ex) {
                window.DYNAD_TV.config.timeoutId && clearTimeout(window.DYNAD_TV.config.timeoutId);
                window.UOLPD.TagManager.Prebid && window.UOLPD.TagManager.Prebid.detachListener(reqid);
                cb();
            }
        }

        function handle(e) {
            if (typeof e.data === 'undefined' || e.data == null || typeof e.data !== 'string'  )
                return;

            if (e.data.indexOf('dynad-tv') == -1 || status == STATUS.TIMEOUT || status == STATUS.CLOSED)
                return;

            if (window.console)
                console.log('dynad.tv - core:', e.data);

            if (e.data.indexOf('dynad-tv-protocol/loaded/') == 0) { // player foi carregado
                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}

                var dm = e.data.substr('dynad-tv-protocol/loaded/'.length).split('/');
                var avWidth = divContainer.parentNode.offsetWidth,
                    avHeight = (document.documentElement.clientHeight * 0.6);

                height = parseInt(dm[1]),
                    width = parseInt(dm[0]);
                if ((dm[0] == '' || dm[0] == 'undefined' || dm[0] == null || dm[0] == 'null') || isNaN(width) || width <= 0 || width < avWidth) {
                    width = avWidth;
                    height = Math.round(avWidth * 0.5625); //16x9
                }

                try {
                    dispatchEventListener('loaded', {
                        'w': width,
                        'h': height
                    });
                } catch (exEvent) {}

                status = STATUS.LOADED;
                resize();
                follow();
            } else if (e.data.indexOf('dynad-tv-protocol/click/') == 0) {
                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}
                try {
                    dispatchEventListener('click');
                } catch (exEvent) {}
            } else if (e.data.indexOf('dynad-tv-protocol/no_data/') == 0) { // player nao contem data
                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}
                var m = e.data.substr('dynad-tv-protocol/no_data/'.length).split('/');
                container.parentNode.style.display = "none";
                try {
                    dispatchEventListener('nodata', m);
                } catch (exEvent) {}
            } else if (e.data == 'dynad-tv-protocol/close') {
                divContainer.style.marginBottom = "0";
                try {
                    dispatchEventListener('closed');
                } catch (exEvent) {}

                try {
                    if (idTimeout != null) {
                        clearTimeout(idTimeout);
                        idTimeout = null;
                    }
                } catch (e) {}

                divContainer.style.height = '0px';
                divContainer.style.width = '0%';
                divContainer.height = '0px';
                container.parentNode.style.display = "none";
                setTimeout(function() {
                    container.parentNode.removeChild(container);
                }, 1000);

                dispose();
            } else if (e.data == 'dynad-tv-protocol/init') {
                checkForVideoBids(function () { 
                    sendLoadMessage();
                    sendActiveViewMessage(isElementVisible(container, vHeight, vWidth));
                });
            } else if (e.data == 'dynad-tv-protocol/user_close') {
                container.contentWindow.postMessage('dynad-tv-protocol/force_close_linear', '*');
            } else if (e.data.indexOf('dynad-tv-protocol/impression_data/') == 0) {
                var op = e.data.substr(('dynad-tv-protocol/impression_data/').length).split('/');
                idAdSystem = op[1], idCreativeId = op[0], idAdId = op[2];
                try {
                    if (op.length > 3) {
                        adVideoDuration = Number(op[3]) * 1000;
                        if (adVideoDuration < 15000)
                            adVideoDuration = 15000
                    }
                } catch (exTimer) {}
            } else if (e.data == 'dynad-tv-protocol/dispatch_timeout_mobile') {
                startTimeoutCounter();                
            } else if (e.data == 'dynad-tv-protocol/state_skip') {
                var op = e.data.substr('dynad-tv-protocol/state_skip/'.length);
                divContainer.setAttribute('state_skip', (op == 'true' ? 'none' : 'block'));
            } else if (e.data == 'dynad-tv-protocol/expand') {
                divContainer.style.width = '100%';
                divContainer.style.marginBottom = "1rem";
                container.style.height = (vHeight + 20) + 'px';
                container.height = (vHeight + 20) + 'px';
                divContainer.style.animationDuration = "1s";
                divContainer.style.WebkitTransitionDuration = "1s";
                divContainer.style.WebkitTransition = "1s";
                divContainer.style.MozTransition = "1s";
                divContainer.style.height = (vHeight + 20) + 'px';
                divContainer.height = (vHeight + 20) + 'px';
                sendStartCounterMessage();
                try {
                    dispatchEventListener('expanded', {
                        'w': vWidth,
                        'h': vHeight
                    });
                } catch (exEvent) {}

                //DESLIGADO EM 23/08 a pedido do Andre
                var bc = document.createElement('div');
                bc.setAttribute('id', 'inarticle_parceiros_bt_close_dynadtv_unique');
                bc.setAttribute('style', "width:30px; text-align: right; line-height:17px; height:17px; position:absolute; top:0px; right:0px; cursor:pointer; z-index:10; color: black; font-size: 12px; display: block");
                bc.setAttribute("onclick", "window.postMessage('dynad-tv-protocol/user_close', '*');");
                bc.innerHTML = '[ x ]';
                divContainer.style.position = 'relative';
                divContainer.appendChild(bc);
            }
        }

        function resize() {
            if( width == 0 || height == 0 )
                return;
                
            var avWidth = divContainer.parentNode.offsetWidth,
                avHeight = (document.documentElement.clientHeight * 0.6);
            if (Math.abs(width - avWidth) < Math.abs(height - avHeight) || width > avWidth) {
                var ratio = width / avWidth;
                vWidth = Math.round(width / ratio);
                vHeight = Math.round(height / ratio);
            } else {
                var ratio = height / avHeight;
                vWidth = Math.round(width / ratio);
                vHeight = Math.round(height / ratio);
            }
            if (vWidth > avWidth) {
                var ratio = vWidth / avWidth;
                vWidth = Math.round(vWidth / ratio);
                vHeight = Math.round(vHeight / ratio);
            }
            if (vHeight > avHeight) {
                var ratio = vHeight / avHeight;
                vWidth = Math.round(vWidth / ratio);
                vHeight = Math.round(vHeight / ratio);
            }
            var sizing = APPLY_PLAYER_SIZE_POLICY(vWidth);
            if(sizing) {
                vWidth = sizing.width;
                vHeight = sizing.height;
                container.contentWindow.postMessage('dynad-tv-protocol/resize/' + vWidth + '/' + vHeight, '*');
            } else {
                window.postMessage('dynad-tv-protocol/close', '*');
            }
        }

        function isElementVisible(el, vdHeight, vdWidth) {
            if( isNaN(vdHeight) ) vdHeight = 0;
			if( isNaN(vdWidth) ) vdWidth = 0;
            var rect = el.getBoundingClientRect();
            var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
            var vertInView = ( (rect.top + (vdHeight * 0.1)) <= windowHeight ) && ( (rect.top + (vdHeight * 0.1)) >= 0 );
            return (vertInView);
        }
        
        function getExposedElementVisible () {
            return function () {
                return isElementVisible(container, vHeight, vWidth);
            }
        }
        
        window['DYNAD_TV_ElementWatcher'] = getExposedElementVisible();

        //
        // acompanha evento de scroll
        //
        function follow() {
            if (isElementVisible(container, vHeight, vWidth)) {
                sendActiveViewMessage(true);
                if (status == STATUS.INITIALIZED) {} else if (status == STATUS.LOADED) {
                    status = STATUS.PLAYING;
                    sendPlayMessage();
                } else if (status == STATUS.PAUSED) {
                    status = STATUS.PLAYING;
                    sendPlayMessage();
                }
            } else {
                sendActiveViewMessage(false);
                if (status == STATUS.PLAYING) {
                    status = STATUS.PAUSED;
                    sendPauseMessage();
                }
            }
        }

        function dispose() {
            if (window.addEventListener) {
                removeEventListener("scroll", follow);
                removeEventListener("touchstart", follow);
                removeEventListener("touchend", follow);
                removeEventListener("resize", resize);
                removeEventListener("focus", sendFocusMessage);
                removeEventListener("blur", sendBlurMessage);
            } else {
                detachEvent("onscroll", follow);
                detachEvent("ontouchstart", follow);
                detachEvent("ontouchend", follow);
                detachEvent("onresize", resize);
                detachEvent("onfocus", sendFocusMessage);
                detachEvent("onblur", sendBlurMessage);
            }
        }

        function sendStartCounterMessage() {
            container.contentWindow.postMessage('dynad-tv-protocol/start-counter', '*');
            try {
                dispatchEventListener('counting');
            } catch (exEvent) {}
        }

        function sendLoadMessage() {
            //var pattern = new RegExp('(\\?|\\&)(sz=).*?(&|$)');
            //DYNAD_TV.config.URL_VAST = DYNAD_TV.config.URL_VAST.replace(pattern,'$1$2480x360$3');
            var params = '&videoplayertype=dynad_in-article&keyword=video-auto-play';
            if (typeof UOLPD !== 'undefined' && typeof UOLPD.dataLayer !== 'undefined') {
                try {
                    for (var key in UOLPD.dataLayer) {
                        params += '&' + key + '=' + UOLPD.dataLayer[key];
                    }
                } catch (exDL) {
                    if (typeof UOLPD.dataLayer.tt_age !== 'undefined') params += '&tt_age=' + UOLPD.dataLayer.tt_age;
                    if (typeof UOLPD.dataLayer.tt_cluster !== 'undefined') params += '&tt_cluster=' + UOLPD.dataLayer.tt_cluster;
                    if (typeof UOLPD.dataLayer.tt_customaudience !== 'undefined') params += '&tt_customaudience=' + UOLPD.dataLayer.tt_customaudience;
                    if (typeof UOLPD.dataLayer.tt_gender !== 'undefined') params += '&tt_gender=' + UOLPD.dataLayer.tt_gender;
                    if (typeof UOLPD.dataLayer.tt_lists !== 'undefined') params += '&tt_lists=' + UOLPD.dataLayer.tt_lists;
                    if (typeof UOLPD.dataLayer.tt_microsegments !== 'undefined') params += '&tt_microsegments=' + UOLPD.dataLayer.tt_microsegments;
                    if (typeof UOLPD.dataLayer.tt_socialclass !== 'undefined') params += '&tt_socialclass=' + UOLPD.dataLayer.tt_socialclass;
                    if (typeof UOLPD.dataLayer.tt_subjects !== 'undefined') params += '&tt_subjects=' + UOLPD.dataLayer.tt_subjects;
                    if (typeof UOLPD.dataLayer.tt_team !== 'undefined') params += '&tt_team=' + UOLPD.dataLayer.tt_team;
                }
            }
            
            if (params != '') {
                if (window.DYNAD_TV.config.URL_VAST.indexOf('&cust_params=') > -1) {
                    var temp = window.DYNAD_TV.config.URL_VAST.split('&cust_params=');
                    window.DYNAD_TV.config.URL_VAST = temp[0] + '&cust_params=' + encodeURIComponent(params.substr(1) + "&") + temp[1];
                } else
                    window.DYNAD_TV.config.URL_VAST += '&cust_params=' + encodeURIComponent(params.substr(1));
            }

            try {
                var vast_updated_url = window.DYNAD_TV.config.URL_VAST;
                var requiredParams = {
                    impl: "impl=s",
                    env: "env=vp",
                    gdfp_req: "gdfp_req=1",
                    ad_rule: "ad_rule=0",
                    vad_type: "vad_type=linear",
                    vpos: "vpos=preroll",
                    pod: "pod=1",
                    min_ad_duration: "min_ad_duration=0",
                    max_ad_duration: "max_ad_duration=999999000",
                    ppos: "ppos=1",
                    lip: "lip=true",
                    'video_url_to_fetch': 'video_url_to_fetch=' + encodeURIComponent(window.location.href)
                };
            
                var paramKeys = Object.keys(requiredParams);
                for(var index = 0; index < paramKeys.length; index++) {
                    if (vast_updated_url.indexOf(paramKeys[index]) == -1){
                        vast_updated_url += "&" + requiredParams[paramKeys[index]];
                    }
                }
                window.DYNAD_TV.config.URL_VAST = vast_updated_url;
            }catch(ex){ }
            
            if( typeof window.DYNAD_TV.config.settings === 'undefined' )
                window.DYNAD_TV.config.settings = new Array();
            window.DYNAD_TV.config.settings.push( {"key": "containerId", "value": containerId} ); 

            if (typeof window.DYNAD_TV.config.settings !== 'undefined') {
                var st = '';
                for (var x = 0; x < window.DYNAD_TV.config.settings.length; x++) {
                    st += (st != '' ? '/' : '') + window.DYNAD_TV.config.settings[x].key + '=' + window.DYNAD_TV.config.settings[x].value;
                }
                if (st != '')
                    container.contentWindow.postMessage('dynad-tv-protocol/settings/' + st, '*');
            }
            container.contentWindow.postMessage('dynad-tv-protocol/load/' + window.DYNAD_TV.config.URL_VAST, '*');
        }

        function sendActiveViewMessage(status) {
            if( status != STATUS.CLOSED && typeof container !== 'undefined' && typeof container.contentWindow !== 'undefined' )
                container.contentWindow.postMessage('dynad-tv-protocol/active_display/' + status, '*');
        }

        function sendFocusMessage() {
            if (status == STATUS.PLAYING && typeof container !== 'undefined' && typeof container.contentWindow !== 'undefined')
                container.contentWindow.postMessage('dynad-tv-protocol/win-focus', '*');
        }

        function sendBlurMessage() {
            console.log('will dispatch blur:', status);
            if (status == STATUS.PLAYING && typeof container !== 'undefined' && typeof container.contentWindow !== 'undefined')
                container.contentWindow.postMessage('dynad-tv-protocol/win-blur', '*');
        }

        function sendPlayMessage() {
            container.contentWindow.postMessage('dynad-tv-protocol/play', '*');
        }

        function sendPauseMessage() {
            container.contentWindow.postMessage('dynad-tv-protocol/pause', '*');
        }
        
        var hidden, visibilityChange;
        try {
            if (typeof document.hidden !== "undefined") {
                hidden = "hidden";
                visibilityChange = "visibilitychange";
            } else if (typeof document.mozHidden !== "undefined") {
                hidden = "mozHidden";
                visibilityChange = "mozvisibilitychange";
            } else if (typeof document.msHidden !== "undefined") {
                hidden = "msHidden";
                visibilityChange = "msvisibilitychange";
            } else if (typeof document.webkitHidden !== "undefined") {
                hidden = "webkitHidden";
                visibilityChange = "webkitvisibilitychange";
            }
        } catch (e) {}

        var idTimerBlur = null;
        if (window.addEventListener) {
            addEventListener("scroll", follow, false);
            addEventListener("touchstart", follow, false);
            addEventListener("touchend", follow, false);
            addEventListener("resize", resize, false);
            addEventListener("message", handle, false);
            
            document.addEventListener(visibilityChange, function() {
                if (document[hidden]) {
                    sendBlurMessage();
                } else {
 
                    sendFocusMessage();
                }
            });
            
            addEventListener("focus", function () {                
                sendFocusMessage();
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
            }, false);
            
            addEventListener("blur", function() {                
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
                idTimerBlur = setTimeout( function () {
                    if ( isMouseOverIfrm === false ) {
                        if ( !(document.activeElement instanceof HTMLIFrameElement) || (document.activeElement instanceof HTMLIFrameElement && document.activeElement.id != container.id) ) {
                            sendBlurMessage();
                        }
                    }
                }, 5);
            }, false);

            container.addEventListener("mouseenter", function(e) {
                isMouseOverIfrm = true;
            }, false);
            container.addEventListener("mouseleave", function(e) {
                isMouseOverIfrm = false;
            }, false);
        } else {
            attachEvent("onscroll", follow);
            attachEvent("ontouchstart", follow, false);
            attachEvent("ontouchend", follow, false);
            attachEvent("onresize", resize, false);
            attachEvent("onmessage", handle);
            
            document.attachEvent('on' + visibilityChange, function() {
                if (document[hidden]) {
                    sendBlurMessage();
                } else {
 
                    sendFocusMessage();
                }
            });
            
            attachEvent("onfocus", function () {                
                sendFocusMessage();
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
            }, false);
            
            attachEvent("onblur", function() {
                if( idTimerBlur != null ) { clearTimeout(idTimerBlur); idTimerBlur = null; }
                idTimerBlur = setTimeout( function () {
                    if ( isMouseOverIfrm === false ) {
                        if ( !(document.activeElement instanceof HTMLIFrameElement) || (document.activeElement instanceof HTMLIFrameElement && document.activeElement.id != container.id) ) {
                            sendBlurMessage();
                        }
                    }
                }, 5);
            }, false);
            
            container.attachEvent("onmouseenter", function(e) {
                isMouseOverIfrm = true;
            }, false);
            
            container.attachEvent("onmouseleave", function(e) {
                isMouseOverIfrm = false;
            }, false);
        }

        follow();

        function startTimeoutCounter() {
            if (idTimeout != null)
                return;

            idTimeout = setTimeout(function() {
                //change status for timeout
                status = STATUS.TIMEOUT;
                setTimeout(function() {
                    //remove container
                    try {
                        divContainer.parentNode.removeChild(divContainer);
                    } catch (e) {}
                }, 1000);
                //dispatch nodata event
                dispatchEventListener('nodata', 'timeout operation');
                //dispose listeners
                dispose();
                //add event counter
            }, window.DYNAD_TV.config.timeout || 8000);

            if (window.addEventListener)
                removeEventListener("touchstart", startTimeoutCounter, false);
            else
                detachEvent("ontouchstart", startTimeoutCounter, false);
        }

        /**** if( !window['_is_mobile_dynadtv_'].any() ) startTimeoutCounter(); ****/
    }

    var divContainer = document.getElementById(containerId),
        ifrm = document.getElementById(reqid.replace('I', 'IF'));
    try {
        try {
            divContainer.style.width = '0%';
            ifrm.style.width = '100%';
            ifrm.width = '100%';

            divContainer.style.height = '0px';
            ifrm.style.height = '0px';
            ifrm.height = 0;
        } catch (e) {
            return false;
        }
        DynAdTvKeeper(ifrm);
    } catch (e) {
        return false;
    }
}
return true;}catch(e){if(typeof console!=='undefined'&&typeof console.log!=='undefined'){console.log('DynAd Error:');console.log(e);}}})('I5550010343_16486833894321372711402','H',2,'_dynad_c_I5550010343_16486833894321372711402','5550010343','3000000127','5000003610','4000039770',window._dd_st_vl_16486833894321372711402);}}catch(e){if(typeof console!=='undefined'&&typeof console.log!=='undefined'){console.log('DynAd Error:');console.log(e);}localCache="";var v='<A HR';v+='EF="https://t.dynad.net/c/?dc=5550010343;ci=5000003610;cr=4000020066.0;ord=0;tid=D3-FE6;srctype=bkp;C=0;tp=HTML;st=1;er=';v+=encodeURI(e.message);v+='" TARGET="_blank" STYLE="" ><IMG ID="I5550010343_16486833894321372711402" S';v+='RC="https://s.dynad.net/stack/EtKfbEG_smAp1XI2-14J_1Ai4M7WYkpLb2egkg2fTzU.png" WIDTH="88" HEIGHT="31" ALT="" BORDER="0"></a><IMG SRC="https://t.dynad.net/n/?dc=5550010343;ci=5000003610;bi=4000020066.0;cr=4000039770.0;srctype=bkp;16486833894321372711402" STYLE="display:none;" WIDTH="0" HEIGHT="0" BORDER="0" />';divAppender(v);}
})();