// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the xml file
	$.get("/data/promotions/all-star-week/results.xml",{},function(xml){
      	
	// Build an HTML string
	HTMLOutput = '';
			
		// Run the function for each student tag in the XML file
		$('event',xml).each(function(i) {
			matchnumber = $(this).find("matchnumber").text();
			challenger = $(this).find("challenger").text();
			teampro = $(this).find("teampro").text();
			winner = $(this).find("winner").text();
			
			// Build row HTML data and store in string
			mydata = buildHTML(matchnumber,challenger,teampro,winner);
			HTMLOutput = HTMLOutput + mydata;
		});
		
		// Update the DIV called Content Area with the HTML string
		$("#writeRoot").append(HTMLOutput);
		$("tr:odd", "#writeRoot").addClass('rowTint');
});
	
});
 
 function buildHTML(matchnumber,challenger,teampro,winner){
	
	// Build HTML string and return
	output = '';
	output += '<tr>';
	output += '<td>'+ matchnumber + '</td>';
	output += '<td>'+ challenger +'</td>';
	output += '<td>'+ teampro +'</td>';
	output += '<td>'+ winner +'</td>';
	output += '</tr>';
	return output;
}
	 
