google.load("feeds", "1");     
function getWeather(Code) {
var feed = new google.feeds.Feed("http://newsrss.bbc.co.uk/weather/forecast/" + Code + "/Next3DaysRSS.xml");      
feed.load(function(result) {        
if (!result.error) {          
var location = result.feed.title;
intStart = location.indexOf(" for ");
intEnd = location.indexOf(",");
if (intStart>0 && intEnd > 0)
{ 
   strLocation = location.substring(intStart+5, intEnd);
}
else
   strLocation = "(unknown)";

var entry = result.feed.entries[0];            
var strWeatherXml = entry.title;
 intStart = strWeatherXml.indexOf(":");
 intEnd = strWeatherXml.length;
 intTempStart = strWeatherXml.indexOf(",");
 intTempEnd = strWeatherXml.lastIndexOf(",");
 if (intStart>0 && intTempEnd > 0)
 { 
   strFirstLetter = strWeatherXml.substring(intStart+2, intStart+3);
   strFirstLetter = strFirstLetter.toUpperCase();
   strForecast = strFirstLetter + strWeatherXml.substring(intStart+3, intTempStart);
   strTemperature = strWeatherXml.substring(intTempStart+1 ,intTempEnd);
   strTemperature = strTemperature.replace(/Max Temp: /, "");
 }
 else
 {
     strForecast = "n/a";
     strTemperature = "";
 }

strWeatherDiv = "BBCWeather" + Code;
var container = document.getElementById(strWeatherDiv);
var div = document.createElement("div");            
div.appendChild(document.createTextNode(strForecast + strTemperature));            
container.appendChild(div);


strLocationAnchor = "BBCWeatherLocation" + Code;
var anchor = document.getElementById(strLocationAnchor);
anchor.href = "http://news.bbc.co.uk/weather/forecast/" + Code;
anchor.title = "BBC weather forecast for " + strLocation;
anchor.innerHTML = strLocation;

}      
});  
}
