// Revision: 2.4
// Last updated: 20th January 2006
/*
	Modified by Alan Orozco
	http://alanorozco.villavicastur.com/
*/
// Revision: 1.2
// Last updated: 07th August 2006
function commentAdded(request) {
	if ($('errors')) { Element.remove('errors'); }
	$('commentlist').lastChild.style.display = "list-item";
	$('commentlist').lastChild.style.opacity = "0";
	var aparecer_cllc = new fx.Opacity($('commentlist').lastChild, {duration: 700});
	aparecer_cllc.custom(0,1);
	$('comment').value = '';
	if ($('nocomment')) { 
		$('nocomment').style.display = "none"; 
	}
	if ($('hidelist')) { 
		$('hidelist').style.display = "none"; 
	}
}

function failure(request) {
	$('errors').style.display = 'block';
	$('errors').innerHTML = request.responseText;
	var resaltar = new fx.Flash($('errors'), {color_from:'#ffffff', color_to:'#F2F0CF', count:2, transition:fx.circ, duration:300});
	resaltar.toggle();
	if($('nocomment')) $('nocomment').style.display = 'block';
}

function loading() {
	if($('nocomment')) $('nocomment').style.display = 'none';
	$('submit').disabled = true;
	$('comment').disabled = true;  
	$('loading').style.display = 'block';
}

function complete(request) {
	$('loading').style.display = 'none';
	$('commentform').style.display = 'block';
	$('submit').disabled = false;
	$('comment').disabled = false;  

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