



function RSS2Item(itemxml)
{
	this.title;
	this.link;
	this.description;
	this.author;
	this.pubDate;
	this.pubTime;
	
	try {
		this.title=itemxml.getElementsByTagName('title')[0].childNodes[0].nodeValue;
	} catch (err) {
	}
	try {
		this.link=itemxml.getElementsByTagName('link')[0].childNodes[0].nodeValue;
	} catch (err) {
	}
	try {
		this.description=itemxml.getElementsByTagName('description')[0].childNodes[0].nodeValue;
	} catch (err) {
	}
	try {
		this.author=itemxml.getElementsByTagName('author')[0].childNodes[0].nodeValue;
	} catch (err) {
	}
	try {
		this.pubDate=itemxml.getElementsByTagName('pubDate')[0].childNodes[0].nodeValue;
		if (this.pubDate.indexOf('+')>0) this.pubDate = this.pubDate.substring(0, this.pubDate.indexOf('+')-4);
		else if (this.pubDate.indexOf('-')>0) this.pubDate = this.pubDate.substring(0, this.pubDate.indexOf('-')-4);
		this.pubTime = this.pubDate.substring(this.pubDate.length-5, this.pubDate.length);
		this.pubDate = this.pubDate.substring(0, this.pubDate.length-5);
	} catch (err) {
	}

}

function rssResponseHandler() {
		if (rssRequest.readyState == 4)
		{
			if (rssRequest.status == 200)
			{
				if (rssRequest.responseText != null) {
					var items = new Array();
					var xmlItems = rssRequest.responseXML.getElementsByTagName("item");
					for (var i=0; i<xmlItems.length; i++)
					{
						items.push(new RSS2Item(xmlItems[i]));
					}
					showRSS(items);
				} else {
					return false;
				}
			}
		}
}

var rssRequest;

function getRSSFeed()
{
	var rssUrl = "/21pUpdates/21PublishBlog.xml";
	if (window.ActiveXObject) rssRequest = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) rssRequest = new XMLHttpRequest();
	rssRequest.open("GET", rssUrl ,true);
	rssRequest.setRequestHeader("Cache-Control", "no-cache");
	rssRequest.setRequestHeader("Pragma", "no-cache");
	rssRequest.onreadystatechange = rssResponseHandler;

	//send the request
	rssRequest.send(null);
}



function showRSS(rssItems)
{
	var updateList = "";
	for (var i=0; i<rssItems.length; i++)
	{
		updateList += "<div class='item'>";
		updateList += "<div class='header'><div class='time'>" + rssItems[i].pubTime + "</div><div class='date'>" + rssItems[i].pubDate + "</div></div>";
		//updateList += "<div class='author'>by: <a href="http://leif.roadrunner.home/fdsa">fdsa</a>";
		updateList += "<div class='j21p_clr'>&nbsp;</div><p class='subtitle'><a href=\"http://21publishblog.21publish.com\">21Publish News Blog</a></p><h3><a href=\"" + rssItems[i].link + "\">" + rssItems[i].title + "</a></h3>";
		updateList += "<p>" + rssItems[i].description + " <a href=\"" + rssItems[i].link + "\">more...</a></p>";
		updateList += "</div>";
	}
	document.getElementById("j21p_rss_updatelist").innerHTML = updateList;

	return true;
}


