<script type="text/javascript">
    function filterComments()
    {
        var selectOption = $('filterByPublishStatus').value;
        window.location.href= "index.php?fuse=knowledgebase&view=KB_manageCommentsView&filter=" + selectOption;
    }
    
    function publishComment()
    {
        var checkbox = document.form.articleid;
        var articlesChecked = "";
        var totalArticles = checkbox.length;
        
        for(var i = 0; i < totalArticles; i++){
            if(checkbox[i].checked){
                articlesChecked = checkbox[i].value + "," + articlesChecked;
            }
        }
        
        new Ajax.Request(
            'index.php?fuse=knowledgebase&action=KB_ApproveComment',
            {
                method:     'post',
                parameters: "&articleId=" + articlesChecked,
                onSuccess:  showResponse,
                onComplete: function(request){
                    setStatus(lang('Comment Published'), 500);
                }
            }
        );
    }
    
    function showResponse(originalRequest)
    {
        var response = originalRequest.responseText;
        alert (response);
        window.location.reload( false );
    }
</script>

<form id="form" name="form" method="POST" action="index.php?fuse=knowledgebase&action=KB_DeleteComment">
    <table width="100%" align="center" cellpadding="0"cellspacing="0" border="0">
        <tr>
            <td valign="top" nowrap>
                <table style="width:100%;" cellpadding='0' border='0' cellspacing='0'>
                    <tr>
                        <td class='snapshot-header-left'>
                        </td>
                        <td class='snapshot-header'>
                            <span class='snapshot-header-text'>
                                {commentsHeader}:
                            </span>
                        </td>
                        <td class='snapshot-header' align="right">
                            <span class='snapshot-header-text-small'>
                                [l]Filter By:[/l]
                            </span>
                            <select id="filterByPublishStatus" name="filterByPublishStatus" onchange="filterComments()">
                                <option value="all" {ALL_SELECTED}>--[l]All[/l]-- </option>
                                <option value="Approved" {APPROVED_SELECTED}>[l]Approved[/l]</option>
                                <option value="NonApproved" {NONAPPROVED_SELECTED}>[l]Not Approved[/l]</option>
                                <option value="Internal" {INTERNAL_SELECTED}>[l]Internal[/l]</option>
                            </select>
                        </td>
                        <td class='snapshot-header-right'>
                        </td>
                    </tr>
                </table>
                
                <!-- BEGIN DYNAMIC BLOCK: noComments -->
                <br />
                [l]There are no user comments stored on the Knowledge Base[/l]
                <!-- END DYNAMIC BLOCK: noComments -->
                
                <!-- BEGIN DYNAMIC BLOCK: kbTableComments -->
                <table width="100%" class="sort-table" id="table-1" border="0" align="center" cellpadding="0" cellspacing="0">
                    <col style="text-align: right" />
                    <col />
                    <col />
                    <col />
                    <col />
                    <thead>
                        <tr class="{trClassHead}">
                            <td width="20px">
                                &nbsp;
                            </td>
                            <td align="left" width="15%">
                                [l]Article Title[/l]
                            </td>
                            <td align="left" width="15%">
                                [l]user[/l]
                            </td>
                            <td align="center" width="15%">
                                [l]email[/l]
                            </td>
                            <td align="center">
                                [l]Added On[/l]
                            </td>
                            <td align="center">
                                [l]Is Approved[/l]
                            </td>
                            <td align="center">
                                [l]Is Internal[/l]
                            </td>
                        </tr>
                    </thead>
                    <tbody>
                        <!-- BEGIN DYNAMIC BLOCK: kbComments -->
                        <tr class="{trClass}" id="TRID_{articleId}">
                            <!-- BEGIN DYNAMIC BLOCK: commentsCheckbox -->
                            <td width="5">
                                <input type="checkbox" style="position:relative;top:1px;" name="articleid[]" id="articleid" value="{articleId}" onClick="checkCheckBox(this);" />
                            </td>
                            <!-- END DYNAMIC BLOCK: commentsCheckbox -->
                            
                            <td align="left" width="15%">
                                <a style="cursor: pointer" id="{articleId}" class="articleLink" >
                                    {articleTitle}
                                </a>
                            </td>
                            <td align="left" width="15%">
                                {commentUser}
                            </td>
                            <td align="left" width="15%" id="TDEMAIL_{articleId}">
                                {commentEmail}
                            </td>
                            <td align="center" nowrap>
                                {commentAddedOn}
                            </td>
                            <td align="center" nowrap id="TDAPPROVED_{articleId}">
                                {commentIsApproved}
                            </td>
                            <td align="center" nowrap id="TDINTERNAL_{articleId}">
                                {commentIsInternal}
                            </td>
                        </tr>
                        <!-- END DYNAMIC BLOCK: kbComments -->
                    <tbody>
                </table>
                <br />
                <input type="checkbox" name="toggleAllChk" onclick="toggleAll(this.form);"/>
                <b>
                    [l]Toggle All[/l]
                </b>
                <!-- END DYNAMIC BLOCK: kbTableComments -->
                
                <table width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td colspan="2">
                            &nbsp;
                        </td>
                    </tr>
                    <tr class="actionfooter">
                        <!-- BEGIN DYNAMIC BLOCK: deleteBtn -->
                        <td valign="middle" align="left" width="10%" nowrap>
                            &nbsp;
                            <input id="btnDelete" name="btnDelete" type="submit" class="button_large" value="[lh]delete comment[/lh]" style="filter:alpha(opacity=50); -moz-opacity:0.4" disabled="true"/>
                            &nbsp;
                        </td>
                        <!-- END DYNAMIC BLOCK: deleteBtn -->
                        
                        <td valign="middle" align="left" width="90%" nowrap>
                            &nbsp;
                            <input id="btnDelete" name="btnPubComment" type="button" class="button_large" value="[lh]Publish Comment[/lh]" style="filter:alpha(opacity=50); -moz-opacity:0.4" disabled="true" onclick="publishComment()"/>
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>

<div id="hello-win" class="x-hidden">
    <div class="x-window-header">
        Comment Details
    </div>
</div>