} else {
                $formtype = 'a_edit';
                $formpostid = $answerid;
                // keep editing if an error
            }
        } elseif ($pagestate == 'edit-' . $answerid && qa_page_q_permit_edit($answer, 'permit_edit_a', $pageerror)) {
            $formtype = 'a_edit';
            $formpostid = $answerid;
        }
    }
    if ($answer['commentbutton']) {
        if (qa_clicked($prefix . 'docomment')) {
            qa_page_q_refresh($pagestart, 'comment-' . $answerid, 'A', $answerid);
        }
        if (qa_clicked('c' . $answerid . '_doadd') || $pagestate == 'comment-' . $answerid) {
            qa_page_q_do_comment($question, $answer, $commentsfollows, $pagestart, $usecaptcha, $cnewin, $cnewerrors, $formtype, $formpostid, $pageerror);
        }
    }
    if (qa_clicked($prefix . 'dofollow')) {
        $params = array('follow' => $answerid);
        if (isset($question['categoryid'])) {
            $params['cat'] = $question['categoryid'];
        }
        qa_redirect('ask', $params);
    }
}
//	Process hide, show, delete, flag, unflag, edit or save button for comments
foreach ($commentsfollows as $commentid => $comment) {
    if ($comment['basetype'] == 'C') {
        $commentparent = @$answers[$comment['parentid']];
        if (!isset($commentparent)) {
            } else {
                $formtype = 'a_edit';
                $formpostid = $answerid;
                // keep editing if an error
            }
        } elseif ($qa_state == 'edit-' . $answerid && qa_page_q_permit_edit($answer, 'permit_edit_a')) {
            $formtype = 'a_edit';
            $formpostid = $answerid;
        }
    }
    if ($answer['commentbutton']) {
        if (qa_clicked('docommenta_' . $answerid)) {
            qa_redirect($qa_request, array('state' => 'comment-' . $answerid));
        }
        if (qa_clicked('docommentadda_' . $answerid) || $qa_state == 'comment-' . $answerid) {
            qa_page_q_do_comment($answer);
        }
    }
    if (qa_clicked('dofollowa_' . $answerid)) {
        $params = array('follow' => $answerid);
        if (isset($question['categoryid'])) {
            $params['cat'] = $question['categoryid'];
        }
        qa_redirect('ask', $params);
    }
}
//	Process hide, show, delete, flag, unflag, edit or save button for comments
foreach ($commentsfollows as $commentid => $comment) {
    if ($comment['basetype'] == 'C') {
        $commentanswer = @$answers[$comment['parentid']];
        if (isset($commentanswer)) {