$(document).ready(function(){ 
	$.get("http://www.pokerstars.cz/data/leader-board/all_matches.xml",{},function(xml){
	myHTMLOutput = '';
	$('match',xml).each(function(i) {
		var theLocalMonth = $(this).find('month').text();
		var theLocalDay = $(this).find('day').text();
		var theYear = $(this).find('year').text();
		var theDate = theLocalDay + '.' + theLocalMonth + '.' + theYear;
		
		var thePro = $(this).find('pro').text();
		//Bits needed in the Results row
		var theResultValue = $(this).find('result').text();
			if (theResultValue == 1) {
				var theResult = "vyhr&aacute;l nad";
			} else {
				var theResult="prohr&aacute;l s";
			}		
		var theUser = $(this).find('user').text();
		var thePrizeValue = $(this).find('prize').text();
		var thePrize = '$' + thePrizeValue + '.000';
		//to add the dark color to the updated row
		var theClass = $(this).attr('updated');
		
		mydata = buildMatchesHTML(theDate,thePro,theResult,theUser,thePrize,theClass);
			myHTMLOutput = myHTMLOutput + mydata;
		});	
		$("#writeMatches").prepend(myHTMLOutput);
	});
});
function buildMatchesHTML(theDate,thePro,theResult,theUser,thePrize,theClass){
	if (theClass == "yes") {
		theClassHTML = " class='last'";
	} 
	else
	{
		theClassHTML = "";
	}
	
	output = '';
	output += '<tr' + theClassHTML + '>';
	output += '<td>'+ theDate + '</td>';
	output += '<td>'+ thePro +'</td>';
	output += '<td>'+ theResult +'</td>';
	output += '<td>'+ theUser +'</td>';
	output += '<td class="money">'+ thePrize +'</td>';
	output += '</tr>';
	return output;
}