var AdSponsorBlock = Class.create(); AdSponsorBlock.prototype = { initialize: function(opt) { for (i in opt) { this[i] = opt[i]; } this.current_ids = [0, 0]; this.load(); }, load: function() { var obj = this; $.ajax({ url: BASE_URL+'/ad_sponsor_block', type: 'POST', data: { action: 'get_banner', 'current_ids[0]': obj.current_ids[0], 'current_ids[1]': obj.current_ids[1], id_type: obj.id_type, markets: obj.markets }, beforeSend: function() { }, dataType: 'json', error: function (request, textStatus, errorThrown) { //alert(textStatus +' ' + errorThrown); }, success: function(data) { if (typeof data.list == 'object') { obj.render(data.list, data.num_rows); setTimeout('banner_block['+obj.index+'].load()', obj.timeInterval); } }, complete: function(request, textStatus) { } }); }, render: function(list, num_rows) { this.container.empty(); var itemContainerStart = ''; var itemContainerEnd = ''; var html = ''; if (num_rows > 0) { html +='
'; itemContainerEnd = ' | '; } var item; var notifyUrl; for (var i in list) { item = list[i]; notifyUrl = BASE_URL + '/sponsor_click?id=' + item.id; this.current_ids[i] = item.id; html += itemContainerStart + ''; html += '' + '' + itemContainerEnd; } if (num_rows > 0) { html +='