// File: readXML.js

// Start function when DOM has completely loaded 
jQuery(document).ready(function(){ 

	// set xml file by browser
	 if(jQuery.browser.msie){
     	var proxy_file = "proxy.php";
 	 }
	 else
	 {
     	var proxy_file = "proxy2.php";
  	 }

	// Open the xml file
	jQuery.post("http://"+window.location.hostname+"/news/scripts/"+proxy_file+"?url=http://weather.yahooapis.com/forecastrss?p=02120",{},function(xml){
      	
		// Build an HTML string
		myHTMLOutput = '';
	 	
		// Run the function for each item tag in the XML file
		jQuery('item',xml).each(function(i) {
			weatherTemp = jQuery(this).find("yweather\\:condition").attr("temp");
			weatherConditions = jQuery(this).find("yweather\\:condition").attr("text");
															
			// Build row HTML data and store in string
			mydata = BuildWeatherHTML(weatherTemp,weatherConditions);
			myHTMLOutput = myHTMLOutput + mydata;
		});
				
		// Update the DIV called Content Area with the HTML string
		jQuery(".weather").append(myHTMLOutput);
	});
});
 
 
 
 function BuildWeatherHTML(weatherTemp,weatherConditions){
	
	// Build HTML string and return
	output = '<strong>Current Weather</strong> ';
	output += + weatherTemp + '&deg;';
	output += ' ' + weatherConditions;
	return output;
}