function addRSSFeed(url){
var myAjax = new Ajax.Request(
	url, 
	{
		method: 'get', 
		parameters: '', 
		onComplete: showResponse
	});
}
function showResponse(request)
{
	var node = request.responseXML; 
	// Get Channel information
	var channel = node.getElementsByTagName('channel').item(0);
	var title = channel.getElementsByTagName('title').item(0).firstChild.data;
	var link = channel.getElementsByTagName('link').item(1).firstChild.data;
	var items = channel.getElementsByTagName('item');
	if(items.length > 0){
		$('ajaxreader').appendChild(document.createElement('div'));
		$('ajaxreader').lastChild.className = "blog";
		var content = $('ajaxreader').lastChild;
		var temp = document.createElement("h3");
		temp.appendChild(document.createElement('a'));
		temp.firstChild.setAttribute('href',link);
		temp.firstChild.appendChild(document.createTextNode(title));
		content.appendChild(temp);
		// Browse items

		for (var n=0; n < items.length && n < 5; n++){
			var itemTitle = items[n].getElementsByTagName('title').item(0).firstChild.data;
			var itemLink = items[n].getElementsByTagName('link').item(0).firstChild.data;
			var itemDesc = items[n].getElementsByTagName('description').item(0).firstChild.data;
	//		itemDesc.replace(/<[^>]+>/g,"");
			if(itemDesc.length > 200){
				k = itemDesc.indexOf(" ",200);
				if(k<0){
					k = itemDesc.length;
				}
				itemDesc = itemDesc.substring(0,k);
			}
		
			temp = document.createElement('h4');
			temp.appendChild(document.createElement('a'));
			temp.firstChild.setAttribute('href', itemLink);
			temp.firstChild.appendChild(document.createTextNode(itemTitle));
			content.appendChild(temp);
			/*try { 
				var itemPubDate = (items[n].getElementsByTagName('pubDate').item(0).firstChild.data).split(" ");
				itemPubDate = new Date(itemPubDate[1] + " " + itemPubDate[2] + " " + itemPubDate[3]);
				temp = document.createElement('span');
				temp.setAttribute('class', "newsDate");
				temp.appendChild(document.createTextNode(itemPubDate.format()));
				content.appendChild(temp);
			} catch (e) { 
				var itemPubDate = '';
			}*/
			temp = document.createElement('p');
			//temp.appendChild(document.createTextNode(itemDesc + "... "));
			temp.innerHTML = itemDesc + "... ";
		
			temp.appendChild(document.createElement('a'));
			temp.lastChild.setAttribute("href",itemLink);
			temp.lastChild.appendChild(document.createTextNode("Read More >>"));
			content.appendChild(temp);
		}
	}
	blogcount--;
	if( blogcount == 1){
		addRSSFeed('http://www.healthlicensedefense.com/b/category/doctors/feed');
	} else if (blogcount == 0)	{
		addRSSFeed('http://www.healthlicensedefense.com/b/category/others-professionals/feed');
	}
}
//var blogcount = 5;
//addRSSFeed('http://www.healthlicensedefense.com/gateway.php?p=' + blogcount);
var blogcount = 2;
addRSSFeed('http://www.healthlicensedefense.com/b/category/nurses/feed');