	// RSS to HTML conversion script for news feeds
	// Developed for HCCT by Demitri Baroutsos
	// Last modified 4 February 2006
	
	var iNewsTimerID = "";
	var iWeatherTimerID = "";
	var strNewsURL = "";
	var strWeatherURL = "";
	
	// Load a specific news feed
	function loadFeed(strFeed)
	{
		if (strFeed.toString().toLowerCase() == 'news')
		{
			divNews.innerHTML = "Loading news, please wait..."
			document.body.style.cursor = 'wait';
			iNewsTimerID = setInterval(loadNews, 1000);
		}
		else if (strFeed.toString().toLowerCase() == 'weather')
		{
			document.body.style.cursor = 'wait';
			divWeather.innerHTML = "Loading weather, please wait..."
			iWeatherTimerID = setInterval(loadWeather, 1000);
		}
	}
	
	// Loads the news feed into the weather DIV
	function loadNews(strURL, strDivID)
	{
		clearInterval(iNewsTimerID);

		transformXML(strURL, "news.xsl", strDivID, "Could not retrieve news feed. Please try again later.")
		
		document.body.style.cursor = 'default';
	}
	
	// Loads the weather feed into the weather DIV
	function loadWeather(strURL, strDivID)
	{
		clearInterval(iWeatherTimerID);
		
		transformXML(strURL, "weather.xsl", strDivID, "Could not retrieve weather feed. Please try again later.")

		document.body.style.cursor = 'default';
	}
	
	// Generic function for loading XML, XSL and transforming or showing a message
	// in a predefined DIV
	function transformXML(strURL, strXSLFile, strDivID, strErrorMessage)
	{
		// Load weather RSS feed
		var XMLDoc = new ActiveXObject("Microsoft.XMLDOM") // Msxml2.DOMDocument.4.0
		XMLDoc.async = false;
		XMLDoc.load("getfeedxml.asp?url=" + escape(strURL))
		
		// Load weather XSL stylesheet
		var XSLDoc = new ActiveXObject("Microsoft.XMLDOM") // Msxml2.DOMDocument.4.0
        XSLDoc.async = false;
        XSLDoc.load(strXSLFile);
		
		// Transform weather feed into HTML
		if (XMLDoc.xml.toString().length > 0)
			document.getElementById(strDivID).innerHTML = XMLDoc.transformNode(XSLDoc.documentElement);
		else
			document.getElementById(strDivID).innerHTML = "<span class=\"error\">Error: " + strErrorMessage + "</span>";
		
		// Free up memory
		XSLDoc = null;
		XMLDoc = null;
	}

