var xmlDocConsole = null;
var ServicioActivo;
var temaEspecialHeader;
var audioEspecialHeader;
var ConsoleUsIntActivo;
var ObjConfigConsole;
var ObjCategorias;
var ObjPublisherId;
var ObjIdTipoElemento;
var publisherid;
var plataform;
var sitepage;
var AdsReady = false;
var listJsonPlacements = [];
var grpubts = document.currentScript.src.split('?')[1]; if(grpubts == undefined){grpubts = '';}
function GRAnuncio(options) {
this.defaultSettings = {
scopeformato: '',
categoriadir: '',
subcategoriadir: '',
idelementosubcategoria: '',
idPlaza: 102,
idProducto: 2,
tagsxportada: '',
activarPromos: false,
urlHostXML: null,
urlBasePromo: null,
tipoPromo: 'hardnews',
sitePage: 'reforma',
esStage: false,
folderScope: 'noticias/',
flujoant: false,
activarPromosEst: false,
temaEspecialHeader: false,
audioEspecialHeader: '1',
member: 8125
}
this.settings = merge_options(this.defaultSettings, options);
if (options.sitePage == undefined) this.CalculaSitePageProducto();
if (options.esStage == undefined) this.EsStage();
this.xdomain = false;
this.xdomain = this.XDomainSite();
this.pathxmlpubconsole = 'libre/publicidad/publicidadconsole.xml';
//this.xmlDocConsole = null;
if (!this.settings.esStage) {
this.LeeXMLPublicidad(this.settings.urlHostXML + this.pathxmlpubconsole);
}
else {
this.settings.activarPromos = false;
//this.xmlDoc = null;
//this.xmlDocConsole = null;
}
this.OASLoaded = false;
this.ObjConfig = null;
this.ObjComerciales = null;
this.ObjEspeciales = null;
this.ServicioActivo = true;
this.XMLToArreglo();
this.Especial = 0;
this.OrdenEspecial = new Array();
this.ConfiguracionOAS(this.settings.idPlaza);
this.oaspromos = false;
if (!this.ServicioActivo && this.settings.activarPromosEst) this.SetJSPromosEstaticos();
else this.SetJSPromoPublicidad();
this.medidasHash = new HashTable();
//this.Carga_OAS_RICH();
//this.EscribeIP();
this.EscribeAdnxs_uid();
plataform = this.getPlataform();
//this.publisherid = this.ValorPublisherId();
//this.cookeEspecial = this.getCookieValid();
sitepage = this.settings.sitePage;
this.adCSS();
}
GRAnuncio.prototype.adCSS = function() {
if (this.settings.tagsxportada.indexOf('x21') > -1 && this.settings.scopeformato.indexOf('articulo') > -1) {
var styleAdCSS = document.createElement('style');
styleAdCSS.setAttribute("id", "styleAdCSS");
if (plataform == 'webdesktop') {
styleAdCSS.textContent = '#Bloque_IN_Publicidad_Main[style*="1 / 1"]{margin-top:-116px;}#Bloque_IN_Publicidad{min-height:125px!Important;}#Bloque_IN_Publicidad_Main[style*="grid-row-start: 1"]{margin-top:-116px;}#Bloque_IN_Publicidad{min-height:125px!Important;}';
if (document.location.href.indexOf('md5=') > -1) {
//if (this.settings.categoriadir != 'centenarius') {
styleAdCSS.textContent += '.gr_contenido_de_articulo{margin-top:159px;padding-top:54px;}.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main){margin-top:20px;padding-top:40px;}';
//}
}
styleAdCSS.textContent += '.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main[style*="1 / 1"]){margin-top:20px;padding-top:40px;}.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main[style*="grid-row-start: 1"]){margin-top:20px;padding-top:40px;}';
} else {
styleAdCSS.textContent = '@media screen and (max-width: 640px){#Bloque_IN_Publicidad_Main[style*="1 / 1"]{margin-top:-77px;}#Bloque_IN_Publicidad_Main[style*="grid-row-start: 1"]{margin-top:-77px;}#Bloque_IN_Publicidad{margin-top:0;min-height:calc((100vw * 0.35313));margin-bottom:0;}';
if (document.location.href.indexOf('md5=') > -1) {
styleAdCSS.textContent += '.gr_contenido_de_articulo{margin-top:calc((100vw * 0.35313) + 42px);padding-top:0;}.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main){margin-top:20px;padding-top:0;}';
}
styleAdCSS.textContent += '.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main[style*="1 / 1"]){margin-top:20px;padding-top:0;}.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main[style*="grid-row-start: 1"]){margin-top:20px;padding-top:0;}}';
styleAdCSS.textContent += '@media screen and (min-width: 641px){';
if (document.location.href.indexOf('md5=') > -1) {
styleAdCSS.textContent += '.gr_contenido_de_articulo{margin-top:269px;padding-top:40px;}.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main){margin-top:20px;}';
}
styleAdCSS.textContent += '.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main[style*="1 / 1"]){margin-top:20px;}.gr_contenido_de_articulo:has(div#Bloque_IN_Publicidad_Main[style*="grid-row-start: 1"]){margin-top:20px;}}';
}
document.head.appendChild(styleAdCSS);
}
}
var adBlockers = false;
//load ast.js - async
(function () {
var d = document, e = d.createElement('script'), p = d.getElementsByTagName('head')[0];
e.type = 'text/javascript'; e.async = true;
e.src = '//acdn.adnxs.com/ast/ast.js';
e.onerror = function (event) { setTimeout(function () { GetListJSON(); }, 1700); adBlockers = true; console.log('Ast.JS Bloqueado por Adblockers'); }
p.insertBefore(e, p.firstChild);
})();
//create empty apntag object if it doesn't exist
var apntag = apntag || {};
//create a queue on the apntag object
apntag.anq = apntag.anq || [];
var cX = cX || {}; cX.callQueue = cX.callQueue || [];
cX.callQueue.push(['invoke', function () {
//var segments = cX.getUserSegmentIds({ persistedQueryId: '5fc56e5e123b017796c30a59ed995d65b00d4aea' });
//// TODO: Do something with the segment ids:
//for (var i = 0; i < segments.length; i++) {
// segments[i] = 'cxsegment_' + segments[i];
//}
var segmentsCookies = cX.getUserSegmentIds({ persistedQueryId: '5fc56e5e123b017796c30a59ed995d65b00d4aea' });
// TODO: Do something with the segment ids:
for (var i = 0; i < segmentsCookies.length; i++) {
segmentsCookies[i] = '"' + segmentsCookies[i] + '"';
}
// Create Cookie Segemnts
document.cookie = "paramCX=" + segmentsCookies.toString();
// Pixel Script
//var d = document, e = d.createElement('script'), p = d.getElementsByTagName('head')[0];
//e.type = 'text/javascript';
//e.src = 'https://secure.adnxs.com/seg?id=' + grAnuncio.Get_Cookie("uidappnexus") + '&add_code=' + segments.toString() + '&member=' + grAnuncio.settings.member + '&t=1';
//p.insertBefore(e, p.firstChild);
}]);
GRAnuncio.prototype.EsStage = function() {
if (document.domain.indexOf('.com') > -1) {
this.settings.esStage = false;
}
else {
this.settings.esStage = true;
}
}
GRAnuncio.prototype.XDomainSite = function() {
if (this.settings.esStage) return false;
else if (this.settings.urlHostXML == null) return false;
else {
if (this.settings.urlHostXML.indexOf(document.domain) > -1) {
return false;
}
else {
return true;
}
}
}
GRAnuncio.prototype.stageBasePub = function() {
if (this.settings.urlHostXMLPublicidad != null) {
this.NtroHost = this.settings.urlHostXMLPublicidad;
}
else {
var host = window.location.href;
var pathfolder = '';
var posicion = host.indexOf(".com");
this.NtroHost = location.protocol + "//" + document.domain + "/";
posicion = host.indexOf("operacionesinternet");
if (posicion > -1) { this.NtroHost = "http://operacionesinternet/stage/cancha/"; this.EsStage = true; }
if (host.indexOf("operacionesinternet") > -1 && window.location.pathname.indexOf("cancha") > -1)
{ this.NtroHost = "http://operacionesinternet/stage/cancha/"; this.EsStage = true; }
if (host.indexOf("operacionesinternet") > -1 && window.location.pathname.indexOf("negocios") > -1)
{ this.NtroHost = "http://operacionesinternet/stage/negocios/"; this.EsStage = true; }
if (host.indexOf("operacionesinternet") > -1 && window.location.pathname.indexOf("elnorte") > -1)
{ this.NtroHost = "http://operacionesinternet/stage/elnorte/"; this.EsStage = true; }
if (host.indexOf("operacionesinternet") > -1 && window.location.pathname.indexOf("reforma") > -1)
{ this.NtroHost = "http://operacionesinternet/stage/reforma/"; this.EsStage = true; }
if (host.indexOf("operacionesinternet") > -1 && window.location.pathname.indexOf("mural") > -1)
{ this.NtroHost = "http://operacionesinternet/stage/mural/"; this.EsStage = true; }
posicion = host.indexOf("intranetwebdevopint");
if (posicion > -1) {
if (window.location.pathname.indexOf("stage"))
this.NtroHost = "http://intranetwebdevopint/stage/cancha/";
else
this.NtroHost = "http://intranetwebdevopint/webs/cancha/";
this.EsStage = true;
}
if (host.indexOf("intranetwebdevopint") > -1) {
pathfolder = window.location.pathname.indexOf("stage") > -1 ? "stage" : "webs";
if (window.location.pathname.indexOf("cancha") > -1) { this.NtroHost = "http://intranetwebdevopint/" + pathfolder + "/cancha/"; }
if (window.location.pathname.indexOf("negocios") > -1) { this.NtroHost = "http://intranetwebdevopint/" + pathfolder + "/negocios/"; }
if (window.location.pathname.indexOf("elnorte") > -1) { this.NtroHost = "http://intranetwebdevopint/" + pathfolder + "/elnorte/"; }
if (window.location.pathname.indexOf("reforma") > -1) { this.NtroHost = "http://intranetwebdevopint/" + pathfolder + "/reforma/"; }
if (window.location.pathname.indexOf("mural") > -1) { this.NtroHost = "http://intranetwebdevopint/" + pathfolder + "/mural/"; }
this.EsStage = true;
}
/*posicion = host.indexOf("localhost");
if (posicion > -1) { this.NtroHost = "http://intranetwebdevopint/stage/cancha/"; }*/
posicion = host.indexOf("localhost");
if (posicion > -1) { this.NtroHost = "http://localhost:52590/Publicidad2013/"; this.EsStage = true; }
posicion = host.indexOf("prueba.agenciareforma.com");
if (posicion > -1) { this.NtroHost = location.protocol + "//prueba.agenciareforma.com/Webs/ElNorte/cancha/"; this.HostExt = true; }
posicion = host.indexOf("busquedas.gruporeforma.com/canchacom/");
if (posicion > -1) { this.NtroHost = location.protocol + "//busquedas.gruporeforma.com/canchacom/"; this.HostExt = true; }
posicion = host.indexOf("busquedas.gruporeforma.com/negocioscom/");
if (posicion > -1) { this.NtroHost = location.protocol + "//busquedas.gruporeforma.com/negocioscom/"; this.HostExt = true; }
posicion = host.indexOf("busquedas.gruporeforma.com/elnorte/");
if (posicion > -1) { this.NtroHost = location.protocol + "//busquedas.gruporeforma.com/elnorte/"; this.HostExt = true; }
posicion = host.indexOf("busquedas.gruporeforma.com/reforma/");
if (posicion > -1) { this.NtroHost = location.protocol + "//busquedas.gruporeforma.com/reforma/"; this.HostExt = true; }
posicion = host.indexOf("busquedas.gruporeforma.com/mural/");
if (posicion > -1) { this.NtroHost = location.protocol + "//busquedas.gruporeforma.com/mural/"; this.HostExt = true; }
}
}
GRAnuncio.prototype.LeeXMLPublicidad = function(rutaxml) {
var refreshxml = new Date();
if (window.XMLHttpRequest) {
miXMLHttpRequest = new XMLHttpRequest();
}
else {
miXMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
miXMLHttpRequest.onload = function(){
if (miXMLHttpRequest.readyState == 4 && miXMLHttpRequest.status == 200) {
//return miXMLHttpRequest.responseXML;
xmlDocConsole = miXMLHttpRequest.responseXML;
GRAnuncio.prototype.XMLToArreglo();
publisherid = GRAnuncio.prototype.ValorPublisherId();
}
}
miXMLHttpRequest.open("GET", rutaxml + "?" + refreshxml.getTime());
miXMLHttpRequest.send();
miXMLHttpRequest.onerror = function (event) { adBlockers = true; console.log('Lectura de PublicicdadConsole.XML Bloqueado por AdBlockers'); }
}
GRAnuncio.prototype.XMLToArreglo = function() {
/*if (this.xmlDoc != null) {
this.ObjConfig = this.GetConfiGral();
this.ObjComerciales = this.GetComercial();
}*/
if (xmlDocConsole != null) {
ServicioActivo = this.GetServicio() == "0" ? true : false;
temaEspecialHeader = this.GetTagTema() == "1" ? true : false;
audioEspecialHeader = this.GetAudioTagTema();
ConsoleUsIntActivo = this.GetTagActivarUsInt() == "1" ? true : false;
ObjConfigConsole = this.GetConfiGralConsole();
ObjCategorias = this.GetCategoriasCMS();
ObjPublisherId = this.GetPublisherId();
ObjIdTipoElemento = this.GetIdTipoElemento();
AdsReady = true;
}
}
GRAnuncio.prototype.GetServicio = function() {
var ObjService = new Array();
var NodoError = xmlDocConsole.getElementsByTagName("sinservicio");
if (NodoError != undefined) {
if (NodoError.length > 0) {
return NodoError[0].firstChild.nodeValue;
}
else {
return "0";
}
}
return "0";
}
GRAnuncio.prototype.GetTagTema = function() {
var NodoError = xmlDocConsole.getElementsByTagName("activarTemaEspecial");
if (NodoError != undefined) {
if (NodoError.length > 0) {
return NodoError[0].firstChild.nodeValue;
}
else {
return "0";
}
}
return "0";
}
GRAnuncio.prototype.GetTagActivarUsInt = function () {
var NodoError = xmlDocConsole.getElementsByTagName("activarConsoleUsInt");
if (NodoError != undefined) {
if (NodoError.length > 0) {
return NodoError[0].firstChild.nodeValue;
}
else {
return "0";
}
}
return "0";
}
GRAnuncio.prototype.GetAudioTagTema = function () {
var NodoError = xmlDocConsole.getElementsByTagName("audioTemaEspecial");
if (NodoError != undefined) {
if (NodoError.length > 0) {
return NodoError[0].firstChild.nodeValue;
}
else {
return "1";
}
}
return "1";
}
GRAnuncio.prototype.GetConfiGralConsole = function () {
ObjConfGralConsole = new Array();
var NodoConfigConsole = null;
NodoConfigConsole = xmlDocConsole.getElementsByTagName("config_gral");
var NodoHijoConfConsole = null;
for (i = 0; i < NodoConfigConsole.length; i++) {
if (NodoConfigConsole[i].nodeType == 1) {
NodoHijoConfConsole = NodoConfigConsole[i].childNodes;
for (j = 0; j < NodoHijoConfConsole.length; j++) {
if (NodoHijoConfConsole[j].nodeType == 1) {
if (NodoHijoConfConsole[j].attributes.length > 0) {
var estatus_Conf = NodoHijoConfConsole[j].attributes.getNamedItem("estatus") ? NodoHijoConfConsole[j].attributes.getNamedItem("estatus").nodeValue : null;
var valor_Conf = NodoHijoConfConsole[j].attributes.getNamedItem("valor") ? NodoHijoConfConsole[j].attributes.getNamedItem("valor").nodeValue : null;
var ancho_Conf = NodoHijoConfConsole[j].attributes.getNamedItem("ancho") ? NodoHijoConfConsole[j].attributes.getNamedItem("ancho").nodeValue : null;
var alto_Conf = NodoHijoConfConsole[j].attributes.getNamedItem("alto") ? NodoHijoConfConsole[j].attributes.getNamedItem("alto").nodeValue : null;
var zona_Conf = NodoHijoConfConsole[j].attributes.getNamedItem("zona") ? NodoHijoConfConsole[j].attributes.getNamedItem("zona").nodeValue : null;
var equivalencia_Conf = NodoHijoConfConsole[j].attributes.getNamedItem("equivalencia") ? NodoHijoConfConsole[j].attributes.getNamedItem("equivalencia").nodeValue : null;
var OAS_Conf = NodoHijoConfConsole[j].attributes.getNamedItem("OAS") ? NodoHijoConfConsole[j].attributes.getNamedItem("OAS").nodeValue : null;
ObjConfGralConsole.push(this.CreaNodoConfigConsole(estatus_Conf, valor_Conf, ancho_Conf, alto_Conf, zona_Conf, equivalencia_Conf, OAS_Conf));
}
}
}
}
}
return ObjConfGralConsole;
}
GRAnuncio.prototype.GetCategoriasCMS = function () {
ObjCategoriasCMS = new Array();
var NodoCategorias = null;
NodoCategorias = xmlDocConsole.getElementsByTagName("categorias");
var NodoHijoCategorias = null;
for (i = 0; i < NodoCategorias.length; i++) {
if (NodoCategorias[i].nodeType == 1) {
NodoHijoCategorias = NodoCategorias[i].childNodes;
for (j = 0; j < NodoHijoCategorias.length; j++) {
if (NodoHijoCategorias[j].nodeType == 1) {
if (NodoHijoCategorias[j].attributes.length > 0) {
var tipo_Conf = NodoHijoCategorias[j].attributes.getNamedItem("tipo") ? NodoHijoCategorias[j].attributes.getNamedItem("tipo").nodeValue : null;
var nombre_Conf = NodoHijoCategorias[j].attributes.getNamedItem("nombre") ? NodoHijoCategorias[j].attributes.getNamedItem("nombre").nodeValue : null;
var arcocategoria_Conf = NodoHijoCategorias[j].attributes.getNamedItem("arcocategoria") ? NodoHijoCategorias[j].attributes.getNamedItem("arcocategoria").nodeValue : null;
var arcosubcategoria_Conf = NodoHijoCategorias[j].attributes.getNamedItem("arcosubcategoria") ? NodoHijoCategorias[j].attributes.getNamedItem("arcosubcategoria").nodeValue : null;
var OAS_Conf = NodoHijoCategorias[j].attributes.getNamedItem("OAS") ? NodoHijoCategorias[j].attributes.getNamedItem("OAS").nodeValue : null;
var anchorTopCat_Conf = NodoHijoCategorias[j].attributes.getNamedItem("anchorTopCat") ? NodoHijoCategorias[j].attributes.getNamedItem("anchorTopCat").nodeValue : null;
var anchorBottomCat_Conf = NodoHijoCategorias[j].attributes.getNamedItem("anchorBottomCat") ? NodoHijoCategorias[j].attributes.getNamedItem("anchorBottomCat").nodeValue : null;
var anchorTopSubCat_Conf = NodoHijoCategorias[j].attributes.getNamedItem("anchorTopSubCat") ? NodoHijoCategorias[j].attributes.getNamedItem("anchorTopSubCat").nodeValue : null;
var anchorBottomSubCat_Conf = NodoHijoCategorias[j].attributes.getNamedItem("anchorBottomSubCat") ? NodoHijoCategorias[j].attributes.getNamedItem("anchorBottomSubCat").nodeValue : null;
var videoOutStream_Conf = NodoHijoCategorias[j].attributes.getNamedItem("videoOutStream") ? NodoHijoCategorias[j].attributes.getNamedItem("videoOutStream").nodeValue : null;
var adArticulo_Conf = NodoHijoCategorias[j].attributes.getNamedItem("adArticulo") ? NodoHijoCategorias[j].attributes.getNamedItem("adArticulo").nodeValue : null;
ObjCategoriasCMS.push(this.CreaNodoCategorias(tipo_Conf, nombre_Conf, arcocategoria_Conf, arcosubcategoria_Conf, OAS_Conf, anchorTopCat_Conf, anchorBottomCat_Conf, anchorTopSubCat_Conf, anchorBottomSubCat_Conf, videoOutStream_Conf, adArticulo_Conf));
}
}
}
}
}
return ObjCategoriasCMS;
}
GRAnuncio.prototype.GetPublisherId = function () {
var ObjPublisherId = new Array();
var NodoPublisherId = null;
NodoPublisherId = xmlDocConsole.getElementsByTagName("publisherId");
var NodoHijoPublisherId = null;
for (i = 0; i < NodoPublisherId.length; i++) {
if (NodoPublisherId[i].nodeType == 1) {
NodoHijoPublisherId = NodoPublisherId[i].childNodes;
for (j = 0; j < NodoHijoPublisherId.length; j++) {
if (NodoHijoPublisherId[j].nodeType == 1) {
if (NodoHijoPublisherId[j].attributes.length > 0) {
var tipo_Conf = NodoHijoPublisherId[j].attributes.getNamedItem("tipo") ? NodoHijoPublisherId[j].attributes.getNamedItem("tipo").nodeValue : null;
var plaza_Conf = NodoHijoPublisherId[j].attributes.getNamedItem("plaza") ? NodoHijoPublisherId[j].attributes.getNamedItem("plaza").nodeValue : null;
var id_Conf = NodoHijoPublisherId[j].attributes.getNamedItem("id") ? NodoHijoPublisherId[j].attributes.getNamedItem("id").nodeValue : null;
ObjPublisherId.push(this.CreaNodoPublisherId(tipo_Conf, plaza_Conf, id_Conf));
}
}
}
}
}
return ObjPublisherId;
}
GRAnuncio.prototype.GetIdTipoElemento = function () {
ObjIdTipoElemento = new Array();
var NodoidTipoElemento = null;
NodoidTipoElemento = xmlDocConsole.getElementsByTagName("idTipoElemento");
var NodoHijoIdTipoElemento = null;
for (i = 0; i < NodoidTipoElemento.length; i++) {
if (NodoidTipoElemento[i].nodeType == 1) {
NodoHijoIdTipoElemento = NodoidTipoElemento[i].childNodes;
for (j = 0; j < NodoHijoIdTipoElemento.length; j++) {
if (NodoHijoIdTipoElemento[j].nodeType == 1) {
if (NodoHijoIdTipoElemento[j].attributes.length > 0) {
var nombre_Conf = NodoHijoIdTipoElemento[j].attributes.getNamedItem("nombre") ? NodoHijoIdTipoElemento[j].attributes.getNamedItem("nombre").nodeValue : null;
var id_Conf = NodoHijoIdTipoElemento[j].attributes.getNamedItem("id") ? NodoHijoIdTipoElemento[j].attributes.getNamedItem("id").nodeValue : null;
ObjIdTipoElemento.push(this.CreaNodoidTipoElemento(nombre_Conf, id_Conf));
}
}
}
}
}
return ObjIdTipoElemento;
}
GRAnuncio.prototype.CreaNodoConfigConsole = function (estatus, valor, ancho, alto, zona, equivalencia, OAS) {
var ConfigConsoleNodo = {};
ConfigConsoleNodo.estatus = estatus;
ConfigConsoleNodo.valor = valor;
ConfigConsoleNodo.ancho = ancho;
ConfigConsoleNodo.alto = alto;
ConfigConsoleNodo.zona = zona;
ConfigConsoleNodo.equivalencia = equivalencia;
ConfigConsoleNodo.OAS = OAS;
return ConfigConsoleNodo;
}
GRAnuncio.prototype.CreaNodoCategorias = function (tipo, nombre, arcocategoria, arcosubcategoria, OAS, anchorTopCat, anchorBottomCat, anchorTopSubCat, anchorBottomSubCat, videoOutStream, adArticulo) {
var CategoriasNodo = {};
CategoriasNodo.tipo = tipo;
CategoriasNodo.nombre = nombre;
CategoriasNodo.arcocategoria = arcocategoria;
CategoriasNodo.arcosubcategoria = arcosubcategoria;
CategoriasNodo.OAS = OAS;
CategoriasNodo.anchorTopCat = anchorTopCat;
CategoriasNodo.anchorBottomCat = anchorBottomCat;
CategoriasNodo.anchorTopSubCat = anchorTopSubCat;
CategoriasNodo.anchorBottomSubCat = anchorBottomSubCat;
CategoriasNodo.videoOutStream = videoOutStream;
CategoriasNodo.adArticulo = adArticulo;
return CategoriasNodo;
}
GRAnuncio.prototype.CreaNodoPublisherId = function (tipo, plaza, id) {
var PublisherIdNodo = {};
PublisherIdNodo.tipo = tipo;
PublisherIdNodo.plaza = plaza;
PublisherIdNodo.id = id;
return PublisherIdNodo;
}
GRAnuncio.prototype.CreaNodoidTipoElemento = function (nombre, id) {
var idTipoElementoNodo = {};
idTipoElementoNodo.nombre = nombre;
idTipoElementoNodo.id = id;
return idTipoElementoNodo;
}
GRAnuncio.prototype.BuscaEle_OASlistpos = function(pos) {
/*var array_pos;
array_pos = auxp_OAS_listpos.split(',');
for (l = 0; l < array_pos.length; l++) {
if (array_pos[l] == pos)
return true;
}*/
if (pos == 'x121') {
/*if (xmlDocConsole != null) {
if (ObjConfigConsole != null) {
for (i = 0; i < ObjConfigConsole.length; i++) {
if (ObjConfigConsole[i].valor == pos) {
if (ObjConfigConsole[i].estatus == '1')
{ return true; }
}
}
}
}*/
return true;
}
return false;
}
GRAnuncio.prototype.ConfiguracionOAS = function(_idPlaza) {
/*if (!ServicioActivo)
return;
OAS_url = location.protocol + '//ads.gruporeforma.com/';
OAS_listpos = this.GetOASListapos();
auxp_OAS_listpos = OAS_listpos;
OAS_query = '';*/
OAS_sitepage = this.GetSitePageCom();
/*OAS_version = 11;
OAS_rn = '001234567890'; OAS_rns = '1234567890';
OAS_rn = new String(Math.random()); OAS_rns = OAS_rn.substring(2, 11);
this.AddMsg();*/
}
GRAnuncio.prototype.GetSitePageCom = function(tipoZona, orden) {
var dirSitePage = '';
var auxsitePage = this.settings.sitePage;
//dirSitePage = auxsitePage.toString().toLowerCase() + '/noticias/';
dirSitePage = auxsitePage.toString().toLowerCase() + '/' + this.settings.folderScope;
var pathScope = this.GetDirectorio();
dirSitePage += pathScope;
if (tipoZona != undefined && tipoZona != null) {
dirSitePage += '/' + tipoZona + '/';
}
if (orden != undefined && orden != null && tipoZona != undefined && tipoZona != null) {
dirSitePage += orden;
}
else if (orden != undefined && orden != null) {
dirSitePage += '/' + orden;
}
return dirSitePage;
}
GRAnuncio.prototype.GetDirectorio = function() {
var directoriopub = '';
switch (this.settings.scopeformato) {
case 'portadah':
directoriopub = 'portada';
break;
case 'portadac':
directoriopub = this.settings.categoriadir.toLowerCase();
break;
case 'portadas':
directoriopub = this.settings.categoriadir.toLowerCase() + '/' + this.settings.subcategoriadir.toLowerCase();
break;
case 'edicionimpresa': case 'busquedas': case 'radio': case 'concentradora/noticias': case 'concentradora/galeriamm': case 'concentradora/fotogaleria':
directoriopub = this.settings.scopeformato;
break;
case 'articulo': case 'fotogaleria': case 'galeriamm': case 'foro':
directoriopub = this.settings.scopeformato + '/' + this.settings.categoriadir.toLowerCase() + '/' + this.settings.subcategoriadir.toLowerCase() + '/' + this.settings.idelementosubcategoria;
break;
case 'articulo/editoriales/cancha':
directoriopub = this.settings.scopeformato + '/' + this.settings.idelementosubcategoria;
break;
case 'carton/editoriales/cancha':
directoriopub = this.settings.scopeformato + '/' + this.settings.categoriadir.toLowerCase();
break;
case 'graficoanimado':
directoriopub = 'flash/' + this.settings.categoriadir.toLowerCase();
break;
case 'coberturas':
directoriopub = this.settings.categoriadir.toLowerCase() + '/' + this.settings.subcategoriadir.toLowerCase() + '/' + this.settings.idelementosubcategoria;
break;
}
return directoriopub;
}
var contadorVideoArticulo = 0;
GRAnuncio.prototype.CONSOLE_AD = function (pos, ancho, alto, equivalencia) {
keywords = this.GetKeywords();
var orden = '';
var datosplacement = this.getPlacement(orden, equivalencia);
placement = datosplacement[0];
try {
if (this.settings.esStage) return;
if (pos == 'x101') {
var texto = $('#texto').length;
var textoPano = $('#textoPano').length;
var iphoneCol960 = $('.col960').length;
var idDefinido = document.getElementById(placement);
if (idDefinido == undefined) {
if (texto == 1) {
$("#texto").append('
');
} else {
if (textoPano == 1) {
$("#textoPano").append('');
} else {
if (iphoneCol960 == 1) {
$(".col960").append('');
}
}
}
} else {
$(".col960").append('');
}
//this.asignarPorBr(placement);
//declara el ancho y alto del div padre
var anchoDiv = document.getElementById(placement + "Div").clientWidth;
var altoDiv = document.getElementById(placement + "Div").clientHeight;
//declara el ancho y alto del div hijo
var anchoPlacement = document.getElementById(placement).clientWidth;
var altoPlacement = document.getElementById(placement).clientHeight;
//resizePlacement
if (anchoDiv == anchoPlacement && altoDiv == altoPlacement) { } else {
resizePlacement();
}
if (window.innerWidth < 415) {
var idDefinidoM = document.getElementById(placement + 'M');
if (idDefinidoM == undefined) { } else {
this.getPlacementConsole(pos, placement, placement + 'M', ancho, alto, keywords);
}
} else {
if (contadorVideoArticulo == 0){
this.getPlacementConsole(pos, placement, placement, ancho, alto, keywords);
contadorVideoArticulo++;
}
}
} else {
//document.write('');
this.getPlacementConsole(pos, placement, placement, ancho, alto, keywords);
}
//document.write('');
//this.HitMonitorOASConsole(OAS_sitepage, pos, placement, keywords, false);
//this.getPlacementConsole(pos, placement, placement, ancho, alto, keywords);
}
catch (ex) {
}
}
GRAnuncio.prototype.Carga_OAS_RICH = function() {
}
GRAnuncio.prototype.Carga_OAS_RICH2 = function() {
}
GRAnuncio.prototype.DisplayAdsStage = function (tag) {
switch (tag) {
case 'x01': case 'x02': case 'x03': case 'x04':
document.write("PUBLICIDAD
180x60
"); break;
case 'x11': case 'x12': case 'x13': case 'x14': case 'x15':
document.write("PUBLICIDAD
300x100
"); break;
case 'x23': case 'x91': case 'x92': case 'x93': case 'x94': case 'x95': /*case 'x101':*/ case 'x102': case 'x103': case 'x105': case 'x107':
document.write("PUBLICIDAD
300x250
"); break;
case 'x21':
document.write("PUBLICIDAD
728x90
"); break;
case 'x25':
document.write("PUBLICIDAD
683x60
"); break;
case 'x05':
document.write("PUBLICIDAD
1x1
"); break;
case 'x131': case 'x98': case 'x99': case 'x106': case 'x108':
document.write("PUBLICIDAD
300x530
"); break;
case 'x96': case 'x97':
document.write("PUBLICIDAD
630x250
"); break;
case 'x100':
document.write("PUBLICIDAD
960x250
"); break;
case 'x117':
document.write("PUBLICIDAD
960x70
"); break;
case 'x114':
document.write("PUBLICIDAD
960x530
"); break;
}
}
GRAnuncio.prototype.DisplayAds = function(posicionanuncio, ponerPromo) {
if (posicionanuncio == 'x101') {
var texto = $('#texto').length;
var textoPano = $('#textoPano').length;
var iphoneCol960 = $('.col960').length;
if (texto == 1) {
$("#texto").append('');
} else {
if (textoPano == 1) {
$("#textoPano").append('');
} else {
if (iphoneCol960 == 1) {
$(".col960").append('');
}
}
}
} else {
//document.write('');
if(document.currentScript == undefined){
document.write('');
}else{
document.currentScript.parentElement.innerHTML += '';
}
}
listJsonPlacements.push({"posicionanuncio":posicionanuncio,"ponerPromo":ponerPromo,"tipoZona":null,"orden":null,"ancho":null,"alto":null,"targetIdDiv":posicionanuncio,"implementado":false});
/*ponerPromo = (typeof ponerPromo == 'undefined') ? true : ponerPromo;
var datosEstatusByPosicion = this.GetEstatusByPosicion(posicionanuncio, null);
var estatus = datosEstatusByPosicion[0];
var equivalencia = datosEstatusByPosicion[1];
var altoXML = datosEstatusByPosicion[2];
var anchoXML = datosEstatusByPosicion[3];
var OASActivo = datosEstatusByPosicion[4];
if (estatus) {
if (this.settings.esStage) {
this.DisplayAdsStage(posicionanuncio);
}
else {
if (this.xdomain) {
this.DisplayAdsExt(posicionanuncio, ponerPromo, anchoXML, altoXML, '', '', OASActivo, equivalencia);
}
else {
if (!ServicioActivo) {
if (this.settings.activarPromos && ponerPromo) {
this.DisplayPromoPublicidad(posicionanuncio);
}
}
else {
if (!OASActivo) {
if (posicionanuncio == 'x09' || posicionanuncio == 'x06') {
this.OrdenEspecial.push('1');
document.getElementsByTagName('body')[0].style.height = '0';
document.getElementsByTagName('html')[0].style.height = '0';
}
if (posicionanuncio == 'x10') { this.OrdenEspecial.push('3'); }
this.CONSOLE_AD(posicionanuncio, anchoXML, altoXML, equivalencia);
} else {
if (this.settings.activarPromos && ponerPromo/) {
this.DisplayPromoPublicidad(posicionanuncio);
}}
}}
}
} else {
if (this.settings.esStage) {
this.DisplayAdsStage(posicionanuncio);
}
}*/
}
GRAnuncio.prototype.DisplayAds2 = function(posicionanuncio, ponerPromo, tipoZona, orden, ancho, alto) {
if (this.settings.subcategoriadir == 'wsj') {
if(document.currentScript == undefined){
document.write('');
}else{
document.currentScript.parentElement.innerHTML += '';
}
}else{
if(document.currentScript == undefined){
document.write('');
}else{
document.currentScript.parentElement.innerHTML += '';
}
listJsonPlacements.push({"posicionanuncio":posicionanuncio,"ponerPromo":ponerPromo,"tipoZona":tipoZona,"orden":orden,"ancho":ancho,"alto":alto,"targetIdDiv":posicionanuncio + tipoZona + orden,"implementado":false});
}
/*ponerPromo = (typeof ponerPromo == 'undefined') ? true : ponerPromo;
tipoZona = (typeof tipoZona == 'undefined') ? null : tipoZona;
orden = (typeof orden == 'undefined') ? null : orden;
var datosEstatusByPosicion = this.GetEstatusByPosicion(posicionanuncio, tipoZona);
var estatus = datosEstatusByPosicion[0];
var equivalencia = datosEstatusByPosicion[1];
var altoXML = datosEstatusByPosicion[2];
var anchoXML = datosEstatusByPosicion[3];
var OASActivo = datosEstatusByPosicion[4];
if (estatus) {
if (this.settings.esStage) {
this.DisplayAdsStage(posicionanuncio);
}
else {
if (this.xdomain) {
this.DisplayAdsExt(posicionanuncio, ponerPromo, ancho, alto, tipoZona, orden, OASActivo, equivalencia);
}
else {
if (!ServicioActivo) {
if (this.settings.activarPromos && ponerPromo) {
this.DisplayPromoPublicidad(posicionanuncio);
}
}
else {
if(!OASActivo){
this.Carga_ConsoleNexusPortada(posicionanuncio, anchoXML, altoXML, tipoZona, orden, equivalencia);
}else{
if (this.settings.activarPromos && ponerPromo) {
this.DisplayPromoPublicidad(posicionanuncio);
}}
}
}
}
} else {
if (this.settings.esStage) {
this.DisplayAdsStage(posicionanuncio);
}
}*/
}
var contadorHubArticulo = 0;
GRAnuncio.prototype.Carga_ConsoleNexusPortada = function (tag, ancho, alto, tipozona, orden, equivalencia) {
try {
if (this.settings.esStage) return;
keywords = this.GetKeywords();
var datosplacement = this.getPlacement(orden, equivalencia);
placement = datosplacement[0];
//document.write('');
//this.HitMonitorOASConsole(OAS_sitepage, tag, placement, keywords, false);
//if (this.settings.scopeformato == 'concentradora/noticias') {
//document.write('');
//} else {
if (placement.indexOf('articulo_hub') > -1 || placement.indexOf('articulo_leaderboard') > -1 || equivalencia.indexOf('articulo') > -1) {
var idDefinido = document.getElementById(placement);
if (idDefinido == undefined) {
//document.write('');
} else {
//document.write('');
}
if (/*/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || */window.innerWidth < 415) {
var idDefinidoM = document.getElementById(placement + 'M');
if (idDefinidoM == undefined) {
setTimeout(function () {
if (contadorHubArticulo == 0) {
placement = placement.replace('outstream1_h1x1', 'hub1_t1x1');
var idDefinidoSetT = document.getElementById(placement + 'M');
if (idDefinidoSetT == undefined) {
var keywordsn2 = grAnuncio.GetKeywords();
//grAnuncio.getPlacementConsole('x91', placement, placement, '300', '250', keywordsn2);
contadorHubArticulo++;
}
}
}, 1500);
} else {
this.getPlacementConsole(tag, placement, placement + 'M', ancho, alto, keywords);
if (placement.indexOf('articulo_leaderboard') > -1) {
resizePlacement();
}
}
} else {
if (contadorHubArticulo == 0) {
this.getPlacementConsole(tag, placement, placement, ancho, alto, keywords);
contadorHubArticulo++;
}
}
//declara el ancho y alto del div padre
var anchoDiv = document.getElementById(placement + "Div").clientWidth;
var altoDiv = document.getElementById(placement + "Div").clientHeight;
//declara el ancho y alto del div hijo
var anchoPlacement = document.getElementById(placement).clientWidth;
var altoPlacement = document.getElementById(placement).clientHeight;
//resizePlacement
if (anchoDiv == anchoPlacement && altoDiv == altoPlacement) { } else {
resizePlacement();
}
} else {
//document.write('');
this.getPlacementConsole(tag, placement, placement, ancho, alto, keywords);
//declara el ancho y alto del div padre
var anchoDiv = document.getElementById(placement + "Div").clientWidth;
var altoDiv = document.getElementById(placement + "Div").clientHeight;
//declara el ancho y alto del div hijo
var anchoPlacement = document.getElementById(placement).clientWidth;
var altoPlacement = document.getElementById(placement).clientHeight;
//resizePlacement
if (anchoDiv == anchoPlacement && altoDiv == altoPlacement) { } else {
resizePlacement();
}
}
//}
}
catch (ex) {
alert(ex);
}
}
GRAnuncio.prototype.DisplayAdsExt = function(posicionanuncio, ponerPromo, ancho, alto) {
if(document.currentScript == undefined){
document.write('');
}else{
document.currentScript.parentElement.innerHTML += '';
}
listJsonPlacements.push({"posicionanuncio":posicionanuncio,"ponerPromo":ponerPromo,"tipoZona":null,"orden":null,"ancho":ancho,"alto":alto,"targetIdDiv":posicionanuncio,"implementado":false});
}
GRAnuncio.prototype.DisplayPromoPublicidad = function(posicionanuncio, _ancho, _alto, idIframe) {
var anuncio_config = null;
if (_ancho != undefined && _alto != undefined) {
anuncio_config = { ancho: _ancho, alto: _alto };
}
else {
anuncio_config = this.GetMedidasPublicidad(posicionanuncio);
}
if (anuncio_config != null) {
var objetoFoto = this.getFotoCropByMedida(anuncio_config.ancho, anuncio_config.alto);
if (objetoFoto != null) {
if (idIframe != undefined) {
try {
var ifrm = document.getElementById(idIframe);
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.open();
if (this.oaspromos)
ifrm.document.write('');
else
ifrm.document.write('');
if (objetoFoto.Imagen.toLowerCase().indexOf('http://') > -1 || objetoFoto.Imagen.toLowerCase().indexOf('https://') > -1)
ifrm.document.write('');
else
ifrm.document.write('');
ifrm.document.write('');
ifrm.document.close();
}
catch (ex) { }
}
else {
if (this.oaspromos)
document.write('');
else
document.write('');
if (objetoFoto.Imagen.toLowerCase().indexOf('http://') > -1 || objetoFoto.Imagen.toLowerCase().indexOf('https://') > -1)
document.write('');
else
document.write('');
document.write('');
}
}
}
}
function DisplayPromoPublicidad(placement, _ancho, _alto) {
var anuncio_config = null;
anuncio_config = { ancho: _ancho, alto: _alto };
if (anuncio_config != null) {
var objetoFoto = getFotoCropByMedida(anuncio_config.ancho, anuncio_config.alto);
if (objetoFoto != null) {
if (placement != undefined) {
try {
var div = document.getElementById(placement);
var urlImagen;
if (objetoFoto.Imagen.toLowerCase().indexOf('http://') > -1 || objetoFoto.Imagen.toLowerCase().indexOf('https://') > -1) {
urlImagen = objetoFoto.Imagen;
} else {
//if (URLImagenes == undefined || URLImagenes == null) { URLImagenes = 'https://img.gruporeforma.com/'; }
//urlImagen = URLImagenes + '/' + objetoFoto.Imagen;
urlImagen = 'https://img.gruporeforma.com/' + objetoFoto.Imagen;
}
div.innerHTML = '';
}
catch (ex) { }
}
}
}
}
GRAnuncio.prototype.SetMostradoPromo = function(objFotoCrop) {
if (promos != undefined) {
for (var i = 0; i < promos.length; i++) {
for (var j = 0; j < promos[i].FotoCrops.length; j++) {
if (promos[i].FotoCrops[j] === objFotoCrop) {
promos[i].MostradoEnPortada = true;
}
}
}
}
}
function SetMostradoPromo(objFotoCrop) {
if (promos != undefined) {
for (var i = 0; i < promos.length; i++) {
for (var j = 0; j < promos[i].FotoCrops.length; j++) {
if (promos[i].FotoCrops[j] === objFotoCrop) {
promos[i].MostradoEnPortada = false;//se cambio por falta de promos
}
}
}
}
}
GRAnuncio.prototype.GetMostradoPromo = function(objFotoCrop) {
if (promos != undefined) {
for (var i = 0; i < promos.length; i++) {
for (var j = 0; j < promos[i].FotoCrops.length; j++) {
if (promos[i].FotoCrops[j] === objFotoCrop) {
return promos[i].MostradoEnPortada;
}
}
}
}
return false;
}
GRAnuncio.prototype.GetMedidasPublicidad = function(posicionanuncio) {
if (xmlDocConsole != null) {
if (ObjConfigConsole != null) {
if (ObjConfigConsole.length > 0) {
for (i = 0; i < ObjConfigConsole.length; i++) {
if (ObjConfigConsole[i].valor == posicionanuncio) {
return ObjConfigConsole[i];
}
}
}
}
}
return null;
}
GRAnuncio.prototype.getFotoCropByMedida = function(Ancho, Alto) {
var arrayBusqueda = this.getFotoCropByTamano(Ancho, Alto);
var aletorioEncontrado = new Array();
aletorioEncontrado = null;
if (arrayBusqueda != null && arrayBusqueda.length > 0) {
if (arrayBusqueda != undefined) {
aletorioEncontrado = this.getRandomByTamano(arrayBusqueda);
if (aletorioEncontrado != null) {
for (var i = 0; i < arrayBusqueda.length; i++) {
if (arrayBusqueda[i].Imagen == aletorioEncontrado.Imagen) {
arrayBusqueda[i].MostradoEnPortada = true;
this.SetMostradoPromo(arrayBusqueda[i]);
break;
}
}
}
}
}
return aletorioEncontrado;
}
function getFotoCropByMedida(ancho, alto) {
var medida = ancho + "x" + alto;
var arrayResultado = new Array();
var medidasHash = new HashTable();
var hashResultado = medidasHash.get(medida);
if (hashResultado == undefined) {
var index = 0;
var arrayTamanos = new Array();
arrayTamanos.length = 0;
if (typeof promos !== 'undefined') {
for (var i = 0; i < promos.length; i++) {
for (var j = 0; j < promos[i].FotoCrops.length; j++) {
if (promos[i].FotoCrops[j].Ancho == ancho && promos[i].FotoCrops[j].Alto == alto) {
arrayTamanos[index] = promos[i].FotoCrops[j];
index++;
}
}
}
}
arrayResultado = arrayTamanos;
if (arrayResultado != "")
medidasHash.set(medida, arrayResultado);
}
var arrayBusqueda = medidasHash.get(medida);
var aletorioEncontrado = new Array();
aletorioEncontrado = null;
if (arrayBusqueda != null && arrayBusqueda != undefined) {
if (arrayBusqueda.length > 0) {
var aleatorio = 0;
var indx = 0;
var fotosDisponibles = new Array();
for (i2 = 0; i2 < arrayBusqueda.length; i2++) {
var GetMostradoPromo;
if (promos != undefined) {
for (var i3 = 0; i3 < promos.length; i3++) {
for (var j2 = 0; j2 < promos[i3].FotoCrops.length; j2++) {
if (promos[i3].FotoCrops[j2] === arrayBusqueda[i3]) {
GetMostradoPromo = promos[i3].MostradoEnPortada;
}
}
}
} else { GetMostradoPromo = false }
if (arrayBusqueda[i2].MostradoEnPortada == false && !(GetMostradoPromo)) {
fotosDisponibles[indx] = arrayBusqueda[i2];
indx++;
}
}
if (fotosDisponibles.length == 0)
return null;
else (fotosDisponibles.length > 1)
aleatorio = Math.floor(Math.random() * fotosDisponibles.length);
aletorioEncontrado = fotosDisponibles[aleatorio];
if (aletorioEncontrado != null) {
for (var i4 = 0; i4 < arrayBusqueda.length; i4++) {
if (arrayBusqueda[i4].Imagen == aletorioEncontrado.Imagen) {
arrayBusqueda[i4].MostradoEnPortada = false;//se cambio por falta de promos
SetMostradoPromo(arrayBusqueda[i4]);
break;
}
}
}
}
}
return aletorioEncontrado;
}
GRAnuncio.prototype.getArrayFotoCropByTamano = function(Ancho, Alto) {
var index = 0;
var arrayTamanos = new Array();
arrayTamanos.length = 0;
if (typeof promos !== 'undefined') {
for (var i = 0; i < promos.length; i++) {
for (var j = 0; j < promos[i].FotoCrops.length; j++) {
if (promos[i].FotoCrops[j].Ancho == Ancho && promos[i].FotoCrops[j].Alto == Alto) {
arrayTamanos[index] = promos[i].FotoCrops[j];
index++;
}
}
}
}
return arrayTamanos;
}
GRAnuncio.prototype.getFotoCropByTamano = function(ancho, alto) {
var medida = ancho + "x" + alto;
var arrayResultado = new Array();
var hashResultado = this.medidasHash.get(medida);
if (hashResultado == undefined) {
arrayResultado = this.getArrayFotoCropByTamano(ancho, alto);
if (arrayResultado != "")
this.medidasHash.set(medida, arrayResultado);
}
return this.medidasHash.get(medida);
}
GRAnuncio.prototype.getRandomByTamano = function(arrayFotos) {
var aleatorio = 0;
var indx = 0;
var fotosDisponibles = new Array();
for (i = 0; i < arrayFotos.length; i++) {
if (arrayFotos[i].MostradoEnPortada == false && !(this.GetMostradoPromo(arrayFotos[i]))) {
fotosDisponibles[indx] = arrayFotos[i];
indx++;
}
}
if (fotosDisponibles.length == 0)
return null;
else (fotosDisponibles.length > 1)
aleatorio = Math.floor(Math.random() * fotosDisponibles.length);
return fotosDisponibles[aleatorio];
}
GRAnuncio.prototype.SetJSPromoPublicidad = function() {
if (this.settings.esStage) return;
if (!this.settings.activarPromos) return;
var urlHostPromoPublicidad = '';
urlHostPromoPublicidad = this.settings.urlBasePromo == null ? this.settings.urlHostXML : this.settings.urlBasePromo;
switch (this.settings.tipoPromo) {
case 'hardnews': case 'softnews': case 'suburbanas':
var d = document, e = d.createElement('script'), p = d.getElementsByTagName('head')[0];
e.type = 'text/javascript'; e.async = true;
e.src = urlHostPromoPublicidad + 'cntoffpub/Coleccion/' + this.GetIdPlazacom() + 'av103_' + this.settings.tipoPromo + '.js?' + grpubts;
p.insertBefore(e, p.firstChild);
break;
default:
var d = document, e = d.createElement('script'), p = d.getElementsByTagName('head')[0];
e.type = 'text/javascript'; e.async = true;
e.src = urlHostPromoPublicidad + 'cntoffpub/Coleccion/' + this.GetIdPlazacom() + 'av103_publicidad.js?' + grpubts;
p.insertBefore(e, p.firstChild);
break;
}
}
GRAnuncio.prototype.GetIdPlazacom = function() {
return grFunc.IdProducto;
}
GRAnuncio.prototype.CalculaSitePageProducto = function() {
if (grFunc != undefined) {
if (grFunc.IdProducto != undefined) {
switch (grFunc.IdProducto) {
case 2: this.settings.sitePage = 'elnorte'; break;
case 3: this.settings.sitePage = 'reforma'; break;
case 5: this.settings.sitePage = 'mural'; break;
}
}
}
}
GRAnuncio.prototype.SetJSPromosEstaticos = function() {
if (this.settings.esStage) return;
if (!this.settings.activarPromos) return;
var urlHostPromoPublicidad = '';
urlHostPromoPublicidad = this.settings.urlBasePromo == null ? this.settings.urlHostXML : this.settings.urlBasePromo;
switch (this.settings.tipoPromo) {
case 'hardnews': case 'softnews': case 'suburbanas':
if (!this.xdomain)
document.write('');
else
document.write('');
break;
default:
if (!this.xdomain)
document.write('');
else
document.write('');
break;
}
this.oaspromos = true;
}
function getFotoCrop(ancho, alto, imagen, url) {
var objFoto = {};
objFoto.Ancho = ancho;
objFoto.Alto = alto;
objFoto.Imagen = imagen;
objFoto.MostradoEnPortada = false;
objFoto.UrlPromo = url;
return objFoto;
}
function getPromo(url, fotoCrops) {
var objPromo = {};
objPromo.Url = url;
objPromo.FotoCrops = fotoCrops;
objPromo.MostradoEnPortada = false;
return objPromo;
}
function HashTable() {
this.hashes = {},
this.id = 0;
}
HashTable.prototype = {
constructor: HashTable,
set: function(obj, value) {
this.hashes[obj] = value;
},
get: function(obj) {
return this.hashes[obj];
}
};
function merge_options(obj1, obj2) {
var obj3 = {};
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
return obj3;
}
GRAnuncio.prototype.getPlacement = function (orden, equivalencia) {
var sitePage = this.settings.sitePage.toLowerCase();
if (sitePage == 'elnorteplay') { sitePage = sitePage.replace('play', ''); }
if (sitePage == 'reformaplay') { sitePage = sitePage.replace('play', ''); }
if (sitePage == 'muralplay') { sitePage = sitePage.replace('play', ''); }
var catdirectorio = this.settings.categoriadir.toLowerCase();
var subcatdirectorio = this.settings.subcategoriadir.toLowerCase();
if (sitePage.indexOf('/') > -1) {
var sitePageSplit = sitePage;
sitePage = sitePageSplit.split("/")[0];
catdirectorio = sitePageSplit.split("/")[1];
}
var tipo;
var placement;
if (xmlDocConsole != null) {
if (ObjCategorias != null) {
if (ObjCategorias.length > 0) {
for (i = 0; i < ObjCategorias.length; i++) {
if (ObjCategorias[i].nombre == catdirectorio) {
tipo = ObjCategorias[i].tipo;
if (tipo == 'noticias') {
placement = sitePage + '_web_' + catdirectorio;
if (equivalencia.indexOf('arco1') > -1 && catdirectorio != 'home') {
resizeTopArco(catdirectorio, subcatdirectorio, tipo);
}
}
if (tipo == 'sociales') {
placement = sitePage + '_web_' + tipo + catdirectorio;
if (equivalencia.indexOf('arco1') > -1 && catdirectorio != 'home') {
resizeTopArco(catdirectorio, subcatdirectorio, tipo);
}
}
if (tipo == 'guias') {
placement = sitePage + '_web_' + tipo;
}
if (tipo == 'edimpresa') {
placement = sitePage + '_web_' + tipo;
}
if (tipo == 'cancha' && placement == undefined) {
if (this.settings.scopeformato = 'articulo' && !this.xdomain) {
placement = sitePage + '_web_' + tipo;
} else {
placement = sitePage + '_web';
}
}
}
}
}
}
}
if (orden != null) { orden = orden.replace('orden', ''); }
if (placement == undefined) { placement = sitePage + '_web__default_default'; } else
{
if (equivalencia != undefined)
{
if (this.settings.categoriadir.toLowerCase() == 'diversion' || this.settings.categoriadir.toLowerCase() == 'guias')
{ equivalencia = equivalencia.replace('noticias', 'hub'); }
if (orden == '' || orden == null) { orden = '1' }
equivalencia = equivalencia.replace('#', orden);
placement = placement + '_' + equivalencia;
}
}
return [placement];
}
GRAnuncio.prototype.GetKeywords = function () {
var idTipoElemento;
if (ObjIdTipoElemento != null) {
if (ObjIdTipoElemento.length > 0) {
for (i = 0; i < ObjIdTipoElemento.length; i++) {
if (ObjIdTipoElemento[i].nombre == this.settings.scopeformato) {
idTipoElemento = ObjIdTipoElemento[i].id;
}
}
}
}
var keywords = {
//'desarollosinmobiliarios' : 'Default',
'subcategoria': this.settings.categoriadir.toLowerCase() + '_' + this.settings.subcategoriadir.toLowerCase()
};
if (this.settings.idelementosubcategoria != '') {
keywords['fingerprint'] = 'CMS_' + idTipoElemento + '_' + this.settings.idelementosubcategoria;
}
if (typeof this.settings.iab !== 'undefined') {
keywords['keywords_iab'] = this.settings.iab;
}
var strKeywordsJSON;
strKeywordsJSON = JSON.stringify(keywords).replace(/"/g, "'");
return strKeywordsJSON;
}
GRAnuncio.prototype.GetEstatusByPosicion = function (posicionanuncio, tipoZona) {
if (adBlockers == true) { console.log('Posicion ' + posicionanuncio + ' Bloqueada por Adblockers, Zona: ' + tipoZona); return [false, undefined, undefined, undefined, undefined]; }
var scopeformato = this.settings.scopeformato;
if (scopeformato == true && posicionanuncio == 'x101') { scopeformato = 'articulo' }
if (scopeformato == true && posicionanuncio == 'x91') { scopeformato = 'articulo' }
var catdirectorio = this.settings.categoriadir.toLowerCase();
var subcategoria = this.settings.subcategoriadir.toLowerCase();
var arcocategoria = '';
var arcosubcategoria = '';
var arco;
var anchor1;
var anchor2;
var OASActivoArco;
var anchorTopCat;
var anchorBottomCat;
var anchorTopSubCat;
var anchorBottomSubCat;
var videoOutStream;
var adArticulo;
var articulo;
var video;
var tipo;
if (xmlDocConsole != null) {
if (posicionanuncio == 'x06' || posicionanuncio == 'x09' || posicionanuncio == 'x69' || posicionanuncio == 'x10' || posicionanuncio == 'x101' || posicionanuncio == 'x91' || posicionanuncio == 'x31' || posicionanuncio == 'x21') {
if (ObjCategorias != null) {
if (ObjCategorias.length > 0) {
for (i = 0; i < ObjCategorias.length; i++) {
if (ObjCategorias[i].nombre == catdirectorio) {
tipo = ObjCategorias[i].tipo;
if (tipo == 'noticias' || tipo == 'sociales' || tipo == 'edimpresa' || tipo == 'guias') {
arcocategoria = ObjCategorias[i].arcocategoria;
arcosubcategoria = ObjCategorias[i].arcosubcategoria;
OASActivoArco = ObjCategorias[i].OAS;
anchorTopCat = ObjCategorias[i].anchorTopCat;
anchorBottomCat = ObjCategorias[i].anchorBottomCat;
anchorTopSubCat = ObjCategorias[i].anchorTopSubCat;
anchorBottomSubCat = ObjCategorias[i].anchorBottomSubCat;
videoOutStream = ObjCategorias[i].videoOutStream;
adArticulo = ObjCategorias[i].adArticulo;
} else {
if (tipo == 'cancha') {
for (i = 0; i < ObjCategorias.length; i++) {
if (ObjCategorias[i].nombre == 'cancha') {
videoOutStream = ObjCategorias[i].videoOutStream;
}
}
}
}
}
}
}
}
}
if (posicionanuncio == 'x06' || posicionanuncio == 'x09') {
if (scopeformato == 'portadah' || scopeformato == 'portadac') {
if (arcocategoria == '1') {
arco = true;
}
}
if (scopeformato == 'portadas') {
if (arcosubcategoria == null) { arcosubcategoria = '' }
var list = arcosubcategoria.split(",");
var index;
for (index = 0; index < list.length; ++index) {
//console.log(list[index]);
if (subcategoria == list[index] || list[index] == '*') {
arco = true;
}
}
}
} else { arco = true; }
if (posicionanuncio == 'x69') {
document.getElementById("pubesp4").style.paddingBottom = "10px";
if (anchorTopCat == '1') {
anchor1 = true;
}
if (anchorTopSubCat == null) { anchorTopSubCat = '' }
var list = anchorTopSubCat.split(",");
var index;
for (index = 0; index < list.length; ++index) {
//console.log(list[index]);
if (subcategoria == list[index] || list[index] == '*') {
anchor1 = true;
}
}
} else { anchor1 = true; }
if (posicionanuncio == 'x10') {
if (anchorBottomCat == '1') {
anchor2 = true;
}
if (anchorBottomSubCat == null) { anchorBottomSubCat = '' }
var list = anchorBottomSubCat.split(",");
var index;
for (index = 0; index < list.length; ++index) {
//console.log(list[index]);
if (subcategoria == list[index] || list[index] == '*') {
anchor2 = true;
}
}
} else { anchor2 = true; }
if (posicionanuncio == 'x101') {
if (videoOutStream == '1') {
video = true;
}
} else { video = true; }
if((posicionanuncio == 'x91' || posicionanuncio == 'x31' || posicionanuncio == 'x21') && (scopeformato == 'articulo')) {
if (adArticulo == '1') {
articulo = true;
}
} else { articulo = true; }
if (ObjConfigConsole != null) {
if (ObjConfigConsole.length > 0) {
for (i = 0; i < ObjConfigConsole.length; i++) {
if (ObjConfigConsole[i].valor == posicionanuncio) {
if (tipoZona == null || tipoZona == '')
{ tipoZona = scopeformato }
if (ObjConfigConsole[i].zona == tipoZona) {
estatus = ObjConfigConsole[i].estatus;
equivalencia = ObjConfigConsole[i].equivalencia;
if (ObjConfigConsole[i].OAS == '1') { OASActivo = true; } else { OASActivo = false; }
if (posicionanuncio == 'x06' || posicionanuncio == 'x09') {
if (OASActivoArco == '1') { OASActivo = true; }
if (OASActivoArco == '0') { OASActivo = false; }
}
altoXML = ObjConfigConsole[i].alto;
anchoXML = ObjConfigConsole[i].ancho;
if (estatus == '1' && arco && anchor1 && anchor2 && video && articulo) {
return [true, equivalencia, altoXML, anchoXML, OASActivo];
}
}
}
}
}
}
}
return [false, undefined, undefined, undefined, undefined];
}
GRAnuncio.prototype.getParameterByName = function (name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
if (!this.xdomain) { var regex = new RegExp("[\\?&]" + name + "=([^]*)"), results = regex.exec(location.search); } else {
var regex = new RegExp("[\\?&]" + name + "=([^]*)"), results = regex.exec(parent.location.search);
}
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
GRAnuncio.prototype.Get_Cookie = function (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return this.GetCookieVal(j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
GRAnuncio.prototype.GetCookieVal = function (offset) {
var endstr = document.cookie.indexOf(";", offset);
if (endstr == -1)
endstr = document.cookie.length;
var clave = unescape(document.cookie.substring(offset, endstr));
return clave.toLowerCase();
}
GRAnuncio.prototype.EscribeAdnxs_uid = function () {
}
GRAnuncio.prototype.getPlacementConsole = function (pos, placement, placementD, ancho, alto, keywordsJSON) {
keywords = keywords.replace(/'/g, '"');
var keywordsJSON = JSON.parse(keywords);
keywordsJSON['app'] = this.Plataform;
var app_segs = JSON.parse('[' + this.Get_Cookie("paramCX") + ']');
keywordsJSON['app_segs'] = app_segs;
keywordsJSON['desarollosinmobiliarios'] = 'Default';
/*var suscriptor = this.Get_Cookie("cusuarioss");
var uidappnexus = this.Get_Cookie("uidappnexus");
if (suscriptor == null) {
keywordsJSON['grsuscriptor'] = '0';
keywordsJSON['grsuscriptorId'] = uidappnexus;
}
else {
if (suscriptor == '') {
keywordsJSON['grsuscriptor'] = '0';
keywordsJSON['grsuscriptorId'] = uidappnexus;
} else {
keywordsJSON['grsuscriptor'] = '1';
keywordsJSON['grsuscriptorId'] = uidappnexus;
}
}*/
//push commands to loading queue, to allow for async loading
apntag.anq.push(function () {
//set global page options
apntag.setPageOpts({
member: grAnuncio.settings.member,
publisherID: publisherid,
keywords: keywordsJSON
});
if (pos == 'x101') {
//define ad tags video
apntag.defineTag({
//required params
invCode: placement,
targetId: placementD,
sizes: [1, 1],
allowedFormats: ['video'],
targetingParams: {},
video: {
frameworks: [1, 2]
},
//the options object is passed to the renderer which creates the outstream player on the page
rendererOptions: {
playerTechnology: [
'flash',
'html5'
],
adText: 'Ad',
showMute: true,
showVolume: true,
showProgressBar: true,
autoInitialSize: true,
allowFullscreen: true,
skippable: {
videoThreshold: 5,
videoOffset: 5,
skipLocation: 'top-right',
skipText: 'Anuncio : (%%TIME%%)',
skipButtonText: 'Ocultar'
}
}
});
} else {
//define ad tags normales
apntag.defineTag({
invCode: placement,
sizes: [ancho, alto],
targetId: placementD
});
}
apntag.loadTags();
apntag.onEvent('adNoBid', placement, function (adObj, adError) {
//En caso de que no hay publicidad en el creatvio
console.log("Sin creativo " + placement);
if (pos == 'x121' && alto == '720') { alto = '530'; }
if (pos == 'x69') { alto = '250'; document.getElementById(placement).style.height = "250px"; }
if (pos != 'x101') {
DisplayPromoPublicidad(placementD, ancho, alto);
}
});
apntag.onEvent('adBadRequest', placement, function (adObj, adError) {
//En caso de que no exista placement
console.log('Placement no existe ' + placement);
if (pos == 'x121' && alto == '720') { alto = '530'; }
if (pos == 'x69') { alto = '250'; document.getElementById(placement).style.height = "250px"; }
if (pos != 'x101') {
DisplayPromoPublicidad(placementD, ancho, alto);
}
});
/*apntag.onEvent('adAvailable', placement, function (adObj, adError) {
//adAvailable
console.log('adAvailable');
if (placement.indexOf("fotogaleria_fullpage") > -1) { alto = '530'; }
DisplayPromoPublicidad(placement, ancho, alto);
});*/
apntag.onEvent('adRequestFailure', placement, function (adObj, adError) {
//adRequestFailure
console.log('adRequestFailure ' + placement);
if (pos == 'x121' && alto == '720') { alto = '530'; }
if (pos == 'x69') { alto = '250'; document.getElementById(placement).style.height = "250px"; }
if (pos != 'x101') {
DisplayPromoPublicidad(placementD, ancho, alto);
}
});
/*apntag.onEvent('adError', placement, function (adObj, adError) {
//adError
console.log('adError ' + placement);
if (pos == 'x121') { alto = '530'; }
if (pos != 'x101') {
DisplayPromoPublicidad(placement, ancho, alto);
}
});*/
apntag.onEvent('adLoaded', placement, function (adObj, adError) {
//En caso de que se ha cargado correctamente
console.log("Placement OK: " + placementD);
});
apntag.showTag(placementD);
});
}
GRAnuncio.prototype.ValorPublisherId = function () {
var publisherId;
//if (!this.settings.esStage) {
if (ObjPublisherId != null) {
if (ObjPublisherId.length > 0) {
for (i = 0; i < ObjPublisherId.length; i++) {
if (ObjPublisherId[i].tipo == plataform) {
if (ObjPublisherId[i].plaza == grAnuncio.settings.sitePage) {
publisherId = ObjPublisherId[i].id;
}
}
}
}
}
//}
return publisherId;
}
GRAnuncio.prototype.getPlataform = function () {
var plataform;
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
//console.log('Esto es un dispositivo móvil');
plataform = 'webmovil';
} else {
plataform = 'webdesktop';
}
return plataform;
}
var placementTemp = '';
var anchoPlacementTemp = '';
var altoPlacementTemp = '';
var esTopTemp;
function resizePlacementCxense(placement, ancho, alto, esTop) {
if(placement != undefined){placementTemp = placement;}
if(ancho != undefined){anchoPlacementTemp = ancho;}
if(alto != undefined){altoPlacementTemp = alto;}
if(esTop != undefined){esTopTemp = esTop;}
var x = document.getElementsByClassName("container_publicidad");
var i;
for (i = 0; i < x.length; i++) {
//declara el ancho y alto del div padre
var anchoDiv = document.body.clientWidth;
//declara el ancho y alto del Placement
var anchoPlacement = x[i].clientWidth;
var altoPlacement = x[i].clientHeight;
if(anchoPlacement == 0) { } else {
if (anchoPlacement > anchoDiv) {
var proporcionAncho = anchoDiv / anchoPlacement;
// Ajustar a lo ancho y lo que dé de alto
var escala = proporcionAncho;
var MarginDown = altoPlacement - (escala * altoPlacement);
//Se asignan los valores a los styles, para el ajuste del contenido
x[i].style.transform = 'scale(' + escala + ')';
x[i].style.transformOrigin = '0 0';
x[i].style.marginBottom = '-' + MarginDown + 'px';
} else {
x[i].style.transform = null;
x[i].style.transformOrigin = null;
x[i].style.marginBottom = null;
}
}
}
var x = document.getElementsByClassName("gr_contenedor_publicidad");
var i;
for (i = 0; i < x.length; i++) {
//declara el ancho y alto del div padre
var anchoDiv = document.body.clientWidth;
//declara el ancho y alto del Placement
var anchoPlacement = x[i].clientWidth;
var altoPlacement = x[i].clientHeight;
if(anchoPlacement == 0) { } else {
if(placementTemp.indexOf('articulo_leaderboard1_h8x1') > -1 || placementTemp.indexOf('articulo_cintillo#_h16x5') > -1){
anchoPlacement = anchoPlacementTemp;
altoPlacement = altoPlacementTemp;
if (esTopTemp == true) {
if (anchoDiv < 961) {//movil 200x600 90x728
x[i].style.borderBottom = null;
//x[i].style.paddingBottom = '22px';
//x[i].parentElement.style.background = '#f5f6fa';
//x[i].parentElement.firstChild.style.margin = '0px';
x[i].parentElement.style.marginTop = '-77px';
document.getElementById('cuerpo').style.paddingTop = '0px';
} else {//desktop 200x600 90x728
x[i].style.borderBottom = '#D3D6DD solid 0.5px';
//x[i].style.paddingBottom = null;
//x[i].parentElement.style.background = null;
x[i].parentElement.style.marginTop = '-116px';
//x[i].parentElement.firstChild.style.margin = null;
document.getElementById('cuerpo').style.paddingTop = '40px';
}
if (anchoDiv < 728) {
x[i].parentElement.style.background = '#f5f6fa';
} else {
x[i].parentElement.style.background = null;
}
if (anchoDiv < 769) {
x[i].parentElement.style.marginTop = '-77px';
}
} else {
if (document.getElementById("styleAdCSS")) {
document.getElementById("styleAdCSS").remove();
}
}
}
if (anchoPlacement > anchoDiv) {
var proporcionAncho = anchoDiv / anchoPlacement;
// Ajustar a lo ancho y lo que dé de alto
var escala = proporcionAncho;
var MarginDown = altoPlacement - (escala * altoPlacement);
//Se asignan los valores a los styles, para el ajuste del contenido
x[i].style.transform = 'scale(' + escala + ')';
x[i].style.transformOrigin = 'top';
if(placementTemp.indexOf('articulo_leaderboard1_h8x1') > -1 || placementTemp.indexOf('articulo_cintillo#_h16x5') > -1){
x[i].style.marginBottom = '-' + MarginDown + 'px';
}
} else {
x[i].style.transform = null;
x[i].style.transformOrigin = null;
x[i].style.marginBottom = null;
}
}
if(anchoDiv < 481 && placementTemp.indexOf('articulo_hub#_t1x1') > -1){
//declara el ancho y alto del div padre
var anchoDoc = window.innerWidth;
var altoDoc = window.innerHeight;
//declara el ancho y alto del div hijo
var anchoPlacement = 300;
var altoPlacement = 250;
var proporcionAncho = anchoDoc / anchoPlacement;
var escala;
// Ajustar a lo ancho y lo que dé de alto
escala = proporcionAncho;
var nuevoHeight = escala * altoPlacement;
var nuevoWidth = escala * anchoPlacement;
//Se asignan los valores a los styles, para el ajuste del contenido
x[i].style.transform = 'scale(' + escala + ')';
x[i].style.transformOrigin = '0 0';
x[i].style.maxWidth = '300px';
//x[i].style.margin = '1.5rem auto';
x[i].style.background = 'transparent';
//x[i].style.border = 'none';
//Calcula nuevo alto y ancho
x[i].style.height = nuevoHeight + 'px';
x[i].style.width = nuevoWidth + 'px';
}else{
if(placementTemp.indexOf('articulo_hub#_t1x1') > -1){
//x[i].style.height = '250px';
x[i].style.background = null;
x[i].style.width = null;
x[i].style.height = null;
x[i].style.maxWidth = null;
}
}
if(anchoDiv < 961){
x[i].style.paddingBottom = '22px';
} else {
x[i].style.paddingBottom = null;
}
}
}
function resizePlacement() {
var x = document.getElementsByClassName("placementDiv");
var i;
for (i = 0; i < x.length; i++) {
x[i].style.height = '100%';
x[i].style.width = '100%';
//declara el ancho y alto del div padre
var anchoDiv = x[i].clientWidth;
var altoDiv = x[i].clientHeight;
//declara el ancho y alto del div hijo
var anchoPlacement = x[i].children[0].clientWidth;
var altoPlacement = x[i].children[0].clientHeight;
//parche para altura de playbuzz
if (x[i].id.indexOf('articulo_leaderboard1_h8x1') > -1) {
altoDiv = (anchoDiv * altoPlacement) / anchoPlacement;
}
//parche para altura de playbuzz iphone
if (x[i].id.indexOf('articulo_leaderboard1_h8x1DivM') > -1 && window.innerWidth < 415) {
anchoDiv = window.innerWidth - 20;
altoDiv = (anchoDiv * 90) / 728;
}
//parche guias obituario
if (x[i].id.indexOf('guias_portada_superleaderboard_h16x1') > -1) {
if (anchoDiv > anchoPlacement) { altoDiv = altoPlacement; } else
{ altoDiv = (anchoDiv * altoPlacement) / anchoPlacement; }
x[i].style.margin = '0 0 10px 0';
}
//parche guias obituario 300x250
if (x[i].id.indexOf('guias_portada_hub1_t1x1') > -1) {
if (anchoDiv > 300) { altoDiv = 250; } else
{ altoDiv = (anchoDiv * altoPlacement) / anchoPlacement; }
}
//parche articulos resize ancho
var fotoH = document.getElementsByClassName("fotoH");
if (fotoH.length == 1 && x[i].id.indexOf('articulo_hub1_t1x1') > -1) {
x[i].style.display = 'flex';
anchoDiv = 300;
altoDiv = 250;
x[i].style.height = '250px';
x[i].style.width = '300px';
}
//parche outstreamvideo
var fotoH = document.getElementsByClassName("fotoH");
if (fotoH.length == 1 && x[i].id.indexOf('articulo_outstream') > -1) {
altoDiv = 1;
anchoPlacement = anchoDiv;
}
//parche para fotogaleria
if (anchoPlacement == 960 && altoPlacement == 720) { anchoDiv = 960; altoDiv = 720; }
//parche para home iphone
if (altoDiv == 0 && document.location.href.indexOf('iphone') > -1) { altoDiv = 250; }
if (altoDiv == 0 && document.location.href.indexOf('articulo') > -1) { altoDiv = 250; }
if (anchoDiv == anchoPlacement && altoDiv == altoPlacement) { } else {
//parche para editoriales
if (anchoDiv == 300 && altoDiv == 530 && anchoPlacement == 300 && altoPlacement == 250) { anchoDiv = 300; altoDiv = 250; }
var proporcionAncho = anchoDiv / anchoPlacement;
var proporcionAlto = altoDiv / altoPlacement;
var escala;
if (proporcionAlto < proporcionAncho) { // Hay que ajustar a lo alto y lo que dé de ancho
escala = proporcionAlto;
} else { // Ajustar a lo ancho y lo que dé de alto
escala = proporcionAncho;
}
var nuevoHeight = escala * altoPlacement;
var nuevoWidth = escala * anchoPlacement;
var MarginTopDown = (altoDiv - (escala * altoPlacement)) / 2;
var MarginLeftRight = (anchoDiv - (escala * anchoPlacement)) / 2;
//Se asignan los valores a los styles, para el ajuste del contenido
x[i].children[0].style.transform = 'scale(' + escala + ')';
x[i].children[0].style.transformOrigin = '0 0';
x[i].children[0].style.float = 'left';
if (x[i].id.indexOf('articulo_hub1_t1x1') > -1) { } else {
x[i].children[0].style.margin = MarginTopDown + 'px ' + MarginLeftRight + 'px';
}
//Calcula nuevo alto y ancho
x[i].style.height = nuevoHeight + 'px';
x[i].style.width = nuevoWidth + 'px';
//parche articulos
if (x[i].id.indexOf('articulo_hub1_t1x1') > -1) {
x[i].style.display = 'flex';
x[i].style.margin = '0 0 15px 0';
}
//parche outstreamvideo
if (x[i].id.indexOf('articulo_outstream') > -1) {
x[i].children[0].style.width = nuevoWidth + 'px';
x[i].style.height = 'auto';
}
//parche publicidadIA
if (document.location.href.indexOf('publicidadIA') > -1) {
x[i].style.position = 'absolute';
}
}
}
}
function resizeTopArco(catdirectorio, subcatdirectorio, tipo) {
//categorias y subcategorias negocio
if (tipo == 'noticias') {
if (catdirectorio == 'negocios' || subcatdirectorio == 'energia' || subcatdirectorio == 'empresas' || subcatdirectorio == 'bienesraices') {
var checkTopNegocios = setInterval(function () {
var topArco = document.getElementById('ad_wallpaper').style.top;
if (topArco == '90px') {
//clearInterval(checkTopNegocios);
} else {
document.getElementById('ad_wallpaper').style.top = '90px';
}
}, 500);
setTimeout(function () { clearInterval(checkTopNegocios); }, 6000);
} else {
var checkTopCategorias = setInterval(function () {
var topArco = document.getElementById('ad_wallpaper').style.top;
if (topArco == '40px') {
//clearInterval(checkTopCategorias);
} else {
document.getElementById('ad_wallpaper').style.top = '40px';
}
}, 500);
setTimeout(function () { clearInterval(checkTopCategorias); }, 6000);
}
}
//sociales urbanas
if (tipo == 'sociales') {
var checkTopSociales = setInterval(function () {
var topArco = document.getElementById('ad_wallpaper').style.top;
if (topArco == '55px') {
//clearInterval(checkTopSociales);
} else {
document.getElementById('ad_wallpaper').style.top = '55px';
}
}, 500);
setTimeout(function () { clearInterval(checkTopSociales); }, 6000);
}
}
window.addEventListener('resize', function () {
resizePlacement();
resizePlacementCxense();
insertPub2();
})
var impresion2 = 0;
var impresion2vO = 0;
function insertPub2() {
if (typeof placement === 'undefined') { return; }
//if (typeof equivalencia !== 'undefined'){
if (placement.indexOf('articulo') > -1/* || equivalencia.indexOf('articulo') > -1*/) {
if (placement.indexOf('articulo_leaderboard') > -1) {
if (/*/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || */window.innerWidth < 415) {
//console.log('Esto es un dispositivo móvil');
var idDefinidoM2 = document.getElementById(placement + 'M');
//si existe
if (idDefinidoM2 == undefined) { } else {
//si no tiene publicidad
if (idDefinidoM2.innerHTML == "") {
//Imprimir una vez
if (impresion2 == 0) {
impresion2++;
var keywordsn2VOL = grAnuncio.GetKeywords();
//grAnuncio.getPlacementConsole('x21', placement, placement + 'M', '728', '90', keywordsn2VOL);
}
}
}
} else {
var idDefinido2 = document.getElementById(placement);
//si existe
if (idDefinido2 == undefined) { } else {
//si no tiene publicidad
if (idDefinido2.innerHTML == "") {
//Imprimir una vez
if (impresion2 == 0) {
impresion2++;
var keywordsn2VOL = grAnuncio.GetKeywords();
//grAnuncio.getPlacementConsole('x21', placement, placement, '728', '90', keywordsn2VOL);
}
}
}
}
} else {
placement = placement.replace('hub1_t1x1', 'outstream1_h1x1');
if (window.innerWidth < 415) {
//console.log('Esto es un dispositivo móvil');
var idDefinidoMVO2 = document.getElementById(placement + 'M');
//si existe
if (idDefinidoMVO2 == undefined) { } else {
//si no tiene publicidad
if (idDefinidoMVO2.innerHTML == "") {
//Imprimir una vez
if (impresion2vO == 0) {
impresion2vO++;
var keywordsn2VO = grAnuncio.GetKeywords();
//grAnuncio.getPlacementConsole('x101', placement, placement + 'M', '1', '1', keywordsn2VO);
}
}
}
} else {
var idDefinidoVO2 = document.getElementById(placement);
//si existe
if (idDefinidoVO2 == undefined) { } else {
//si no tiene publicidad
if (idDefinidoVO2.innerHTML == "") {
//Imprimir una vez
if (impresion2vO == 0) {
impresion2vO++;
var keywordsn2VO = grAnuncio.GetKeywords();
//grAnuncio.getPlacementConsole('x101', placement, placement, '1', '1', keywordsn2VO);
}
}
}
}
placement = placement.replace('outstream1_h1x1', 'hub1_t1x1');
if (/*/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || */window.innerWidth < 415) {
//console.log('Esto es un dispositivo móvil');
var idDefinidoM2 = document.getElementById(placement + 'M');
//si existe
if (idDefinidoM2 == undefined) { } else {
//si no tiene publicidad
if (idDefinidoM2.innerHTML == "") {
//Imprimir una vez
if (impresion2 == 0) {
impresion2++;
var keywordsn2 = grAnuncio.GetKeywords();
//grAnuncio.getPlacementConsole('x91', placement, placement + 'M', '300', '250', keywordsn2);
}
}
}
} else {
var idDefinido2 = document.getElementById(placement);
//si existe
if (idDefinido2 == undefined) { } else {
//si no tiene publicidad
if (idDefinido2.innerHTML == "") {
//Imprimir una vez
if (impresion2 == 0) {
impresion2++;
var keywordsn2 = grAnuncio.GetKeywords();
//grAnuncio.getPlacementConsole('x91', placement, placement, '300', '250', keywordsn2);
}
}
}
}
}
}
//}
}
var countDisplayAdsCxense = 0;
GRAnuncio.prototype.DisplayAdsCxense = function (posicionanuncio, ponerPromo, tipoZona, orden, ancho, alto, targetIdDiv, esTop) {
ponerPromo = (typeof ponerPromo == 'undefined') ? true : ponerPromo;
tipoZona = (typeof tipoZona == 'undefined') ? null : tipoZona;
orden = (typeof orden == 'undefined') ? null : orden;
var datosEstatusByPosicion = this.GetEstatusByPosicion(posicionanuncio, tipoZona);
var estatus = datosEstatusByPosicion[0];
var equivalencia = datosEstatusByPosicion[1];
equivalenciaTemp = equivalencia;
var altoXML = datosEstatusByPosicion[2];
var anchoXML = datosEstatusByPosicion[3];
if (estatus) {
if (this.settings.esStage) {
this.DisplayAdsStageCxense(posicionanuncio, targetIdDiv);
return true;
}
else {
var datosplacement = this.getPlacement(orden, equivalencia);
placement = datosplacement[0];
keywords = this.GetKeywords();
var timerInterval = setInterval(function () {
if (document.getElementById(targetIdDiv)) {
if(grAnuncio.getPlataform() == 'webdesktop' && equivalenciaTemp.indexOf('articulo_leaderboard1_h8x1') > -1 && optionsPublicidad.tagsxportada.indexOf('x21') > -1){
ancho = 728;
alto = 90;
}
keywords = keywords.replace(/'/g, '"');
var keywordsJSON = JSON.parse(keywords);
keywordsJSON['app'] = grAnuncio.Plataform;
var app_segs = JSON.parse('[' + grAnuncio.Get_Cookie("paramCX") + ']');
keywordsJSON['app_segs'] = app_segs;
keywordsJSON['desarollosinmobiliarios'] = 'Default';
apntag.setPageOpts({
member: grAnuncio.settings.member,
publisherID: publisherid,
keywords: keywordsJSON
});
//define ad tags normales
apntag.defineTag({
invCode: placement,
sizes: [ancho, alto],
targetId: targetIdDiv
});
apntag.loadTags();
apntag.onEvent('adNoBid', targetIdDiv, function (adObj, adError) {
//En caso de que no hay publicidad en el creatvio
console.log("Sin creativo Cxense: " + placement);
//if (pos == 'x31') { ancho = '630'; alto = '250'; }
//if (pos == 'x69') { alto = '250'; document.getElementById(placement).style.height = "250px"; }
DisplayPromoPublicidad(targetIdDiv, ancho, alto);
//$('#' + targetIdDiv)[0].children[0].style.display = 'block';
});
apntag.onEvent('adBadRequest', targetIdDiv, function (adObj, adError) {
//En caso de que no exista placement
console.log('Placement Cxense no existe: ' + placement);
//if (pos == 'x31') { ancho = '630'; alto = '250'; }
//if (pos == 'x69') { alto = '250'; document.getElementById(placement).style.height = "250px"; }
DisplayPromoPublicidad(targetIdDiv, ancho, alto);
//$('#' + targetIdDiv)[0].children[0].style.display = 'block';
});
apntag.onEvent('adRequestFailure', targetIdDiv, function (adObj, adError) {
//adRequestFailure
console.log('adRequestFailure Cxense: ' + placement);
//if (pos == 'x31') { ancho = '630'; alto = '250'; }
//if (pos == 'x69') { alto = '250'; document.getElementById(placement).style.height = "250px"; }
DisplayPromoPublicidad(targetIdDiv, ancho, alto);
//$('#' + targetIdDiv)[0].children[0].style.display = 'block';
});
apntag.onEvent('adLoaded', targetIdDiv, function (adObj, adError) {
//En caso de que se ha cargado correctamente
console.log("Placement Cxense OK: " + placement);
//if(countDisplayAdsCxense == 0){resizePlacementCxense(equivalenciaTemp, ancho, alto, esTop);countDisplayAdsCxense++;}
});
apntag.showTag(targetIdDiv);
//declara el ancho del document
var anchoDocument = document.body.clientWidth;
//declara el ancho del placement
var anchoPlacement = ancho + 40;
//resizePlacement
//if (anchoPlacement > anchoDocument) {
//resizePlacementCxense();
//}
document.getElementById(targetIdDiv).style.minHeight = alto + 'px';
resizePlacementCxense(equivalenciaTemp, ancho, alto, esTop);
clearInterval(timerInterval);
}
}, 1);
}
} else {
if (this.settings.esStage) {
this.DisplayAdsStageCxense(posicionanuncio, targetIdDiv);
return true;
}
else {
if(grAnuncio.getPlataform() == 'webdesktop' && posicionanuncio.indexOf('x21') > -1){
ancho = 728;
alto = 90;
}
if(posicionanuncio.indexOf('x21') > -1){
resizePlacementCxense('articulo_leaderboard1_h8x1', ancho, alto, esTop);
}
if(posicionanuncio.indexOf('x31') > -1){
resizePlacementCxense('articulo_cintillo#_h16x5', ancho, alto, esTop);
}
if(posicionanuncio.indexOf('x91') > -1){
resizePlacementCxense('articulo_hub#_t1x1', ancho, alto, esTop);
}
DisplayPromoPublicidad(targetIdDiv, ancho, alto);
return false;
}
}
}
GRAnuncio.prototype.DisplayAdsStageCxense = function (tag, targetIdDiv) {
switch (tag) {
case 'x01': case 'x02': case 'x03': case 'x04':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
180x60
"; break;
case 'x11': case 'x12': case 'x13': case 'x14': case 'x15':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
300x100
"; break;
case 'x23': case 'x91': case 'x92': case 'x93': case 'x94': case 'x95': /*case 'x101':*/ case 'x102': case 'x103': case 'x105': case 'x107':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
300x250
"; break;
case 'x21':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
728x90
"; break;
case 'x25':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
683x60
"; break;
case 'x05':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
1x1
"; break;
case 'x131': case 'x98': case 'x99': case 'x106': case 'x108':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
300x530
"; break;
case 'x96': case 'x97':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
630x250
"; break;
case 'x100':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
960x250
"; break;
case 'x117':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
960x70
"; break;
case 'x114':
document.getElementById(targetIdDiv).innerHTML = "PUBLICIDAD
960x530
"; break;
}
}
GRAnuncio.prototype.DisplayAdsVideoCxense = function (posicionanuncio, ponerPromo, targetIdDiv) {
ponerPromo = (typeof ponerPromo == 'undefined') ? true : ponerPromo;
var datosEstatusByPosicion = this.GetEstatusByPosicion(posicionanuncio, null);
var estatus = datosEstatusByPosicion[0];
var equivalencia = datosEstatusByPosicion[1];
var altoXML = datosEstatusByPosicion[2];
var anchoXML = datosEstatusByPosicion[3];
if (estatus) {
if (this.settings.esStage) {
this.DisplayAdsStageCxense(posicionanuncio, targetIdDiv);
return true;
}
else {
var datosplacement = this.getPlacement('', equivalencia);
placementVideo = datosplacement[0];
keywords = this.GetKeywords();
var timerInterval = setInterval(function () {
if (document.getElementById(targetIdDiv)) {
keywords = keywords.replace(/'/g, '"');
var keywordsJSON = JSON.parse(keywords);
keywordsJSON['app'] = grAnuncio.Plataform;
var app_segs = JSON.parse('[' + grAnuncio.Get_Cookie("paramCX") + ']');
keywordsJSON['app_segs'] = app_segs;
keywordsJSON['desarollosinmobiliarios'] = 'Default';
apntag.setPageOpts({
member: grAnuncio.settings.member,
publisherID: publisherid,
keywords: keywordsJSON
});
//define ad tags video
apntag.defineTag({
//required params
invCode: placementVideo,
targetId: targetIdDiv,
sizes: [1, 1],
allowedFormats: ['video'],
targetingParams: {},
video: {
frameworks: [1, 2]
},
//the options object is passed to the renderer which creates the outstream player on the page
rendererOptions: {
playerTechnology: [
'flash',
'html5'
],
adText: 'Ad',
showMute: true,
showVolume: true,
showProgressBar: true,
autoInitialSize: true,
allowFullscreen: true,
skippable: {
videoThreshold: 5,
videoOffset: 5,
skipLocation: 'top-right',
skipText: 'Anuncio : (%%TIME%%)',
skipButtonText: 'Ocultar'
}
}
});
apntag.loadTags();
apntag.onEvent('adNoBid', targetIdDiv, function (adObj, adError) {
//En caso de que no hay publicidad en el creatvio
console.log("Sin creativo Video Cxense: " + placementVideo);
});
apntag.onEvent('adBadRequest', targetIdDiv, function (adObj, adError) {
//En caso de que no exista placement
console.log('Placement Video Cxense no existe: ' + placementVideo);
});
apntag.onEvent('adRequestFailure', targetIdDiv, function (adObj, adError) {
//adRequestFailure
console.log('adRequestFailure Video Cxense: ' + placementVideo);
});
apntag.onEvent('adLoaded', targetIdDiv, function (adObj, adError) {
//En caso de que se ha cargado correctamente
console.log("Placement Video Cxense OK");
});
apntag.showTag(targetIdDiv);
clearInterval(timerInterval);
}
}, 1);
}
} else {
if (this.settings.esStage) {
this.DisplayAdsStageCxense(posicionanuncio, targetIdDiv);
return true;
}
else {
return false;
}
}
}
var timerDisplayAds = setInterval(function () {
if (AdsReady === true && xmlDocConsole !== null && typeof apntag.setPageOpts !== 'undefined') {
//console.log(apntag.setPageOpts);
GetListJSON();
clearInterval(timerDisplayAds);
//ASTXML = true;
}
}, 1);
function GetListJSON() {
setInterval(function () {
for (iJSON = 0; iJSON < listJsonPlacements.length; iJSON++) {
if (document.getElementById(listJsonPlacements[iJSON].targetIdDiv)) {
if(/*document.getElementById(listJsonPlacements[iJSON].targetIdDiv).children.length == 0*/listJsonPlacements[iJSON].implementado == false){
DisplayAdsJSON(listJsonPlacements[iJSON].posicionanuncio,listJsonPlacements[iJSON].ponerPromo,listJsonPlacements[iJSON].tipoZona,listJsonPlacements[iJSON].orden,listJsonPlacements[iJSON].ancho,listJsonPlacements[iJSON].alto,listJsonPlacements[iJSON].targetIdDiv);
listJsonPlacements[iJSON].implementado = true;
}
}
}
}, 1);
}
//setTimeout(function(){ GetListJSON(); }, 1200);
function DisplayAdsJSON(posicionanuncioJSON, ponerPromoJSON, tipoZonaJSON, ordenJSON, anchoJSON, altoJSON, targetIdDivJSON) {
var datosEstatusByPosicion = grAnuncio.GetEstatusByPosicion(posicionanuncioJSON, tipoZonaJSON);
var estatus = datosEstatusByPosicion[0];
var equivalencia = datosEstatusByPosicion[1];
var altoXML;if(altoJSON == undefined || altoJSON == ""){altoXML = datosEstatusByPosicion[2];}else{altoXML = altoJSON;}
var anchoXML;if(anchoJSON == undefined || anchoJSON == ""){anchoXML = datosEstatusByPosicion[3];}else{anchoXML = anchoJSON;}
if (estatus) {
if (grAnuncio.settings.esStage) {
grAnuncio.DisplayAdsStageCxense(posicionanuncioJSON, targetIdDivJSON);
return true;
}
else {
console.log(posicionanuncioJSON + ' - ' + ordenJSON + ' - ' + tipoZonaJSON);
if (posicionanuncioJSON == 'x09' || posicionanuncioJSON == 'x06') {
grAnuncio.OrdenEspecial.push('1');
document.getElementsByTagName('body')[0].style.height = '0';
document.getElementsByTagName('html')[0].style.height = '0';
grFunc.CargaAnuncioEspecialExpandible();
}
if (posicionanuncioJSON == 'x10') { grAnuncio.OrdenEspecial.push('3'); grFunc.CargaAnuncioEspecialBottom(); }
var datosplacement = grAnuncio.getPlacement(ordenJSON, equivalencia);
var placement = datosplacement[0];
var keywords = grAnuncio.GetKeywords();
keywords = keywords.replace(/'/g, '"');
var keywordsJSON = JSON.parse(keywords);
keywordsJSON['app'] = plataform;
var app_segs = JSON.parse('[' + grAnuncio.Get_Cookie("paramCX") + ']');
keywordsJSON['app_segs'] = app_segs;
keywordsJSON['desarollosinmobiliarios'] = 'Default';
apntag.setPageOpts({
member: grAnuncio.settings.member,
publisherID: publisherid,
keywords: keywordsJSON
});
//define ad tags normales
apntag.defineTag({
invCode: placement,
sizes: [anchoXML, altoXML],
targetId: targetIdDivJSON
});
apntag.loadTags();
apntag.onEvent('adNoBid', targetIdDivJSON, function (adObj, adError) {
//En caso de que no hay publicidad en el creatvio
console.log("Sin creativo Cxense: " + placement);
//$('#' + targetIdDiv)[0].children[0].style.display = 'block';
if (posicionanuncioJSON == 'x121' && altoXML == '720') { altoXML = '530'; }
DisplayPromoPublicidad(targetIdDivJSON, anchoXML, altoXML);
});
apntag.onEvent('adBadRequest', targetIdDivJSON, function (adObj, adError) {
//En caso de que no exista placement
console.log('Placement Cxense no existe: ' + placement);
//$('#' + targetIdDiv)[0].children[0].style.display = 'block';
if (posicionanuncioJSON == 'x121' && altoXML == '720') { altoXML = '530'; }
DisplayPromoPublicidad(targetIdDivJSON, anchoXML, altoXML);
});
apntag.onEvent('adRequestFailure', targetIdDivJSON, function (adObj, adError) {
//adRequestFailure
console.log('adRequestFailure Cxense: ' + placement);
//$('#' + targetIdDiv)[0].children[0].style.display = 'block';
if (posicionanuncioJSON == 'x121' && altoXML == '720') { altoXML = '530'; }
DisplayPromoPublicidad(targetIdDivJSON, anchoXML, altoXML);
});
apntag.onEvent('adLoaded', targetIdDivJSON, function (adObj, adError) {
//En caso de que se ha cargado correctamente
console.log("Placement Cxense OK: " + placement);
});
apntag.showTag(targetIdDivJSON);
//declara el ancho del document
var anchoDocument = document.body.clientWidth;
//declara el ancho del placement
var anchoPlacement = anchoXML + 40;
//resizePlacement
if (anchoPlacement > anchoDocument) {
resizePlacementCxense();
}
}
} else {
if (grAnuncio.settings.esStage) {
grAnuncio.DisplayAdsStageCxense(posicionanuncioJSON, targetIdDivJSON);
return true;
}
else {
if (posicionanuncioJSON == 'x121' && altoXML == '720') { altoXML = '530'; }
if (posicionanuncioJSON == 'x91' && anchoXML == undefined && altoXML == undefined) { altoXML = '250'; anchoXML = '300'; }
DisplayPromoPublicidad(targetIdDivJSON, anchoXML, altoXML);
return false;
}
}
}