// File: ldacr.js

// Start function when DOM has completely loaded 
$(document).ready(function(){ 
	
	// Open the xml file
	$.get("ldacr2011.xml",{},function(xml){
      
  	
		// Build an HTML string
		myHTMLOutput = '';
	 	myHTMLOutput += '<table class="square1" cellspacing="0">';
		myHTMLOutput += '<tr><td class="title" colspan="3">Landscape Acrylic Prints</td></tr>'
	  	myHTMLOutput += '<tr><td class="hed" colspan="1">Imperial</td><td class="hed" colspan="1">Metric</td><td class="hed" colspan="1">Retail Price</td></tr>';
	  	
		// Run the function for each size tag in the XML file
		$('size',xml).each(function(i) {
			sizeImphldacr = $(this).find("imphldacr").text();
			sizeImpvldacr = $(this).find("impvldacr").text();
			sizeMetrichldacr = $(this).find("metrichldacr").text();
			sizeMetricvldacr = $(this).find("metricvldacr").text();
			sizePriceldacr = $(this).find("priceldacr").text();
			sizeX = ' x ' 
			
			// Build row HTML data and store in string
			mydata = BuildSizeHTML(sizeImphldacr,sizeX,sizeImpvldacr,sizeMetrichldacr,sizeMetricvldacr,sizePriceldacr); 
			myHTMLOutput = myHTMLOutput + mydata;
		});
		myHTMLOutput += '</table>';
		
		// Update the DIV called Content Area with the HTML string
		$(".ldacr").append(myHTMLOutput);
});
});


 
 function BuildSizeHTML(sizeImphldacr,sizeX,sizeImpvldacr,sizeMetrichldacr,sizeMetricvldacr,sizePriceldacr){
	

	
	// Build HTML string and return
	output = '';
	output += '<tr>';
	output += '<td class="light">'+ sizeImphldacr + sizeX + sizeImpvldacr +'</td>';
	output += '<td class="light">'+ sizeMetrichldacr + sizeX + sizeMetricvldacr +'</td>';
	output += '<td class="light">'+ sizePriceldacr +'</td>';
	output += '</tr>';
	return output;
}

