// File: whoarewe.js

// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the homepage.xml file
	$.get("content/whoarewe.xml",{},function(xml){
      	
		// Build an HTML string   
		introContent = $(xml).find('intro_txt').text();
		myHTMLOutput = introContent;

		myHTMLOutput += '<div id="imgGallery"><ul>'; 
	  	
		// Run the function for each student tag in the XML file
		$('content_images',xml).each(function(i) {
			imgName = $(this).find("img_name").text();
			imgCaption = $(this).find("img_caption").text();

			// Build row HTML data and store in string
			mydata = BuildHTML(imgName,imgCaption);
			myHTMLOutput = myHTMLOutput + mydata;
		});
		myHTMLOutput += '</ul></div>';
		
		// Update the DIV called Content Area with the HTML string
		$("#ContentArea").append(myHTMLOutput);
	});
});
 
 
 
 function BuildHTML(imgName,imgCaption){
	
	if (imgName == '') {
			image_src = '';
	} else {
			image_src = '<li><img src="images/' + imgName + '" border="0" alt="Eminence Road Farm Winery" /><p>' + imgCaption + '</p></li>';
	}

	// Build HTML string and return
	output = '';
	output += image_src;
	return output;
}