function textareaCount ( textbox )
{
	chars = $( textbox ).getValue( ).length;
	$( 'char-count' ).update( chars );
	if ( chars > 1000 )
	{
		$( 'comment-character-count' ).addClassName( 'too-many-characters' );
		$( 'comment-submit' ).disabled = true;
		$( 'comment-submit' ).src = '/images/buttons/bt-submit_inactive.gif';
	}
	else
	{
		$( 'comment-character-count' ).removeClassName( 'too-many-characters' );
		$( 'comment-submit' ).disabled = false;
		$( 'comment-submit' ).src = '/images/buttons/bt-submit.gif';
	}
}

function onCommentAdded ( request )
{
	if ( $( 'no-comments-yet' ) ) 
		$( 'no-comments-yet' ).hide( );
	new Effect.DropOut( 'comment-form', { duration: 1.0 } );
	$( 'add-another-comment' ).show( );
	$( 'add-comment-button' ).disabled = false;
	$( 'new-comment' ).insert( { top: request.responseText } );
	new Effect.Appear( 'new-comment' );
}

function deleteComment ( comment_id )
{
	if ( !confirm( "Are you sure you want to delete this comment?" ) )
		return false;

	new Ajax.Request( '/site/deleteComment_Ajax/comment_id/' + comment_id,
		{ 
			method: 'post',
			onComplete: function ( ) { 
				$( 'comment-' + comment_id ).className = "notifier";
				$( 'comment-' + comment_id ).innerHTML = "This comment has been deleted";
			}
		}		
	);
	return true;
}

function showCommentForm (  )
{
	$( 'comment-textarea' ).value = '';
	$( 'char-count' ).update( 0 );
	new Effect.DropOut( 'add-another-comment' );
	new Effect.Appear( 'comment-form' );
}
