/**
 * Code to hide and re-show the comment form
 */

function hideCommentForm() {

	// check if there are displayable form errors
	if ($$('#commentFormContainer p.error')[0] != null) {
		
		// do not hide in case of a form error
		return;
	}

	// build show link
	var commentLink = new Element('a', {
	    'href': '#',
	    'id': 'commentFormLink',
	    'html': 'Add Comment &gt;&gt;',
	    'events': {
	        'click': function(){
				showCommentForm();
				return false;
			}
	    }
	});

	// put link below the above container
	commentLink.injectBefore($('commentFormContainer'));
	
	// hide the container
	$('commentFormContainer').setStyle('display', 'none');
}


function showCommentForm() {

	$('commentFormLink').setStyle('display', 'none');
	$('commentFormContainer').setStyle('display', 'block');
}
