// This function gets the list of the player.
// Pass the rank argument to find the row with the searched player.
// Pass rank argument as zero to display the top 10 list. 
function get_player_list(rank, tournament_type, tournament_id)
{
	// Make a POST request to reader.php with action as 'get_list' and
	// rank as the rank of the player to be highlighted or 
	// rank as 0 if top 10 list is to be displayed. 
	
	new Ajax.Request('http://www.gowildcasino.com/casino-tournaments/table_js/xml_reader.html', {
	method:'post',
	parameters: {rank: rank, action: 'get_list', tournament_type: tournament_type, tournament_id: tournament_id},
	requestHeaders: {Accept: 'application/json'},
	onSuccess: function(transport)
	{	
		$('player_list').update(transport.responseText);		
	}	
	});
}

function search_player(tournament_type, tournament_id)
{
	// Make a POST request to reader.php with action as 'search_list' and
	// search_str as the string to be searched.
	
	new Ajax.Request('http://www.gowildcasino.com/casino-tournaments/table_js/xml_reader.html', {
	method:'post',
	parameters: {search_str: $('search_str').value, action: 'search_list', tournament_type: tournament_type, tournament_id: tournament_id},
	requestHeaders: {Accept: 'application/json'},
	onSuccess: function(transport)
	{	
		$('search_result').update(transport.responseText);
		if(transport.responseText == '<strong>Sorry, no search result found.</strong>')
		{
			get_player_list(0, tournament_type, tournament_id);
		}
				
	}	
	});
}
