<html>

<%@page info="EditEventData" language="java" pageEncoding="utf-8" contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/jato.tld" prefix="jato"%>
<%@taglib uri="/WEB-INF/uwc.tld" prefix="uwc"%>

<%@include file="../../uwc/js/resourceBundleUtils.js"%>

<jato:useViewBean className="com.sun.uwc.calclient.EditEventDataViewBean">

<head>
<title><jato:getDisplayFieldValue escape="false" name="Banner"/></title>
<script src="../uwc/js/browserVersion.js" type="text/javascript"> </script>
<script type="text/javascript">
<!--
  if (is_ie5up) // IE5
  {
   document.write("<LINK href=<%= getLocalizedLabel(session, "skinModel", "Style-Sheet-IE", "../uwc/css/css_ie5win.css") %> type=text/css rel=stylesheet>")
  }
  else if (is_gecko) // Netscape 6/7 or Mozilla
  {
   document.write("<LINK href=<%= getLocalizedLabel(session, "skinModel", "Style-Sheet-NN", "../uwc/css/css_ns6up.css") %> type=text/css rel=stylesheet>")
  }
  else  // All others
  {
   document.write("<LINK href=<%= getLocalizedLabel(session, "skinModel", "Style-Sheet-NN", "../uwc/css/css_ns6up.css") %> type=text/css rel=stylesheet>")
  }
//-->
</script>
<script>
<!--
function handleEnter(event) {
     if (is_ie5up) {
         if(event.keyCode == 13) {
            var inviteeText = document.forms[0].elements["eventInvitee"].value;
            if((null == inviteeText) || ("" == trim(inviteeText))) {
                        UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-BlankInvitee-alert", "Enter a valid invitee name. You cannot leave this field blank.") %>');
            return false;
            }
            document.forms[0].elements["add"].click();
          }
     }
     else {
        if(event.which == 13) {
            var inviteeText = document.forms[0].elements["eventInvitee"].value;
            if((null == inviteeText) || ("" == trim(inviteeText))) {
                        UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-BlankInvitee-alert", "Enter a valid invitee name. You cannot leave this field blank.") %>');
            return false;
            }
            document.forms[0].elements["add"].click();
         }
     }
     return true
}
//-->
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="Popup" onLoad="return loadPage();">

<jato:form name="EditEventData" method="post" defaultCommandChild="/Save" onSubmit="saveRVSPStatus();">

<input type="hidden" name="submitType">
<input type="hidden" name="RecurrenceModifier">
<jato:hidden name="TimeZone"/>
<jato:hidden name="EventUID"/>
<jato:hidden name="EventRID"/>
<jato:hidden name="PreviousCalid"/>
<jato:hidden name="RSVPNotRequestedAttendees" defaultValue=""/>
<jato:hidden name="emailsSelectedFromAB" defaultValue=""/>
<jato:hidden name="hasAttendeesModified" defaultValue=""/>
<jato:hidden name="CurrentAnchorPoint" defaultValue=""/>
<jato:hidden name="OrgCalid" defaultValue=""/>
<jato:hidden name="PreviousPrivacy" defaultValue=""/>
<jato:hidden name="PreviousShowAsBusy" defaultValue=""/>

<!-- Popup Title -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" title="">
  <tr>
    <td class="PopupTitle"><span class="PopupTitleText"><jato:getDisplayFieldValue escape="false" name="Banner"/></span></td>
  </tr>
</table>

<!-- Error pagelet -->
<jato:containerView name="errorPlugin">
    <%@include file="/uwc/common/popuperror2.jsp"%>
</jato:containerView>

<!-- Jump Link Section -->
<div class="ConJmpScnDiv">
<table border="0" cellspacing="0" cellpadding="0">
  <tbody>
  <tr> 
    <td valign="top"> 
      <div class="ConJmpLnkDiv"><a href="#details" class="JmpLnk" title="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-EventDetails-section-title", "Jump Down to the Events Details Section") %>" tabindex="1"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Anchor-image", "../uwc/images/to_anchor.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-EventDetails-section-title", "Jump Down to the Events Details Section") %>" width="16" height="10" border="0"><%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-EventDetails-section", "Event Details") %></a></div>
    </td>
    <td valign="top"> 
      <div class="ConJmpLnkDiv"><a href="#invitees" class="JmpLnk" title="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Invitees-section-title", "Jump Down to the Invitees Section") %>" tabindex="2"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Anchor-image", "../uwc/images/to_anchor.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Invitees-section-title", "Jump Down to the Invitees Section") %>" width="16" height="10" border="0"><%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Invitees-section", "Invitees") %></a></div>
    </td>
  </tr>
  <tr> 
    <td valign="top"> 
      <div class="ConJmpLnkDiv"><a href="#recurrence" class="JmpLnk" title="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Recurrence-section-title", "Jump Down to the Recurrence Section") %>" tabindex="3"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Anchor-image", "../uwc/images/to_anchor.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Recurrence-section-title", "Jump Down to the Recurrence Section") %>" width="16" height="10" border="0"><%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Recurrence-section", "Recurrence") %></a></div>
    </td>
    <td valign="top"> 
      <div class="ConJmpLnkDiv"><a href="#reminders" class="JmpLnk" title="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Reminders-section-title", "Jump Down to the Reminders Section") %>" tabindex="4"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Anchor-image", "../uwc/images/to_anchor.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Reminders-section-title", "Jump Down to the Reminders Section") %>" width="16" height="10" border="0"><%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Reminders-section", "Reminders") %></a></div>
    </td>
  </tr>
  </tbody> 
</table>
</div>

<a name="details" id="details"></a>
<!-- Sub-Section Header -->  
<table width="100%" border="0" cellspacing="0" cellpadding="0" title="">
  <tr> 
    <td><img src="../uwc/images/spacer.gif" width="10" height="5" alt=""></td>
    <td class="SectionDivider" width="100%"><img src="../uwc/images/spacer.gif" width="1" height="5" alt=""></td>
    <td><img src="../uwc/images/spacer.gif" width="10" height="5" alt=""></td>
  </tr>
  <tr> 
    <td colspan="3" class="SectionHeader"><span class="SectionHeader"><%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-EventDetails-section", "Event Details") %></span></td>
  </tr>
</table>

<!-- Event Details Section -->
<table class="FormInputTable" width="100%" border="0" cellspacing="0" cellpadding="0" title="">
    <tr> 
      <td colspan="2"><img src="../uwc/images/spacer.gif" width="1" height="10" alt=""></td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="eventTitle"><%= getLocalizedLabel(session, "uwc-calclient-Title", "Title") %>:</label></span></td>
      <td class="PropInput" width="100%"> 
        <jato:textField name="Title" size="50" elementId="eventTitle" tabIndex="5"/>
      </td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="calendarMenu"><%= getLocalizedLabel(session, "uwc-calclient-Calendar", "Calendar") %>:</label></span></td>
      <td class="PropInput"> 
        <jato:content name="NewEventOnlyContent">
          <uwc:uwccombobox name="CalID" elementId="calendarMenu" tabIndex="6"/>
        </jato:content>
        <jato:content name="EditEventOnlyContent">
          <jato:text name="ReadOnlyCalDisplay"/>
          <jato:hidden name="ReadOnlyCalid"/>
        </jato:content>
      </td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="monthMenu"><%= getLocalizedLabel(session, "uwc-calclient-Date", "Date") %>:</label></span></td>
      <td class="PropInput" nowrap> 
        <jato:combobox name="StartDateMonth" elementId="monthMenu" tabIndex="7"/>
        <label for="dayMenu"></label>
        <jato:combobox name="StartDateDay" elementId="dayMenu" tabIndex="8"/>
        <label for="yearMenu"></label>
        <jato:combobox name="StartDateYear" elementId="yearMenu" tabIndex="9"/>
        <a href="javascript:;" accesskey="C" onClick="openMiniCalendar(); return false;" onKeyPress="openMiniCalendar(); return false;" title="<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-title", "Select Date from Calendar") %>"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-calclient-minicalendar-image", "../uwc/images/CalendarLink_wo.gif") %>" width="20" height="20" align="absmiddle" border="0" title="<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-title", "Select Date from Calendar") %>" alt="<%= getLocalizedLabel(session, "uwc-calclient-minicalendar-title", "Select Date from Calendar") %>" tabindex="10"></a> 
      </td>
    </tr>
    <tr> 
      <td class="PropLabel">&nbsp;</td>
      <td class="PropInput"> 
        <jato:checkbox name="AllDay" elementId="allDay" tabIndex="11" onClick="if(this.checked) { disableTime(); } else { activateTime(); }; "/>
        <label for="allDay"><%= getLocalizedLabel(session, "uwc-calclient-AllDayEvent", "All day event") %></label></td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="hourMenu"><%= getLocalizedLabel(session, "uwc-calclient-Time", "Time") %>:</label></span></td>
      <td class="PropInput"> 
        <jato:combobox name="StartTimeHours" elementId="hourMenu" tabIndex="12"/>
        <label for="minutesMenu"></label>
        <jato:combobox name="StartTimeMinutes" elementId="minutesMenu" tabIndex="13"/>
      </td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="durationHour"><%= getLocalizedLabel(session, "uwc-calclient-Duration", "Duration") %>:</label></span></td>
      <td class="PropInput" nowrap> 
        <jato:combobox name="DurationHours" elementId="durationHour" tabIndex="14"/>
        <label for="durationHour"><%= getLocalizedLabel(session, "uwc-calclient-HourOrHours", "hour(s)") %></label> 
        <jato:combobox name="DurationMinutes" elementId="durationMinutes" tabIndex="15"/>
        <label for="durationMinutes"><%= getLocalizedLabel(session, "uwc-calclient-options-minutes", "minutes") %></label></td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="showAsBusy"><%= getLocalizedLabel(session, "uwc-calclient-Availability", "Availability") %>:</label></span></td>
      <td class="PropInput" nowrap> 
        <jato:checkbox name="ShowAsBusy" elementId="showAsBusy" tabIndex="16" onClick="if(this.checked) { warnForPrivateEvents(); };"/>
        <label for="showAsBusy"><%= getLocalizedLabel(session, "uwc-calclient-ShowAsBusy", "Show as busy") %></label></td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="typeMenu"><%= getLocalizedLabel(session, "uwc-calclient-Type", "Type") %>:</label></span></td>
      <td class="PropInput"> 
        <jato:combobox name="Category" elementId="typeMenu" tabIndex="17"/>
      </td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="privacyMenu"><%= getLocalizedLabel(session, "uwc-calclient-Privacy", "Privacy") %>:</label></span></td>
      <td class="PropInput"> 
        <jato:combobox name="Privacy" elementId="privacyMenu" tabIndex="18" onChange="handlePrivacyChange(); return false;"/>
      </td>
    </tr>
    <tr> 
      <td class="PropLabel"><span class="Lbl2"><label for="eventLocation"><%= getLocalizedLabel(session, "uwc-calclient-Location", "Location") %>:</label></span></td>
      <td class="PropInput"> 
        <jato:textField name="Location" size="50" elementId="eventLocation" tabIndex="19"/>
      </td>
    </tr>
    <tr> 
      <td class="PropLabel" valign="top"><span class="Lbl2"><label for="eventNotes"><%= getLocalizedLabel(session, "uwc-calclient-Notes", "Notes") %>:</label></span></td>
      <td class="PropInput"> 
        <jato:textArea name="Description" wrap="VIRTUAL" cols="70" rows="2" elementId="eventNotes" tabIndex="20"/>
      </td>
    </tr>
  </table>
<div class="ConJmpTopDiv"><a href="#top" class="JmpTopLnk" title="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" tabindex="21"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Top-image", "../uwc/images/to_top.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" width="11" height="10" border="0"><%= getLocalizedLabel(session, "uwc-common-BackToTop", "Back to top") %></a></div>

<a name="recurrence" id="recurrence"></a>

<jato:containerView name="RecurrencePane">
  <%@include file="/uwc/calclient/RecurrencePane.jsp"%>
</jato:containerView>

<div class="ConJmpTopDiv"><a href="#top" class="JmpTopLnk" title="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" tabindex="23"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Top-image", "../uwc/images/to_top.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" width="11" height="10" border="0"><%= getLocalizedLabel(session, "uwc-common-BackToTop", "Back to top") %></a></div>

<a name="invitees" id="invitees"></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0" title="">
  <tr> 
    <td colspan="3"><img src="../uwc/images/spacer.gif" width="1" height="10" alt=""></td>
  </tr>
  <tr> 
    <td><img src="../uwc/images/spacer.gif" width="10" height="5" alt=""></td>
    <td class="SectionDivider" width="100%"><img src="../uwc/images/spacer.gif" width="1" height="5" alt=""></td>
    <td><img src="../uwc/images/spacer.gif" width="10" height="5" alt=""></td>
  </tr>
  <tr> 
      <td colspan="3" class="SectionHeader"><span class="SectionHeader"><%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Invitees-section", "Invitees") %></span></td>
  </tr>
</table>

<table class="FormInputTable" width="100%" border="0" cellspacing="0" cellpadding="0" title="">
  <tr> 
    <td class="PropLabel"><span class="Lbl2"><label for="eventInvitee"><%= getLocalizedLabel(session, "uwc-calclient-Invitee", "Invitee") %>:</label></span></td>
    <td class="PropInputWHelp" width="100%"> 
      <jato:textField name="Attendee" size="40" elementId="eventInvitee" onKeyPress="return handleEnter(event)" tabIndex="24"/>
      <jato:button styleClass="Btn1" name="AddAttendee" elementId="add" defaultValue=" Add " onMouseOver="if (this.disabled==0) this.className='Btn1Hov'" onFocus="if (this.disabled==0) this.className='Btn1Hov'" onMouseOut="if (this.disabled==0) this.className='Btn1'" onBlur="if (this.disabled==0) this.className='Btn1'" onClick="return handleAdd();" tabIndex="25"/>
      <jato:button styleClass="Btn2" name="AddAttendeesFromAB" elementId="addAddressBook" defaultValue="Add from Address Book" onClick="openSearchPopup(); return false;" onMouseOver="if (this.disabled==0) this.className='Btn2Hov'" onFocus="if (this.disabled==0) this.className='Btn2Hov'" onMouseOut="if (this.disabled==0) this.className='Btn2'" onBlur="if (this.disabled==0) this.className='Btn2'" tabIndex="26"/>
    </td>
  </tr>
  <tr> 
    <td>&nbsp;</td>
    <td><span class="inlineHelpText"><%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-Invitees-section-intro", "Type the invitee's email address, or calendar id, then click Add. You may also add invitees from your Address Book.") %></span></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <label for="quickInviteMenu"></label>
      <uwc:uwccombobox name="QuickInviteList" elementId="quickInviteMenu" tabIndex="27" onClick="handleQuickInviteList(this.value); return false;"/>
    </td>
  </tr>
  <tr> 
    <td colspan="2"><img src="../uwc/images/spacer.gif" width="1" height="6" alt=""></td>
  </tr>
  <tr> 
    <td class="PropLabel" nowrap valign="top"><span class="Lbl2"><label for="eventInviteeList"><%= getLocalizedLabel(session, "uwc-calclient-InviteeList", "Invitee List") %>:</label></span></td>
    <td class="PropInput"> 
      <table border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td valign="top"> 
            <jato:listbox name="AttendeeList" size="7" extraHtml="multiple" elementId="eventInviteeList" tabIndex="27"/>
          </td>
          <td valign="top"> 
            <table class="AddRmvBtnTbl" border="0" cellspacing="0" cellpadding="0" title="">
              <tbody> 
                <tr> 
                  <td align="center"><img src="../uwc/images/spacer.gif" width="10" height="1" alt=""></td>
                  <td class="PropInput" align="center"> 
                    <div class="AddRmvHrzWin"> 
                      <input class="Btn1" type="button" name="requestRSVP" id="requestRSVP" tabindex="28" value=" <%= getLocalizedLabel(session, "uwc-calclient-RequestRSVP", "Request RSVP") %> " onMouseOver="if (this.disabled==0) this.className='Btn1Hov'" onMouseOut="if (this.disabled==0) this.className='Btn1'" onClick="handleRequestRSVP(); return false;" title="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-RequestRSVP-title", "Request RSVP from Invitees") %>">
                    </div>
                    <div class="AddRmvHrzWin"> 
                      <input class="Btn1" type="button" name="checkAvailability" id="checkAvailability" tabindex="29" value="<%= getLocalizedLabel(session, "uwc-calclient-CheckAvailability", "Check Availability") %>" onMouseOver="if (this.disabled==0) this.className='Btn1Hov'" onMouseOut="if (this.disabled==0) this.className='Btn1'"  onClick="MM_openBrWindow('<jato:text name="CheckAvailabilityUrl" escape="false"/>','availability','scrollbars=yes,resizable=yes,width=800,height=700')" title="<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-CheckAvailability-title", "Check Availability of Invitees") %>">
                    </div>
                    <div class="AddRmvHrzWin"> 
                      <jato:button styleClass="Btn2" name="RemoveAttendee" elementId="remove" tabIndex="30" defaultValue="      Remove       " onMouseOver="if (this.disabled==0) this.className='Btn2Hov'" onMouseOut="if (this.disabled==0) this.className='Btn2'" onClick="return handleRemove();"/>
                    </div>
                  </td>
                </tr>
              </tbody> 
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<div class="ConJmpTopDiv"><a href="#top" class="JmpTopLnk" title="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" tabindex="31"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Top-image", "../uwc/images/to_top.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" width="11" height="10" border="0"><%= getLocalizedLabel(session, "uwc-common-BackToTop", "Back to top") %></a></div>

<a name="reminders" id="reminders"></a>

<jato:containerView name="RemindersPane">
  <%@include file="/uwc/calclient/RemindersPane.jsp"%>
</jato:containerView>

<div class="ConJmpTopDiv"><a href="#top" class="JmpTopLnk" title="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" tabindex="44"><img src="<%= getLocalizedLabel(session, "skinModel", "uwc-common-To-Top-image", "../uwc/images/to_top.gif") %>" alt="<%= getLocalizedLabel(session, "uwc-common-BackToTop-title", "Jump to Top of Page") %>" width="11" height="10" border="0"><%= getLocalizedLabel(session, "uwc-common-BackToTop", "Back to top") %></a></div>
<!-- Spacer -->
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0" title="">
  <TR> 
    <TD><IMG src="../uwc/images/spacer.gif" width="1" height="20" alt=""></TD>
  </TR>
</TABLE>

<!-- Defined a hidden button called 'Save' which requires for triggering default form action or as a place holder for default command child to call handleSaveRequest method in assoicated view bean. This 'Save' button will *always* be *hidden* because it is put inside a non-visible div tag. -->
<div style="visibility: hidden;">
  <jato:button styleClass="Btn2" name="Save" onClick="handleSave('Save'); return false;" extraHtml="title=\"A hidden button for internal use\""/>
</div>

</jato:form>

<script src="../uwc/js/scripts.js" type="text/javascript"> </script>
<script src="../uwc/js/uwcUtils.js" type="text/javascript"> </script>
<script src="../uwc/js/date_utils.js" type="text/javascript"> </script>

<script language=JavaScript type=text/javascript>
<!--

// RecurrenceModifier types
// Defualt modifier type for 'Delete' is CANCEL, 
// Defualt modifier type for 'Save' it is 'THIS_INSTANCE_ONLY'
//
var CANCEL = "Cancle";
var THIS_INSTANCE_ONLY = "ThisInstanceOnly";
var THIS_AND_FUTURE_INSTANCES = "ThisAndFutureInstances";

function isRecurrenceModifierExists() {
  if(undefined == document.EditEventData.elements["EditEventData.EventRID"]) {
    return false;
  }
  else if(null == document.EditEventData.elements["EditEventData.EventRID"]) {
    return false;
  }

  var rid = document.EditEventData.elements["EditEventData.EventRID"].value;
  if((null == rid) || ("" == trim(rid))) {
    return false;
  }

  return true;
}

function handleDelete() {
  if(false == validateData()) {
    return false;
  }
  document.EditEventData.submitType.value = 'Delete';
  if(isRecurrenceModifierExists()) 
  {
    MM_openBrWindow('<%= getContextURI(request) %>/uwc/js/DeleteEventConfirmRepeatSelection.jsp', 'RepeatingSelection', 'scrollbars=yes,resizable=yes,width=500,height=175');
  }
  else if(UWCConfirm("<%= getLocalizedLabel(session, "uwc-calclient-event-DeleteEventConfirmQuestion", "Are you sure you want to delete this event?") %>"))
  {
    setRepeatingSelectionModifier(THIS_INSTANCE_ONLY);
  }
  else 
  {
    setRepeatingSelectionModifier(CANCEL);
  }
}

function handleSave(theSubmitType) {
  if(false == validateData()) {
    return false;
  }
  document.EditEventData.submitType.value = theSubmitType;
  if(isRecurrenceModifierExists()) 
  {
    MM_openBrWindow('<%= getContextURI(request) %>/uwc/js/SaveEventConfirmRepeatSelection.jsp', 'RepeatingSelection', 'scrollbars=yes,resizable=yes,width=500,height=175');
  }
  else {
    setRepeatingSelectionModifier(THIS_INSTANCE_ONLY);
  }
}


function setRepeatingSelectionModifier(theModifier) {
  if(CANCEL == theModifier) {
    return;
  }
  saveRVSPStatus();
  document.EditEventData.RecurrenceModifier.value = theModifier;
  document.EditEventData.submit();
}

function handleHelp(theHelp) {
  NotImplemented("Help called for '" + theHelp + "'");
}   

function warnForPrivateEvents() {
  var isShowAsBusy = document.EditEventData.elements["showAsBusy"].checked;
  var priv = document.EditEventData.elements["EditEventData.Privacy"].value;

  if(("PRIVATE" == priv) && isShowAsBusy) {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-WarningForPartiallyPrivateEvents", "You are creating a Private event with the Availability check box selected.\\nOnly the date and time of the event will be displayed to others accessing your calendar. ") %>');
  }
}

function handlePrivacyChange() {
  var priv = document.EditEventData.elements["EditEventData.Privacy"].value;
  var isShowAsBusy = document.EditEventData.elements["showAsBusy"].checked;

  if(("PUBLIC" == priv) && (false == isShowAsBusy)) {
    document.EditEventData.elements["showAsBusy"].checked = true;
    return;
  }
  else if(("PRIVATE" == priv) && (isShowAsBusy)) {
    document.EditEventData.elements["showAsBusy"].checked = false;
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-WarningForPurePrivateEvents", "You are creating a Private event with the Availability check box deselected.\\nOthers will not see the event when they access your calendar.") %>');
    return;
  }

  return;
}   

function validateData() {
   var monthOptions = document.EditEventData.elements["monthMenu"].options;
   var theMonth = monthOptions.selectedIndex;
   var theDay = document.EditEventData.elements["dayMenu"].value;
   var theYear = document.EditEventData.elements["yearMenu"].value;

   if(false == isValidDate(theDay ,theMonth, theYear)) {
     UWCAlert('<%= getLocalizedLabel(session, "uwc-mail-error-invalid-date", "Invalid Date Selection !") %>');
     return false;
   }

   return true;
}

function disableTime() {
  document.EditEventData.elements["hourMenu"].disabled = true;
  document.EditEventData.elements["minutesMenu"].disabled = true;
  document.EditEventData.elements["durationHour"].disabled = true;
  document.EditEventData.elements["durationMinutes"].disabled = true;
}

function activateTime() {
  document.EditEventData.elements["hourMenu"].disabled = false;
  document.EditEventData.elements["minutesMenu"].disabled = false;
  document.EditEventData.elements["durationHour"].disabled = false;
  document.EditEventData.elements["durationMinutes"].disabled = false;
}

// Week start and week end preferences required by minical pop up
weekstart = <jato:text name="weekstart"/>
weekends = [<jato:text name="weekends"/>];

function getWeekStart() {
  return weekstart;
}

function getWeekEnds() {
  return weekends;
}

function openMiniCalendar() {
   var monthOptions = document.EditEventData.elements["monthMenu"].options;
   var theDate = new Date();
   theDate.setMonth(monthOptions.selectedIndex);
   theDate.setDate(document.EditEventData.elements["dayMenu"].value);
   theDate.setYear(document.EditEventData.elements["yearMenu"].value);
   var theDateStr = escape(theDate.toUTCString());
   MM_openBrWindow('<%= getContextURI(request) %>/uwc/js/minicalendarpopup.jsp?date=' + theDateStr, 'minical', 'scrollbars=yes,resizable=yes,width=250,height=225');
   return;
}

function acceptSelectedDate(theDateStr) {
  var monthOptions = document.EditEventData.elements["monthMenu"].options;
  var theDate = new Date(theDateStr);
  document.EditEventData.elements["monthMenu"].value = monthOptions[theDate.getMonth()].value;
  document.EditEventData.elements["dayMenu"].value = theDate.getDate();
  document.EditEventData.elements["yearMenu"].value = theDate.getFullYear();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openSearchPopup() {
  theUrl = "<%= getContextURI(request) %>/abs/select-popup-main.xml?";
  theUrl = theUrl + "wcfg_col1=dnnolink" + "&";
  theUrl = theUrl + "wcfg_col2=primemailnolink" + "&";
  theUrl = theUrl + "wcfg_ablist=1" + "&";
  theUrl = theUrl + "wcfg_abtype=2" + "&";
  theUrl = theUrl + "wcfg_buttonlabel=AddInvitees" + "&";

  openWinAutoHeight(theUrl, 'search','scrollbars=yes,resizable=yes,width=700');
}

function GetSharedObject() {
  sharedObj = new Object();
  sharedObj.expandselectedgroup = "0";
  sharedObj.expandonmissing = "";
  sharedObj.fieldsToReturn = new Array("displayname", "email_1");
  sharedObj.nid = new Array("");
  sharedObj.sid = new Array("");
  return sharedObj;
}

function AcceptData(inputArray) {
  if(null == inputArray) {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-AddFromAddressBook-NoInvitees", "Select invitees to be added to the Invitee list.") %>');
  }

  if(inputArray.length < 2) {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-AddFromAddressBook-NoData", "No invitee is added to the Invitee list. Your address book did not have an invitee name that matches the search text.") %>');
  }

  if(inputArray[0].length > 0) {
    var theEmails = "";
    var theLength = inputArray[0].length;
    for(i=0; i < theLength; i++) {
      var emailId = ((null == inputArray[1][i])? "" : trim(inputArray[1][i])); 
      var userCN = ((null == inputArray[0][i])? "" : trim(inputArray[0][i])); 
      theEmails = theEmails + emailId + "$" + userCN;
      if(i < (theLength - 1)) {
        theEmails = theEmails + "!!SEPARATOR!!"; 
      }
    }
    document.EditEventData.elements["EditEventData.emailsSelectedFromAB"].value = theEmails;
    document.EditEventData.submitType.value = "AddAttendeesFromAB";
    saveRVSPStatus();
    document.EditEventData.elements["EditEventData.hasAttendeesModified"].value = "true";
    document.EditEventData.submit();
  } 
  else {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-AddFromAddressBook-NoData", "Cannot add invitees - No data available from search window") %>');
  }
}

function handleRemove() {
  if(false == anyInviteeExists()) {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-NoInviteesExistsToRemove-alert", "There are no invitees in the Invitee list to remove.") %>');
    return false;
  }

  var inviteeOpts = document.EditEventData.elements["eventInviteeList"].options;
  if(-1 == inviteeOpts.selectedIndex) {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-SelectInviteesToRemove-alert", "Please select the invitee(s) to remove") %>');
    return false;
  }

  if(false == UWCConfirm('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-DeleteInviteesConfirm-question", "Are you sure you want to remove the selected invitees?") %>'))
  {
    return false;
  }

  saveRVSPStatus(); 
  document.EditEventData.elements["EditEventData.hasAttendeesModified"].value = "true";
  return true;
}

function handleQuickInviteList(selectedCal) {
  if("QuickCalInvite" == selectedCal) {
    return false;
  }

  saveRVSPStatus();
  document.EditEventData.elements["EditEventData.hasAttendeesModified"].value = "true";
  document.EditEventData.submitType.value = "QuickInviteList";
  document.EditEventData.submit();
  return true;
}

function handleAdd() {
  var theAttendee = document.EditEventData.elements["EditEventData.Attendee"].value;
  if((null == theAttendee) || ("" == trim(theAttendee))) {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-BlankInvitee-alert", "Enter a valid invitee name. You cannot leave this field blank.") %>');
    return false;
  }

  saveRVSPStatus(); 
  document.EditEventData.elements["EditEventData.hasAttendeesModified"].value = "true";
  return true;
}

function handleRequestRSVP() {
  if(false == anyInviteeExists()) {
    UWCAlert('<%= getLocalizedLabel(session, "uwc-calclient-event-EditEvent-NoInviteesExistsForRequestRSVP-alert", "Add invitees to the Invitee list and then click Request RSVP. At present there are no invitees in the Invitee list to request for RSVP.") %>');
    return;
  }

  MM_openBrWindow('../uwc/js/rsvp_frameset.jsp','rsvp','scrollbars=yes,resizable=yes,width=600,height=500')
}

function anyInviteeExists() {
  var inviteesLength = document.EditEventData.elements["eventInviteeList"].length;
  if((0 == inviteesLength) || (1 == inviteesLength)) {
    return false;
  }       
  if(2 == inviteesLength) {
    var inviteeOpts = document.EditEventData.elements["eventInviteeList"].options;
    var theInviteeValue = inviteeOpts[0].value; 
    if("NoInviteesSelected" == theInviteeValue) {
      return false;
    }
  }
  return true;
}

function setRsvpNotRequestedAttendeesArray(theArray) {
  nonRsvps = getDelimitedString(theArray, dolorDelimiter);
  document.EditEventData.elements["EditEventData.hasAttendeesModified"].value = "true";
}

function getRsvpNotRequestedAttendeesArray() {
  var theArray = parseDelimitedString(nonRsvps, dolorDelimiter); 
  return theArray;
}

function loadPage() {
  if(document.EditEventData.elements["allDay"].checked) { 
    disableTime(); 
  }
  else { 
    activateTime(); 
  }
  nonRsvps = document.EditEventData.elements["EditEventData.RSVPNotRequestedAttendees"].value;

  var theAnchorPoint = trim(document.EditEventData.elements["EditEventData.CurrentAnchorPoint"].value);
  if((null != theAnchorPoint) && ("" != theAnchorPoint)) {
    self.location = self.location + "#" + theAnchorPoint;
  }

  return true;
}

function saveRVSPStatus() {
  document.EditEventData.elements["EditEventData.RSVPNotRequestedAttendees"].value = nonRsvps;
  return true;
}

var nonRsvps = "";
var dolorDelimiter = "$";

//-->
</script>

</body>

</jato:useViewBean>

</html>
