var Begun_loading = -1,Begun_timer = new Array();
function getBegunBanners(Begun_Keywords, Begun_Limit, Begun_offset, Begun_id) {
	if(!Begun_timer[Begun_id]) $(Begun_id).update('<center><b>Loading...</b></center>');
	if(Begun_loading<0) {
		Begun_loading = 1;
		new Ajax.Request('/js/begun_gateway.php', {
			method: 'post', 
			parameters: {keywords: Begun_Keywords, limit: Begun_Limit, offset: Begun_offset}, 
			onComplete: function(OR) {
				var Response = OR.responseText.strip();
				$(Begun_id).update('');
				if(Response != 'no_keywords') {
					var banners = eval(Response).banners;
					for (var i=0; i < banners.length; i++) {
						$(Begun_id).insert(new Element('DIV', {'class':'begun_div'}).update(
									'<a class="begun_link" rel="nofollow" target="_blank" href="' + banners[i]['url'] + '">'
									+ '<img align="left" src="' + banners[i]['banner_url'] + '">'
									+ '<font class="begun_title"><u><b>' + banners[i]['title'] + '</b></u></font><br/>'
									+ '<font class="begun_desc">' + banners[i]['desc'] + '</font><br/>'
									+ '<font class="begun_domain">' + banners[i]['domain'] + '</font>'
									+ '</a>'));
					}
				}
				Begun_loading = -1;
			},
			onFailure: function(OR) {
				$(Begun_id).update('');
				Begun_loading = -1;
			}
		});
	}
	else {
		Begun_timer[Begun_id] = setInterval(function() {
			if(Begun_loading < 0) {
				if(Begun_timer[Begun_id]) clearInterval(Begun_timer[Begun_id]);
				getBegunBanners(Begun_Keywords, Begun_Limit, Begun_offset, Begun_id);
			}
		}, 100);
	}
}
