// JavaScript Document

function getBlogEntriesByCategory(inCategory, inNumber)
            {
                var theBlogPath = "/health/feed-resources/blogs-rss/rss/health-fullfeed.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('rssContent');
                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;
							var theDescription = theItem.getElementsByTagName('description')[0].firstChild.data; // can retrieve other elements you need
							theDescription = theDescription.substr(0,80) + '...';
                            theOutputDiv.innerHTML += '<div class="blog-entry reform-hub"><a href="' + theLink + '">' + theTitle + '<\/a><br />' + '<p>' + theDescription + '<\/p>' + '<\/div>';
               theCount++;
                        }
                    }
                    if (theCount >= inNumber)
                    {
                        break; // already reached the maximum number of items to display
                    }
                }
            }