<%@ 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="com.zimbra.i18n" %>


<app:handleError>
<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"/>

<zm:computeSearchContext var="context" usecache="true"/>
<zm:getMailbox var="mailbox"/>
<app:composeCheck/>
<app:keyboard cache="home" globals="true" mailbox="${mailbox}" folders="true"/>

<%-- bug:35733 Deep linking  --%>
<c:if test="${not empty param.app}">
	<c:choose>
          <c:when test="${param.app eq 'calendar' and (mailbox.features.calendar or mailbox.features.calendarUpsell)}">
              <c:redirect url="/h/calendar" />
          </c:when>
          <c:when test="${param.app eq 'mail' and mailbox.features.mail and not empty param.id}">
              <c:redirect url="/h/search?st=message&id=${param.id}&action=view" />
          </c:when>
          <c:when test="${param.app eq 'mail' and mailbox.features.mail}">
			<c:redirect url="/h/search" />
		  </c:when>
		  <c:when test="${param.app eq 'voice' and mailbox.features.voice}">
			<c:redirect url="/h/search?st=voicemail" />
		  </c:when>
		  <c:when test="${param.app eq 'options' and mailbox.features.options}">
			  <c:redirect url="/h/options?selected=${param.section}" />
		  </c:when>
		  <c:when test="${param.app eq 'contacts' and mailbox.features.contacts}">
			  <c:redirect url="/h/search?st=contact" />
		  </c:when>
		  <c:when test="${param.app eq 'tasks' and mailbox.features.tasks}">
			  <c:redirect url="/h/search?st=task" />
		  </c:when>
	</c:choose>
</c:if>
<%-- end --%>

<c:set var="action" value="${empty param.paction ? param.action : param.paction}" scope="request"/>
<c:if test="${not empty param.expand}">
    <c:set target="${sessionScope.expanded}" property="${param.expand}" value="expand"/>
</c:if>
<c:if test="${not empty param.collapse}">
    <c:set target="${sessionScope.expanded}" property="${param.collapse}" value="collapse"/>
</c:if>
<c:set var="toolbar">
    <table width=100% cellspacing=0>
        <tr valign='middle'>
            <td class='TbBt'>
                <table cellspacing=0 cellpadding=0 class='Tb'>
                    <tr>
                        <td>
                            <c:set var="refreshUrl" value="/h/home" />
                            <a href="${fn:escapeXml(refreshUrl)}" <c:if test="${keys}"></c:if>><app:img src="startup/ImgRefresh.png" altkey="refresh"/><span style='padding-left:5px'><fmt:message key="refresh"/></span></a>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</c:set>
</app:handleError>

<c:if test="${param.mesg eq 'welcome'}">
<app:status style="info" html="true">
    <fmt:message key="htmlWelcomeMesg"/>
</app:status>
</c:if>

<c:set var="fullname" value="${fn:escapeXml(mailbox.name)}"/>            
<c:set var="folder" value="${mailbox.inbox}"/>
<fmt:message key="inbox" var="label"/>
<c:url var="url" value="/h/${empty base ? 'search' : base}">
<c:param name="sfi" value="${folder.id}"/>
</c:url>
<app:handleError>
    <fmt:message var="unknownRecipient" key="unknownRecipient"/>
    <fmt:message var="noSubject" key="noSubject"/>
</app:handleError>

<c:set var="selected" value="${empty param.selected ? 'home' : param.selected}"/>
<app:view mailbox="${mailbox}" title="${fn:escapeXml(empty label ? folder.name : label)} (${folder.unreadCount})" context="${context}" selected='home' folders="true" tags="true" searches="true" keys="true">

<table width="100%" cellpadding="0" cellspacing="0" >
<tr>
    <td class='TbTop'>${toolbar}</td>
</tr>
<tr>
<td class='ZhAppContent' style="padding:7px;width:100%;height:100%;valign:top;">       
       <span class="HelloGreeting">Welcome, ${empty fullname ? mailbox.name : fullname} &nbsp;</span>
       <c:if test="${not empty mailbox.accountInfo.prevSession}">
		   <span class="HelloLastLogin">last login ${zm:displayDate(pageContext, mailbox.accountInfo.prevSession)}</span>
	   </c:if>
<br><br>
<table width="100%" border="0" cellpadding="8" cellspacing="0">
<tr>
    <c:if  test="${mailbox.features.mail}" >
    <td valign="top" width="50%">
        <table cellpadding="0" cellspacing="0" border='0' width='100%'>
            <tr>
                <td>
                     <table border="0" cellpadding="0" cellspacing="0" width="100%">
        				<tr>
       						 <td class="ImgAccountsHeader_L" nowrap='nowrap'></td>
       						 <td class="ImgAccountsHeader__H AccountsHeader" nowrap='nowrap'><fmt:message key="mailHeader"/></td>
       						 <td class="ImgAccountsHeader_R" nowrap='nowrap'></td>
				        </tr>
				       </table>
                </td>
            </tr>
            <tr class="ZhHomeRow">
                <td class="ZhHomeCell">
                    <span style="font-weight:bold; font-size:12px;"><c:out value="${mailbox.name}"></c:out><br></span>
                    <a style="text-decoration:none;" href='${url}'>
                        ${folder.unreadCount}&nbsp;<fmt:message key="unread"/>
                    </a>
				</td>
            </tr>
        </table>
    </td>
    </c:if>
    <!-- for comcast cdv user -->
    <c:if test="${not mailbox.features.mail}" >
    <td valign="top" width="40%">
        <iframe width="100%" scrolling="no" frameborder="0" src="http://www.comcast.net/szcc_mc_hsd_upsell.html"></iframe>
    </td>
    </c:if>
    <!-- end -->    
    <td valign="top" width="50%">
		<c:choose>
			<c:when test="${mailbox.features.calendar}">
				<c:set var="tz" value="${mailbox.prefs.timeZone}" scope="request"/>
				<c:set scope="request" var="dateContext" value="${zm:getToday(tz)}"/>
				<app:apptGadget timezone="${tz}" date="${dateContext}" />
			</c:when>
			<c:otherwise>
				<c:if test="${mailbox.features.voice}">
					<table cellpadding="0" cellspacing="0" border='0' width='100%'>
						<tr><td>
							<table border="0" cellpadding="0" cellspacing="0" width="100%">
								<tr>
									<td class="ImgVoiceAccountsHeader_L" nowrap='nowrap'></td>
									<td class="ImgVoiceAccountsHeader__H AccountsHeader" nowrap='nowrap'>
										<fmt:message key="voiceHeader"/>
									</td>
									<td class="ImgVoiceAccountsHeader_R" nowrap='nowrap'></td>
								</tr>
							</table>
						</td></tr>
						<tr><td class="ZhHomeVoiceCell">
							<%--
							Going with the theory that voice access is really really slow, we put
							the voice account summary in an iframe to speed up home page loading
							--%> 
							<iframe class="ZhHomeVoiceIframe" scrolling="auto" marginWidth="0" marginHeight="0" frameBorder="0" src="<c:url value="/h/homevoice"/>"></iframe>
						</td>
						</tr>
					</table>
				</c:if>
			</c:otherwise>
		</c:choose>
    </td>
	<c:set var="comcast_msgcenterad" value="false"/>
		<c:forEach var="zimlets" items="${mailbox.attrs.zimbraZimletAvailableZimlets}">
		    <c:if test="${zimlets eq 'comcast_msgcenterad'}">
	        <c:set var="comcast_msgcenterad" value="true"/>
		</c:if>
		</c:forEach>
		<c:if test="${comcast_msgcenterad}">
		<td rowspan="2" align="center">
			<iframe src="http://pn2.adserver.yahoo.com/a?f=2022363872&pn=comcast&p=com-mail&l=LREC&c=sh&bg=ffffff&no_expandable=1"
	              marginwidth="0"
	              marginheight="0"
	              width="300"
	              height="264"
	              border="0"
	              frameborder="0"
	              style="border:none;"
	              scrolling="no" align="center"></iframe>
           <a style="color:black;text-decoration:none;" target="_blank" href="<fmt:message key="adSlugLink" />" ><fmt:message key="advertisement" /></a>
			</td>
		</c:if>
</tr>
</table>
</td>
</tr>
</table>

</app:view>
        
