<%@ page buffer="8kb" autoFlush="true" %>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="zm" uri="com.zimbra.zm" %>
<%@ taglib prefix="mo" uri="com.zimbra.mobileclient" %>
<%@ 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="com.zimbra.i18n" %>
<%@ taglib prefix="app" uri="com.zimbra.htmlclient" %>
<mo:handleError>
    <zm:getMailbox var="mailbox"/>
    <c:choose>
        <c:when test="${not empty mailbox.prefs.locale}">
            <fmt:setLocale value='${mailbox.prefs.locale}' scope='request'/>
        </c:when>
        <c:otherwise>
            <fmt:setLocale value='${pageContext.request.locale}' scope='request'/>
        </c:otherwise>
    </c:choose>
    <fmt:setBundle basename="/messages/ZhMsg" scope="request"/>

    <fmt:message var="title" key="${fn:escapeXml(param.st)}"/>
</mo:handleError>
<c:if test="${(param.st eq 'briefcases' && mailbox.features.briefcases) || (param.st eq 'notebooks' && mailbox.features.notebook)}">
<c:if test="${not empty param.sq && empty param.actionSaveFolder && empty param.actionSaveSearch && empty param.actionSaveTag}">
    <c:set var="query" value="${param.sq}"/>
</c:if>
<c:set var="context_url" value="${requestScope.baseURL!=null?requestScope.baseURL:'zmain'}"/>
<c:url var="currentUrl" value="${context_url}"><c:param name="st" value="${param.st}"/></c:url>
<c:set value="${title}" var="title" scope="request"/>
<div class="stb tbl">
    <div class="tr">
            <span class="td" >&laquo;
                <c:if test="${mailbox.features.tasks}">
                    <c:if test="${param.st ne 'tasks'}">
                        <a href='${context_url}?st=tasks'>
                    </c:if>
                        <fmt:message key="taskList"/>
                    <c:if test="${param.st ne 'tasks'}">
                        </a>
                    </c:if> ::
                </c:if>
                <c:if test="${mailbox.features.notebook}">
                  
                    <c:if test="${param.st ne 'notebooks'}">
                        <a href='${context_url}?st=notebooks'>
                    </c:if>
                        <fmt:message key="notebooks"/>
                    <c:if test="${param.st ne 'notebooks'}">
                        </a>    
                    </c:if>
                 :: </c:if>
                <c:if test="${mailbox.features.briefcases}">
                    <c:if test="${param.st ne 'briefcases'}">
                        <a href='${context_url}?st=briefcases'>
                    </c:if>
                        <fmt:message key="briefcases"/>
                    <c:if test="${param.st ne 'briefcases'}">
                        </a>
                    </c:if>
                                            
                </c:if>  &raquo; </span>
    </div>
</div>
<div class="tb tbl">
    <div class="tr">
        <div class="td">
            <span class="Title left">
                    <c:if test="${param.st eq 'briefcases'}">
                        <fmt:message key="briefcases"/>
                    </c:if>
                    <c:if test="${param.st eq 'notebooks'}">
                        <fmt:message key="notebooks"/>
                    </c:if>
                </span>
                 <span class="right">
                    <c:if test="${param.st eq 'briefcases'}">
                        <a onclick="return toggleElem('nfldrfrm',this,'<fmt:message key="close"/>','<fmt:message key="create"/>');" class="zo_button1"
                           href="?st=${fn:escapeXml(param.st)}${empty param.showBCCreate?'&showBCCreate=1':''}${empty param.ajax ? '#folders' : ''}"><fmt:message key="${empty param.showBCCreate ? 'create' : 'close'}"/></a>
                    </c:if>
                    <c:if test="${param.st eq 'notebooks'}">
                        <a onclick="return toggleElem('nfldrfrm',this,'<fmt:message key="close"/>','<fmt:message key="create"/>');" class="zo_button1"
                           href="?st=${fn:escapeXml(param.st)}${empty param.showNBCreate?'&showNBCreate=1':''}${empty param.ajax ? '#folders' : ''}"><fmt:message key="${empty param.showNBCreate ? 'create' : 'close'}"/></a>
                    </c:if>
                </span>
        </div>
    </div>
</div>
<c:if test="${param.st eq 'briefcases'}">
    <mo:folderForm type="folder" id="${param.id}" hide="${empty param.showBCCreate}" url="${currentUrl}" st="${param.st}"/><c:set var="count" value="${0}"/>
    <zm:forEachFolder var="folder" skiproot="${false}" skipsystem="${false}" skiptrash="${true}">
        <c:if test="${count lt sessionScope.F_LIMIT and folder.isDocumentView}">
            <mo:overviewFolder folder="${folder}" types="briefcase"/>
            <mo:doFolderTree skiproot="${true}" parentid="${folder.id}" skipsystem="false"/>
        <c:set var="count" value="${count+1}"/></c:if>
    </zm:forEachFolder>
</c:if>
<c:if test="${param.st eq 'notebooks'}">
    <mo:folderForm type="folder" id="${param.id}" hide="${empty param.showNBCreate}" url="${currentUrl}" st="${param.st}"/><c:set var="count" value="${0}"/>
    <zm:forEachFolder var="folder" skiproot="${false}" skipsystem="${false}" skiptrash="${true}">
        <c:if test="${count lt sessionScope.F_LIMIT and folder.isWikiView}">
            <mo:overviewFolder folder="${folder}" types="wiki"/>
            <mo:doFolderTree skiproot="${true}" parentid="${folder.id}" skipsystem="false"/>
        <c:set var="count" value="${count+1}"/></c:if>
    </zm:forEachFolder>
</c:if>
<mo:overviewFolder types="${param.st eq 'briefcases' ? 'briefcase' : 'wiki' }" folder="${mailbox.trash}"/><c:set var="count" value="${0}"/>
<zm:forEachFolder var="folder" skiproot="${true}" parentid="${mailbox.trash.id}" skipsystem="${false}">
    <c:if test="${count lt sessionScope.F_LIMIT and (param.st eq 'briefcases' and folder.isDocumentView )}">
        <mo:overviewFolder folder="${folder}" types="briefcase"/>
    <c:set var="count" value="${count+1}"/></c:if>
    <c:if test="${count lt sessionScope.F_LIMIT and (param.st eq 'notebooks' and folder.isWikiView )}">
        <mo:overviewFolder folder="${folder}" types="wiki"/>
    <c:set var="count" value="${count+1}"/></c:if>
</zm:forEachFolder>
<div class="tb tbl">
    <div class="tr">
        <div class="td">
            <span class="Title left">
                <fmt:message key="searches"/></span>
            <span class="right">
                <a onclick="return toggleElem('nsrchfrm',this,'<fmt:message key="close"/>','<fmt:message key="create"/>');" class="zo_button1"
                   href="?st=${fn:escapeXml(param.st)}${empty param.showSearchCreate?'&showSearchCreate=1':''}${empty param.ajax ? '#searches' : ''}"><fmt:message key="${empty param.showSearchCreate ? 'create' : 'close'}"/></a>
            </span>
        </div>
    </div>
</div>
<mo:folderForm type="search" id="${param.sid}" hide="${empty param.showSearchCreate}" url="${currentUrl}" st="${param.st}"/><c:set var="count" value="${0}"/>
<zm:forEachFolder var="folder" skipsystem="${true}" skiptopsearch="${false}">
    <c:if test="${count lt sessionScope.F_LIMIT and (folder.isSearchFolder && (empty query || fn:containsIgnoreCase(folder.name,query)))}">
        <c:if test="${param.st eq 'briefcases' && (folder.types eq 'document' || folder.types eq 'briefcase')}">
            <mo:overviewSearchFolder folder="${folder}" types="briefcase"/>
        <c:set var="count" value="${count+1}"/></c:if>
        <c:if test="${count lt sessionScope.F_LIMIT and param.st eq 'notebooks' && (folder.types eq 'wiki' || folder.types eq 'notebook')}">
            <mo:overviewSearchFolder folder="${folder}" types="wiki"/>
        <c:set var="count" value="${count+1}"/></c:if>
    </c:if>
</zm:forEachFolder>
<div class="tb tbl">
    <div class="tr">
        <div class="td">
            <span class="Title left">
                        <fmt:message key="tags"/>
            </span>
            <c:if test="${mailbox.features.tagging}"><span class="right">
                <a onclick="return toggleElem('ntagfrm',this,'<fmt:message key="close"/>','<fmt:message key="create"/>');" class="zo_button1"
                   href="?st=${fn:escapeXml(param.st)}${empty param.showTagCreate?'&showTagCreate=1':''}${empty param.ajax ? '#tags' : ''}"><fmt:message key="${empty param.showTagCreate ? 'create' : 'close'}"/></a>
            </span></c:if>
        </div>
    </div>
</div>
<c:if test="${mailbox.features.tagging}">
    <mo:folderForm type="tag" id="${param.tid}" hide="${empty param.showTagCreate}" url="${currentUrl}" st="${param.st}"/>
</c:if>
<zm:forEachTag var="tag">
    <c:if test="${empty query || fn:containsIgnoreCase(tag.name, query)}">
        <mo:overviewTag calendars="${false}" tag="${tag}" types="${param.st eq 'briefcases'? 'briefcase' : 'wiki'}"/>
    </c:if>
</zm:forEachTag>
</c:if>