$(function() {
	$(document).everyTime(3000, loadEvents);
});

function loadEvents() {
	$.ajax({
		type: 'get',
		url: '/bg/events.php', 
		cache: false,
		data: { 'act': 'load_events' },
		dataType: 'json',
		success: function(json) {
			if (json.result == 0) {
				if (json.data && json.data.events) {
					$(json.data.events).each(function() {
						if (this.is_invite == true) {
							$.showInvite(this);
						} else {
							var msgs = [ this.message ];
							$.showError(msgs);
						}
					});
				}
			} else {
				$.showError(json.errors);
			}
		}
	});
	
}