var mode = "H"; var ads = [{"id": 1, "banners": [{"id": 1, "name": "ssee", "img": "http://ssee.wadobo.com/static/sbfront/img/logo-secec-nostripe-text.png", "url": "http://ssee.wadobo.com", "ads": 1}], "name": "ssee", "waittime": 5, "active": true, "seq": false, "width": 300, "height": 60, "mode": "B", "tournament": null}, {"id": 3, "banners": [{"id": 3, "name": "ssee", "img": "http://ssee.wadobo.com/static/sbfront/img/logo-secec-nostripe-text.png", "url": "http://ssee.wadobo.com", "ads": 3}, {"id": 4, "name": "django", "img": "https://wadobo.com/static/img/djangologo.png", "url": "https://wadobo.com", "ads": 3}], "name": "mixta H", "waittime": 8, "active": true, "seq": false, "width": 300, "height": 60, "mode": "H", "tournament": null}, {"id": 5, "banners": [{"id": 7, "name": "Suzuki", "img": "http://www.liganortedesalto.com/descargas/prueba/1905_CopaSuzuki_Publi.png", "url": "https://concursos.secretariasecuestres.com/tournament/detail/151/", "ads": 5}], "name": "copa_suzuki", "waittime": 5, "active": true, "seq": false, "width": 210, "height": 105, "mode": "H", "tournament": null}, {"id": 8, "banners": [{"id": 10, "name": "iframe", "img": "https://youtu.be/z8wsK3niChI", "url": "https://concursos.secretariasecuestres.com/static/media/upload-files/2019/02/1905_CopaSuzuki_Info.pdf", "ads": 8}], "name": "iframe", "waittime": 0, "active": true, "seq": false, "width": 300, "height": 300, "mode": "H", "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 += '
'; html += ''; html += ''; html += ''; html += '
'; } var res = document.getElementById('ads'); res.innerHTML = html; if (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]); }