function wppa_comment_html($id, $comment_allowed)
{
    global $wpdb;
    global $current_user;
    global $wppa_first_comment_html;
    $result = '';
    if (wppa_in_widget()) {
        return $result;
    }
    // NOT in a widget
    // Find out who we are either logged in or not
    $vis = is_user_logged_in() ? 'display:none; ' : '';
    if (!$wppa_first_comment_html) {
        $wppa_first_comment_html = true;
        // Find user
        if (wppa_get_post('comname')) {
            wppa('comment_user', wppa_get_post('comname'));
        }
        if (wppa_get_post('comemail')) {
            wppa('comment_email', wppa_get_post('comemail'));
        } elseif (is_user_logged_in()) {
            get_currentuserinfo();
            wppa('comment_user', $current_user->display_name);
            //user_login;
            wppa('comment_email', $current_user->user_email);
        }
    }
    // Loop the comments already there
    $n_comments = 0;
    if (wppa_switch('comments_desc')) {
        $ord = 'DESC';
    } else {
        $ord = '';
    }
    $comments = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . WPPA_COMMENTS . ' WHERE photo = %s ORDER BY id ' . $ord, $id), ARRAY_A);
    wppa_dbg_q('Q-Comm');
    $com_count = count($comments);
    $color = 'darkgrey';
    if (wppa_opt('fontcolor_box')) {
        $color = wppa_opt('fontcolor_box');
    }
    if ($comments && (is_user_logged_in() || !wppa_switch('comment_view_login'))) {
        $result .= '
			<div' . ' id="wppa-comtable-wrap-' . wppa('mocc') . '"' . ' style="display:none;"' . '>' . '<table' . ' id="wppacommentstable-' . wppa('mocc') . '"' . ' class="wppa-comment-form"' . ' style="margin:0; "' . '>' . '<tbody>';
        foreach ($comments as $comment) {
            // Show a comment either when it is approved, or it is pending and mine or i am a moderator
            if ($comment['status'] == 'approved' || current_user_can('wppa_moderate') || current_user_can('wppa_comments') || ($comment['status'] == 'pending' || $comment['status'] == 'spam') && $comment['user'] == wppa('comment_user')) {
                $n_comments++;
                $result .= '
					<tr' . ' class="wppa-comment-' . $comment['id'] . '"' . ' valign="top"' . ' style="border-bottom:0 none; border-top:0 none; border-left: 0 none; border-right: 0 none; "' . ' >' . '<td' . ' valign="top"' . ' class="wppa-box-text wppa-td"' . ' style="vertical-align:top; width:30%; border-width: 0 0 0 0; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . $comment['user'] . ' ' . __('wrote:', 'wp-photo-album-plus') . '<br />' . '<span style="font-size:9px; ">' . wppa_get_time_since($comment['timestamp']) . '</span>';
                // Avatar ?
                if (wppa_opt('comment_gravatar') != 'none') {
                    // Find the default
                    if (wppa_opt('comment_gravatar') != 'url') {
                        $default = wppa_opt('comment_gravatar');
                    } else {
                        $default = wppa_opt('comment_gravatar_url');
                    }
                    // Find the avatar, init
                    $avt = false;
                    $usr = false;
                    // First try to find the user by email address ( works only if email required on comments )
                    if ($comment['email']) {
                        $usr = get_user_by('email', $comment['email']);
                    }
                    // If not found, try to find the user by login name ( works only if login name is equal to display name )
                    if (!$usr) {
                        $usr = get_user_by('login', $comment['user']);
                    }
                    // Still no user, try to find him by display name
                    if (!$usr) {
                        $usr = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE `display_name` = %s", $comment['user']));
                        // Accept this user if he is the only one with this display name
                        if (count($usr) != 1) {
                            $usr = false;
                        }
                    }
                    // If a user is found, see for local Avatar ?
                    if ($usr) {
                        $avt = str_replace("'", "\"", get_avatar($usr->ID, wppa_opt('gravatar_size'), $default));
                    }
                    // Global avatars off ? try myself
                    if (!$avt) {
                        $avt = '
										<img' . ' class="wppa-box-text wppa-td"' . ' src="http://www.gravatar.com/avatar/' . md5(strtolower(trim($comment['email']))) . '.jpg?d=' . urlencode($default) . '&s=' . wppa_opt('gravatar_size') . '"' . ' alt="' . __('Avatar', 'wp-photo-album-plus') . '"' . ' />';
                    }
                    // Compose the html
                    $result .= '
									<div class="com_avatar">' . $avt . '</div>';
                }
                $result .= '</td>';
                $txtwidth = floor(wppa_get_container_width() * 0.7) . 'px';
                $result .= '<td' . ' class="wppa-box-text wppa-td"' . ' style="width:70%; word-wrap:break-word; border-width: 0 0 0 0;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<p' . ' class="wppa-comment-textarea wppa-comment-textarea-' . wppa('mocc') . '"' . ' style="' . 'margin:0;' . 'background-color:transparent;' . 'width:' . $txtwidth . ';' . 'max-height:90px;' . 'overflow:auto;' . 'word-wrap:break-word;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . html_entity_decode(esc_js(stripslashes(wppa_convert_smilies($comment['comment']))));
                if ($comment['status'] != 'approved' && (current_user_can('wppa_moderate') || current_user_can('wppa_comments'))) {
                    if (wppa('no_esc')) {
                        $result .= wppa_moderate_links('comment', $id, $comment['id']);
                    } else {
                        $result .= wppa_html(esc_js(wppa_moderate_links('comment', $id, $comment['id'])));
                    }
                } elseif ($comment['status'] == 'pending' && $comment['user'] == wppa('comment_user')) {
                    $result .= '<br /><span style="color:red; font-size:9px;" >' . __('Awaiting moderation', 'wp-photo-album-plus') . '</span>';
                } elseif ($comment['status'] == 'spam' && $comment['user'] == wppa('comment_user')) {
                    $result .= '<br /><span style="color:red; font-size:9px;" >' . __('Marked as spam', 'wp-photo-album-plus') . '</span>';
                }
                $result .= '</p>' . '</td>' . '</tr>' . '<tr class="wppa-comment-' . $comment['id'] . '">' . '<td colspan="2" style="padding:0">' . '<hr style="background-color:' . $color . '; margin:0;" />' . '</td>' . '</tr>';
            }
        }
        $result .= '</tbody>' . '</table>' . '</div>';
    }
    // See if we are currently in the process of adding/editing this comment
    $is_current = $id == wppa('comment_photo') && wppa('comment_id');
    if ($is_current) {
        $txt = wppa('comment_text');
        $btn = __('Edit!', 'wp-photo-album-plus');
    } else {
        $txt = '';
        $btn = __('Send!', 'wp-photo-album-plus');
    }
    // Prepare the callback url
    $returnurl = wppa_get_permalink();
    $album = wppa_get_get('album');
    if ($album !== false) {
        $returnurl .= 'wppa-album=' . $album . '&';
    }
    $cover = wppa_get_get('cover');
    if ($cover) {
        $returnurl .= 'wppa-cover=' . $cover . '&';
    }
    $slide = wppa_get_get('slide');
    if ($slide !== false) {
        $returnurl .= 'wppa-slide&';
    }
    $occur = wppa_get_get('occur');
    if ($occur) {
        $returnurl .= 'wppa-occur=' . $occur . '&';
    }
    $lasten = wppa_get_get('lasten');
    if ($lasten) {
        $returnurl .= 'wppa-lasten=' . $lasten . '&';
    }
    $topten = wppa_get_get('topten');
    if ($topten) {
        $returnurl .= 'wppa-topten=' . $topten . '&';
    }
    $comten = wppa_get_get('comten');
    if ($comten) {
        $returnurl .= 'wppa-comten=' . $comten . '&';
    }
    $tag = wppa_get_get('tag');
    if ($tag) {
        $returnurl .= 'wppa-tag=' . $tag . '&';
    }
    $returnurl .= 'wppa-photo=' . $id;
    // The comment form
    if ($comment_allowed) {
        $result .= '<div' . ' id="wppa-comform-wrap-' . wppa('mocc') . '"' . ' style="display:none;"' . ' >' . '<form' . ' id="wppa-commentform-' . wppa('mocc') . '"' . ' class="wppa-comment-form"' . ' action="' . $returnurl . '"' . ' method="post"' . ' onsubmit="return wppaValidateComment( ' . wppa('mocc') . ' )"' . ' >' . wp_nonce_field('wppa-nonce-' . wppa('mocc'), 'wppa-nonce-' . wppa('mocc'), false, false) . ($album ? '<input type="hidden" name="wppa-album" value="' . $album . '" />' : '') . ($cover ? '<input type="hidden" name="wppa-cover" value="' . $cover . '" />' : '') . ($slide ? '<input type="hidden" name="wppa-slide" value="' . $slide . '" />' : '') . '<input' . ' type="hidden"' . ' name="wppa-returnurl"' . ' id="wppa-returnurl-' . wppa('mocc') . '"' . ' value="' . $returnurl . '"' . ' />' . ($is_current ? '<input' . ' type="hidden"' . ' id="wppa-comment-edit-' . wppa('mocc') . '"' . ' name="wppa-comment-edit"' . ' value="' . wppa('comment_id') . '"' . ' />' : '') . '<input type="hidden" name="wppa-occur" value="' . wppa('occur') . '" />' . '<table id="wppacommenttable-' . wppa('mocc') . '" style="margin:0;">' . '<tbody>' . '<tr valign="top" style="' . $vis . '">' . '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your name:', 'wp-photo-album-plus') . '</td>' . '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<input' . ' type="text"' . ' name="wppa-comname"' . ' id="wppa-comname-' . wppa('mocc') . '"' . ' style="width:100%; " value="' . wppa('comment_user') . '"' . ' />' . '</td>' . '</tr>';
        if (wppa_switch('comment_email_required')) {
            $result .= '<tr valign="top" style="' . $vis . '">' . '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your email:', 'wp-photo-album-plus') . '</td>' . '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<input' . ' type="text"' . ' name="wppa-comemail"' . ' id="wppa-comemail-' . wppa('mocc') . '"' . ' style="width:100%;"' . ' value="' . wppa('comment_email') . '"' . ' />' . '</td>' . '</tr>';
        }
        $result .= '<tr valign="top" style="vertical-align:top;">' . '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your comment:', 'wp-photo-album-plus') . '<br />' . wppa('comment_user') . '<br />';
        if (is_user_logged_in() && wppa_opt('comment_captcha') == 'all' || !is_user_logged_in() && wppa_opt('comment_captcha') != 'none') {
            $wid = '20%';
            if (wppa_opt('fontsize_box')) {
                $wid = wppa_opt('fontsize_box') * 1.5 . 'px';
            }
            $captkey = $id;
            if ($is_current) {
                $captkey = $wpdb->get_var($wpdb->prepare('SELECT `timestamp` FROM `' . WPPA_COMMENTS . '` WHERE `id` = %s', wppa('comment_id')));
            }
            wppa_dbg_q('Q-Com-ts');
            $result .= wppa_make_captcha($captkey) . '<input' . ' type="text"' . ' id="wppa-captcha-' . wppa('mocc') . '"' . ' name="wppa-captcha"' . ' style="width:' . $wid . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' />&nbsp;';
        }
        $result .= '<input type="button" name="commentbtn" onclick="wppaAjaxComment( ' . wppa('mocc') . ', ' . $id . ' )" value="' . $btn . '" style="margin:0 4px 0 0;" />' . '<img id="wppa-comment-spin-' . wppa('mocc') . '" src="' . wppa_get_imgdir() . 'wpspin.gif" style="display:none;" />' . '</td>' . '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >';
        if (wppa_switch('comment_smiley_picker')) {
            $result .= wppa_get_smiley_picker_html('wppa-comment-' . wppa('mocc'));
        }
        $result .= '<textarea' . ' name="wppa-comment"' . ' id="wppa-comment-' . wppa('mocc') . '"' . ' style="height:60px; width:100%; "' . '>' . esc_textarea(stripslashes($txt)) . '</textarea>' . '</td>' . '</tr>' . '</tbody>' . '</table>' . '</form>' . '</div>';
    } else {
        if (wppa_switch('login_links')) {
            $result .= sprintf(__('You must <a href="%s">login</a> to enter a comment', 'wp-photo-album-plus'), site_url('wp-login.php', 'login'));
        } else {
            $result .= __('You must login to enter a comment', 'wp-photo-album-plus');
        }
    }
    $result .= '<div id="wppa-comfooter-wrap-' . wppa('mocc') . '" style="display:block;" >' . '<table id="wppacommentfooter-' . wppa('mocc') . '" class="wppa-comment-form" style="margin:0;">' . '<tbody>' . '<tr style="text-align:center;">' . '<td style="text-align:center; cursor:pointer;' . __wcs('wppa-box-text') . '" >' . '<a onclick="wppaOpenComments( ' . wppa('mocc') . ', -1 ); return false;" >';
    if ($n_comments) {
        $result .= sprintf(_n('%d comment', '%d comments', $n_comments, 'wp-photo-album-plus'), $n_comments);
    } else {
        if ($comment_allowed) {
            $result .= __('Leave a comment', 'wp-photo-album-plus');
        }
    }
    $result .= '</a>' . '</td>' . '</tr>' . '</tbody>' . '</table>' . '</div>' . '<div style="clear:both"></div>';
    return $result;
}
function wppa_comment_html($id, $comment_allowed)
{
    global $wpdb;
    global $wppa;
    global $current_user;
    global $wppa_first_comment_html;
    $result = '';
    if ($wppa['in_widget']) {
        return $result;
    }
    // NOT in a widget
    // Find out who we are either logged in or not
    $vis = is_user_logged_in() ? $vis = 'display:none; ' : '';
    if (!$wppa_first_comment_html) {
        $wppa_first_comment_html = true;
        // Find user
        if (wppa_get_post('comname')) {
            $wppa['comment_user'] = wppa_get_post('comname');
        }
        if (wppa_get_post('comemail')) {
            $wppa['comment_email'] = wppa_get_post('comemail');
        } elseif (is_user_logged_in()) {
            get_currentuserinfo();
            $wppa['comment_user'] = $current_user->display_name;
            //user_login;
            $wppa['comment_email'] = $current_user->user_email;
        }
    }
    // Loop the comments already there
    $n_comments = 0;
    if (wppa_switch('comments_desc')) {
        $ord = 'DESC';
    } else {
        $ord = '';
    }
    $comments = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . WPPA_COMMENTS . ' WHERE photo = %s ORDER BY id ' . $ord, $id), ARRAY_A);
    wppa_dbg_q('Q-Comm');
    $com_count = count($comments);
    $color = 'darkgrey';
    if (wppa_opt('wppa_fontcolor_box')) {
        $color = wppa_opt('wppa_fontcolor_box');
    }
    if ($comments) {
        $result .= '<div id="wppa-comtable-wrap-' . $wppa['mocc'] . '" style="display:none;" >';
        $result .= '<table id="wppacommentstable-' . $wppa['mocc'] . '" class="wppa-comment-form" style="margin:0; "><tbody>';
        foreach ($comments as $comment) {
            // Show a comment either when it is approved, or it is pending and mine or i am a moderator
            if ($comment['status'] == 'approved' || current_user_can('wppa_moderate') || current_user_can('wppa_comments') || ($comment['status'] == 'pending' || $comment['status'] == 'spam') && $comment['user'] == $wppa['comment_user']) {
                $n_comments++;
                $result .= '<tr class="wppa-comment-' . $comment['id'] . '" valign="top" style="border-bottom:0 none; border-top:0 none; border-left: 0 none; border-right: 0 none; " >';
                $result .= '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; border-width: 0 0 0 0; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >';
                $result .= $comment['user'] . ' ' . __a('wrote:');
                $result .= '<br /><span style="font-size:9px; ">' . wppa_get_time_since($comment['timestamp']) . '</span>';
                if (wppa_opt('wppa_comment_gravatar') != 'none') {
                    // Find the default
                    if (wppa_opt('wppa_comment_gravatar') != 'url') {
                        $default = wppa_opt('wppa_comment_gravatar');
                    } else {
                        $default = wppa_opt('wppa_comment_gravatar_url');
                    }
                    // Find the avatar
                    $avt = '';
                    $usr = get_user_by('login', $comment['user']);
                    if ($usr) {
                        // Local Avatar ?
                        $avt = str_replace("'", "\"", get_avatar($usr->ID, wppa_opt('wppa_gravatar_size'), $default));
                    }
                    if ($avt == '') {
                        // Global avatars off, try myself
                        $avt = '<img class="wppa-box-text wppa-td" src="http://www.gravatar.com/avatar/' . md5(strtolower(trim($comment['email']))) . '.jpg?d=' . urlencode($default) . '&s=' . wppa_opt('wppa_gravatar_size') . '" alt="' . __a('Avatar') . '" />';
                    }
                    // Compose the html
                    $result .= '<div class="com_avatar">' . $avt . '</div>';
                }
                $result .= '</td>';
                $txtwidth = floor(wppa_get_container_width() * 0.7) . 'px';
                $result .= '<td class="wppa-box-text wppa-td" style="width:70%; word-wrap:break-word; border-width: 0 0 0 0;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<p class="wppa-comment-textarea wppa-comment-textarea-' . $wppa['mocc'] . '" style="margin:0; background-color:transparent; width:' . $txtwidth . '; max-height:90px; overflow:auto; word-wrap:break-word;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . html_entity_decode(esc_js(stripslashes(wppa_convert_smilies($comment['comment']))));
                if ($comment['status'] != 'approved' && (current_user_can('wppa_moderate') || current_user_can('wppa_comments'))) {
                    if ($wppa['no_esc']) {
                        $result .= wppa_moderate_links('comment', $id, $comment['id']);
                    } else {
                        $result .= wppa_html(esc_js(wppa_moderate_links('comment', $id, $comment['id'])));
                    }
                } elseif ($comment['status'] == 'pending' && $comment['user'] == $wppa['comment_user']) {
                    $result .= '<br /><span style="color:red; font-size:9px;" >' . __a('Awaiting moderation') . '</span>';
                } elseif ($comment['status'] == 'spam' && $comment['user'] == $wppa['comment_user']) {
                    $result .= '<br /><span style="color:red; font-size:9px;" >' . __a('Marked as spam') . '</span>';
                }
                $result .= '</p>';
                $result .= '</td>';
                $result .= '</tr>';
                $result .= '<tr class="wppa-comment-' . $comment['id'] . '"><td colspan="2" style="padding:0"><hr style="background-color:' . $color . '; margin:0;" /></td></tr>';
            }
        }
        $result .= '</tbody></table>';
        $result .= '</div>';
    }
    // See if we are currently in the process of adding/editing this comment
    $is_current = $id == $wppa['comment_photo'] && $wppa['comment_id'];
    // $debugtext=' ( id='.$id.', comment_photo='.$wppa['comment_photo'].', comment_id='.$wppa['comment_id'].' )';
    if ($is_current) {
        $txt = $wppa['comment_text'];
        $btn = __a('Edit!');
    } else {
        $txt = '';
        $btn = __a('Send!');
    }
    // Prepare the callback url
    $returnurl = wppa_get_permalink();
    $album = wppa_get_get('album');
    if ($album !== false) {
        $returnurl .= 'wppa-album=' . $album . '&';
    }
    $cover = wppa_get_get('cover');
    if ($cover) {
        $returnurl .= 'wppa-cover=' . $cover . '&';
    }
    $slide = wppa_get_get('slide');
    if ($slide !== false) {
        $returnurl .= 'wppa-slide&';
    }
    $occur = wppa_get_get('occur');
    if ($occur) {
        $returnurl .= 'wppa-occur=' . $occur . '&';
    }
    $lasten = wppa_get_get('lasten');
    if ($lasten) {
        $returnurl .= 'wppa-lasten=' . $lasten . '&';
    }
    $topten = wppa_get_get('topten');
    if ($topten) {
        $returnurl .= 'wppa-topten=' . $topten . '&';
    }
    $comten = wppa_get_get('comten');
    if ($comten) {
        $returnurl .= 'wppa-comten=' . $comten . '&';
    }
    $tag = wppa_get_get('tag');
    if ($tag) {
        $returnurl .= 'wppa-tag=' . $tag . '&';
    }
    $returnurl .= 'wppa-photo=' . $id;
    // The comment form
    if ($comment_allowed) {
        $result .= '<div id="wppa-comform-wrap-' . $wppa['mocc'] . '" style="display:none;" >';
        $result .= '<form id="wppa-commentform-' . $wppa['mocc'] . '" class="wppa-comment-form" action="' . $returnurl . '" method="post" style="" onsubmit="return wppaValidateComment( ' . $wppa['mocc'] . ' )">';
        $result .= wp_nonce_field('wppa-nonce-' . wppa('mocc'), 'wppa-nonce-' . wppa('mocc'), false, false);
        //, $alb );
        if ($album) {
            $result .= '<input type="hidden" name="wppa-album" value="' . $album . '" />';
        }
        if ($cover) {
            $result .= '<input type="hidden" name="wppa-cover" value="' . $cover . '" />';
        }
        if ($slide) {
            $result .= '<input type="hidden" name="wppa-slide" value="' . $slide . '" />';
        }
        $result .= '<input type="hidden" name="wppa-returnurl" id="wppa-returnurl-' . wppa('mocc') . '" value="' . $returnurl . '" />';
        if ($is_current) {
            $result .= '<input type="hidden" id="wppa-comment-edit-' . $wppa['mocc'] . '" name="wppa-comment-edit" value="' . $wppa['comment_id'] . '" />';
        }
        $result .= '<input type="hidden" name="wppa-occur" value="' . $wppa['occur'] . '" />';
        $result .= '<table id="wppacommenttable-' . $wppa['mocc'] . '" style="margin:0;">';
        $result .= '<tbody>';
        $result .= '<tr valign="top" style="' . $vis . '">';
        $result .= '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your name:') . '</td>';
        $result .= '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" ><input type="text" name="wppa-comname" id="wppa-comname-' . $wppa['mocc'] . '" style="width:100%; " value="' . $wppa['comment_user'] . '" /></td>';
        $result .= '</tr>';
        if (wppa_switch('comment_email_required')) {
            $result .= '<tr valign="top" style="' . $vis . '">';
            $result .= '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your email:') . '</td>';
            $result .= '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" ><input type="text" name="wppa-comemail" id="wppa-comemail-' . $wppa['mocc'] . '" style="width:100%; " value="' . $wppa['comment_email'] . '" /></td>';
            $result .= '</tr>';
        }
        $result .= '<tr valign="top" style="vertical-align:top;">';
        $result .= '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your comment:') . '<br />' . $wppa['comment_user'] . '<br />';
        if (wppa_switch('comment_captcha')) {
            $wid = '20%';
            if (wppa_opt('wppa_fontsize_box')) {
                $wid = wppa_opt('wppa_fontsize_box') * 1.5 . 'px';
            }
            $captkey = $id;
            if ($is_current) {
                $captkey = $wpdb->get_var($wpdb->prepare('SELECT `timestamp` FROM `' . WPPA_COMMENTS . '` WHERE `id` = %s', $wppa['comment_id']));
            }
            wppa_dbg_q('Q-Com-ts');
            $result .= wppa_make_captcha($captkey) . '<input type="text" id="wppa-captcha-' . $wppa['mocc'] . '" name="wppa-captcha" style="width:' . $wid . '; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" />&nbsp;';
        }
        // orig							$result .= '<input type="submit" name="commentbtn" value="'.$btn.'" style="margin:0;" /></td>';
        $result .= '<input type="button" name="commentbtn" onclick="wppaAjaxComment( ' . $wppa['mocc'] . ', ' . $id . ' )" value="' . $btn . '" style="margin:0 4px 0 0;" />';
        $result .= '<img id="wppa-comment-spin-' . $wppa['mocc'] . '" src="' . wppa_get_imgdir() . 'wpspin.gif" style="display:none;" />';
        $result .= '</td>';
        $result .= '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >';
        /*							if ( wppa_switch( 'use_wp_editor' ) ) {
        								$quicktags_settings = array( 'buttons' => 'strong,em,link,block,ins,ul,ol,li,code,close' );
        								ob_start();
        								wp_editor( stripslashes( $txt ), 'wppacomment'.wppa_alfa_id( $id ), array( 'wpautop' => false, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
        								$editor = ob_get_clean();
        								$result .= str_replace( "'", '"', $editor );
        							}
        							else {
        /**/
        if (wppa_switch('comment_smiley_picker')) {
            $result .= wppa_get_smiley_picker_html('wppa-comment-' . $wppa['mocc']);
        }
        $result .= '<textarea name="wppa-comment" id="wppa-comment-' . $wppa['mocc'] . '" style="height:60px; width:100%; ">' . esc_textarea(stripslashes($txt)) . '</textarea>';
        /*							}
        /* */
        $result .= '</td>';
        $result .= '</tr>';
        $result .= '</tbody>';
        $result .= '</table>';
        $result .= '</form>';
        // $result.=$debugtext;
        $result .= '</div>';
    } else {
        if (wppa_switch('login_links')) {
            $result .= sprintf(__a('You must <a href="%s">login</a> to enter a comment'), site_url('wp-login.php', 'login'));
        } else {
            $result .= __a('You must login to enter a comment');
        }
    }
    $result .= '<div id="wppa-comfooter-wrap-' . $wppa['mocc'] . '" style="display:block;" >';
    $result .= '<table id="wppacommentfooter-' . $wppa['mocc'] . '" class="wppa-comment-form" style="margin:0;">';
    $result .= '<tbody><tr style="text-align:center; "><td style="text-align:center; cursor:pointer;' . __wcs('wppa-box-text') . '" ><a onclick="wppaOpenComments( ' . $wppa['mocc'] . ', -1 ); return false;">';
    // wppaStartStop( '.$wppa['mocc'].', -1 ); return false;">';
    if ($n_comments) {
        $result .= sprintf(__a('%d comments'), $n_comments);
    } else {
        if ($comment_allowed) {
            $result .= __a('Leave a comment');
        }
    }
    $result .= '</a></td></tr></tbody></table>';
    $result .= '</div><div style="clear:both"></div>';
    return $result;
}