function gFeedDisplay( tabtitle, url, feedlimit )
{
	var feedpointer = new google.feeds.Feed( url )
	var tabdivid = tabtitle.toLowerCase();
	
	feedpointer.setNumEntries( feedlimit )
	
	document.write('<div id="' + tabdivid + '" class="tabbertab" style="padding:10px;"><img src="images/progress.gif" alt="Progress" class="loadingimg" /> Loading feed...</div>')
	
	this.feedcontainer = document.getElementById( tabdivid )
	
	var displayer = this
	
	feedpointer.load( function( result ) { displayer.formatoutput( result, tabdivid, tabtitle ) } ) //call Feed.load() to retrieve and output RSS feed
}

gFeedDisplay.prototype.formatoutput = function( result, tabdivid, tabtitle )
{
	if (!result.error)
	{ //if RSS feed successfully fetched
		var thefeeds = result.feed.entries //get all feed entries as a JSON array
		var rssoutput = ""

		for (var i=0; i<thefeeds.length; i++)
		{ //loop through entries
			var itemdate = new Date(thefeeds[i].publishedDate).toLocaleString()
			rssoutput += "<div class='feeditem'>"
			rssoutput += "<div class='feedtitlewrap'><table class='feedtitletable'>"
			rssoutput += "<tr>"
			rssoutput += "<td class='feedtitle'>"
			rssoutput += "<a href='" + thefeeds[i].link + "' title='" + thefeeds[i].title + "'>" + thefeeds[i].title + "</a>"
			rssoutput += "</td>"
			rssoutput += "</tr>"
			rssoutput += "</table></div>"
			rssoutput += "<div class='feeddate'>" + itemdate + "</div>"
			rssoutput += "<div class='feeddesc'>" + thefeeds[i].content + "</div>"
			rssoutput += "<div style='clear:both;'></div>"
			rssoutput += "</div>"
		}
		this.feedcontainer.innerHTML = "<h2>" + tabtitle + "</h2>" + rssoutput

	}
	else
	{	//else, output error	
		//if (gURLArg('reload'))
		//{
			this.feedcontainer.innerHTML = 'Error fetching feeds: ' + result.error.message + '. Most likely due to slow offsite feed generation. Try <a href="/" onclick="javascript:window.location.reload()">reloading</a> the page.'
		//}
		//else
		//{
		//	javascript:window.location = window.location.href + '?reload=true';
		//}
	}
}

function gURLArg ( arg )
{
	var searchString = document.location.search;

	// strip off the leading '?'
	searchString = searchString.substring(1);

	var nvPairs = searchString.split("&");

	for (i = 0; i < nvPairs.length; i++)
	{
		var nvPair = nvPairs[i].split("=");
		var name = nvPair[0];
		var value = nvPair[1];
		
		if ( arg = nvPair[0] )
		{
			return nvPair[1];
		}
	}
}