// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the xml file
	$.get("/blogfeeds/wcoop/wcoop_teamps.xml",{},function(xml){
      	
	// Build an HTML string
	HTMLOutput = '';
			
		// Run the function for each student tag in the XML file
		$('item',xml).each(function(i) {
												
			blogtitle = $(this).find("title").text();
			bloglink = $(this).find("link").text();
			blogpubdate = $(this).find("pubDate").text();
			blogpost = $(this).find("post").text();
			playername = $(this).find("playername").text();
			
			// Build row HTML data and store in string
			mydata = buildHTMLb(blogtitle,bloglink,blogpubdate,blogpost,playername);
			HTMLOutput = HTMLOutput + mydata;
			
		});
		
		// Update the DIV called Content Area with the HTML string
		$("#TPS").append(HTMLOutput);
});
	
});
 
 function buildHTMLb(blogtitle,bloglink,blogpubdate,blogpost,playername){
	
	// Build HTML string and return
	output = '';
	output += '<div class="post-o_container">';
	output += '<div class="alignLeft"><a href="http://www.pokerstars.pl/team-pokerstars/' + playername + '/" target="_blank"><img src="http://www.wcoop.com/images/team-pokerstars/' + playername + '.jpg" border="0" alt="' + playername + '" /></a></div>';
	output += '<div class="txt">';
	output += '<p><a href="' + bloglink + '" class="bold_link" target="_blank"><span class="red_title_big">' + blogtitle + '</span></a></p>';
	output += '<p>Posted on ' + blogpubdate + '</p>';
	output += '<p>' + blogpost + '... <a href="' + bloglink + '" class="bold_link" target="_blank">more</a></p>';
	output += '</div></div>';
	output += '<div class="dotted_line">&nbsp;</div>';
	return output;
}
