var fader = true;

function featuredComments(comments) {
	removeNode('featuredCommentsOutput');

	var featuredComments = document.getElementById('featuredComments');
	var featuredCommentsOutput = document.createElement('div');
	featuredCommentsOutput.setAttribute('id', 'featuredCommentsOutput');
	featuredCommentsOutput.setAttribute('class', 'featuredCommentsOutput');

	var outputDiv = document.createElement('div');

	//-1 as prefs is last object
	for (var i = 0; i < (comments.length - 1); i++)
	{
		var outCommentDiv = document.createElement('div');

		var outBlockQuote = document.createElement('blockquote');

		var outQuote = document.createElement('div');
		outQuote.appendChild(document.createTextNode(comments[i].quote));
		var outName = document.createElement('cite');
		outName.setAttribute('class', 'featuredCommentsName');
		outName.appendChild(document.createTextNode(comments[i].name));
		var outDate = document.createElement('span');
		outDate.setAttribute('class', 'featuredCommentsDate');
		outDate.appendChild(document.createTextNode(comments[i].date));

		outName.appendChild(document.createElement('br'));
		outName.appendChild(outDate);
		outQuote.appendChild(document.createElement('br'));
		outQuote.appendChild(outName);

		outBlockQuote.appendChild(outQuote);
		outCommentDiv.appendChild(outBlockQuote);

		outputDiv.appendChild(outCommentDiv);
	}
	featuredCommentsOutput.appendChild(outputDiv);
	featuredComments.appendChild(featuredCommentsOutput);

	var commentSpeed = comments[comments.length - 1].commentSpeed;

	if (fader) {
		new SimpleSlide('featuredCommentsOutput',{type: 'fade', direction: 'forward', duration: 600, auto: 'loop', time: commentSpeed});
	} else
		featuredCommentsOutput.setAttribute('class', 'featuredCommentsOutputNonFade');
}

function showComments() {
	removeNode('jsonComments');

	var div = document.getElementById('featuredComments');
	var featuredComments = document.createElement('div');
	featuredComments.setAttribute('id', 'featuredCommentsOutput');
	featuredComments.appendChild(document.createTextNode('Loading...'));
	div.appendChild(featuredComments);

	// Retrieve the JSON feed.
	var script = document.createElement('script');

	var address = siteURL + '/frontpage/featuredComments';

	script.setAttribute('src', address); //returns default callback
	script.setAttribute('id', 'jsonComments');
	script.setAttribute('type', 'text/javascript');
	document.documentElement.firstChild.appendChild(script);
}
