// Revision: 2.4
// Last updated: 20th January 2006
function commentAdded(request) {
	if ($('newcommenterrors')) { Element.remove('newcommenterrors'); }
	new Effect.Appear($('commentlist').lastChild);
	$('comment').value = '';
	$('comment').disabled = true;
	$('submit').disabled = true;
	if ($('nocomment')) { Element.remove('nocomment'); }
	if ($('hidelist')) { Element.remove('hidelist'); }
}

function failure(request) {
	Element.show('newcommenterrors');
	$('newcommenterrors').innerHTML = request.responseText;
	$('newcommenterrors').style.display = 'block';
	new Effect.Highlight('newcommenterrors',{queue:'end'});
	if ($('nocomment')) { Element.show('nocomment'); }
}

function loading() {
	if ($('nocomment')) { Element.hide('nocomment'); }
	$('submit').disabled = true;
	$('comment').disabled = true;  
	Element.show('newcommentloading');
}

function complete(request) {
	Element.hide('newcommentloading');
	Element.show('commentform');
	$('submit').disabled = false;
	$('comment').disabled = false;  

	if (request.status == 200) {
		commentAdded()
		return true;
	} else {
		failure(request) 
		return false
	};
}
