// File: wherearewe.js

// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the homepage.xml file
	$.get("content/wherearewe.xml",{},function(xml){
      	
		// Build an HTML string	  	
		introContent = $(xml).find('intro_txt').text();
		myHTMLOutput = introContent + '<br /><div style="clear:both;"></div><br />';

		// Run the function for each student tag in the XML file
		$('location',xml).each(function(i) {
			listingTitle = $(this).find("title").text();
			
			myHTMLOutput += '<b class="location">' + listingTitle + '</b><br />';

				$('listing'+i,xml).each(function(x) {
					listingName = $(this).find("name").text();
					listingInfo = $(this).find("info").text();
					listingLink = $(this).find("url").text();
		
					// Build row HTML data and store in string
					mydata = EminenceHTML(listingName,listingInfo,listingLink);
					myHTMLOutput = myHTMLOutput + mydata;
				});
			myHTMLOutput += '<br /><div style="clear:both;"></div><br />';
		});
		
		// Update the DIV called Content Area with the HTML string
		$("#ContentArea").append(myHTMLOutput);
	});
});
 
 
 
function EminenceHTML(listingName,listingInfo,listingLink){
	
	output = '';
	output += '<b>' + listingName + '</b> ' + listingInfo + ' ';

	if(listingLink != '')
		output += '<a href="http://'+listingLink+'" target="_blank">'+listingLink+'</a>';
	output += '<br /><br />';

	return output;
}