#if ($groups) ## on the initial load of this template where no search has been performed, we don't want to show the results box
<div class="lightGreyBox" style="padding: 8px;">
    #set ($groupsExist = $groups && !$groups.isEmpty())
    <form name="selectorform">

        <table id="entitySearchResults">
            <col class="firstColumn">
            <col class="secondColumn">
            <thead>
                <tr>
                    <th >$action.getText("check.all")</th>
                    <th>
                        <input type="checkbox" name="all" value="0" #if (!$groupsExist) disabled="disabled" #end>
                    </th>
                    <th>$action.getText("groupname.word")</th>
                </tr>
            </thead>

            #set( $groups = $action.getGroups() )

            <tbody>
                #if ($groupsExist)
                    #foreach ($group in $groups)
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                            <input type="checkbox" name="group" value="$generalUtil.htmlEncode($group.name)"/>
                        </td>
                        <td>
                            $generalUtil.htmlEncode($group.name)
                        </td>
                    </tr>
                    #end
                #else
                    <tr><td colspan="3">$action.getText("no.groups.found")</td></tr>
                #end
            </tbody>
        </table>

        <input type="hidden" name="actionName" value="$generalUtil.htmlEncode($actionName)"/>
        <input type="hidden" name="startIndex" value="$generalUtil.htmlEncode($startIndex)"/>
        #if ($groupsExist)
            #entityPagination($action.paginationSupport "$actionName?groupnameTerm=$!generalUtil.urlEncode($groupnameTerm)&key=$!generalUtil.urlEncode($key)&actionName=$!generalUtil.urlEncode($actionName)&onPopupSubmit=$!generalUtil.urlEncode($onPopupSubmit)&")
            <div align="right">
                <input type="button" value="$action.getText('groups.select')" class="$generalUtil.htmlEncode(${onPopupSubmit})" id="select-entities">
            </div>
        #end
    </form>
</div>
#end

