<script>
    function update(idx) {
        var checkbox = document.getElementById('c' + idx);
        var cell = document.getElementById('td' + idx);
        if (checkbox.checked) {
            cell.className = "holiday";
        } else {
            cell.className = "schoolday";
        }
    }
    function toggle(idx) {
        var checkbox = document.getElementById('c' + idx);
        checkbox.checked = !checkbox.checked;
        update(idx);
    }
    document.write('\074style\076 input.chk { display: none } \074/style\076');
</script>
<div i18n:domain="schooltool">
  <div metal:use-macro="macro:form">
    <metal:block fill-slot="above-buttons">
      <tal:block tal:define="calendar view/preview_term"
                 tal:condition="calendar">
        <div class="buttons" tal:condition="view/actions/refresh">
          <input tal:replace="structure view/actions/refresh/render" />
        </div>
        <p class="fieldset-legend" i18n:translate="">
          Please specify which days school is in session.
        </p>
        <h3 i18n:translate="">
          Click on a day to toggle its state. You can also toggle
          the days of a week:
        </h3>
        <table class="schoolday-legend">
          <tr>
            <td class="legend" i18n:translate="">Legend:</td>
            <td class="schoolday" i18n:translate="">In Session</td>
            <td class="holiday" i18n:translate="">Not In Session</td>
            <td>&nbsp;</td>
          </tr>
        </table>
        <p class="buttons">
          <input class="button-neutral" type="submit" name="TOGGLE_0" value="Monday"
                 i18n:attributes="value" />
          <input class="button-neutral" type="submit" name="TOGGLE_1" value="Tuesday"
                 i18n:attributes="value" />
          <input class="button-neutral" type="submit" name="TOGGLE_2" value="Wednesday"
                 i18n:attributes="value" />
          <input class="button-neutral" type="submit" name="TOGGLE_3" value="Thursday"
                 i18n:attributes="value" />
          <input class="button-neutral" type="submit" name="TOGGLE_4" value="Friday"
                 i18n:attributes="value" />
          <input class="button-neutral" type="submit" name="TOGGLE_5" value="Saturday"
                 i18n:attributes="value" />
          <input class="button-neutral" type="submit" name="TOGGLE_6" value="Sunday"
                 i18n:attributes="value" />
        </p>
        <table class="schooldaymodel" tal:repeat="month calendar">
          <tr>
            <th class="month" colspan="8" i18n:translate="">
              <span tal:replace="month/month" i18n:name="month" /> <span tal:replace="month/year" i18n:name="year" />
            </th>
          </tr>
          <tr>
            <th class="day"></th>
            <th class="day" width="12%" i18n:translate="">Monday</th>
            <th class="day" width="12%" i18n:translate="">Tuesday</th>
            <th class="day" width="12%" i18n:translate="">Wednesday</th>
            <th class="day" width="12%" i18n:translate="">Thursday</th>
            <th class="day" width="12%" i18n:translate="">Friday</th>
            <th class="day" width="12%" i18n:translate="">Saturday</th>
            <th class="day" width="12%" i18n:translate="">Sunday</th>
          </tr>
          <tr tal:repeat="week month/weeks">
            <th class="week" i18n:translate="">
              Week <span tal:replace="week/number" i18n:name="week_number" />
            </th>
            <td tal:repeat="day week/days"
                tal:attributes="class day/class;
                                id python:day['index'] and 'td%d' % day['index'];
                                onclick day/onclick">
              <label tal:condition="day/number">
                <span tal:replace="day/number">N</span>
                <input type="checkbox" name="holiday" class="chk"
                       tal:attributes="value day/date; checked day/checked;
                                       onchange string:javascript:update(${day/index});
                                       id string:c${day/index};" />
              </label>
            </td>
          </tr>
        </table>
      </tal:block>
    </metal:block>
    <div class="buttons"
         metal:fill-slot="bottom-buttons">
      <tal:block condition="view/actions|nothing">
        <tal:loop tal:repeat="action view/actions/values">
          <input tal:replace="structure action/render"
                 tal:condition="python: action is not view.actions.get('refresh')"/>
        </tal:loop>
      </tal:block>
    </div>
  </div>
</div>
