var fader = true;

function featuredComments(comments) {
	removeNode('featuredCommentsOutput');

	var featuredCommentsTable = document.getElementById('featuredComments');
	var featuredCommentsTableBody = document.createElement('tbody');

	for (var i = 0; i < (comments.length - 1); i++){
	
		var featuredCommentsRow = document.createElement('tr');
		var featuredComments = document.createElement('td');
		var featuredCommentsOutput = document.createElement('div');
		featuredCommentsOutput.setAttribute('id', 'featuredCommentsOutput');
		featuredCommentsOutput.setAttribute('class', 'featuredCommentsOutput');

		var outputDiv = document.createElement('div');
	
		var outCommentDiv = document.createElement('div');
		outCommentDiv.setAttribute('id', 'featuredCommentsContext');
	
		var outBlockQuote = document.createElement('blockquote');
		outBlockQuote.appendChild(document.createElement('br'));
		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(document.createElement('br'));
		outQuote.appendChild(outName);
	
		outBlockQuote.appendChild(outQuote);
		outCommentDiv.appendChild(outBlockQuote);
		outputDiv.appendChild(outCommentDiv);
		
		featuredCommentsOutput.appendChild(outputDiv);
		featuredComments.appendChild(featuredCommentsOutput);
		featuredCommentsRow.appendChild(featuredComments);
		featuredCommentsTableBody.appendChild(featuredCommentsRow)
	}
	
	featuredCommentsTable.appendChild(featuredCommentsTableBody);

	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);
}