<!-- BEGIN tags -->
<div class="gadget tag">
    <div class="gadget_header"><h2>{title}</h2><div class="gadget_menubar">{menubar}</div></div>
  <div class="gadget_container">
    <div class="gadget_response"><div id="simple_response" class="{type}">{text}</div></div>

    <form name="tags" id="tags" action="{requested_url}" method="post">
        <input type="hidden" name="gadget" value="Tags"/>
        <input type="hidden" name="action" value="ManageTags"/>
        <input type="hidden" name="new_tag_name" value=""/>

        <div class="filters">
            <label for="gadgets_filter">{lbl_gadgets}: </label>
            <select id="gadgets_filter" name="gadgets_filter">
                <option
                value="">{lbl_all}</option>
                <option
                <!-- BEGIN gadget -->
                <option {selected} value="{name}">{title}</option>
                <!-- END gadget -->
            </select>
            <input type="text" id="term" name="term" size="20" value="{txt_term}">

            <button value="{filter}" id="filter_button" name="filter_button"
                    type="submit"><img src="{icon_filter}" alt="{filter}"/>&nbsp;{filter}
            </button>
        </div>

        <div class="gadget_content content">
            <table>
                <thead>
                <tr>
                    <th><input type="checkbox" onclick="toggleCheckboxes();"></th>

                    <th>{lbl_tag_name}</th>
                    <th>{lbl_tag_title}</th>
                    <th>{lbl_tag_usage_count}</th>
                </tr>
                </thead>

                <tbody>
                <!-- BEGIN tag -->
                <tr>
                    <td>
                        <input type="checkbox" name="tags_checkbox[]" value="{id}">
                    </td>
                    <td><a href="{tag_url}">{name}</a></td>
                    <td><a href="{tag_url}">{title}</a></td>
                    <td>{usage_count}</td>

                </tr>
                <!-- END tag -->
                </tbody>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="5">
                        {lbl_page_item}
                        <select id="page_item" name="page_item" onchange="this.form.submit();">
                            <option {opt_page_item_10} value="10">10</option>
                            <option {opt_page_item_20} value="20">20</option>
                            <option {opt_page_item_50} value="50">50</option>
                            <option {opt_page_item_100} value="100">100</option>
                        </select>
                    </td>
                </tr>
                </tfoot>
            </table>
            <!-- INCLUDE PageNavigation.html -->

            <div class="gadget_actions actions">
                <label for="tags_actions_combo">{lbl_actions}:&nbsp;</label>
                <select title="{lbl_actions}" id="tags_actions_combo" name="tags_actions_combo">
                    <option value="">{lbl_no_action}</option>
                    <option value="delete">{lbl_delete}</option>
                    <option value="merge">{lbl_merge}</option>
                </select>

                <button value="{lbl_actions}" id="action_button" name="action_button"
                        onclick="javascript: return doDGAction();" ><img src="{icon_ok}" alt="{lbl_actions}"/>
                </button>
            </div>

        </div>
    </form>
  </div>
  <div class="gadget_footer"></div>
</div>

<script type="text/javascript">
    function toggleCheckboxes(){
        do_check = !do_check;
        $$("input[name='tags_checkbox[]']").each(function(el) { el.checked = do_check; });
    }
    var do_check = false;

    function doDGAction() {
        var action = document.getElementById("tags_actions_combo").value;
        if(action == 'delete') {
            document.tags.action.value = 'DeleteTags';
        } else if(action == 'merge') {
            if($$("input[name='tags_checkbox[]']:checked").length<2) {
                alert("{selectMoreThanOneTags}");
                return false;
            }
            var newName = prompt("{enterNewTagName}:");
            if (newName.trim() == "") {
                return false;
            }

            document.tags.action.value = 'MergeTags';
            document.tags.new_tag_name.value = newName;
        } else {
            return false;
        }
        document.getElementById("tags").submit();
        return true;
    }
</script>
<!-- END tags -->

<!-- BEGIN edit_tag -->
<div class="gadget tag">
    <div class="gadget_header"><h2>{title}</h2><div class="gadget_menubar">{menubar}</div></div>
  <div class="gadget_container">
    <form name="groups" id="groups" action="{base_script}" method="post">
        <input type="hidden" name="gadget" value="Tags"/>
        <input type="hidden" name="action" value="UpdateTag"/>
        <input type="hidden" name="tid" value="{tid}"/>

        <div class="gadget_content content">
            <fieldset>
                <div><label for="name">{lbl_name}:</label>
                    <input name="name" id="name" value="{name}" type="text"/>
                </div>
                <div><label for="title">{lbl_title}:</label>
                    <input name="title" id="title" value="{tag_title}" type="text"/>
                </div>
                <div><label for="description">{lbl_description}:</label>
                    <textarea name="description" id="description" cols="45" rows="4">{description}</textarea>
                </div>
            </fieldset>
        </div>
        <div class="gadget_actions actions">
            <button type="submit" value="{save}">{save}</button>
        </div>
    </form>
  </div>
  <div class="gadget_footer"></div>
</div>
<!-- END edit_tag -->