//Loads content in the NewsArticle container.
var contentLoader = new Class({
	initialize: function(listId,targetId,itemTree,conduit) {
		this.feedConduit = conduit;
		this.myList = $(listId);
		this.myTarget = $(targetId);
		this.myItems = this.myList.getElements(itemTree);
		this.myItems.each(function(item) {
			item.addEvent("click", function(event) {
				var param = item.href.split('?')[1];
				this.loadContent(param);
				event = new Event(event).stop();
			}.bind(this));
		}.bind(this));
	},
	loadContent: function(param) {	
		var myAjax = new Ajax(this.feedConduit+'?'+ param, {
			method: 'get',
			evalScripts: true,
			update: this.myTarget,
			onRequest: function(data) {
				this.myTarget.setHTML('<p class="error">Loading...</p>');
			}.bind(this),
			onFailure: function(data) {
				this.myTarget.setHTML('<p class="error">Could not load asset.</p>');
			}.bind(this)
		}).request();
	}
});

//Loads panes in the NewsNav.
var paneLoader = new Class({
	initialize: function(listId,targetId,itemTree,conduit) {
		this.feedConduit = conduit;
		this.myList = $(listId);
		this.myTarget = $(targetId);
		this.myItems = this.myList.getElements(itemTree);
		this.myItems.each(function(item) {
			item.addEvent("click", function(event) {
				var param = item.href.split('?')[1];
				this.loadContent(param);
				event = new Event(event).stop();
			}.bind(this));
		}.bind(this));
	},
	loadContent: function(param) {	
		var myAjax = new Ajax(this.feedConduit+'?'+ param, {
			method: 'get',
			evalScripts: true,
			update: this.myTarget,
			onRequest: function(data) {
				this.myTarget.setHTML('<p class="error">Loading...</p>');
			}.bind(this),
			onFailure: function(data) {
				this.myTarget.setHTML('<p class="error">Could not load asset.</p>');
			}.bind(this)
		}).request();
	}
});