(function () {window._dt_dynad_5550021485_16389010602251275238609='';window._tp_dynad_5550021485_16389010602251275238609={};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_5550021485_16389010602251275238609=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_5550021485_16389010602251275238609=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,5550021485,5000003610,4000039770,1638901120,30,'I');}else{db.setCk('uid','',0)}})});
var ele=document.createElement("div");ele.setAttribute("id","_dynad_c_I5550021485_16389010602251275238609");ele.setAttribute("style","background-color:transparent; border:0; z-index:1; margin:0; overflow:hidden; visibility:visible; display:block; width:100%; height:0px; ");var target=(function(isIE){try {
  var container300250InText = document.getElementById(
    "banner-300x250-top-area"
  );
  if (
    container300250InText &&
    typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
  ) {
    return [container300250InText.parentNode, container300250InText];
  }
} catch (exPushDFP) {}

if (
  typeof window.DYNAD_TV !== "undefined" &&
  typeof window.DYNAD_TV.config !== "undefined" &&
  typeof window.DYNAD_TV.config.container !== "undefined" &&
  typeof window.DYNAD_TV.config.container.obj !== "undefined"
) {
  var i = document.createElement("img");
  i.setAttribute(
    "src",
    "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="
  );
  i.style.display = "none";
  window.DYNAD_TV.config.container.obj.appendChild(i);
  return [window.DYNAD_TV.config.container.obj, i];
}

if (typeof window["DynAd_tv_Container"] !== "undefined") {
  try {
    var playerCnt = window["DynAd_tv_Container"];
    if (playerCnt && playerCnt.getAttribute("id") == "uolpd-video-inarticle")
      playerCnt.setAttribute(
        "style",
        "width: " +
          playerCnt.style.width +
          ";height: " +
          playerCnt.style.height +
          "; position: relative"
      );
    // height: '+ 380 + 'px  ;
  } catch (e) {
    if (console && console.error)
      console.error("unable to resize container", e);
  }

  try {
    var jsNS = document.createElement("script");
    jsNS.setAttribute(
      "src",
      "//s.dynad.net/stack/FcQVaHc6MaOcDzQjhAV0q78AMg75kNqHmVHSvf95ffqIXpBr_a_IcwHLcQMTBDGewfxoQXBulUZbsXy3Fo9ZHg.js"
    );
    jsNS.setAttribute("type", "text/javascript");
    jsNS.setAttribute("async", "true");
    window["DynAd_tv_Container"].appendChild(jsNS);
    return [window["DynAd_tv_Container"], jsNS];
  } catch (exComScore) {}
}

var containerContent = null;
if (typeof containerContent === "undefined" || containerContent == null) {
  var e = document.getElementById("texto");
  if (e != null && typeof e !== "undefined" && e.tagName == "DIV")
    containerContent = e;
}

if (typeof containerContent !== "undefined" && containerContent != null) {
  var chd = containerContent.children;
  var numTagP = 0,
    firstTagP = null;
  for (var x = 0; x < chd.length; x++) {
    if (
      typeof chd[x] !== "undefined" &&
      typeof chd[x].tagName !== "undefined"
    ) {
      if (chd[x].tagName == "P") {
        numTagP++;
        firstTagP = chd[x];
      }
    }
  }

  if (numTagP == 1) {
    chd = firstTagP.children;
    var numTagBR = 0;
    for (var x = 0; x < chd.length; x++) {
      if (
        typeof chd[x] !== "undefined" &&
        typeof chd[x].tagName !== "undefined"
      ) {
        if (chd[x].tagName == "BR") numTagBR++;
      }
    }

    if (numTagBR >= 3) containerContent = firstTagP;
  }
}

try {
  if (typeof containerContent !== "undefined" && containerContent != null) {
    var chd = containerContent.children;
    var re = [],
      nen = 0;
    for (var x = 0; x < chd.length; x++) {
      if (
        typeof chd[x] !== "undefined" &&
        typeof chd[x].tagName !== "undefined"
      ) {
        if (
          chd[x].tagName == "P" ||
          chd[x].tagName == "BR" ||
          chd[x].tagName == "H3"
        ) {
          var hasModoFotoNear = false;
          try {
            for (var xx = x - 1; xx >= x - 3; xx--) {
              if (chd[xx] && chd[xx].tagName == "DIV") {
                if (
                  chd[xx].hasAttribute("class") &&
                  chd[xx].getAttribute("class").indexOf("mod-foto") > -1
                ) {
                  hasModoFotoNear = true;
                  break;
                }
              }
            }
          } catch (e) {}

          if (!hasModoFotoNear) {
            re.push(chd[x]);
            nen++;
          } else {
            if (console && console.log)
              console.log("discarted container [near mod-foto]", chd[x]);
          }
        }
      }
    }

    if (nen >= 3) {
      var indexPos = 2;
      try {
        if (re[1].innerHTML.trim() == "<strong>Leia mais:</strong>" && nen >= 4)
          indexPos = 3;
        else if (
          typeof containerContent.querySelector("imagem-representativa") !==
            "undefined" &&
          nen >= 4
        )
          indexPos = 3;
      } catch (e) {}

      try {
        var jsNS = document.createElement("script");
        jsNS.setAttribute(
          "src",
          "//s.dynad.net/stack/FcQVaHc6MaOcDzQjhAV0q78AMg75kNqHmVHSvf95ffqIXpBr_a_IcwHLcQMTBDGewfxoQXBulUZbsXy3Fo9ZHg.js"
        );
        jsNS.setAttribute("type", "text/javascript");
        jsNS.setAttribute("async", "true");
        re[4].appendChild(jsNS);
      } catch (exComScore) {}
      return [containerContent, re[indexPos]];
    }
  }
} catch (e) {}

try {
  setTimeout(function () {
    var ic = document.createElement("img");
    ic.setAttribute("src", "//t.dynad.net/pc/?dc=5550001587;ord=" + Date.now());
    ic.setAttribute(
      "style",
      "width: 0px; height: 0px; visibility: hidden; position: absolute; z-index: 0;"
    );
    document.getElementsByTagName("body")[0].appendChild(ic);
  }, 50);
} 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_5550021485_16389010602251275238609;var dt_dynad=window._dt_dynad_5550021485_16389010602251275238609;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_I5550021485_16389010602251275238609').innerHTML=r;if(window.execScript&&n!='') window.execScript(n); else if(n!='')eval(n);};try{
var _rp16389010602251275238609=(function(reqid,type,step,containerId,placementId){try{var APPLY_PLAYER_SIZE_POLICY = function (desired_width) {
  var MIN_WIDTH = 256;
  var 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;
  }
  var isMobile = {
    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) != null;
    },
    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 (
        isMobile.Android() ||
        isMobile.BlackBerry() ||
        isMobile.iOS() ||
        isMobile.Opera() ||
        isMobile.Windows()
      );
    },
  };

  var checkSaveData = function checkSaveData() {
    if ("connection" in navigator) {
      return navigator.connection.saveData;
    } else return false;
  };

  if (isMobile.any()) {
    var logMessage =
      "[dynad-tv] - Plataforma móvel nao suportada para exibição de vídeos. Cancelando a impressão do vídeo.";
    var pixelId = 5550001586;

    if (isMobile.Android()) {
      if (!isValidApp("android") || checkSaveData()) {
        logMessage =
          "[dynad-tv] - Versão de aplicativo Android não suportada para exibição de vídeos. Cancelando a impressão do vídeo.";
        createStatusPixel(pixelId, logMessage);
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      }

      return true;
    }

    if (isMobile.iOS()) {
      var nav = navigator.userAgent.toLowerCase();
      if (nav.indexOf(" os 10_") == -1 && nav.indexOf(" os 11_") == -1) {
        logMessage =
          "[dynad-tv] - iOS inferior ao 10 nao é suportado para exibição de vídeos. Cancelando a impressão do vídeo.";
        createStatusPixel(pixelId, logMessage);
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        var styleElem = document.head.appendChild(
          document.createElement("style")
        );
        styleElem.innerHTML =
          "div[id*=banner-300x250-outstream-area]:before {content: 'Publicidade';display: block;width: 100%;text-align: center;text-transform: uppercase;height: 11px;font-size: 10px;margin-bottom: 18px;letter-spacing: 1.53px;color: #000000;}";
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      }

      if (!isValidApp("iOS")) {
        logMessage =
          "[dynad-tv] - Versão de aplicativo iOS não suportada para exibição de vídeos. Cancelando a impressão do vídeo.";
        createStatusPixel(pixelId, logMessage);
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        var styleElem = document.head.appendChild(
          document.createElement("style")
        );
        styleElem.innerHTML =
          "div[id*=banner-300x250-outstream-area]:before {content: 'Publicidade';display: block;width: 100%;text-align: center;text-transform: uppercase;height: 11px;font-size: 10px;margin-bottom: 18px;letter-spacing: 1.53px;color: #000000;}";
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      }

      if (document.location.href.indexOf("testeplayeruol") == -1) {
        //DESLIGADO EM 07/05, Andre detectou tela preta no iPad dele.
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      } else return true;
    }

    createStatusPixel(pixelId, logMessage);
    return false;
  }

  function isValidApp(device) {
    var appParameters =
      document.location.href.indexOf("app=") !== -1 &&
      document.location.href.indexOf("plataforma=") !== -1;
    console.log("Varíavel app ===> ", window._uolappmobile);
    var isAppInTheMap = false;
    var appMap = {
      iOS: {
        "app-uol": {
          version: "2.10.0",
          tagImpressionId: 5550005410,
        },
        "app-placar": {
          version: "3.16.0",
          tagImpressionId: 5550005413,
        },
      },
      android: {
        "app-uol": {
          version: "2.16.0",
          tagImpressionId: 5550005410,
        },
        "app-placar": {
          version: "3.22.0",
          tagImpressionId: 5550005413,
        },
      },
    };

    if (!appParameters) {
      console.log(
        "[dynad-tv] - Não foram identificados padrões de aplicativos. Iniciando a versão mobile."
      );
      if (document.location.href.indexOf("testeplayeruol") == -1) {
        if (device == "iOS") {
          //DESLIGADO EM 07/05, Andre detectou tela preta no iPad dele.
          return false;
        }
      }
      return true;
    }

    if (appParameters && !window._uolappmobile) {
      return false;
    }

    if (
      appParameters &&
      window._uolappmobile &&
      (!window._uolappmobile.version || !window._uolappmobile.name)
    ) {
      return false;
    }

    for (key in appMap[device]) {
      if (key == window._uolappmobile.name) {
        isAppInTheMap = true;
        if (window._uolappmobile.version < appMap[device][key].version) {
          return false;
        }

        var logMessage =
          "[dynad-tv] - Foi identificado um aplicativo " +
          device +
          " válido. Iniciando versão de vídeo para o app.";
        var pixelId = appMap[device][key].tagImpressionId;
        createStatusPixel(pixelId, logMessage);

        break;
      }
    }

    if (isAppInTheMap == false) {
      return false;
    }

    return true;
  }

  function createStatusPixel(pixelId, logMessage) {
    if (logMessage != undefined) {
      console.log(logMessage);
    }

    setTimeout(function () {
      try {
        var number_video = 0;
        if (typeof window.DYNAD_TV.config.video != "undefined") {
          number_video = window.DYNAD_TV.config.video;
          console.log("[dynad-tv] number_video = ", number_video);
        } else {
          console.log("[dynad-tv] number_video! ");
        }

        var ic = document.createElement("img");
        ic.setAttribute(
          "src",
          "https://t.dynad.net/pc/?dc=" +
            pixelId +
            ";ord=" +
            Date.now() +
            ";video=" +
            number_video
        );
        ic.setAttribute(
          "style",
          "width: 0px; height: 0px; visibility: hidden; position: absolute; z-index: 0;"
        );
        document.getElementById(containerId).appendChild(ic);
      } catch (e) {}
    }, 50);
  }
}

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(),
      },
    };

  var deviceIsMobile = (function (a) {
    if (
      /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(
        a
      ) ||
      /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(
        a.substr(0, 4)
      )
    ) {
      return true;
    } else {
      return false;
    }
  })(navigator.userAgent || navigator.vendor || window.opera);

  function DynAdTvKeeper(container) {
    var actual_width = null;
    var actual_height = null;
    var videoSize = null;

    if (window.DYNAD_TV.config.URL_VAST.match("videoplayersize%3D")) {
      var sizeLarge = function sizeLarge() {
        window.DYNAD_TV.config.URL_VAST =
          window.DYNAD_TV.config.URL_VAST.replace(
            "videoplayersize%3D",
            "videoplayersize%3Dlarge"
          );
        videoSize = "large";
      };

      var sizeSmall = function sizeSmall() {
        window.DYNAD_TV.config.URL_VAST =
          window.DYNAD_TV.config.URL_VAST.replace(
            "videoplayersize%3D",
            "videoplayersize%3Dsmall"
          );
        videoSize = "small";
      };

      resize();
      // mobile
      if (deviceIsMobile) {
        var deviceSize = window.screen.availWidth * window.screen.availHeight;
        var playerSize = actual_width * actual_height;

        if (playerSize >= deviceSize * 0.2) {
          sizeLarge();
        } else {
          sizeSmall();
        }
      }
      // desktop
      else {
        if (actual_height < 300 || actual_width < 400) {
          sizeSmall();
        } else {
          sizeLarge();
        }
      }
    }

    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,
      dispatchedPassback = false,
      isMouseOverIfrm = false,
      comScoreStreamingTag = null,
      comScoreStreamingTagID = null,
      adVideoDuration = 30000;

    var idAdSystem = "",
      idCreativeId = "",
      idAdId = "";

    function isMobile() {
      var isMobile = {
        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 (
            isMobile.Android() ||
            isMobile.BlackBerry() ||
            isMobile.iOS() ||
            isMobile.Opera() ||
            isMobile.Windows()
          );
        },
      };
      return isMobile.any();
    }

    function comScorePauseVideoAdvertisement() {
      try {
        if (comScoreStreamingTagID != null) {
          comScoreStreamingTag = document.createElement("script");
          comScoreStreamingTag.setAttribute("type", "text/javascript");
          comScoreStreamingTag.setAttribute("async", "true");
          comScoreStreamingTag.setAttribute(
            "src",
            "https://sb.scorecardresearch.com/p?c1=2&c2=27893134&ns_ap_sv=2.1511.10&ns_type=hidden&ns_st_it=a&ns_st_sv=4.0.0&ns_st_ad=1&ns_st_sq=1&ns_st_id=" +
              comScoreStreamingTagID +
              "&ns_st_ec=2&ns_st_cn=1&ns_st_ev=end&ns_st_ct=va11&ns_st_cl=" +
              adVideoDuration +
              "&ns_st_pt=" +
              adVideoDuration +
              "&c3=UOLADNET&c4=*null&c6=*null&ns_ts=" +
              Date.now()
          );
          divContainer.appendChild(comScoreStreamingTag);
          if (console && console.log)
            console.log(
              "[dynad-tv] - called method stop at comScore streaming tag."
            );
        }
      } catch (exInitComScore) {
        if (console && console.error)
          console.error(
            "[dynad-tv] - failed to dispatch pause comScore streaming tag.",
            exInitComScore
          );
      }
    }

    function comScorePlayVideoAdvertisement() {
      try {
        if (comScoreStreamingTagID == null) comScoreStreamingTagID = Date.now();
        comScoreStreamingTag = document.createElement("script");
        comScoreStreamingTag.setAttribute("type", "text/javascript");
        comScoreStreamingTag.setAttribute("async", "true");
        comScoreStreamingTag.setAttribute(
          "src",
          "https://sb.scorecardresearch.com/p?c1=2&c2=27893134&ns_ap_sv=2.1511.10&ns_type=hidden&ns_st_it=a&ns_st_sv=4.0.0&ns_st_ad=1&ns_st_sq=1&ns_st_id=" +
            comScoreStreamingTagID +
            "&ns_st_ec=1&ns_st_cn=1&ns_st_ev=play&ns_st_ct=va11&ns_st_cl=" +
            adVideoDuration +
            "&ns_st_pt=0&c3=UOLADNET&c4=*null&c6=*null&ns_ts=" +
            Date.now()
        );
        divContainer.appendChild(comScoreStreamingTag);
        if (console && console.log)
          console.log(
            "[dynad-tv] - called method play at comScore streaming tag."
          );
      } catch (exInitComScore) {
        comScoreStreamingTagID = null;
        if (console && console.error)
          console.error(
            "[dynad-tv] - failed to dispatch play comScore streaming tag.",
            exInitComScore
          );
      }
    }

    function addAdServerCounter(id) {
      if (id == 5550001580 && window._uolappmobile != undefined) {
        if (window._uolappmobile.name == "app-uol") {
          id = 5550005411;
        }

        if (window._uolappmobile.name == "app-placar") {
          id = 5550005412;
        }
      }

      var number_video = 0;
      if (typeof window.DYNAD_TV.config.video != "undefined") {
        number_video = window.DYNAD_TV.config.video;
        console.log("[dynad-tv] number_video = ", number_video);
      } else {
        console.log("[dynad-tv] number_video! ");
      }

      var ic = document.createElement("img");
      ic.setAttribute(
        "src",
        "https://t.dynad.net/pc/?dc=" +
          id +
          ";ord=" +
          Date.now() +
          ";video=" +
          number_video
      );
      ic.setAttribute(
        "style",
        "width: 0px; height: 0px; visibility: hidden; position: absolute; z-index: 0;"
      );
      divContainer.appendChild(ic);
    }

    function dispatchEventListener(eventName, eventData) {
      if (console.log)
        console.log(
          "[dynad-tv] - tag (events): " + eventName + " / " + eventData
        );
      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 == "closed" || eventName == "nodata") {
        // Desk
        if (window.innerWidth > 767) {
          try {
            var containerThreeNatives = document.getElementById(
              "uolpd-video-inarticle"
            );
            if (containerThreeNatives && window.innerWidth > 767) {
              //   Math.random() > 0.5 ? window.triggerUOLTM("vitrine-inarticle") : window.triggerUOLTM("vitrine-inarticle-2");
              //   console.log(
              //     "[dynad-tv] - tag (events): DFP push for Three Natives outstream InText"
              //   );
            }
          } catch (exPushDFP) {}
        }
        // Mobile
        else {
          try {
            var container300250InText = document.getElementById(
              "banner-300x250-top-area"
            );
            if (
              container300250InText &&
              typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
            ) {
              window["callbackPushBanner300x250TopArea"]();
              console.log(
                "[dynad-tv] - tag (events): DFP push for 300x250 InText"
              );
            }
          } catch (exPushDFP) {}
        }
      }
    }

    function notifyMetricsMonitor() {
      try {
        if (Math.random() < 0.1) {
          var script = document.createElement("script");
          script.setAttribute("async", "true");
          script.setAttribute("type", "text/javascript");
          var foreignKeys = ["key1", "key2"].toString();
          window["callback"] = function (result) {};
          script.setAttribute(
            "src",
            "//metrics.dynad.net/resources/counter/jsonp/incWithFk/dynadtv/monitor/delivery/" +
              placementId +
              "?ord=" +
              Date.now() +
              "&callback=callback"
          );
          (
            document.head ||
            document.getElementsByTagName("head")[0] ||
            document.body ||
            document.documentElement ||
            document.getElementsByTagName("body")[0]
          ).appendChild(script);
        }
      } catch (e) {
        if (console && console.error)
          console.error("failed to append metrics monitoring pixel", e);
      }
    }

    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_floating",
            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 (console.log) console.log("[dynad-tv] - tag: " + e.data);

      if (e.data.indexOf("dynad-tv-protocol/loaded/") == 0) {
        // player foi carregado
        try {
          if (idTimeout != null) {
            clearTimeout(idTimeout);
            idTimeout = null;
          }
        } catch (e) {}
        try {
          dispatchEventListener("loaded", {
            w: width,
            h: height,
          });
        } catch (exEvent) {}
        var dm = e.data.substr("dynad-tv-protocol/loaded/".length).split("/");
        height = parseInt(dm[1]);
        width = parseInt(dm[0]);

        try {
          if (height <= 0 || width <= 0) {
            width = divContainer.parentNode.offsetWidth;
            height = Math.floor((9 / 16) * width);
          }
        } catch (e) {}

        status = STATUS.LOADED;
        resize();
        follow();
        //notifyMetricsMonitor();

        if (
          divContainer.parentNode.getAttribute("id") == "uolpd-video-inarticle"
        ) {
          divContainer.style.width = "100%";
          container.style.height = vHeight + 36 + "px";
          container.height = vHeight + 36 + "px";
          divContainer.style.height = vHeight + 36 + "px";
          divContainer.height = vHeight + 36 + "px";
          divContainer.parentNode.style.height = vHeight + 36 + "px";

          divContainer.parentNode.height = vHeight + 36 + "px";
        }
      } else if (e.data.indexOf("dynad-tv-protocol/click/") == 0) {
        // player nao contem data
        try {
          if (idTimeout != null) {
            clearTimeout(idTimeout);
            idTimeout = null;
          }
        } catch (e) {}
        try {
          dispatchEventListener("click");
        } catch (exEvent) {}
        addAdServerCounter(5550001579);
      } 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("/");
        try {
          dispatchEventListener("nodata", m);
        } catch (exEvent) {}
        //addAdServerCounter(5550001577);

        //notifyMetricsMonitor();

        /****
              //PASSBACK DESLIGADO EM 30/05, DEIXANDO PLAYER UNICO DO GOOGLE OPERANDO.
              if( !dispatchedPassback && typeof window.DYNAD_TV.config.passback !== 'undefined' && !isMobile() ) {
                  window.DYNAD_TV.config.URL_VAST = window.DYNAD_TV.config.passback
                  status = STATUS.INITIALIZED;
                  dispatchedPassback = true;
                  ifrm.setAttribute('src', '//s.dynad.net/stack/LgY1T9JAP0K1_MprP6oR2vwOqLNRLh63qf6HJcArD96FV625y4INXTs_6cvwvYQ-9r_KEAPiiCSxfXZ7bBrShaBpCA29ibyjuyYGP0LTXAY.html?v=20170210.1');
                  if( console.log )
                      console.log('[dynad-tv] - tag: loading passback player (ADX)');
              } else {
                  try {
                      if( idTimeout != null ) {
                          clearTimeout(idTimeout);
                          idTimeout = null;
                      }
                  } catch (e){}
                  var m = e.data.substr('dynad-tv-protocol/no_data/'.length).split('/');
                  try { dispatchEventListener('nodata', m ); } catch(exEvent){}
                  //addAdServerCounter(5550001577);
              }
              ****/
      } else if (e.data == "dynad-tv-protocol/close") {
        status = STATUS.CLOSED;
        try {
          dispatchEventListener("closed");
        } catch (exEvent) {}

        try {
          if (idTimeout != null) {
            clearTimeout(idTimeout);
            idTimeout = null;
          }
        } catch (e) {}
        container.style.height = "0px";
        container.height = "0px";
        divContainer.style.height = "0px";
        //   divContainer.style.width = "0%";
        divContainer.height = "0px";
        //   divContainer.style.overflow = "hidden";
        setTimeout(function () {
          container.parentNode.removeChild(container);
        }, 1000);

        dispose();
        comScorePauseVideoAdvertisement();
        if (document.getElementById("floater_bt_close_dynadtv_unique"))
          document.getElementById(
            "floater_bt_close_dynadtv_unique"
          ).style.display = "none";
      } 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",
          "*"
        );
        window["callbackiruol_user_close"] = function (d) {};
        var e = document.createElement("script");
        //e.setAttribute('type', 'text/javascript');
        //e.setAttribute('async', 'true');
        //e.setAttribute('src', '//metrics.dynad.net/resources/counter/jsonp/multipleIncWithFk/dynadtv/behavior/close_button/override/?callback=callbackiruol_user_close&ord=' + Date.now() + '&override_0=' + encodeURIComponent(idAdSystem + '/' + idAdId + '/' + idCreativeId));
        //divContainer.appendChild(e);
      } 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.indexOf("dynad-tv-protocol/state_skip/") == 0) {
        var op = e.data.substr("dynad-tv-protocol/state_skip/".length);
        divContainer.setAttribute(
          "state_skip",
          op == "true" ? "none" : "block"
        );
        //var btCloseEle = document.getElementById('floater_bt_close_dynadtv_unique');
        //if( btCloseEle )
        //    btCloseEle.style.display = divContainer.getAttribute('state_skip');
      } else if (e.data == "dynad-tv-protocol/expand") {
        divContainer.style.width = "100%";

        divContainer.parentNode.style.height = vHeight + 36 + "px";
        divContainer.parentNode.height = vHeight + 36 + "px";

        container.style.height = vHeight + 36 + "px";
        container.height = vHeight + 36 + "px";
        //   divContainer.style.animationDuration = "1s";
        //   divContainer.style.WebkitTransitionDuration = "1s";
        //   divContainer.style.WebkitTransition = "1s";
        //   divContainer.style.MozTransition = "1s";
        divContainer.style.height = vHeight + 36 + "px";
        divContainer.height = vHeight + 36 + "px";
        sendStartCounterMessage();
        try {
          dispatchEventListener("expanded", {
            w: vWidth,
            h: vHeight,
          });
        } catch (exEvent) {}
        comScorePlayVideoAdvertisement();
        addAdServerCounter(5550001580);

        var bc = document.createElement("div");
        bc.setAttribute("id", "floater_bt_close_dynadtv_unique");
        bc.setAttribute(
          "style",
          "width:30px; text-align: right; height:15px; position:absolute; top:-4px; 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.overflow = "visible";
        //if( divContainer.hasAttribute('state_skip') )
        //    bc.style.display = divContainer.getAttribute('state_skip');
        divContainer.style.position = "relative";
        //divContainer.appendChild(bc);

        var listIds = [];

        if (listIds.length > 0) {
          for (var i = 0; i < listIds.length; i++) {
            if (idCreativeId === listIds[i]) {
              bc.setAttribute("display", "none");
              bc.style.setProperty("display", "none");
              return;
            }
          }
        }

        setTimeout(function () {
          if (vWidth > 0 && vHeight > 0)
            storeWindowSize(
              divContainer.getBoundingClientRect().width,
              divContainer.getBoundingClientRect().height,
              vWidth,
              vHeight
            );
        }, 2000);
      }
    }

    function storeWindowSize(w, h, vW, vH) {
      var script = document.createElement("script");
      script.setAttribute("async", "true");
      script.setAttribute("type", "text/javascript");
      window["callback"] = function (result) {};
      //script.setAttribute('src', '//metrics.dynad.net/resources/counter/jsonp/incWithFk/dynadtv/behavior/screen_width_2/'+w+'_'+h+'_'+vW+'_'+vH+'_'+ document.location.hostname.replace(/[^a-zA-Z]/gi, '_') +'?ord='+Date.now()+'&callback=callback');
      //(document.head || document.getElementsByTagName("head")[0] || document.body || document.documentElement || document.getElementsByTagName('body')[0]).appendChild(script);
    }

    function resize() {
      var avWidth = divContainer.parentNode.offsetWidth,
        avHeight = avWidth * (9 / 16);

      if (isMobile()) {
        //quando for mobile, desconta borda do UOL (10px de cada lado)
        avWidth -= 20;
        avHeight = avWidth * (9 / 16);
      }

      /**
          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);
          }***/

      vWidth = Math.round(avWidth);
      vHeight = Math.round(avHeight);

      if (isNaN(vWidth) || isNaN(vHeight)) {
        // console.log('[dynad-tv] Tentou realizar um resize com um valor que não era um tamanho válido. Resize redefinido para 0x0.');
        vWidth = 0;
        vHeight = 0;
      } else {
        var sizing = APPLY_PLAYER_SIZE_POLICY(vWidth);
        if (sizing) {
          vWidth = sizing.width;
          vHeight = sizing.height;

          actual_width = vWidth;
          actual_height = vHeight;

          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.2 <= windowHeight &&
        rect.top + vdHeight * 0.8 >= 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 getUVTags() {
      try {
        return typeof universal_variable.page.tags === "object" &&
          Array.isArray(universal_variable.page.tags)
          ? universal_variable.page.tags.toString()
          : "";
      } catch (e) {
        return "";
      }
    }

    function sendLoadMessage() {
      var pattern = new RegExp("(\\?|\\&)(sz=).*?(&|$)");
      DYNAD_TV.config.URL_VAST = DYNAD_TV.config.URL_VAST.replace(
        pattern,
        "$1$2480x360$3"
      );

      var number_video = 0;
      if (typeof window.DYNAD_TV.config.video != "undefined") {
        number_video = window.DYNAD_TV.config.video;
        console.log("[dynad-tv] sendLoadMessage number_video = ", number_video);
      } else {
        console.log("[dynad-tv] sendLoadMessage number_video! ");
      }

      var params =
        "&videoplayertype=dynad_in-article&videoplayersize=" +
        videoSize +
        "&keyword=video-auto-play&videoinarticlepos="+
        number_video +
        "&tags=" +
        getUVTags();

      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") {
        var st = "";
        for (var x = 0; x < window.DYNAD_TV.config.settings.length; x++) {
          st +=
            (st != "" ? "/" : "") +
            window.DYNAD_TV.config.settings[x].key +
            "=" +
            encodeURIComponent(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.PLAYING &&
        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
        addAdServerCounter(5550001578);
      }, window.DYNAD_TV.config.timeout || 16000);

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

    /*** if (!isMobile.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.zIndex = 0;

      divContainer.style.height = "0px";
      ifrm.style.height = "0px";
      ifrm.height = 0;
      divContainer.style.position = "absolute";

      ifrm.style.position = "absolute";
      ifrm.style.left = 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);}}})('I5550021485_16389010602251275238609', 'H', 1,'_dynad_c_I5550021485_16389010602251275238609','5550021485');if(_rp16389010602251275238609==true||typeof _rp16389010602251275238609==='undefined'){divAppender("<iframe id='IF5550021485_16389010602251275238609' name='I5550021485_16389010602251275238609' src='https://s.dynad.net/stack/928W5r5IndTfocT3VdUV-AB8UVlc0JbnGWyFZsei5gU.html' style='border:0; visibility:visible; width:100%; height:0px; ' 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('IF5550021485_16389010602251275238609');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=5550021485;ct=1;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE14;bid=;iid=QjEyQjk1NkM0RDRCRUJGRL+Wkq0BUJYZpEOlCER+p6ksAtRTFZmuZTP9PWTK0oPZTRGHVC93+XihQAwruhPkC8PnunPoI5SZLxO2YzO+1R8=;;","clickTAG2":"https://t.dynad.net/c/?dc=5550021485;ct=2;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE14;bid=;iid=QjEyQjk1NkM0RDRCRUJGRL+Wkq0BUJYZpEOlCER+p6ksAtRTFZmuZTP9PWTK0oPZTRGHVC93+XihQAwruhPkC8PnunPoI5SZLxO2YzO+1R8=;;","clickTAG3":"https://t.dynad.net/c/?dc=5550021485;ct=3;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE14;bid=;iid=QjEyQjk1NkM0RDRCRUJGRL+Wkq0BUJYZpEOlCER+p6ksAtRTFZmuZTP9PWTK0oPZTRGHVC93+XihQAwruhPkC8PnunPoI5SZLxO2YzO+1R8=;;","clickTAG4":"https://t.dynad.net/c/?dc=5550021485;ct=4;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE14;bid=;iid=QjEyQjk1NkM0RDRCRUJGRL+Wkq0BUJYZpEOlCER+p6ksAtRTFZmuZTP9PWTK0oPZTRGHVC93+XihQAwruhPkC8PnunPoI5SZLxO2YzO+1R8=;;","clickTAG5":"https://t.dynad.net/c/?dc=5550021485;ct=5;ci=5000003610;cr=4000039770.0;cb=4000020066.0;ord=0;tid=D3-FE14;bid=;iid=QjEyQjk1NkM0RDRCRUJGRL+Wkq0BUJYZpEOlCER+p6ksAtRTFZmuZTP9PWTK0oPZTRGHVC93+XihQAwruhPkC8PnunPoI5SZLxO2YzO+1R8=;;","_d_site_id":"3000000127","_d_placement_id":"5550021485","_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_16389010602251275238609=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;
  var 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;
  }
  var isMobile = {
    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) != null;
    },
    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 (
        isMobile.Android() ||
        isMobile.BlackBerry() ||
        isMobile.iOS() ||
        isMobile.Opera() ||
        isMobile.Windows()
      );
    },
  };

  var checkSaveData = function checkSaveData() {
    if ("connection" in navigator) {
      return navigator.connection.saveData;
    } else return false;
  };

  if (isMobile.any()) {
    var logMessage =
      "[dynad-tv] - Plataforma móvel nao suportada para exibição de vídeos. Cancelando a impressão do vídeo.";
    var pixelId = 5550001586;

    if (isMobile.Android()) {
      if (!isValidApp("android") || checkSaveData()) {
        logMessage =
          "[dynad-tv] - Versão de aplicativo Android não suportada para exibição de vídeos. Cancelando a impressão do vídeo.";
        createStatusPixel(pixelId, logMessage);
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      }

      return true;
    }

    if (isMobile.iOS()) {
      var nav = navigator.userAgent.toLowerCase();
      if (nav.indexOf(" os 10_") == -1 && nav.indexOf(" os 11_") == -1) {
        logMessage =
          "[dynad-tv] - iOS inferior ao 10 nao é suportado para exibição de vídeos. Cancelando a impressão do vídeo.";
        createStatusPixel(pixelId, logMessage);
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        var styleElem = document.head.appendChild(
          document.createElement("style")
        );
        styleElem.innerHTML =
          "div[id*=banner-300x250-outstream-area]:before {content: 'Publicidade';display: block;width: 100%;text-align: center;text-transform: uppercase;height: 11px;font-size: 10px;margin-bottom: 18px;letter-spacing: 1.53px;color: #000000;}";
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      }

      if (!isValidApp("iOS")) {
        logMessage =
          "[dynad-tv] - Versão de aplicativo iOS não suportada para exibição de vídeos. Cancelando a impressão do vídeo.";
        createStatusPixel(pixelId, logMessage);
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        var styleElem = document.head.appendChild(
          document.createElement("style")
        );
        styleElem.innerHTML =
          "div[id*=banner-300x250-outstream-area]:before {content: 'Publicidade';display: block;width: 100%;text-align: center;text-transform: uppercase;height: 11px;font-size: 10px;margin-bottom: 18px;letter-spacing: 1.53px;color: #000000;}";
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      }

      if (document.location.href.indexOf("testeplayeruol") == -1) {
        //DESLIGADO EM 07/05, Andre detectou tela preta no iPad dele.
        var container300250InText = document.getElementById(
          "banner-300x250-top-area"
        );
        if (
          container300250InText &&
          typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
        ) {
          window["callbackPushBanner300x250TopArea"]();
          console.log("[dynad-tv] - tag (events): DFP push for 300x250 InText");
        }
        return false;
      } else return true;
    }

    createStatusPixel(pixelId, logMessage);
    return false;
  }

  function isValidApp(device) {
    var appParameters =
      document.location.href.indexOf("app=") !== -1 &&
      document.location.href.indexOf("plataforma=") !== -1;
    console.log("Varíavel app ===> ", window._uolappmobile);
    var isAppInTheMap = false;
    var appMap = {
      iOS: {
        "app-uol": {
          version: "2.10.0",
          tagImpressionId: 5550005410,
        },
        "app-placar": {
          version: "3.16.0",
          tagImpressionId: 5550005413,
        },
      },
      android: {
        "app-uol": {
          version: "2.16.0",
          tagImpressionId: 5550005410,
        },
        "app-placar": {
          version: "3.22.0",
          tagImpressionId: 5550005413,
        },
      },
    };

    if (!appParameters) {
      console.log(
        "[dynad-tv] - Não foram identificados padrões de aplicativos. Iniciando a versão mobile."
      );
      if (document.location.href.indexOf("testeplayeruol") == -1) {
        if (device == "iOS") {
          //DESLIGADO EM 07/05, Andre detectou tela preta no iPad dele.
          return false;
        }
      }
      return true;
    }

    if (appParameters && !window._uolappmobile) {
      return false;
    }

    if (
      appParameters &&
      window._uolappmobile &&
      (!window._uolappmobile.version || !window._uolappmobile.name)
    ) {
      return false;
    }

    for (key in appMap[device]) {
      if (key == window._uolappmobile.name) {
        isAppInTheMap = true;
        if (window._uolappmobile.version < appMap[device][key].version) {
          return false;
        }

        var logMessage =
          "[dynad-tv] - Foi identificado um aplicativo " +
          device +
          " válido. Iniciando versão de vídeo para o app.";
        var pixelId = appMap[device][key].tagImpressionId;
        createStatusPixel(pixelId, logMessage);

        break;
      }
    }

    if (isAppInTheMap == false) {
      return false;
    }

    return true;
  }

  function createStatusPixel(pixelId, logMessage) {
    if (logMessage != undefined) {
      console.log(logMessage);
    }

    setTimeout(function () {
      try {
        var number_video = 0;
        if (typeof window.DYNAD_TV.config.video != "undefined") {
          number_video = window.DYNAD_TV.config.video;
          console.log("[dynad-tv] number_video = ", number_video);
        } else {
          console.log("[dynad-tv] number_video! ");
        }

        var ic = document.createElement("img");
        ic.setAttribute(
          "src",
          "https://t.dynad.net/pc/?dc=" +
            pixelId +
            ";ord=" +
            Date.now() +
            ";video=" +
            number_video
        );
        ic.setAttribute(
          "style",
          "width: 0px; height: 0px; visibility: hidden; position: absolute; z-index: 0;"
        );
        document.getElementById(containerId).appendChild(ic);
      } catch (e) {}
    }, 50);
  }
}

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(),
      },
    };

  var deviceIsMobile = (function (a) {
    if (
      /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(
        a
      ) ||
      /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(
        a.substr(0, 4)
      )
    ) {
      return true;
    } else {
      return false;
    }
  })(navigator.userAgent || navigator.vendor || window.opera);

  function DynAdTvKeeper(container) {
    var actual_width = null;
    var actual_height = null;
    var videoSize = null;

    if (window.DYNAD_TV.config.URL_VAST.match("videoplayersize%3D")) {
      var sizeLarge = function sizeLarge() {
        window.DYNAD_TV.config.URL_VAST =
          window.DYNAD_TV.config.URL_VAST.replace(
            "videoplayersize%3D",
            "videoplayersize%3Dlarge"
          );
        videoSize = "large";
      };

      var sizeSmall = function sizeSmall() {
        window.DYNAD_TV.config.URL_VAST =
          window.DYNAD_TV.config.URL_VAST.replace(
            "videoplayersize%3D",
            "videoplayersize%3Dsmall"
          );
        videoSize = "small";
      };

      resize();
      // mobile
      if (deviceIsMobile) {
        var deviceSize = window.screen.availWidth * window.screen.availHeight;
        var playerSize = actual_width * actual_height;

        if (playerSize >= deviceSize * 0.2) {
          sizeLarge();
        } else {
          sizeSmall();
        }
      }
      // desktop
      else {
        if (actual_height < 300 || actual_width < 400) {
          sizeSmall();
        } else {
          sizeLarge();
        }
      }
    }

    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,
      dispatchedPassback = false,
      isMouseOverIfrm = false,
      comScoreStreamingTag = null,
      comScoreStreamingTagID = null,
      adVideoDuration = 30000;

    var idAdSystem = "",
      idCreativeId = "",
      idAdId = "";

    function isMobile() {
      var isMobile = {
        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 (
            isMobile.Android() ||
            isMobile.BlackBerry() ||
            isMobile.iOS() ||
            isMobile.Opera() ||
            isMobile.Windows()
          );
        },
      };
      return isMobile.any();
    }

    function comScorePauseVideoAdvertisement() {
      try {
        if (comScoreStreamingTagID != null) {
          comScoreStreamingTag = document.createElement("script");
          comScoreStreamingTag.setAttribute("type", "text/javascript");
          comScoreStreamingTag.setAttribute("async", "true");
          comScoreStreamingTag.setAttribute(
            "src",
            "https://sb.scorecardresearch.com/p?c1=2&c2=27893134&ns_ap_sv=2.1511.10&ns_type=hidden&ns_st_it=a&ns_st_sv=4.0.0&ns_st_ad=1&ns_st_sq=1&ns_st_id=" +
              comScoreStreamingTagID +
              "&ns_st_ec=2&ns_st_cn=1&ns_st_ev=end&ns_st_ct=va11&ns_st_cl=" +
              adVideoDuration +
              "&ns_st_pt=" +
              adVideoDuration +
              "&c3=UOLADNET&c4=*null&c6=*null&ns_ts=" +
              Date.now()
          );
          divContainer.appendChild(comScoreStreamingTag);
          if (console && console.log)
            console.log(
              "[dynad-tv] - called method stop at comScore streaming tag."
            );
        }
      } catch (exInitComScore) {
        if (console && console.error)
          console.error(
            "[dynad-tv] - failed to dispatch pause comScore streaming tag.",
            exInitComScore
          );
      }
    }

    function comScorePlayVideoAdvertisement() {
      try {
        if (comScoreStreamingTagID == null) comScoreStreamingTagID = Date.now();
        comScoreStreamingTag = document.createElement("script");
        comScoreStreamingTag.setAttribute("type", "text/javascript");
        comScoreStreamingTag.setAttribute("async", "true");
        comScoreStreamingTag.setAttribute(
          "src",
          "https://sb.scorecardresearch.com/p?c1=2&c2=27893134&ns_ap_sv=2.1511.10&ns_type=hidden&ns_st_it=a&ns_st_sv=4.0.0&ns_st_ad=1&ns_st_sq=1&ns_st_id=" +
            comScoreStreamingTagID +
            "&ns_st_ec=1&ns_st_cn=1&ns_st_ev=play&ns_st_ct=va11&ns_st_cl=" +
            adVideoDuration +
            "&ns_st_pt=0&c3=UOLADNET&c4=*null&c6=*null&ns_ts=" +
            Date.now()
        );
        divContainer.appendChild(comScoreStreamingTag);
        if (console && console.log)
          console.log(
            "[dynad-tv] - called method play at comScore streaming tag."
          );
      } catch (exInitComScore) {
        comScoreStreamingTagID = null;
        if (console && console.error)
          console.error(
            "[dynad-tv] - failed to dispatch play comScore streaming tag.",
            exInitComScore
          );
      }
    }

    function addAdServerCounter(id) {
      if (id == 5550001580 && window._uolappmobile != undefined) {
        if (window._uolappmobile.name == "app-uol") {
          id = 5550005411;
        }

        if (window._uolappmobile.name == "app-placar") {
          id = 5550005412;
        }
      }

      var number_video = 0;
      if (typeof window.DYNAD_TV.config.video != "undefined") {
        number_video = window.DYNAD_TV.config.video;
        console.log("[dynad-tv] number_video = ", number_video);
      } else {
        console.log("[dynad-tv] number_video! ");
      }

      var ic = document.createElement("img");
      ic.setAttribute(
        "src",
        "https://t.dynad.net/pc/?dc=" +
          id +
          ";ord=" +
          Date.now() +
          ";video=" +
          number_video
      );
      ic.setAttribute(
        "style",
        "width: 0px; height: 0px; visibility: hidden; position: absolute; z-index: 0;"
      );
      divContainer.appendChild(ic);
    }

    function dispatchEventListener(eventName, eventData) {
      if (console.log)
        console.log(
          "[dynad-tv] - tag (events): " + eventName + " / " + eventData
        );
      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 == "closed" || eventName == "nodata") {
        // Desk
        if (window.innerWidth > 767) {
          try {
            var containerThreeNatives = document.getElementById(
              "uolpd-video-inarticle"
            );
            if (containerThreeNatives && window.innerWidth > 767) {
              //   Math.random() > 0.5 ? window.triggerUOLTM("vitrine-inarticle") : window.triggerUOLTM("vitrine-inarticle-2");
              //   console.log(
              //     "[dynad-tv] - tag (events): DFP push for Three Natives outstream InText"
              //   );
            }
          } catch (exPushDFP) {}
        }
        // Mobile
        else {
          try {
            var container300250InText = document.getElementById(
              "banner-300x250-top-area"
            );
            if (
              container300250InText &&
              typeof window["callbackPushBanner300x250TopArea"] !== "undefined"
            ) {
              window["callbackPushBanner300x250TopArea"]();
              console.log(
                "[dynad-tv] - tag (events): DFP push for 300x250 InText"
              );
            }
          } catch (exPushDFP) {}
        }
      }
    }

    function notifyMetricsMonitor() {
      try {
        if (Math.random() < 0.1) {
          var script = document.createElement("script");
          script.setAttribute("async", "true");
          script.setAttribute("type", "text/javascript");
          var foreignKeys = ["key1", "key2"].toString();
          window["callback"] = function (result) {};
          script.setAttribute(
            "src",
            "//metrics.dynad.net/resources/counter/jsonp/incWithFk/dynadtv/monitor/delivery/" +
              placementId +
              "?ord=" +
              Date.now() +
              "&callback=callback"
          );
          (
            document.head ||
            document.getElementsByTagName("head")[0] ||
            document.body ||
            document.documentElement ||
            document.getElementsByTagName("body")[0]
          ).appendChild(script);
        }
      } catch (e) {
        if (console && console.error)
          console.error("failed to append metrics monitoring pixel", e);
      }
    }

    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_floating",
            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 (console.log) console.log("[dynad-tv] - tag: " + e.data);

      if (e.data.indexOf("dynad-tv-protocol/loaded/") == 0) {
        // player foi carregado
        try {
          if (idTimeout != null) {
            clearTimeout(idTimeout);
            idTimeout = null;
          }
        } catch (e) {}
        try {
          dispatchEventListener("loaded", {
            w: width,
            h: height,
          });
        } catch (exEvent) {}
        var dm = e.data.substr("dynad-tv-protocol/loaded/".length).split("/");
        height = parseInt(dm[1]);
        width = parseInt(dm[0]);

        try {
          if (height <= 0 || width <= 0) {
            width = divContainer.parentNode.offsetWidth;
            height = Math.floor((9 / 16) * width);
          }
        } catch (e) {}

        status = STATUS.LOADED;
        resize();
        follow();
        //notifyMetricsMonitor();

        if (
          divContainer.parentNode.getAttribute("id") == "uolpd-video-inarticle"
        ) {
          divContainer.style.width = "100%";
          container.style.height = vHeight + 36 + "px";
          container.height = vHeight + 36 + "px";
          divContainer.style.height = vHeight + 36 + "px";
          divContainer.height = vHeight + 36 + "px";
          divContainer.parentNode.style.height = vHeight + 36 + "px";

          divContainer.parentNode.height = vHeight + 36 + "px";
        }
      } else if (e.data.indexOf("dynad-tv-protocol/click/") == 0) {
        // player nao contem data
        try {
          if (idTimeout != null) {
            clearTimeout(idTimeout);
            idTimeout = null;
          }
        } catch (e) {}
        try {
          dispatchEventListener("click");
        } catch (exEvent) {}
        addAdServerCounter(5550001579);
      } 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("/");
        try {
          dispatchEventListener("nodata", m);
        } catch (exEvent) {}
        //addAdServerCounter(5550001577);

        //notifyMetricsMonitor();

        /****
              //PASSBACK DESLIGADO EM 30/05, DEIXANDO PLAYER UNICO DO GOOGLE OPERANDO.
              if( !dispatchedPassback && typeof window.DYNAD_TV.config.passback !== 'undefined' && !isMobile() ) {
                  window.DYNAD_TV.config.URL_VAST = window.DYNAD_TV.config.passback
                  status = STATUS.INITIALIZED;
                  dispatchedPassback = true;
                  ifrm.setAttribute('src', '//s.dynad.net/stack/LgY1T9JAP0K1_MprP6oR2vwOqLNRLh63qf6HJcArD96FV625y4INXTs_6cvwvYQ-9r_KEAPiiCSxfXZ7bBrShaBpCA29ibyjuyYGP0LTXAY.html?v=20170210.1');
                  if( console.log )
                      console.log('[dynad-tv] - tag: loading passback player (ADX)');
              } else {
                  try {
                      if( idTimeout != null ) {
                          clearTimeout(idTimeout);
                          idTimeout = null;
                      }
                  } catch (e){}
                  var m = e.data.substr('dynad-tv-protocol/no_data/'.length).split('/');
                  try { dispatchEventListener('nodata', m ); } catch(exEvent){}
                  //addAdServerCounter(5550001577);
              }
              ****/
      } else if (e.data == "dynad-tv-protocol/close") {
        status = STATUS.CLOSED;
        try {
          dispatchEventListener("closed");
        } catch (exEvent) {}

        try {
          if (idTimeout != null) {
            clearTimeout(idTimeout);
            idTimeout = null;
          }
        } catch (e) {}
        container.style.height = "0px";
        container.height = "0px";
        divContainer.style.height = "0px";
        //   divContainer.style.width = "0%";
        divContainer.height = "0px";
        //   divContainer.style.overflow = "hidden";
        setTimeout(function () {
          container.parentNode.removeChild(container);
        }, 1000);

        dispose();
        comScorePauseVideoAdvertisement();
        if (document.getElementById("floater_bt_close_dynadtv_unique"))
          document.getElementById(
            "floater_bt_close_dynadtv_unique"
          ).style.display = "none";
      } 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",
          "*"
        );
        window["callbackiruol_user_close"] = function (d) {};
        var e = document.createElement("script");
        //e.setAttribute('type', 'text/javascript');
        //e.setAttribute('async', 'true');
        //e.setAttribute('src', '//metrics.dynad.net/resources/counter/jsonp/multipleIncWithFk/dynadtv/behavior/close_button/override/?callback=callbackiruol_user_close&ord=' + Date.now() + '&override_0=' + encodeURIComponent(idAdSystem + '/' + idAdId + '/' + idCreativeId));
        //divContainer.appendChild(e);
      } 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.indexOf("dynad-tv-protocol/state_skip/") == 0) {
        var op = e.data.substr("dynad-tv-protocol/state_skip/".length);
        divContainer.setAttribute(
          "state_skip",
          op == "true" ? "none" : "block"
        );
        //var btCloseEle = document.getElementById('floater_bt_close_dynadtv_unique');
        //if( btCloseEle )
        //    btCloseEle.style.display = divContainer.getAttribute('state_skip');
      } else if (e.data == "dynad-tv-protocol/expand") {
        divContainer.style.width = "100%";

        divContainer.parentNode.style.height = vHeight + 36 + "px";
        divContainer.parentNode.height = vHeight + 36 + "px";

        container.style.height = vHeight + 36 + "px";
        container.height = vHeight + 36 + "px";
        //   divContainer.style.animationDuration = "1s";
        //   divContainer.style.WebkitTransitionDuration = "1s";
        //   divContainer.style.WebkitTransition = "1s";
        //   divContainer.style.MozTransition = "1s";
        divContainer.style.height = vHeight + 36 + "px";
        divContainer.height = vHeight + 36 + "px";
        sendStartCounterMessage();
        try {
          dispatchEventListener("expanded", {
            w: vWidth,
            h: vHeight,
          });
        } catch (exEvent) {}
        comScorePlayVideoAdvertisement();
        addAdServerCounter(5550001580);

        var bc = document.createElement("div");
        bc.setAttribute("id", "floater_bt_close_dynadtv_unique");
        bc.setAttribute(
          "style",
          "width:30px; text-align: right; height:15px; position:absolute; top:-4px; 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.overflow = "visible";
        //if( divContainer.hasAttribute('state_skip') )
        //    bc.style.display = divContainer.getAttribute('state_skip');
        divContainer.style.position = "relative";
        //divContainer.appendChild(bc);

        var listIds = [];

        if (listIds.length > 0) {
          for (var i = 0; i < listIds.length; i++) {
            if (idCreativeId === listIds[i]) {
              bc.setAttribute("display", "none");
              bc.style.setProperty("display", "none");
              return;
            }
          }
        }

        setTimeout(function () {
          if (vWidth > 0 && vHeight > 0)
            storeWindowSize(
              divContainer.getBoundingClientRect().width,
              divContainer.getBoundingClientRect().height,
              vWidth,
              vHeight
            );
        }, 2000);
      }
    }

    function storeWindowSize(w, h, vW, vH) {
      var script = document.createElement("script");
      script.setAttribute("async", "true");
      script.setAttribute("type", "text/javascript");
      window["callback"] = function (result) {};
      //script.setAttribute('src', '//metrics.dynad.net/resources/counter/jsonp/incWithFk/dynadtv/behavior/screen_width_2/'+w+'_'+h+'_'+vW+'_'+vH+'_'+ document.location.hostname.replace(/[^a-zA-Z]/gi, '_') +'?ord='+Date.now()+'&callback=callback');
      //(document.head || document.getElementsByTagName("head")[0] || document.body || document.documentElement || document.getElementsByTagName('body')[0]).appendChild(script);
    }

    function resize() {
      var avWidth = divContainer.parentNode.offsetWidth,
        avHeight = avWidth * (9 / 16);

      if (isMobile()) {
        //quando for mobile, desconta borda do UOL (10px de cada lado)
        avWidth -= 20;
        avHeight = avWidth * (9 / 16);
      }

      /**
          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);
          }***/

      vWidth = Math.round(avWidth);
      vHeight = Math.round(avHeight);

      if (isNaN(vWidth) || isNaN(vHeight)) {
        // console.log('[dynad-tv] Tentou realizar um resize com um valor que não era um tamanho válido. Resize redefinido para 0x0.');
        vWidth = 0;
        vHeight = 0;
      } else {
        var sizing = APPLY_PLAYER_SIZE_POLICY(vWidth);
        if (sizing) {
          vWidth = sizing.width;
          vHeight = sizing.height;

          actual_width = vWidth;
          actual_height = vHeight;

          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.2 <= windowHeight &&
        rect.top + vdHeight * 0.8 >= 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 getUVTags() {
      try {
        return typeof universal_variable.page.tags === "object" &&
          Array.isArray(universal_variable.page.tags)
          ? universal_variable.page.tags.toString()
          : "";
      } catch (e) {
        return "";
      }
    }

    function sendLoadMessage() {
      var pattern = new RegExp("(\\?|\\&)(sz=).*?(&|$)");
      DYNAD_TV.config.URL_VAST = DYNAD_TV.config.URL_VAST.replace(
        pattern,
        "$1$2480x360$3"
      );

      var number_video = 0;
      if (typeof window.DYNAD_TV.config.video != "undefined") {
        number_video = window.DYNAD_TV.config.video;
        console.log("[dynad-tv] sendLoadMessage number_video = ", number_video);
      } else {
        console.log("[dynad-tv] sendLoadMessage number_video! ");
      }

      var params =
        "&videoplayertype=dynad_in-article&videoplayersize=" +
        videoSize +
        "&keyword=video-auto-play&videoinarticlepos="+
        number_video +
        "&tags=" +
        getUVTags();

      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") {
        var st = "";
        for (var x = 0; x < window.DYNAD_TV.config.settings.length; x++) {
          st +=
            (st != "" ? "/" : "") +
            window.DYNAD_TV.config.settings[x].key +
            "=" +
            encodeURIComponent(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.PLAYING &&
        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
        addAdServerCounter(5550001578);
      }, window.DYNAD_TV.config.timeout || 16000);

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

    /*** if (!isMobile.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.zIndex = 0;

      divContainer.style.height = "0px";
      ifrm.style.height = "0px";
      ifrm.height = 0;
      divContainer.style.position = "absolute";

      ifrm.style.position = "absolute";
      ifrm.style.left = 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);}}})('I5550021485_16389010602251275238609','H',2,'_dynad_c_I5550021485_16389010602251275238609','5550021485','3000000127','5000003610','4000039770',window._dd_st_vl_16389010602251275238609);}}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=5550021485;ci=5000003610;cr=4000020066.0;ord=0;tid=D3-FE14;srctype=bkp;C=0;tp=HTML;st=1;er=';v+=encodeURI(e.message);v+='" TARGET="_blank" STYLE="" ><IMG ID="I5550021485_16389010602251275238609" 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=5550021485;ci=5000003610;bi=4000020066.0;cr=4000039770.0;srctype=bkp;16389010602251275238609" STYLE="display:none;" WIDTH="0" HEIGHT="0" BORDER="0" />';divAppender(v);}
})();