/* Load blog for Swine Flu Hub */
function getBlogEntriesByCategory (inBlog, inCategory, inNumber) {
	var theBlogPath = "/cro/feed-resources/blogs-rss/rss/" + inBlog + ".xml";
	createXMLHttp(theBlogPath, inCategory, inNumber);
}
function createXMLHttp(inURL, inCategory, inNumber) {
	theReqObj = false; 
	if (window.XMLHttpRequest) {
		theReqObj = new XMLHttpRequest();
	}
	if (window.ActiveXObject) {
		theReqObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	theReqObj.open("GET", inURL, true);
	theReqObj.onreadystatechange = function () {
		if (theReqObj.readyState == 2) {
		}
		if (theReqObj.readyState == 4) {
			var theXmlDoc = theReqObj.responseXML;
			var theObj = processBlog(theXmlDoc, inCategory, inNumber);
		}
	}
	theReqObj.send(null);
}

function processBlog (inXmlDoc, inCategory, inNumber) {
	var theOutputDiv = document.getElementById('rssContent1');
	var theNode = inXmlDoc.documentElement;
	var theItems = theNode.getElementsByTagName('item');
	var theCount = 0;
	for (var i = 0; (i < theItems.length); i++) {
		var theItem = theItems[i];
		var theCategories = theItem.getElementsByTagName('category');
		for (var j = 0; (j < theCategories.length); j++) {
			var theCategory = theCategories[j].firstChild.data;
			if (theCategory == inCategory) {
				var theTitle = theItem.getElementsByTagName('title')[0].firstChild.data;
				var theLink = theItem.getElementsByTagName('link')[0].firstChild.data;
				theOutputDiv.innerHTML += '<ul class="bullet-list">' + '<li><a href="' + theLink + '">' + theTitle + '<\/a>' +  '<\/li>' + '<\/ul>'; 
				theCount++;
				break;
			}
		}
		if (theCount >= inNumber) {
			break; // already reached the maximum number of items to display
		}
	}
}
