// Revision: 0.9.0
// Last updated: 20th January 2006
function commentAdded() {
	if (hideOnSubmit == 0)
	{
		new Effect.Fade($('commentbody'));
		$('comment').disabled = true; 	// if comment success. Comment box is disable to avoid spam
		$('submit').disabled = true;  	// if comment success. Submit button is disable to avoid spam
	}
	if ($('error')) { Element.remove('error'); }
	new Effect.Appear($('commentlist').lastChild);
	Element.hide('nocommentyet'); 	// hide No Comments notice if first comment added
}

function failure(request) {
	Element.show('error');
	$('error').innerHTML = "<p>" + request.responseText + "</p>";
	new Effect.Highlight('error',{queue:'end'});
}

function loading() {
	$('submit').disabled = true;
	$('comment').disabled = true;  
	Element.show('loading');
}

function complete(request) {
	Element.hide('loading');
	Element.show('commentform');
	$('submit').disabled = false;  // avoid disabling submit button
	$('comment').disabled = false; // avoid disabling commentbox

	if (request.status == 200) {commentAdded()}
	else {failure(request)};
}
