function sm_comments__startup()
{
    $('form.handler__form_comments').each(
    function()
    {
        $(this).attr( 'action', $(this).attr('form_action') );

        $(this).ajaxForm( {
            beforeSubmit: null,
            success:      comments_response,
            dataType:     'json'
        } );

        return true;
    } );

    $('.handler__comments_submit').click(
    function()
    {		
        buggy_clean();
        //$('form.handler__form_comments').submit();
		return true;
    } );

   /* $('.handler__comments_btn_quote').click(
    function()
    {
        $('#comment_message_object').attr(
            'value',
            '[quote='+$(this).attr('author')+']'+$(this).attr('message')+'[/quote]'+"\n"
        );

        $('#comment_message_object').focus();

        return true;
    } );*/

    return true;
}

function comments_response( responseBody, responseStatus )
{
    if( responseStatus == 'success' && responseBody )
    {
        buggy_clean();
        if( responseBody.status == 'error' )
        {	
            buggy_markup( responseBody.error_messages );
            return true;
        }
        else if( responseBody.status == 'done' )
        {	
			/*
            var fullname = responseBody.comment.guest_name;
            
            if( responseBody.comment.lname )
            {
                fullname += ' ' + responseBody.comment.lname;
            }*/
            $('.sm-comments-newitem-container .sm-comments-newitem-value-name').html( responseBody.comment.guest_name );
            $('.sm-comments-newitem-container .sm-comments-newitem-value-t_posted').html( responseBody.comment.t_posted );
			$('.sm-comments-newitem-container .sm-comments-newitem-value-email').html( responseBody.comment.guest_email );
            $('.sm-comments-newitem-container .sm-comments-newitem-value-message').html( responseBody.comment.message );

            $('.sm-comments-emptyinfo-container').fadeOut(200);
            $('.sm-comments-form').fadeOut( 500, function() { $('.sm-comments-newitem-container').fadeIn( 500 ); } );

            return true;
        }
    }

    return true;
}

