/**
 * Class Name    : 	rssReader.js
 * Author(s)     : 	Anjeeta Manish
 * Creation Date : 	25 Mar, 2009
 * Functionality : 	Javascript file to fetch the RSS feed entries for Dr.Greg Allgood Work's page. 
					The functions in this file simply load the parsed html from the XMLFeedReader.jsp.
 * Dependencies	 : 	NA
 * Copyright     : 	P&G
 * Modifications : 	<Author> <Date> <Description of Modification>
 */
var xmlRequestObj;
var xmlDoc;

window.setInterval("updateTimer()", 1200000); // update the data every 20 mins

function getRSS()
{
	//call the right constructor for the browser being used
	if (window.XMLHttpRequest)     // Object of the current windows
	{
		// Firefox, Safari, ...
		xmlRequestObj = new XMLHttpRequest();
		if (xmlRequestObj.overrideMimeType)
		{ 
			xmlRequestObj.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)   // ActiveX version
	{
		try 
		{  
			xmlRequestObj = new ActiveXObject('Msxml2.XMLHTTP');   
		}
		catch (e1) 
		{
			try 
			{   
				xmlRequestObj = new ActiveXObject('Microsoft.XMLHTTP');   // Internet Explorer  
			}
			catch (e2) 
			{
				xmlRequestObj = false;
			}
		}
	}
	else if (!xmlRequestObj && window.createRequest) 
	{
		try {
			xmlRequestObj = window.createRequest();
		} 
		catch (e) {
			xmlRequestObj=false;
		}
	}else
		alert("Ajax is not supported");
	
	xmlRequestObj.onreadystatechange = function()
	{ 
		if(xmlRequestObj.readyState == 4)
		{
			if(xmlRequestObj.status == 200)
			{
				if (xmlRequestObj.responseText != null)
				{
					showRSS(xmlRequestObj.responseText);
				}
				else
				{
					alert("Failed to receive RSS file from the server - file not found.");
					return false;
				}

			}
			else	
				alert("Error: returned status code " + xmlRequestObj.status + "\n Recieved >> " + xmlRequestObj.statusText);
		}	
	}

	//prepare the xmlhttprequest object
	xmlRequestObj.open("GET", "/pgcom/jsp/csdw/XMLFeedReader.jsp", true);
	xmlRequestObj.setRequestHeader("Cache-Control", "no-cache");
	xmlRequestObj.setRequestHeader("Pragma", "no-cache");

	xmlRequestObj.send(null);
}

//shows the RSS content in the browser
function showRSS(divContent)
{
	document.getElementById("drCntntRght").innerHTML = divContent;	
}

// Timer to check the change in RSS feeds blog
function updateTimer() {
	getRSS();
}