<%@ page buffer="8kb" autoFlush="true" %>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="zm" uri="com.zimbra.zm" %>
<%@ taglib prefix="app" uri="com.zimbra.htmlclient" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setBundle basename="/msgs/ZhMsg" scope="session"/>
<app:handleError>
    <c:if test="${!empty param.doAction}"><app:tagAction/></c:if>
    <zm:getMailbox var="mailbox"/>
    <c:set var="toolbar">
        <table width=100% cellspacing=0 class='Tb'>
            <tr><td align=left class=TbBt><input type=hidden class='tbButton' name="zzz">&nbsp;</td></tr>
        </table>
    </c:set>
    <fmt:message var="title" key="manageTags"/>
</app:handleError>

<app:view title="${title}" context="${null}" selected='managetags' tags="true" editmode="true" keys="true">

<form action="" method="post">
<table width=100% cellspacing="0" cellpadding="0">
<tr>
<td class='TbTop'>${toolbar}</td>
</tr>
<tr>
<td class='ZhAppContent'>

<table border="0" cellpadding="0" cellspacing="10" width=100%>
<tbody>
<tr>
    <td colspan="2" class="sectionLabel" valign="top">
        <fmt:message key="createNewTag"/>
    </td>
</tr>
<tr>
    <td nowrap align=right><fmt:message key="tagName"/> :</td>
    <td><input name='newTagName' type='text' autocomplete='off' size='35' value=""></td>
</tr>

<tr>
    <td nowrap valign="top" align='right'> <fmt:message key="tagColor"/> : </td>
    <td class='Tags'>
        <table cellspacing="4" cellpadding="0">
            <tr>
                <td><input checked align=top type="radio" name="newTagColor" value="orange"></td>
                <td><app:img altkey="ALT_TAG_ORANGE" src="tag/TagOrange.gif"/></td>
                <td><fmt:message key="orange"/></td>
            </tr>
            <tr>
                <td><input type="radio" name="newTagColor" value="blue"></td>
                <td><app:img altkey="ALT_TAG_BLUE" src="tag/TagBlue.gif"/></td>
                <td><fmt:message key="blue"/></td>
            </tr>
            <tr>
                <td><input type="radio" name="newTagColor" value="cyan"></td>
                <td><app:img altkey="ALT_TAG_CYAN" src="tag/TagCyan.gif"/></td>
                <td><fmt:message key="cyan"/></td>
                </tr>
            <tr>
                <td><input type="radio" name="newTagColor" value="green"></td>
                <td><app:img altkey="ALT_TAG_GREEN" src="tag/TagGreen.gif"/></td>
                <td><fmt:message key="green"/></td>
            </tr>
            <tr>
                <td><input type="radio" name="newTagColor" value="purple"></td>
                <td><app:img altkey="ALT_TAG_PURPLE" src="tag/TagPurple.gif"/></td>
                <td><fmt:message key="purple"/></td>
        </tr>
            <tr>
                <td><input type="radio" name="newTagColor" value="red"></td>
                <td><app:img altkey="ALT_TAG_RED" src="tag/TagRed.gif"/></td>
                <td><fmt:message key="red"/></td>
        </tr>
            <tr>
                <td><input type="radio" name="newTagColor" value="yellow"></td>
                <td><app:img altkey="ALT_TAG_YELLOW" src="tag/TagYellow.gif"/></td>
                <td><fmt:message key="yellow"/></td>
            </tr>
        </table>
    </td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td valign="top">
        <input class='tbButton' type="submit" name="actionCreate" value="<fmt:message key="createTag"/>">
    </td>
</tr>
<c:if test="${mailbox.hasTags}">

<tr>
    <td colspan="2" class="sectionLabel" valign="top"><fmt:message key="renameTag"/></td>
</tr>
<tr>
    <td nowrap align='right'><fmt:message key="tagName"/> :</td>
    <td>
        <select name="tagToRename">
            <option value="" selected/>
            <fmt:message key="chooseTagToRename"/>
            <option disabled/>
            <fmt:message key="actionOptSep"/>
            <zm:forEachTag var="tag">
                <option value="t:${tag.id}"/>
                ${fn:escapeXml(tag.name)}
            </zm:forEachTag>
        </select>
    </td>
</tr>
<tr>
    <td nowrap align='right'><fmt:message key="newName"/> :</td>
    <td><input name='newName' type='text' autocomplete='off' size='35' value=""></td>
</tr>

<tr>
    <td>&nbsp;</td>
    <td><input class='tbButton' type="submit" name="actionRename" value="<fmt:message key="renameTag"/>"></td>
</tr>

<tr>
    <td colspan="2" class="sectionLabel" valign="top"> <fmt:message key="changeTagColor"/></td>
</tr>
<tr>
    <td nowrap align='right'><fmt:message key="tagName"/>: </td>
    <td>
        <select name="tagToChangeColor">
            <option value="" selected/><fmt:message key="chooseTagToChange"/>
            <option disabled/><fmt:message key="actionOptSep"/>
            <zm:forEachTag var="tag">
                <option value="t:${tag.id}"/>${fn:escapeXml(tag.name)}
            </zm:forEachTag>
        </select>
    </td>
</tr>
<tr>
    <td nowrap align='right' valign='top'><fmt:message key="tagColor"/> :</td>
    <td class='Tags'>
        <table cellspacing="4" cellpadding="0">
            <tr>
                <td><input checked align=top type="radio" name="newColor" value="orange"></td>
                <td><app:img altkey="ALT_TAG_ORANGE" src="tag/TagOrange.gif"/></td>
                <td><fmt:message key="orange"/></td>
            </tr>
            <tr>
                <td><input type="radio" name="newColor" value="blue"></td>
                <td><app:img altkey="ALT_TAG_BLUE" src="tag/TagBlue.gif"/></td>
                <td><fmt:message key="blue"/></td>
            </tr>
            <tr>
                <td><input type="radio" name="newColor" value="cyan"></td>
                <td><app:img altkey="ALT_TAG_CYAN" src="tag/TagCyan.gif"/></td>
                <td><fmt:message key="cyan"/></td>
                </tr>
            <tr>
                <td><input type="radio" name="newColor" value="green"></td>
                <td><app:img altkey="ALT_TAG_GREEN" src="tag/TagGreen.gif"/></td>
                <td><fmt:message key="green"/></td>
            </tr>
            <tr>
                <td><input type="radio" name="newColor" value="purple"></td>
                <td><app:img altkey="ALT_TAG_PURPLE" src="tag/TagPurple.gif"/></td>
                <td><fmt:message key="purple"/></td>
        </tr>
            <tr>
                <td><input type="radio" name="newColor" value="red"></td>
                <td><app:img altkey="ALT_TAG_RED" src="tag/TagRed.gif"/></td>
                <td><fmt:message key="red"/></td>
        </tr>
            <tr>
                <td><input type="radio" name="newColor" value="yellow"></td>
                <td><app:img altkey="ALT_TAG_YELLOW" src="tag/TagYellow.gif"/></td>
                <td><fmt:message key="yellow"/></td>
            </tr>
        </table>
    </td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td valign='top'><input class='tbButton' type="submit" name="actionColorChange" value="<fmt:message key="changeTagColor"/>"></td>
</tr>

<tr>
    <td colspan="2" class="sectionLabel" valign="top"><fmt:message key="deleteTag"/></td>
</tr>
<tr>
    <td align='right' nowrap><fmt:message key="tagName"/>:</td>
    <td>
        <select name="tagToDelete">
            <option value="" selected/>
            <fmt:message key="chooseTagToDelete"/>
            <option disabled/>
            <fmt:message key="actionOptSep"/>
            <zm:forEachTag var="tag">
                <option value="t:${tag.id}"/>
                ${fn:escapeXml(tag.name)}
            </zm:forEachTag>
        </select>
    </td>

</tr>
<tr>
    <td>&nbsp;</td>
    <td><input class='tbButton' type="submit" name="actionDelete" value="<fmt:message key="deleteTag"/>"></td>
</tr>
</c:if>
<tr>
    <td colspan='2'>&nbsp;</td>
</tr>

</tbody>
</table>
</td>
</tr>
</table>
<input type="hidden" name="doAction" value="1"/>
</form>
</app:view>
