var communityBoxRepeat = 600000; // time after which it gets repeated, set to 0 to not repeat
var communityBoxUrl = 'index.php?eID=tx_communitybox_pi1';
var communityBoxRunAfter = '';

/**
 * Sets all the fields that show the amount of online users.
 *
 * @return void
 */
function communityBoxSetOnlineUsers() {
	
	var ajax = new Ajax.Request(
		communityBoxUrl,
		{
			method: 'get',
			onSuccess: function(response) {
				// evaluate the content of the eID script
				$$('.communityBox .onlineContainer').each(
					function (node) {
						node.innerHTML = response.responseText;
					}
				);
				
				if (communityBoxRepeat) {
					setTimeout('communityBoxSetOnlineUsers()', communityBoxRepeat);
				}
						
				communityBoxFunctionAfter();
			},
			onFailure: function(response) {
				/*alert(response.responseText);*/
			}
		}
	);
}

// starts the script
document.observe('dom:loaded',
	function (e) {
		communityBoxSetOnlineUsers();
		communityBoxFunctionAfter = new Function(communityBoxRunAfter);
		communityBoxFunctionStart = new Function(communityBoxRunAtStart);

		communityBoxFunctionStart();
	}
);

