var mode = "V";
var ads = [{"id": 7, "banners": [{"id": 9, "name": "Suzuki_premios", "img": "http://www.liganortedesalto.com/descargas/prueba/1905_CopaSuzuki_Publicidad.png", "url": "https://concursos.secretariasecuestres.com/static/media/upload-files/2019/02/1905_CopaSuzuki_Info.pdf", "ads": 7}], "name": "suzuki_prueba3", "waittime": 5, "active": true, "seq": false, "width": 300, "height": 300, "mode": "V", "tournament": null}, {"id": 9, "banners": [{"id": 11, "name": "app", "img": "http://www.liganortedesalto.com/descargas/prueba/2023_alquilerAplicacion.png", "url": "https://api.whatsapp.com/send?phone=34650226770", "ads": 9}], "name": "pruebapubli", "waittime": 10, "active": true, "seq": false, "width": 300, "height": 300, "mode": "V", "tournament": null}];
var start_ad = 0;
function get_col(ad) {
var col = 12;
if (mode == 'H') {
col = col / ad.banners.length;
}
return col;
}
function get_size(ad) {
var size = "";
if (mode == 'H') {
size += 'height="' + ad.height + '"';
} else if (mode == 'V') {
size += 'width="' + ad.width + '"';
}
return size;
}
function gen_ad(ad) {
var html = "";
var col = get_col(ad);
var size = get_size(ad);
for (var banner in ad.banners) {
html += '';
}
var res = document.querySelectorAll('.c-ads');
for (let element of Array.from(res)) {
element.innerHTML = html
}
if (res.length > 0 && ads.length > 1) {
setTimeout(function() {
start_ad = (start_ad + 1) % ads.length;
gen_ad(ads[start_ad]);
}, ads[start_ad].waittime * 1000);
}
}
if (ads.length > 0) {
gen_ad(ads[start_ad]);
}