 $(document).ready(function(){
//************************************************************
  $(".answer_comment").click(answer_comment);
  $(".quote_comment").click(quote_comment);
  $("#comment_submit").click(send_comment)
//************************************************************
  });

  function quote_comment(event)
  {
    event.preventDefault();
    var parent = $(this).parent().parent()
    var author = (parent.find('.niccolor').find('a').length) ?
        parent.find('.niccolor').find('a').html() :
        parent.find('.niccolor').html();
    var quote_id = parent.attr('id').slice(8);
    $("#comment_comment").val($("#comment_comment").val()+'[quote ID=' + quote_id + ']' + author + '[/quote]');
    $("#comment_comment").focus();
  }

  function answer_comment(event)
  {
    event.preventDefault();
    $("#comment_comment").focus();
  }

  function send_comment(event)
  {
    var error = false;
    if ($("#comment_name").val() == "")
    {
      $("#comment_name_error").text("Введите имя.");
      error = true;
    }
    else
    {
      $("#comment_name_error").text("");
    }
    if ($("#comment_comment").val() == "")
    {
      $("#comment_comment_error").text("Введите текст комментария.");
      error = true;
    }
    else
    {
      $("#comment_comment_error").text("");
    }
    if ($("#comment_capture") && $("#comment_capture").val() == "")
    {
      $("#comment_capture_error").text("Введите код.");
      error = true;
    }
    else
    {
      $("#comment_capture_error").text("");
    }
    if (error)
    {
      event.preventDefault();
    }
  }