<?xml version="1.0" standalone="yes"?>
<!DOCTYPE div>
<div xmlns="http://www.w3.org/1999/xhtml"
  xmlns:var="http://www.skyrix.com/od/binding"
  xmlns:label="OGo:label"
  xmlns:const="http://www.skyrix.com/od/constant"
  xmlns:rsrc="OGo:url"
  class="linked_attachment_frame"
  >
  <!-- TODO: add iMIP actions -->

  <input id="iCalendarAttachment" type="hidden"
	var:value="pathToAttachment"/>

  <var:if condition="couldParseCalendar" const:negate="1">
    <fieldset>
      <legend>Parsing Error</legend>
      
      The SOGo/SOPE iCalendar parser could not parse the body of this MIME part.

      <pre><var:string value="flatContentAsString" /></pre>
    </fieldset>
  </var:if>

  <var:if condition="couldParseCalendar">
    <div class="popupMenu" id="contactsMenu">
      <ul></ul>
    </div>
    <fieldset>
      <legend>
	<var:string label:value="Appointment"/>:
	<strong><var:string value="inEvent.summary" /></strong> <!-- TODO: shorted title -->

	<var:if condition="isLoggedInUserTheOrganizer">
	  (<var:string label:value="organized_by_you"/>)
	</var:if>
	<var:if condition="isLoggedInUserAnAttendee">
	  (<var:string label:value="you_are_an_attendee"/>)
	</var:if>
      </legend>
      
      <var:if condition="inCalendar.method.uppercaseString" const:value="REQUEST">
	<!-- sent to attendees to propose or update a meeting -->
	<var:if condition="isLoggedInUserAnAttendee">
	  <var:if condition="hasCalendarAccess">
	    <div class="uix_ical_toolbar" id="iCalendarToolbar">
        <p>
                <var:if condition="currentUserAttendee.rsvp" const:value="true">
	      <var:if condition="currentUserAttendee.partStatWithDefault"
          const:value="ACCEPTED" const:negate="YES">
          <a href="#" class="button actionButton" id="iCalendarAccept">
            <span><var:string label:value="Accept" /></span></a>
	      </var:if>
	      <var:if condition="currentUserAttendee.partStatWithDefault"
          const:value="DECLINED" const:negate="YES">
          <a href="#" class="button actionButton" id="iCalendarDecline">
            <span><var:string label:value="Decline" /></span></a>
	      </var:if>
	      <var:if condition="currentUserAttendee.partStatWithDefault"
          const:value="TENTATIVE" const:negate="YES">
          <a href="#" class="button actionButton" id="iCalendarTentative">
            <span><var:string label:value="Tentative" /></span></a>
	      </var:if>
	      <var:if condition="currentUserAttendee.partStatWithDefault"
          const:value="DELEGATED" const:negate="YES">
          <a href="#" class="button actionButton" id="editDelegate">
            <span><var:string label:value="Delegate ..." /></span></a>
		<span id="delegateEditor" style="display: none;">
      <span class="floatLeft"><var:string label:value="Delegated to" /></span>
      <input name="delegatedTo" id="delegatedTo" type="text" />
      <a href="#" class="button actionButton" id="iCalendarDelegate" name="delegateOK">
        <span><var:string label:value="OK" /></span></a>
		</span>
	      </var:if>
	      <var:if condition="currentUserAttendee.partStatWithDefault"
		const:value="DELEGATED">
		<span id="delegateEditor">
		  <span class="floatLeft"><var:string label:value="Delegated to" />
		    <a var:href="currentUserAttendee.delegatedTo" name="delegatedToLink" id="delegatedToLink"><var:string value="currentUserAttendee.delegatedTo.rfc822Email" /></a></span>
		    <input name="delegatedTo" id="delegatedTo" type="text" var:value="currentUserAttendee.delegatedTo.rfc822Email" var:uid="currentUserAttendee.delegatedTo.rfc822Email" style="display: none;" />
        <a href="#" class="button actionButton" id="iCalendarDelegate" style="display: none;">
          <span><var:string label:value="OK" /></span></a>
		</span>
	      </var:if>
                </var:if>
	      <var:if condition="isEventStoredInCalendar" const:negate="YES">
          <a href="#" class="button actionButton" id="iCalendarAddToCalendar">
            <span><var:string label:value="Add to calendar" /></span></a>
        </var:if>
      </p>
	    </div>
	  </var:if>

	  <p class="clear">
	    <var:string label:value="Organizer" />
	    <a var:href="inEvent.organizer.email"
	      ><var:string value="organizerDisplayName" /></a>
	    <var:string label:value="request_info" />
	  </p>
	</var:if>
	
	<var:if condition="isLoggedInUserAnAttendee" const:negate="YES">
	  <p>
	    <var:string label:value="Organizer" />
	    <a var:href="inEvent.organizer.email"
	      ><var:string value="organizerDisplayName" /></a>
	    <var:string label:value="request_info_no_attendee" />
	  </p>
	</var:if>
      </var:if>

      <var:if condition="inCalendar.method.uppercaseString" const:value="REPLY">
	<!-- sent to organizer to update the status of the participant -->
	<var:if condition="isReplySenderAnAttendee" const:negate="1">
	  <p><var:string label:value="reply_info_no_attendee" /></p>
	</var:if>

	<var:if condition="isReplySenderAnAttendee">
	  <var:if condition="canOriginalEventBeUpdated"
	    ><dl class="dl-horizontal">
              <dt><var:string label:value="Status Update" />:</dt>
	      <dd><i><var:string label:value="$inReplyAttendee.partStatWithDefault" /></i>,
	      <var:string label:value="was" />
	      <i><var:string label:value="$storedReplyAttendee.partStatWithDefault" /></i>.
              <br/><input id="iCalendarUpdateUserStatus" class="button"
		type="button" label:value="Update status"/></dd>
	    </dl></var:if>
	</var:if>
      </var:if>

      <var:if condition="inCalendar.method.uppercaseString" const:value="CANCEL">
	<!-- sent to attendees to notify of the attendee being removed or the
	event being deleted -->
        <dl class="dl-horizontal">
          <dd><var:string label:value="cancel_info_text" />
	<var:if condition="isEventStoredInCalendar">
	  <br/><a href="#" id="iCalendarDeleteFromCalendar" class="button">
	    <span><var:string label:value="Delete from calendar" /></span></a>
	</var:if></dd>
        </dl>
      </var:if>

      <var:if condition="inCalendar.method.uppercaseString" const:value="ADD">
	<!-- TODO -->
        <dl class="dl-horizontal">
          <dd><var:string label:value="add_info_text" /></dd>
        </dl>
      </var:if>

      <var:if condition="inCalendar.method.uppercaseString" const:value="PUBLISH">
	<!-- none-scheduling event sent to someone for adding to the calendar -->
        <dl class="dl-horizontal">
          <dd><var:string label:value="publish_info_text" /></dd>
        </dl>
      </var:if>
      
      <var:if condition="isLoggedInUserTheOrganizer">
	<!--
	Possible Status:
	REPLY    => check whether it matches, if not suggest change, show
	comment
	REFRESH  => add button to resent iCal
	COUNTER  => show panel to decide on counter
	-->
      </var:if>
      <var:if condition="isLoggedInUserTheOrganizer" const:negate="1">
	<!--
	Possible Status:
	REQUEST => ACCEPT, TENTATIVELY, DECLINE buttons with comment field
	- only show buttons for attendees
	PUBLISH => just the 'add to calendar' button, rewrite organizer?
	ADD / CANCEL
	DECLINE-COUNTER
	-->
      </var:if>

      <!-- the user comment is used in replies -->
      <var:if condition="inEvent.userComment.isNotEmpty">
	<div class="linked_attachment_meta" style="background-color: white;">
	  <var:string value="inEvent.userComment" const:insertBR="1" />
	</div>
	<br />
      </var:if>
      
      <div class="linked_attachment_meta" style="background-color: white;">
        <dl id="iCalAttendees" class="dl-horizontal">
          <dt><var:string label:value="Time"/>:</dt>
          <dd><var:string value="startDate" />
            <var:if condition="inEvent.isAllDay" const:negate="YES">
              <var:string value="startTime" />
            </var:if>
            <var:if condition="isEndDateOnSameDay">
              <var:if condition="inEvent.isAllDay" const:negate="YES">
                <var:string label:value="to" />
                <var:string value="endTime" />
              </var:if>
            </var:if>
            <var:if condition="isEndDateOnSameDay" const:negate="YES">
              <var:string label:value="to" />
              <var:string value="endDate" />
              <var:if condition="inEvent.isAllDay" const:negate="YES">
                <var:string value="endTime" />
              </var:if>
            </var:if>
          </dd>

          <dt><var:string label:value="Organizer"/>:</dt>
          <dd><a var:href="authorativeEvent.organizer.email"
		><var:string value="organizerDisplayName" /></a>
          </dd>
          <dt><var:string label:value="Attendees"/>:</dt>
	      <var:foreach list="authorativeEvent.participants" item="attendee">
		<var:if condition="attendee.delegatedTo" const:negate="YES"><!-- don't show attendees that delegated the invitation -->                 <dd><span var:class="currentAttendeeClass"
                    ><div class="status-icon"><!-- space --></div
                      ><a var:href="attendee.email">
		  <var:string value="attendeeForDisplay"/></a>
		(<var:string label:value="$attendee.partStatWithDefault" /><var:if condition="attendee.delegatedTo"> <var:string label:value="to" /> <var:string value="attendee.delegatedTo.rfc822Email" /></var:if><var:if condition="attendee.delegatedFrom.length">, <var:string label:value="delegated from" /> <var:string value="attendee.delegatedFrom.rfc822Email" /></var:if>)</span>
              </dd></var:if>
	      </var:foreach>

          <var:if condition="authorativeEvent.comment.isNotEmpty">
          <dt><var:string label:value="Comment"/>:</dt>
          <dd><var:string value="authorativeEvent.comment" const:insertBR="1" /></dd>
          </var:if>
	</dl>
      </div>
    </fieldset>
  </var:if><!-- could parse -->

  <!--
  <var:string value="appointment" />
  <br />
  <br />
  <br />
  -->
  <!-- <pre style="display: none;"><var:string value="flatContentAsString" /></pre> -->
</div>
