$(document).ready(function(){ 


	$.get("/local/xml/s0000078_e.xml",{},function(xml){
      	

		ecOutput = '';
	 	ecOutput += '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="ecvalley">';
	  	ecOutput += '';
	  	

		$('forecast',xml).each(function(i) {
			ecPeriod = $(this).find("period").text();
			ecText = $(this).children("textSummary").text();
			ecRegion = $(this).find("region").text();
			ecIcon = $(this).find("iconCode").text();
			ecIcon2 = $(this).find("iconCode").text(); 
			
			


			ecData = ecBuild(ecPeriod,ecText,ecRegion,ecIcon,ecIcon2);
			ecOutput = ecOutput + ecData;
			

				});




				
		ecOutput += '</table>';
		

		$("#ValleyEC").append(ecOutput);
	});
});
 
 
 
 function ecBuild(ecPeriod,ecText,ecRegion,ecIcon){
	

	if ((ecIcon) != "-"){
		ecIcon2HTML = "<strong>(" + ecIcon2 + ")</strong>";
	}
	else
	{
		ecIcon2HTML = "";
	}
	

	output = '';
	output += '<tr>';
	output += '<td><img class="weatherImage" alt="" src="http://www.weatheroffice.gc.ca/weathericons/' + ecIcon2 + '.gif" /></td>';
	output += '<td ><span class="title">'+ ecPeriod + '</span><br />' + ecText + '</td>';

	// http://www.weatheroffice.gc.ca/weathericons/
	
	
	output += '</tr>';
	return output;
}
	  

