<%@ taglib uri="webwork" prefix="webwork" %>
<html>
<head>
<title>Calendar</title>

<style type="text/css">@import url(<%= request.getContextPath() %>/includes/js/calendar/skins/aqua/theme.css);</style>
<script type="text/javascript" src="<%= request.getContextPath() %>/includes/js/calendar/calendar.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/includes/js/calendar/lang/calendar-<webwork:property value="./language"/>.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/includes/js/calendar/calendar-setup.js"></script>

</head>
<body bgcolor="f0f0f0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div id="calendar-container" border="0"></div>
<script type="text/javascript">

 // Hack to avoid bug in jscalendar - JRA-7713
 if (!Calendar._TT["WEEKEND"]) Calendar._TT["WEEKEND"] = "0,6";
 if (!Calendar._TT["DAY_FIRST"]) Calendar._TT["DAY_FIRST"] = "Display %s first";

  var formName = '<webwork:property value="./form"/>';
  var fieldName = '<webwork:property value="./field"/>';

  function dateChanged(calendar)
  {
    // Beware that this function is called even if the end-user only
    // changed the month/year.  In order to determine if a date was
    // clicked you can use the dateClicked property of the calendar:
    if (calendar.dateClicked)
    {
      // OK, a date was clicked
      // Change the date in the calling page
      // Retrieve the form
      var form = window.opener.document.forms[formName];
      var element = form.elements[fieldName];
      element.value=calendar.date.print(calendar.params.ifFormat);

      window.close();

      window.opener.focus();
      element.focus();
    }
  };
  Calendar.setup(
    {
      flat         : "calendar-container", // ID of the parent element
      flatCallback : dateChanged,          // our callback function
      firstDay     : 0,                  // first day of the week
    <webwork:if test="$dateTimePicker == 'true'">
      ifFormat     : "<webwork:property value="./dateTimeFormat"/>",  // our date and time format
      showsTime    : "true",               //display the time selector
      timeFormat   : <webwork:property value="./timeFormat" />  // 12 or 24 hours format
    </webwork:if>
    <webwork:else>
      ifFormat     : "<webwork:property value="./dateFormat"/>"  // our date only format
    </webwork:else>
    }
  );

</script>
</body>
</html>