<%@ 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:setBundle basename='/messages/AjxMsg' var='AjxMsg' scope='request' />
    
    <fmt:message var="title" key="addAttendeesResourcesFromContacts"/>
    <fmt:message var="hourFmt" key="CAL_APPT_EDIT_HOUR_FORMAT"/>
    <zm:composeUploader var="uploader"/>
    <c:set var="compose" value="${uploader.compose}"/>
    <c:set var="tz" value="${zm:getTimeZone(compose.timeZone)}"/>
    <c:set var="today" value="${zm:getCalendarMidnight(uploader.compose.apptStartCalendar.timeInMillis,tz)}"/>
    <c:set var="endDay" value="${zm:getCalendarMidnight(uploader.compose.apptEndCalendar.timeInMillis,tz)}"/>
    <c:choose>
        <c:when test="${compose.allDay}">
            <c:set var="aStart" value="${0}"/>
            <c:set var="aEnd" value="${24*60}"/>
        </c:when>
        <c:otherwise>
            <c:set var="aStart" value="${uploader.compose.startHour * 60 + uploader.compose.startMinute}"/>
            <c:set var="aEnd" value="${uploader.compose.endHour * 60 + uploader.compose.endMinute}"/>
        </c:otherwise>
    </c:choose>
    <c:set var="aEnd" value="${aEnd + (endDay.timeInMillis - today.timeInMillis)/(1000*60)}"/>
    <c:if test="${aStart % 30 ne 0 }">
        <c:set var="aStart" value="${aStart + (30 - (aStart % 30))}"/>
    </c:if>
    <c:if test="${aEnd % 30 ne 0 }">
        <c:set var="aEnd" value="${aEnd + (30 - (aEnd % 30))}"/>
    </c:if>

    <c:choose>
        <c:when test="${uploader.isContactSearch}">
            <c:choose>
                <c:when test="${mailbox.features.contactsDetailedSearch}">
                    <c:set var="nameQuery" value="${uploader.contactSearchNameQuery}"/>
                    <c:set var="phoneticQuery" value="${uploader.contactSearchPhoneticQuery}"/>
                    <c:set var="emailQuery" value="${uploader.contactSearchEmailQuery}"/>
                    <c:set var="deptQuery" value="${uploader.contactSearchDeptQuery}"/>
                    <c:set var="query" value="${nameQuery}"/>
                </c:when>
                <c:otherwise>
                    <c:set var="query" value="${uploader.contactSearchQuery}"/>
                </c:otherwise>
            </c:choose>
            <c:choose>
                <c:when test="${uploader.contactLocation eq 'gal'}">
                    <zm:searchGal var="searchGal" query="${query}" dept="${deptQuery}" email="${emailQuery}" type="account"/>
                </c:when>
                 <c:when test="${uploader.contactLocation eq 'resources'}">
                     <zm:searchGal var="searchGal" query="${query}" dept="${deptQuery}" email="${emailQuery}" type="resource"/>
                </c:when>
                <c:otherwise>
                    <c:if test="${not empty phoneticQuery}">
                        <c:set var="phoneticQueryString" value="#phoneticFirstName:${phoneticQuery} OR #phoneticLastName:${phoneticQuery}"/>
                        <c:choose>
                            <c:when test="${not empty query}">
                                <c:set var="query" value="(${query} OR ${phoneticQueryString})"/>
                            </c:when>
                            <c:otherwise>
                                <c:set var="query" value="(${phoneticQueryString})"/>
                            </c:otherwise>
                        </c:choose>
                    </c:if>
                    <c:if test="${not empty emailQuery}">
                        <c:set var="query" value="${query} to:${emailQuery}*"/>
                    </c:if>
                    <zm:search var="search" query="${query}" sort="nameAsc" types="contact" field="contact:" start="${0}" end="${0}" timezone="${mailbox.prefs.timeZone}" folderid=""/>
                </c:otherwise>
            </c:choose>
        </c:when>
        <c:otherwise>
            <zm:search var="search" query="is:local" limit="100" sort="nameAsc" types="contact" field="contact:" start="${0}" end="${0}" timezone="${mailbox.prefs.timeZone}" folderid=""/>
            <c:set var="query" value=""/>
        </c:otherwise>
    </c:choose>
</app:handleError>

<app:view mailbox="${mailbox}" title="${title}" selected='compose' folders="true" tags="true" searches="true" context="${null}" keys="false" date="${requestScope.dateContext}"
    onload="var e=document.getElementById('findField'); if (e) e.focus();">

<c:set var="toolbar">
    <table width=100%>
        <tr valign='middle'>
            <td class='TbBt'>
                <table class='Tb'>
                    <tr>
                        <app:button name="actionContactDone" src="common/ImgCheck.png" tooltip="done" text="done"/>
                        <td><div class='vertSep'></div></td>
                        <app:button name="actionContactAdd" src="contacts/ImgContactsPicker.png" tooltip="addSelected" text="addSelected"/>
                        <td><div class='vertSep'></div></td>
                        <app:button name="actionContactCancel" src="common/ImgCancel.png" tooltip="cancel" text="cancel"/>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</c:set>
<SCRIPT TYPE="text/javascript">
<!--
var checkEnter = function(f,e) {var k; if (window.event) k = window.event.keyCode; else if (e) k = e.which; else return true;
if (k == 13) { document.getElementById("doSearch").click();return false;} else {return true;}}
//-->
</SCRIPT>
<form action="" method="post" enctype="multipart/form-data" accept-charset="utf-8">
<table width=100%>
    <tr>
        <td class='TbTop'>
                ${toolbar}
        </td>
    </tr>
    <tr>
        <td class='ZhAppContent' align="">
            <table width="100%">
                <tr>
                    <td style="padding:0 15px;">
                        <table>
                        <tr>
                            <td>
                                <table class="ZPropertySheet" cellspacing="6">
                                                        <tr>
                                                            <td>&nbsp;</td>
                                                            <td>
                                                                <table>
                                                                    <tr>
                                                                        <td>
                                                                            <input id="allday" type=checkbox name="allDay" <c:if test="${compose.allDay}">checked</c:if> value="1">
                                                                        </td>
                                                                        <td>
                                                                           <label for="allday"><fmt:message key="allDayEvent"/></label>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td class="editViewLabel"><label for="start"><fmt:message key="start"/>:</label></td>
                                                            <td>
                                                                <table>
                                                                    <tr>
                                                                        <td>
                                                                            <input id="start" type=text size="12" maxlength="20" name="startDate" value="${fn:escapeXml(compose.startDate)}">
                                                                        </td>
                                                                        <td>&nbsp;</td>
                                                                        <td>@</td>
                                                                        <td>&nbsp;</td>
                                                                        <td>
                                                                            <select name="startHour">
                                                                                <c:set var="h" value="${compose.startHour}"/>
                                                                                <c:forEach var="hi" begin="0" end="23">
                                                                                    <option value="${hi}" <c:if test="${h eq hi}"> selected</c:if>>
                                                                                        <fmt:formatDate value="${zm:getTodayHour(hi, null).time}" pattern="${hourFmt}"/>
                                                                                    </option>
                                                                                </c:forEach>
                                                                            </select>
                                                                        </td>
                                                                        <td>&nbsp;</td>
                                                                        <td>
                                                                            <select name="startMinute">
                                                                                <c:set var="m" value="${compose.startMinute}"/>
                                                                                <option <c:if test="${m eq 0}">selected </c:if> value="0">:00
                                                                                <option <c:if test="${m eq 5}">selected </c:if> value="5">:05
                                                                                <option <c:if test="${m eq 10}">selected </c:if> value="10">:10
                                                                                <option <c:if test="${m eq 15}">selected </c:if> value="15">:15
                                                                                <option <c:if test="${m eq 20}">selected </c:if> value="20">:20
                                                                                <option <c:if test="${m eq 25}">selected </c:if> value="25">:25
                                                                                <option <c:if test="${m eq 30}">selected </c:if> value="30">:30
                                                                                <option <c:if test="${m eq 35}">selected </c:if> value="35">:35
                                                                                <option <c:if test="${m eq 40}">selected </c:if> value="40">:40
                                                                                <option <c:if test="${m eq 45}">selected </c:if> value="45">:45
                                                                                <option <c:if test="${m eq 50}">selected </c:if> value="50">:50
                                                                                <option <c:if test="${m eq 55}">selected </c:if> value="55">:55
                                                                            </select>
                                                                        </td>
                                                                        <td>

                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td class="editViewLabel"><label for="end"><fmt:message key="end"/>:</label></td>
                                                            <td>
                                                                <table>
                                                                    <tr>
                                                                        <td>
                                                                            <input id="end" type=text size="12" maxlength="20" name="endDate" value="${fn:escapeXml(compose.endDate)}">
                                                                        </td>
                                                                        <td>&nbsp;</td>
                                                                        <td>@</td>
                                                                        <td>&nbsp;</td>
                                                                        <td>
                                                                            <select name="endHour">
                                                                                <c:set var="h" value="${compose.endHour}"/>
                                                                                <c:forEach var="hi" begin="0" end="23">
                                                                                    <option value="${hi}" <c:if test="${h eq hi}"> selected</c:if>>
                                                                                        <fmt:formatDate value="${zm:getTodayHour(hi, null).time}" pattern="${hourFmt}"/>
                                                                                    </option>
                                                                                </c:forEach>
                                                                            </select>
                                                                        </td>
                                                                        <td>&nbsp;</td>
                                                                        <td>
                                                                            <select name="endMinute">
                                                                                <c:set var="m" value="${compose.endMinute}"/>
                                                                                <option <c:if test="${m eq 0}">selected </c:if> value="0">:00
                                                                                <option <c:if test="${m eq 5}">selected </c:if> value="5">:05
                                                                                <option <c:if test="${m eq 10}">selected </c:if> value="10">:10
                                                                                <option <c:if test="${m eq 15}">selected </c:if> value="15">:15
                                                                                <option <c:if test="${m eq 20}">selected </c:if> value="20">:20
                                                                                <option <c:if test="${m eq 25}">selected </c:if> value="25">:25
                                                                                <option <c:if test="${m eq 30}">selected </c:if> value="30">:30
                                                                                <option <c:if test="${m eq 35}">selected </c:if> value="35">:35
                                                                                <option <c:if test="${m eq 40}">selected </c:if> value="40">:40
                                                                                <option <c:if test="${m eq 45}">selected </c:if> value="45">:45
                                                                                <option <c:if test="${m eq 50}">selected </c:if> value="50">:50
                                                                                <option <c:if test="${m eq 55}">selected </c:if> value="55">:55
                                                                            </select>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        <c:if test="${mailbox.prefs.useTimeZoneListInCalendar or not zm:isSameTimeZone(compose.timeZone, mailbox.prefs.timeZoneCanonicalId)}">
                                                            <c:set var="addedTimeZone" value="true"/>
                                                            <tr>
                                                                <td nowrap align=right>
                                                                    <label for="timeZone"><fmt:message key="timeZonePref"/>:</label>
                                                                </td>
                                                                <td>
                                                                    <select name="timeZone" id="timeZone">
                                                                        <zm:forEachTimeZone var="tz">
                                                                            <fmt:message var="displayName" bundle='${AjxMsg}' key="${tz.id}"/>
                                                                            <option
                                                                                    <c:if test="${compose.timeZone eq tz.id}">selected</c:if>
                                                                                    value="${fn:escapeXml(tz.id)}">${fn:escapeXml(displayName)}</option>
                                                                        </zm:forEachTimeZone>
                                                                    </select>
                                                                </td>
                                                            </tr>
                                                        </c:if>

                                                        </table>
                            </td>
                            <td valign="bottom" style="padding:3px 10px;">
                                <input type="submit" value="<fmt:message key="applyChanges"/>" name="actionContactAdd" class="SearchButton"/>
                            </td>
                        </tr>
                    </table>
                    </td>
                    <td align="right" valign="top" width="20%" nowrap="nowrap">
                        <fieldset>
                            <legend><fmt:message key="key"/></legend>
                            <table width="100%">
                            <tr>
                                <td>
                                    <div class="keyDiv ZmScheduler-F "></div>
                                </td>
                                <td nowrap="nowrap">
                                    <fmt:message key="free"/>
                                </td>
                                <td>
                                    <div class="keyDiv ZmScheduler-B "></div>
                                </td>
                                <td nowrap="nowrap">
                                    <fmt:message key="busy"/>
                                </td>
                                <td>
                                    <div class="keyDiv ZmScheduler-T "></div>
                                </td>
                                <td nowrap="nowrap">
                                    <fmt:message key="tentative"/>
                                </td>
                                <td>
                                    <div class="keyDiv ZmScheduler-O "></div>
                                </td>
                                <td nowrap="nowrap">
                                    <fmt:message key="outOfOffice"/>
                                </td>
                                <td nowrap="nowrap">
                                    <div class="keyDiv ZmScheduler-U "></div>
                                </td>
                                <td nowrap="nowrap">
                                    <fmt:message key="unknown"/>
                                </td>
                            </tr>
                        </table>
                        </fieldset>
                                      
                    </td>
                </tr>
                 <tr>
                    <td colspan="2">
                        <hr size="1"/>
                    </td>
                </tr>
            </table>
            
            <table class="ZhSchedularTbl">
                <tr><fmt:message key="CAL_APPT_SCHEDULE_HEADER_FORMAT" var="hdrFormat"/>
                    <th width="30%">
                        <table align="center">
                            <tr>
                                <td>
                                    <input type="image" value="1" src="<app:imgurl value="startup/ImgLeftArrow.png"/>" name="schedulePrevDate"/>
                                </td>
                                <th nowrap="nowrap">
                                    <fmt:formatDate pattern="${hdrFormat}" value="${compose.apptStartCalendar.time}" timeZone="${tz}"/>
                                </th>
                                <td>
                                    <input type="image" value="1" src="<app:imgurl value="startup/ImgRightArrow.png"/>" name="scheduleNextDate"/>
                                </td>
                            </tr>
                        </table>

                    </th>
                    <td>&nbsp;</td>
                <tr>
                    <th width="30%" class="attName MsgHdr"> <fmt:message key="attendees"/> </th>
                    <td>
                        <table>
                            <tr>
                                <c:forEach begin="0" end="24" step="1" var="indx">
                                    <td colspan="2" align="center"><div class="hourLblDiv"/>${indx % 12 eq 0 ? 12 : (indx > 12 ? indx - 12 : indx) }</td>
                                </c:forEach>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td><div class="gridDiv"/></td>
                                <c:forEach begin="0" end="47" step="1" var="indx">
                                    <%--<c:set var="allAttFBStaus" value="${allAttFBStaus},${indx}=F"/>--%>
                                    <c:set var="curTm" value="${indx*30}"/>
                                    <td><div id="allAtt_${indx}" class="allAttShDiv ZmScheduler-F gridDiv halfHour ${curTm eq aStart ? ' start ' :''} ${curTm eq aEnd ? ' end ' :''} ${indx eq 0 ? ' firstDiv ' : ''} ${indx % 2 eq 1 ? ' anHour ' : ''}"/></td>
                                </c:forEach>
                                 <td><div class="gridDiv ${compose.allDay ? 'end ':''}"/></td>
                                <td>&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="attName">${fn:escapeXml(mailbox.defaultIdentity.fromEmailAddress.fullAddress)}</td>
                    <td>
                        <table>
                            <tr>
                                <td><div class="gridDiv"/></td>
                                <c:set var="aday" value="${today}"/>
                                <c:set var="emailid" value="${fn:trim(mailbox.defaultIdentity.fromEmailAddress.address)}"/>
                                <zm:getFreeBusyAppointments var="attFreeBusy" varexception="exp" start="${aday.timeInMillis}" end="${zm:addDay(aday,1).timeInMillis}" email="${emailid}"/>
                                <c:forEach begin="0" end="47" step="1" var="indx">
                                    <c:set var="curTm" value="${indx*30}"/>
                                   <c:set var="hasappt" value="${zm:hasAnyAppointments(attFreeBusy, today.timeInMillis + curTm*60*1000, today.timeInMillis + (curTm+30)*60*1000)}"/>
                                    <c:if test="${hasappt}">
                                        <zm:forEachAppoinment var="anAppt" appointments="${attFreeBusy}" start="${today.timeInMillis + curTm*60*1000}" end="${today.timeInMillis + (curTm+30)*60*1000}">
                                            <c:set var="status" value="${anAppt.freeBusyActual}"/>
                                        </zm:forEachAppoinment>
                                    </c:if>
                                    <td><div id="att_0_${indx}" class="gridDiv halfHour ${hasappt ? ' ZmScheduler-' : ''}${status} ${curTm eq aStart ? ' start ' :''} ${curTm eq aEnd ? ' end ' :''} ${indx eq 0 ? ' firstDiv ' : ''} ${indx % 2 eq 1 ? ' anHour ' : ''}"/></td>
                                </c:forEach>
                                <c:set var="rows" value="1"/>
                                <td><div class="gridDiv ${compose.allDay ? 'end ':''}"/></td>
                                <td>&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <c:forEach items="${uploader.allAttendeesAndResourcesList}" var="anAttendee" varStatus="row">
                    <c:if test="${! empty anAttendee and not empty fn:trim(anAttendee.fullAddressQuoted)}">
                    <tr>
                        <td class="attName">${fn:escapeXml(anAttendee.fullAddressQuoted)}</td>
                        <td>
                            <table>
                                <tr>
                                    <td><div class="gridDiv"/></td>
                                    <c:set var="aday" value="${today}"/>
                                    <c:set var="emailid" value="${fn:trim(anAttendee.address)}"/>
                                    <zm:getFreeBusyAppointments var="attFreeBusy" varexception="exp" start="${aday.timeInMillis}" end="${zm:addDay(aday,1).timeInMillis}" email="${emailid}"/>
                                    <c:forEach begin="0" end="47" step="1" var="indx">
                                        <c:set var="curTm" value="${indx*30}"/>
                                       <c:set var="hasappt" value="${zm:hasAnyAppointments(attFreeBusy, today.timeInMillis + curTm*60*1000, today.timeInMillis + (curTm+30)*60*1000)}"/>
                                        <c:if test="${hasappt}">
                                            <zm:forEachAppoinment var="anAppt" appointments="${attFreeBusy}" start="${today.timeInMillis + curTm*60*1000}" end="${today.timeInMillis + (curTm+30)*60*1000}">
                                                <c:set var="status" value="${anAppt.freeBusyActual}"/>
                                            </zm:forEachAppoinment>
                                        </c:if>
                                        <td><div id="att_${rows}_${indx}" class="gridDiv halfHour ${hasappt ? ' ZmScheduler-' : ''}${status} ${curTm eq aStart ? ' start ' :''} ${curTm eq aEnd ? ' end ' :''} ${indx eq 0 ? ' firstDiv ' : ''} ${indx % 2 eq 1 ? ' anHour ' : ''}"/></td>
                                    </c:forEach>
                                    <c:set var="rows" value="${rows+1}"/>
                                    <td><div class="gridDiv ${compose.allDay ? 'end ':''}"/></td>
                                    <td>
                                        <input type="image" name="removeAttendee" alt="<fmt:message key="remove"/>" value="${fn:escapeXml(anAttendee.fullAddress)}" src="<app:imgurl value="common/ImgCancel.png"/>">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    </c:if>
                </c:forEach>
                <script type="text/javascript">       <%-- to update the all attendees row with the f/b union of indiviual attendees statuses --%>
                    for(var i=0;i<=${rows};i++){
                        for(var j=0;j<=47;j++){
                            var elem = document.getElementById('att_'+i+'_'+j);
                            if(elem && elem.className){
                                if(elem.className.indexOf('ZmScheduler-B') > -1 ){
                                    document.getElementById('allAtt_'+j).className = document.getElementById('allAtt_'+j).className.replace(/ZmScheduler-[FUTO]/ig,'ZmScheduler-B');
                                }else if(elem.className.indexOf('ZmScheduler-O') > -1 ){
                                    document.getElementById('allAtt_'+j).className = document.getElementById('allAtt_'+j).className.replace(/ZmScheduler-[FUT]/ig,'ZmScheduler-O');
                                }else if(elem.className.indexOf('ZmScheduler-T') > -1 ){
                                    document.getElementById('allAtt_'+j).className = document.getElementById('allAtt_'+j).className.replace(/ZmScheduler-[FU]/ig,'ZmScheduler-T');
                                }else if(elem.className.indexOf('ZmScheduler-U') > -1 ){
                                    document.getElementById('allAtt_'+j).className = document.getElementById('allAtt_'+j).className.replace(/ZmScheduler-F/ig,'ZmScheduler-U');
                                }
                            }
                        }
                    }
                </script>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="2">
                        <c:choose>
                            <c:when test="${mailbox.features.contactsDetailedSearch}">

                                <label for="nameField"><fmt:message key="name"/>:</label>
                                <input type="text" id="nameField" class="searchField" style='width:20%' maxlength=2048 name='contactSearchNameQuery' value="${fn:escapeXml(nameQuery)}" onkeypress="return checkEnter(this,event)"/>

                                <span id="phoneticNameDisplay" style="display:${(empty uploader.contactLocation || uploader.contactLocation eq 'personal' || uploader.contactLocation eq 'contact') ? 'inline':'none'}">
                                    <label for="phoneticNameField"><fmt:message key="phoneticName"/>:</label>
                                    <input type="text" id="phoneticNameField" class="searchField" style='width:20%' maxlength=2048 name='contactSearchPhoneticQuery' value="${fn:escapeXml(phoneticQuery)}" onkeypress="return checkEnter(this,event)"/>
                                </span>

                                <label for="emailField"><fmt:message key="email"/>:</label>
                                <input type="text" id="emailField" class="searchField" style='width:20%' maxlength=2048 name='contactSearchEmailQuery' value="${fn:escapeXml(emailQuery)}" onkeypress="return checkEnter(this,event)"/>

                                <span id="departmentDisplay" style="display:${uploader.contactLocation eq 'gal' ? 'inline':'none'}">
                                    <label for="deptField"><fmt:message key="department"/>:</label>
                                    <input type="text" id="deptField" class="searchField" style='width:20%' maxlength=2048 name='contactSearchDeptQuery' value="${fn:escapeXml(deptQuery)}" onkeypress="return checkEnter(this,event)"/>
                                </span>

                            </c:when>
                            <c:otherwise>
                                <label for="findField"><fmt:message key="find"/>:</label>
                                <input type="text" id="findField" class="searchField" style='width:50%' maxlength=2048 name='contactSearchQuery' value="${fn:escapeXml(query)}" onkeypress="return checkEnter(this,event)">
                            </c:otherwise>
                        </c:choose>
                        <c:if test="${mailbox.features.contactsDetailedSearch}">
                            <script type="text/javascript">
                                function changeSearchType(value) {
                                    var phonetic = document.getElementById("phoneticNameDisplay");
                                    var department = document.getElementById("departmentDisplay");
                                    if (phonetic) {
                                        phonetic.style.display = (value=="contact") ? "inline":"none";
                                    }
                                    if (department) {
                                        department.style.display = (value=="gal") ? "inline":"none";
                                    }
                                }
                            </script>
                        </c:if>
                        &nbsp;
                        <fmt:message key="in"/>
                        &nbsp;
                        <select name="contactLocation" <c:if test="${mailbox.features.contactsDetailedSearch}">onchange="changeSearchType(this.value)"</c:if>>
                            <c:if test="${mailbox.features.contacts}">
                                <option <c:if test="${empty uploader.contactLocation or uploader.contactLocation eq 'personal' or uploader.contactLocation eq 'contact'}">selected</c:if> value="contact"/>
                                <fmt:message key="searchPersonalContacts"/>
                            </c:if>
                            <c:if test="${mailbox.features.gal}">
                                <option <c:if test="${uploader.contactLocation eq 'gal'}">selected</c:if> value="gal"/>
                                <fmt:message key="GAL"/>
                            </c:if>
                            <c:if test="${mailbox.features.galAutoComplete}">
                                <option <c:if test="${uploader.contactLocation eq 'resources'}">selected</c:if> value="resources"/>
                                <fmt:message key="resources"/>
                            </c:if>
                        </select>
                        <input id="doSearch" class="SearchButton" type=submit name='actionContactSearch'
                               value="<fmt:message key="search"/>">

                    </td>
                </tr>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td class='List' colspan="2">
                        <div class="TbTop">${toolbar}</div>
                        <app:contactAddListView attendeeMode="${true}" searchResult="${search}" searchGalResult="${searchGal}" uploader="${uploader}"/>
                    </td>
                </tr>
             </table>
        </td>
    </tr>
    <tr>
        <td class='TbBottom'>
                <%--${toolbar}--%>&nbsp;
        </td>
    </tr>
</table>

    <input type="hidden" name="apptFolderId" value="${fn:escapeXml(compose.apptFolderId)}"/>
    <input type="hidden" name="classProp" value="${fn:escapeXml(compose.classProp)}"/>
    <input type="hidden" name="invId" value="${fn:escapeXml(compose.inviteId)}"/>
    <input type="hidden" name="exInvId" value="${fn:escapeXml(compose.exceptionInviteId)}"/>
    <input type="hidden" name="useInstance" value="${fn:escapeXml(compose.useInstance ? '1' : '0') }"/>
    <input type="hidden" name="instStartTime" value="${fn:escapeXml(compose.instanceStartTime)}"/>
    <input type="hidden" name="instDuration" value="${fn:escapeXml(compose.instanceDuration)}"/>
    <input type="hidden" name="subject" value="${fn:escapeXml(compose.subject)}"/>
    <input type="hidden" name="location" value="${fn:escapeXml(compose.location)}"/>
    <input type="hidden" name="freeBusyStatus" value="${fn:escapeXml(compose.freeBusyStatus)}"/>
    <%--<input type="hidden" name="allDay" value="${fn:escapeXml(compose.allDay ? '1':'0')}"/>--%>
    <input type="hidden" name="startDate" value="${fn:escapeXml(compose.startDate)}"/>
    <input type="hidden" name="startHour" value="${fn:escapeXml(compose.startHour)}"/>
    <input type="hidden" name="startMinute" value="${fn:escapeXml(compose.startMinute)}"/>
    <input type="hidden" name="endDate" value="${fn:escapeXml(compose.endDate)}"/>
    <input type="hidden" name="endHour" value="${fn:escapeXml(compose.endHour)}"/>
    <input type="hidden" name="endMinute" value="${fn:escapeXml(compose.endMinute)}"/>
    <input type="hidden" name="timeZone" value="${fn:escapeXml(compose.timeZone)}"/>
    <input type="hidden" name="attendees" value="${fn:escapeXml(compose.attendees)}"/>
    <input type="hidden" name="resources" value="${fn:escapeXml(compose.resources)}"/>
    <input type="hidden" name="body" value="${fn:escapeXml(compose.content)}"/>
    <c:forEach var="ma" items="${compose.messageAttachments}">
        <input type="hidden" name="messageAttachment" value="${ma.id}:${fn:escapeXml(ma.subject)}"/>
    </c:forEach>
    <c:forEach var="ca" items="${compose.checkedAttachmentNames}">
        <input type="hidden" name="originalAttachment" value="${fn:escapeXml(ca.key)}"/>
    </c:forEach>
    <input type="hidden" name="pendingAttendees" value="${fn:escapeXml(uploader.pendingAttendees)}"/>
	<input type="hidden" name="pendingResources" value="${fn:escapeXml(uploader.pendingResources)}"/>

        <input type="hidden" name="repeatBasicType" value="${fn:escapeXml(compose.repeatBasicType)}"/>
       <input type="hidden" name="repeatType" value="${fn:escapeXml(compose.repeatType)}"/>
        <input type="hidden" name="repeatDailyInterval" value="${fn:escapeXml(compose.repeatDailyInterval)}"/>
        <input type="hidden" name="repeatWeeklyByDay" value="${fn:escapeXml(compose.repeatWeeklyByDay)}"/>
        <input type="hidden" name="repeatWeeklyInterval" value="${fn:escapeXml(compose.repeatWeeklyInterval)}"/>
        <input type="hidden" name="repeatWeeklySun" value="${fn:escapeXml(compose.repeatWeeklySun) ? '1' : '0'}"/>
        <input type="hidden" name="repeatWeeklyMon" value="${fn:escapeXml(compose.repeatWeeklyMon) ? '1' : '0'}"/>
        <input type="hidden" name="repeatWeeklyTue" value="${fn:escapeXml(compose.repeatWeeklyTue) ? '1' : '0'}"/>
        <input type="hidden" name="repeatWeeklyWed" value="${fn:escapeXml(compose.repeatWeeklyWed) ? '1' : '0'}"/>
        <input type="hidden" name="repeatWeeklyThu" value="${fn:escapeXml(compose.repeatWeeklyThu) ? '1' : '0'}"/>
        <input type="hidden" name="repeatWeeklyFri" value="${fn:escapeXml(compose.repeatWeeklyFri) ? '1' : '0'}"/>
        <input type="hidden" name="repeatWeeklySat" value="${fn:escapeXml(compose.repeatWeeklySat) ? '1' : '0'}"/>
        <input type="hidden" name="repeatMonthlyInterval" value="${fn:escapeXml(compose.repeatMonthlyInterval)}"/>
        <input type="hidden" name="repeatMonthlyMonthDay" value="${fn:escapeXml(compose.repeatMonthlyMonthDay)}"/>
        <input type="hidden" name="repeatMonthlyRelativeInterval" value="${fn:escapeXml(compose.repeatMonthlyRelativeInterval)}"/>
        <input type="hidden" name="repeatMonthlyRelativeOrd" value="${fn:escapeXml(compose.repeatMonthlyRelativeOrd)}"/>
        <input type="hidden" name="repeatMonthlyRelativeDay" value="${fn:escapeXml(compose.repeatMonthlyRelativeDay)}"/>
        <input type="hidden" name="repeatYearlyMonthDay" value="${fn:escapeXml(compose.repeatYearlyMonthDay)}"/>
        <input type="hidden" name="repeatYearlyMonth" value="${fn:escapeXml(compose.repeatYearlyMonth)}"/>
        <input type="hidden" name="repeatYearlyRelativeOrd" value="${fn:escapeXml(compose.repeatYearlyRelativeOrd)}"/>
        <input type="hidden" name="repeatYearlyRelativeDay" value="${fn:escapeXml(compose.repeatYearlyRelativeDay)}"/>
        <input type="hidden" name="repeatYearlyRelativeMonth" value="${fn:escapeXml(compose.repeatYearlyRelativeMonth)}"/>
        <input type="hidden" name="repeatEndType" value="${fn:escapeXml(compose.repeatEndType)}"/>
        <input type="hidden" name="repeatEndCount" value="${fn:escapeXml(compose.repeatEndCount)}"/>
        <input type="hidden" name="repeatEndDate" value="${fn:escapeXml(compose.repeatEndDate)}"/>
        <input type="hidden" name="crumb" value="${fn:escapeXml(mailbox.accountInfo.crumb)}"/>
</form>
</app:view>
