//HALL OF FAME - Weekly Table
$(document).ready(function(){ 
	$.get("http://www.pokerstars.cz/data/leader-board/halloffame.xml",{},function(xml){
	HTMLOutput = '';	
	$('hof-all',xml).each(function(i) {			
		HTMLOutput += '<table class="tbl_weekly" width="80%"><tr><th>Po&#345;ad&iacute;</th><th>U&#382;ivatelsk&eacute; ID</th><th>Zem&#283;</th><th>Body</th><th>Datum</th></tr>';
		$('hof-weekly ranking',xml).each(function(i) {
			place = $(this).find("place").text();
			name = $(this).find("userID").text();
			country = $(this).find("country").text();
			var iniPoints = $(this).find("points").text();
			var makingLocal_Points = iniPoints.replace(/\,/g, ".");
			var points = makingLocal_Points.replace(/((\d+)\.(\d{3}))\.(\d{2})/, "$1,$4"); 
			var theLocalMonth = $(this).find("month").text();
			var theLocalDay = $(this).find("day").text();
			var year = $(this).find("year").text();
			
			var date = theLocalDay + '.' + theLocalMonth + '.' + year;
			
			mydata = buildWeeklyTable(place,name,country,points,date);
			HTMLOutput = HTMLOutput + mydata;
		});
		HTMLOutput += '</table>';
		$("#writeWeeklyTable").append(HTMLOutput);
	});
});
	
});
 //The HOF Weekly table
function buildWeeklyTable(place,name,country,points,date){
	output = '';
	output += '<tr>';
	output += '<td>'+ place + '.</td>';
	output += '<td>'+ name +'</td>';
	output += '<td style="text-align:center;">'+ country +'</td>';
	output += '<td>'+ points +'</td>';
	output += '<td>'+ date +'</td>';
	output += '</tr>';
	return output;
}
//HALL OF FAME - Monthly Table
$(document).ready(function(){ 
	$.get("http://www.pokerstars.cz/data/leader-board/halloffame.xml",{},function(xml){
	HTMLOutput = '';	
	$('hof-all',xml).each(function(i) {			
		HTMLOutput += '<table class="tbl_monthly" width="80%"><tr><th>Po&#345;ad&iacute;</th><th>U&#382;ivatelsk&eacute; ID</th><th>Zem&#283;</th><th>Body</th><th>M&#283;s&iacute;c</th></tr>';
		$('hof-monthly ranking',xml).each(function(i) {
			place = $(this).find("place").text();
			name = $(this).find("userID").text();
			country = $(this).find("country").text();
			var iniPoints = $(this).find("points").text();
			var makingLocal_Points = iniPoints.replace(/\,/g, ".");
			var points = makingLocal_Points.replace(/((\d+)\.(\d{3}))\.(\d{2})/, "$1,$4"); 
			var month = $(this).find("month").text();			
			var monthNames = { '1':'Led', '2':'&Uacute;nor', '3':'B&#345;e', '4':'Dub', '5':'Kv&#283;', '6':'&#268;er', '7':'&#268;vc', '8':'Srp', '9':'Z&aacute;&#345;', '10':'&#344;&iacute;j', '11':'Lis', '12':'Pro'}; 
			year = $(this).find("year").text();			
			date = monthNames[month] + ' ' + year;
			
			mydata = buildMonthlyTable(place,name,country,points,date);
			HTMLOutput = HTMLOutput + mydata;
		});
		HTMLOutput += '</table>';
		$("#writeMonthlyTable").append(HTMLOutput);
	});
});
	
});
 //The HOF Monthly table
function buildMonthlyTable(place,name,country,points,date){
	output = '';
	output += '<tr>';
	output += '<td>'+ place + '.</td>';
	output += '<td>'+ name +'</td>';
	output += '<td style="text-align:center;">'+ country +'</td>';
	output += '<td>'+ points +'</td>';
	output += '<td>'+ date +'</td>';
	output += '</tr>';
	return output;
}
//HALL OF FAME - Yearly Table
$(document).ready(function(){ 
	$.get("http://www.pokerstars.cz/data/leader-board/halloffame.xml",{},function(xml){
	HTMLOutput = '';	
	$('hof-all',xml).each(function(i) {			
		HTMLOutput += '<table class="tbl_yearly" width="80%"><tr><th>Po&#345;ad&iacute;</th><th>U&#382;ivatelsk&eacute; ID</th><th>Zem&#283;</th><th>Body</th><th>Rok</th></tr>';
		$('hof-yearly ranking',xml).each(function(i) {
			place = $(this).find("place").text();
			name = $(this).find("userID").text();
			country = $(this).find("country").text();
			var iniPoints = $(this).find("points").text();
			var makingLocal_Points = iniPoints.replace(/\,/g, ".");
			var points = makingLocal_Points.replace(/((\d+)\.(\d{3}))\.(\d{2})/, "$1,$4");
			year = $(this).find("year").text();			
						
			mydata = buildYearlyTable(place,name,country,points,year);
			HTMLOutput = HTMLOutput + mydata;
		});
		HTMLOutput += '</table>';
		$("#writeYearlyTable").append(HTMLOutput);
	});
});
	
});
 //The HOF Yearly table
function buildYearlyTable(place,name,country,points,year){
	output = '';
	output += '<tr>';
	output += '<td>'+ place + '.</td>';
	output += '<td>'+ name +'</td>';
	output += '<td style="text-align:center;">'+ country +'</td>';
	output += '<td>'+ points +'</td>';
	output += '<td>'+ year +'</td>';
	output += '</tr>';
	return output;
}