var lobby = {
	updateLobbyChat: function() {
		objLobbyChat = new Ajax.Request('/xmldataset.php?status=chat', {
			method:'get',
			onSuccess: function(ajaxResponse) {
				objChat = $('chat_messages'); 
				jsonData = ajaxResponse.responseText.evalJSON();
				
				anzItems = jsonData.length;
				for(i = 0; i < anzItems; i++) {
					objChat.innerHTML += '<span><a href="/profil.php?spieler=' + jsonData[i].id + '">'+ jsonData[i].name + '</a>: ' + jsonData[i].message + '</span><br />';
				}
				objChat.scrollTop = objChat.scrollHeight;
		}});
	},
	updateGameList: function() {
		objGameList = new Ajax.Request('/xmldataset.php?liste=games', {
			method: 'get',
			onSuccess: function(ajaxResponse) {
				objGameList = $('game_list_list');
				objGameList.innerHTML = '';
				jsonData = ajaxResponse.responseText.evalJSON();
				anzItems = jsonData.length;
				myTemplate = new Template(jsonData[0].template);
				
				for(i = 1; i < anzItems; i++) {
					objGameList.innerHTML += myTemplate.evaluate({
						'id': jsonData[i].id,
						'director': jsonData[i].director,
						'director_id': jsonData[i].director_id,
						'players': jsonData[i].players,
						'date': jsonData[i].date,
						'type':	jsonData[i].type,
						'action': jsonData[i].action,
						'status': jsonData[i].status});
				}
			}
		});
	},
	updatePlayerOnline: function() {
		objPlayerOnline = new Ajax.Request('xmldataset.php?liste=online&count=50', {
			method: 'get',
			onSuccess: function(ajaxResponse) {
				objPlayer = $('player_online');
				objPlayer.innerHTML = '<ul>';
				
				jsonData = ajaxResponse.responseText.evalJSON();
				anzItems = jsonData.length;
				myTemplate = new Template(jsonData[0].template);
				
				for(i = 1; i < anzItems; i++) {
					objPlayer.innerHTML += myTemplate.evaluate({
						'id': jsonData[i].id,
						'name': jsonData[i].name,
						'status': jsonData[i].status,
						'statusclass': jsonData[i].statusclass});
				}
				
				objPlayer.innerHTML += '</ul>';
			}
		});
	},
	updateFriendsOnline: function() {
		objPlayerOnline = new Ajax.Request('xmldataset.php?liste=freunde', {
			method: 'get',
			onSuccess: function(ajaxResponse) {
				objPlayer = $('my_friends');
				objPlayer.innerHTML = '<ul>';
				
				jsonData = ajaxResponse.responseText.evalJSON();
				anzItems = jsonData.length;
				myTemplate = new Template(jsonData[0].template);
				
				for(i = 1; i < anzItems; i++) {
					objPlayer.innerHTML += myTemplate.evaluate({
						'id': jsonData[i].id,
						'name': jsonData[i].name,
						'status': jsonData[i].status,
						'statusclass': jsonData[i].statusclass});
				}
				
				objPlayer.innerHTML += '</ul>';
			}
		});
	}
}
