function rssFeed(rssFeedPath, renderIntoContainer, firstRenderCallback, trackingName) {
	// initialize the visibility check
	this.trackingName = trackingName || 'rss';
	this.firstRenderCallback = firstRenderCallback;
	this.renderIntoContainer = renderIntoContainer;
	this.rssFeedPath = rssFeedPath;
	
	this.config = {
		path: rssFeedPath,
		limit: 20
	};
	
	this.data = [];
	this.current = 0;
	this.hasresponse = false;
	
	var thisObj = this;


	this.getRSSFeed = function(callback) {
		this.hasresponse = false;
		this.data = [];
		this.current = 0;
		this.postcallback = callback;
		
		netShelter.getStoryModelsFromFeed(
	       	this.config.path,
	       	this._postsDataCallback,
			'rss'
		);
	}

	this._postsDataCallback = function(storyModelList) {
		thisObj.data = storyModelList;
		if (thisObj.data.length > thisObj.config.limit)
			thisObj.data.length = thisObj.config.limit;
		
		//auto render to element
		if (thisObj.postcallback)
			thisObj.postcallback(thisObj);
		
		thisObj.hasresponse = true;
		sendLoadedTrackingEventIfLoaded(thisObj.trackingName);
	}
	
	this.next = function() {
		if(thisObj.data.length > thisObj.current - 1){
			thisObj.current++;
			return thisObj.data[thisObj.current];
		}
		return false;
	}
	
	this.rewind = function() {
		thisObj.current = 0;
	}
		
}

function renderRSSFeed(rssobj) {
	var tobj = new rssPostTempl();
	var html = "";
	
	while (rss = rssobj.next()) {
		html += tobj.toHTML(rss);
	}
	$(rssobj.renderIntoContainer).html(html);

	rssobj.firstRenderCallback(rssobj.trackingName);
	rssobj.rewind();
}	


var rssPostTempl = function() {
	var self = this;

	this.toHTML = function(storyModel) {
		// #community_poster is how the others were set up.  Yes, it's dumb to reuse an ID.
		return	"<div id = 'community_poster' class = 'community_stream_blog_post'>\
					<h1>\
						<a href = '" + storyModel.articlePath + "' target = '_blank' class='trackable' objType='communityStreamClick' nstrack-asset='blog_post_title' >" +
							storyModel.title + "\
						</a>\
					</h1>\
					<p>\
						<a href = '" + storyModel.articlePath + "' target = '_blank' style = 'color: white;' class = 'continueReadingLink trackable' objType='communityStreamClick' nstrack-asset='blog_post_summary'' >" +
							storyModel.summary + " \
						</a>\
					</p>\
				</div>\
				<div class='msgSep'>\
					&nbsp;\
				</div>";
	}
	
	function parseURL(value) {
		return value.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g, function(url) {
			var r = "<a objType='communityStreamClick' class='trackable' nstrack-asset='url."+url+"' href='"+url+"' target='_blank'>"+url+"</a>";
			return r;
		});
	}
}


