<%@ 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>
    <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="${param.app}"/>
    <c:set var="iframeUrl" value="" />
    <c:if test="${param.app eq 'calendar' and not empty mailbox.features.calendarUpsellURL}">
        <c:set var="iframeUrl" value="${mailbox.features.calendarUpsellURL}" />        
    </c:if>
</app:handleError>


<app:view mailbox="${mailbox}" title="${title}" selected='${param.app}' context="${context}" keys="true" editmode="true">
    <table width="100%" height="100%"cellpadding="0" cellspacing="0">
        <tr>
            <td class="list">
                <iframe onload="resizeIframe();" id="upsellIframe" style="width:100%; height:400px;" marginWidth="0" marginHeight="0" frameBorder="0" src="${fn:escapeXml(iframeUrl)}"></iframe>
            </td>
        </tr>
    </table>

    <script type="text/javascript">

        var isKonqueror = /KHTML/.test(navigator.userAgent);
        var isIE = ( /MSIE/.test(navigator.userAgent) && !/(Opera|Gecko|KHTML)/.test(navigator.userAgent) );
        var iframe = document.getElementById("upsellIframe");
        iframe.style.width = "100%";
        iframe.style.height = "400px";
        iframe.marginWidth = 0;
        iframe.marginHeight = 0;
        iframe.border = 0;
        iframe.frameBorder = 0;
        iframe.style.border = "none";

        var resizeIframe = function() {
            if (iframe !=null) {
                iframe.style.display = 'none';
                var height = document.getElementById("skin_app_table").offsetHeight-5;
                iframe.style.height = height + 'px';
                iframe.style.display = '';
            }
        }

        window.onresize = resizeIframe;

        setTimeout(resizeIframe, 1000);
    </script>
</app:view>