<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="section.xsl"/>
  <xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>
  <xsl:template match="/">
    <xsl:apply-templates select="ShowPage" mode="block">
      <xsl:with-param name="hide">append comment</xsl:with-param>
      <xsl:with-param name="TitleOnly">
        <xsl:if test="count(/ShowPage/Subobj[@id=/ShowPage/ex])=1">yes</xsl:if>
      </xsl:with-param>
    </xsl:apply-templates>
  </xsl:template>
  <xsl:template match="ShowPage" mode="addstyle">
    <style>
      table.WF {display: none;}
      table#WF td {border-top: 1px solid #cccccc;}
    </style>
  </xsl:template>
  <xsl:template match="ShowPage0" mode="ancestor"/>
  <xsl:template match="ShowPage" mode="Untergeordnet">
    <xsl:param name="tbcolor">
      <xsl:choose>
        <xsl:when test="count(tbcolor)">
          <xsl:value-of select="tbcolor"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$pdcolor"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <script language="JavaScript" type="text/javascript">
      function EditPageAdv(id){
      open('<xsl:value-of select="Script"/>?m=edit&amp;param=AdvEdit&amp;f='+id,'edit_'+id);
      }
      function EditPageInt(id){
      <xsl:choose>
        <xsl:when test="count(//table[@class='WF']) &gt; 0">
          open('<xsl:value-of select="Script"/>?m=edit&amp;f='+id,'edit_'+id);
        </xsl:when>
        <xsl:otherwise>
          open('<xsl:value-of select="Script"/>?m=edit&amp;param=AdvEdit&amp;f='+id,'edit_'+id);
        </xsl:otherwise>
      </xsl:choose>
      }
    </script>
    <xsl:choose>
      <xsl:when test="done">
        <xsl:apply-templates select="donetext"/>
        <xsl:value-of select="done"/>
        <xsl:apply-templates select="next"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="count(/ShowPage/Subobj[@id=/ShowPage/ex])!=1">
          <xsl:for-each select="Xform">
            <form action="{/ShowPage/Script}?f={@f}&amp;INFO={../INFO}" target="{@target}" name="{@name}" method="post">
              <input type="submit" value="{@submit}" style="{@style}"/>
            </form>
            <xsl:if test="count(@break)">
              <br />
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="//tr[td[1]='xform']">
            <form action="{/ShowPage/Script}" target="_blank" name="{td[2]}">
              <input type="hidden" name="INFO" value="{../INFO}"/>
              <input type="hidden" name="f" value="{td[4]}"/>
              <input type="submit" value="{td[3]}"/>
            </form>
          </xsl:for-each>
        </xsl:if>
        <xsl:if test="count(//Frage|//frage|//table[@class='WF']/tbody/tr) or contains(Edit/@link,'m=edit')">
          <form method="post" name="form1">
            <xsl:choose>
              <xsl:when test="contains(Edit/@link,'m=edit') and count(/ShowPage/Subobj[@id=/ShowPage/ex])!=1">
                <xsl:attribute name="action">
                  <xsl:value-of select="//ShowPage/Script"/>
                  <xsl:text>?f=</xsl:text>
                  <xsl:value-of select="@id"/>
                  <xsl:text>&amp;m=polling</xsl:text>
                </xsl:attribute>
                <xsl:if test="count(nosender)=0">
                  <table border="0" cellpadding="0">
                    <tr valign="top">
                      <td nowrap="nowrap" style="width: 248px;">
                        <xsl:value-of select="$lsDays"/>
                        <xsl:text>: </xsl:text>
                        <input type="text" size="4" name="sDauer" style="width: 75px;"/>
                        <br/>
                        <xsl:value-of select="$lsMultisession"/>
                        <xsl:text>: </xsl:text>
                        <input type="checkbox" name="bMultisession" value="Multisession" checked="checked" style="width: 30px;"/>
                      </td>
                      <td>
                        <xsl:value-of select="$lsEmails" disable-output-escaping="yes"/>
                      </td>
                      <td>
                        <textarea rows="7" cols="50" name="iAnzahl" style="width: 300px;" data-gramm_editor="false"></textarea>
                      </td>
                    </tr>
                  </table>
                </xsl:if>
              </xsl:when>
              <xsl:otherwise>
                <xsl:attribute name="action">
                  <xsl:value-of select="//ShowPage/Script"/>
                  <xsl:text>?f=</xsl:text>
                  <xsl:value-of select="@id"/>
                  <xsl:text>&amp;m=createorupdate&amp;INFO=</xsl:text>
                  <xsl:value-of select="INFO"/>
                </xsl:attribute>
                <!-- cookieless -->
                <input type="hidden" name="INFO">
                  <xsl:attribute name="value">
                    <xsl:value-of select="INFO"/>
                  </xsl:attribute>
                </input>
              </xsl:otherwise>
            </xsl:choose>
            <input type="hidden" name="sName">
              <xsl:attribute name="value">
                <xsl:value-of select="@id"/>
              </xsl:attribute>
            </input>
            <input type="hidden" name="bSave" value="bSave"/>
            <input type="hidden" name="sTemplate" value="NextWF.xsl"/>
            <input type="hidden" name="sTitle">
              <xsl:attribute name="value">
                <xsl:value-of select="DoneTitle"/>
                <xsl:value-of select="//tr[td[1]='DoneTitle']/td[3]"/>
              </xsl:attribute>
            </input>
            <input type="hidden" name="mBody">
              <xsl:attribute name="value">
                <xsl:text>&lt;Xtext/&gt;</xsl:text>
                <xsl:text>&lt;start&gt;</xsl:text>
                <xsl:value-of select="start"/>
                <xsl:value-of select="//tr[td[1]='start']/td[3]"/>
                <xsl:text>&lt;/start&gt;</xsl:text>
                <xsl:text>&lt;donetext&gt;</xsl:text>
                <xsl:value-of select="DoneText"/>
                <xsl:value-of select="//tr[td[1]='DoneText']/td[3]"/>
                <xsl:text>&lt;/donetext&gt;</xsl:text>
                <xsl:text>&lt;done&gt;</xsl:text>
                <xsl:value-of select="@now"/>
                <xsl:text>&lt;/done&gt;</xsl:text>
                <xsl:text>&lt;next&gt;</xsl:text>
                <xsl:value-of select="DoneNext"/>
                <xsl:value-of select="//tr[td[1]='DoneNext']/td[3]"/>
                <xsl:text>&lt;/next&gt;</xsl:text>
                <xsl:text>&lt;User&gt;</xsl:text>
                <xsl:value-of select="LogonUser"/>
                <xsl:text>&lt;/User&gt;</xsl:text>
                <xsl:if test="count(bgcolor)">
                  <xsl:text>&lt;bgcolor&gt;</xsl:text>
                  <xsl:value-of select="bgcolor"/>
                  <xsl:text>&lt;/bgcolor&gt;</xsl:text>
                </xsl:if>
                <xsl:if test="count(pdcolor)">
                  <xsl:text>&lt;pdcolor&gt;</xsl:text>
                  <xsl:value-of select="pdcolor"/>
                  <xsl:text>&lt;/pdcolor&gt;</xsl:text>
                </xsl:if>
                <xsl:if test="count(tbcolor)">
                  <xsl:text>&lt;tbcolor&gt;</xsl:text>
                  <xsl:value-of select="tbcolor"/>
                  <xsl:text>&lt;/tbcolor&gt;</xsl:text>
                </xsl:if>
                <xsl:if test="count(text)">
                  <xsl:text>&lt;text&gt;</xsl:text>
                  <xsl:value-of select="text"/>
                  <xsl:text>&lt;/text&gt;</xsl:text>
                </xsl:if>
                <xsl:if test="count(sImage)">
                  <xsl:text>&lt;sImage&gt;</xsl:text>
                  <xsl:value-of select="sImage"/>
                  <xsl:text>&lt;/sImage&gt;</xsl:text>
                </xsl:if>
              </xsl:attribute>
            </input>
            <table border="0" cellspacing="0" cellpadding="3"  id="WF">
              <xsl:choose>
                <xsl:when test="count(/ShowPage/Subobj)=1">
                </xsl:when>
                <xsl:when test="count(/ShowPage/Subobj[@id=/ShowPage/ex])=1">
                  <tr>
                    <td colspan="2">
                      <xsl:apply-templates select="/ShowPage/Subobj[@id=/ShowPage/ex]/User"/>
                      <xsl:text> </xsl:text>
                      <xsl:value-of select="/ShowPage/Subobj[@id=/ShowPage/ex]/done"/>
                    </td>
                  </tr>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="Vorgabe"/>
                </xsl:otherwise>
              </xsl:choose>
              <xsl:for-each select="Frage|frage|//table[@class='WF']/tbody/tr">
                <xsl:variable name="id" select="position()"/>
                <xsl:choose>
                  <xsl:when test="td[1][.='start' or .='XAppendWLR' or .='nosender' or starts-with(.,'Done') or .= 'default' or .='submit' or .='xform']"/>
                  <xsl:otherwise>
                    <!-- ##########################  -->
                    <xsl:if test="td[1]!='Label' ">
                    </xsl:if>
                    <!-- ##########################  -->
                    <input type="hidden" name="xBodyFields">
                      <xsl:attribute name="value">
                        <xsl:text>xS</xsl:text>
                        <xsl:value-of select="position()"/>
                      </xsl:attribute>
                    </input>

                    <tr>
                      <xsl:choose>
                        <xsl:when test="@type[.='Label' or .='label'] or td[1]='label'">
                          <td colspan="2">
                            <xsl:apply-templates select="Text|text"/>
                            <xsl:apply-templates select="td[3]" mode="in"/>
                          </td>
                        </xsl:when>
                        <xsl:when test="@type[.='Text' or .='text'] or normalize-space(td[1])='text'">
                          <td colspan="2" style="font-size: 12px;">
                            <xsl:apply-templates select="Text|text"/>
                            <xsl:apply-templates select="td[3]" mode="in"/>
                            <br/>
                            <textarea wrap="virtual" style="width: 100%" name="xS{$id}">
                              <xsl:attribute name="rows">
                                <xsl:choose>
                                  <xsl:when test="count(@size)">
                                    <xsl:value-of select="@size"/>
                                  </xsl:when>
                                  <xsl:otherwise>6</xsl:otherwise>
                                </xsl:choose>
                              </xsl:attribute>
                              <xsl:choose>
                                <xsl:when test="count(/ShowPage/Subobj/done)=1 and count(/ShowPage/Subobj)=1 ">
                                  <xsl:value-of select="/ShowPage/Subobj/node()[name()=concat('xS',$id)]"/>
                                </xsl:when>
                                <xsl:when test="count(/ShowPage/Subobj[@id=/ShowPage/ex])=1">
                                  <xsl:value-of select="/ShowPage/Subobj[@id=/ShowPage/ex]/node()[name()=concat('xS',$id)]"/>
                                </xsl:when>
                                <xsl:otherwise>
                                  <xsl:value-of select="Vorgabe"/>
                                </xsl:otherwise>
                              </xsl:choose>
                            </textarea>
                          </td>
                        </xsl:when>
                        <xsl:when test="@type[.='Week' or .='week'] or td[1]='week'">
                          <input type="hidden" name="xS{$id}"/>
                          <td colspan="2" style="font-size: 12px;">
                            <xsl:apply-templates select="Text"/>
                            <xsl:apply-templates select="td[3]" mode="in"/>
                            <xsl:call-template name="week">
                              <xsl:with-param name="xS" select="$id"/>
                              <xsl:with-param name="week">
                                <xsl:choose>
                                  <xsl:when test="count(/ShowPage/Subobj/done)=1 and count(/ShowPage/Subobj)=1 ">
                                    <xsl:value-of select="/ShowPage/Subobj/node()[name()=concat('xS',$id)]"/>
                                  </xsl:when>
                                  <xsl:when test="count(/ShowPage/Subobj[@id=/ShowPage/ex])=1">
                                    <xsl:value-of select="/ShowPage/Subobj[@id=/ShowPage/ex]/node()[name()=concat('xS',$id)]"/>
                                  </xsl:when>
                                  <xsl:when test="td[1]='week'">
                                    <xsl:value-of select="td[4]"/>
                                  </xsl:when>
                                  <xsl:otherwise>
                                    <xsl:value-of select="Default"/>
                                  </xsl:otherwise>
                                </xsl:choose>
                              </xsl:with-param>
                            </xsl:call-template>
                          </td>
                        </xsl:when>
                        <xsl:when test="@type[.='Field' or .='field'] or td[1]='field'">
                          <td style="font-size: 12px; width: 90%">
                            <xsl:apply-templates select="td[3]" mode="in" />
                          </td>
                          <td style="font-size: 12px;">
                            <input type="text" name="xS{position()}">
                              <xsl:apply-templates select="@style" mode="copy"/>
                              <xsl:attribute name="value">
                                <xsl:choose>
                                  <xsl:when test="count(/ShowPage/Subobj/done)=1 and count(/ShowPage/Subobj)=1 ">
                                    <xsl:value-of select="/ShowPage/Subobj/node()[name()=concat('xS',$id)]"/>
                                  </xsl:when>
                                  <xsl:when test="count(/ShowPage/Subobj[@id=/ShowPage/ex])=1">
                                    <xsl:value-of select="/ShowPage/Subobj[@id=/ShowPage/ex]/node()[name()=concat('xS',$id)]"/>
                                  </xsl:when>
                                  <xsl:otherwise>
                                    <xsl:value-of select="Vorgabe"/>
                                  </xsl:otherwise>
                                </xsl:choose>
                              </xsl:attribute>
                            </input>
                          </td>
                        </xsl:when>
                        <xsl:otherwise>
                          <td style="font-size: 12px; border-top: 1px solid #cccccc;">
                            <xsl:apply-templates select="Text|text"/>
                            <xsl:apply-templates select="td[3]" mode="in"/>
                          </td>
                          <td style="font-size: 12px; text-align: right; border-top: 1px solid #cccccc;" >
                            <select style="{@style}" align="right">
                              <xsl:attribute name="name">
                                <xsl:text>xS</xsl:text>
                                <xsl:value-of select="position()"/>
                              </xsl:attribute>
                              <xsl:choose>
                                <xsl:when test="count(/ShowPage/Subobj/done)=1 and count(/ShowPage/Subobj)=1">
                                  <option selected="selected">
                                    <xsl:value-of select="/ShowPage/Subobj/node()[name()=concat('xS',$id)]"/>
                                  </option>
                                </xsl:when>
                                <xsl:when test="count(/ShowPage/Subobj[@id=/ShowPage/ex])=1">
                                  <option selected="selected">
                                    <xsl:value-of select="/ShowPage/Subobj[@id=/ShowPage/ex]/node()[name()=concat('xS',$id)]"/>
                                  </option>
                                </xsl:when>
                                <xsl:otherwise>
                                  <xsl:value-of select="Vorgabe|vorgabe"/>
                                </xsl:otherwise>
                              </xsl:choose>
                              <option>
                                <xsl:value-of select="/ShowPage/Default|/ShowPage/default|//tr[td[1]='default']/td[3]"/>
                              </option>
                              <xsl:for-each select="td[4]/ol/li">
                                <option>
                                  <xsl:value-of select="position()"/>
                                  <xsl:text> - </xsl:text>
                                  <xsl:value-of select="."/>
                                </option>
                              </xsl:for-each>
                              <xsl:for-each select="Option|option|td[4]/ul/li">
                                <option>
                                  <xsl:value-of select="."/>
                                </option>
                              </xsl:for-each>
                            </select>
                          </td>
                        </xsl:otherwise>
                      </xsl:choose>
                    </tr>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:for-each>
              <xsl:choose>
                <xsl:when test="done[.='true']"/>
                <xsl:otherwise>
                  <tr>
                    <td>
                      <xsl:if test="/ShowPage/Subobj/done !=''">
                        <xsl:text> </xsl:text>
                        <xsl:value-of select="DoneText"/>
                        <xsl:value-of select="//tr[td[1]='DoneText']/td[3]"/>
                        <xsl:value-of select="/ShowPage/Subobj/done"/>
                      </xsl:if>
                    </td>
                    <td  style="text-align: right;">
                      <input type="submit">
                        <xsl:attribute name="value">
                          <xsl:choose>
                            <xsl:when test="count(Submit|submit)">
                              <xsl:value-of select="Submit|submit"/>
                            </xsl:when>
                            <xsl:when test="//table[@class='WF']/tbody/tr/td[1]='submit'">
                              <xsl:value-of select="//table[@class='WF']/tbody/tr[td[1]='submit']/td[3]"/>
                            </xsl:when>
                            <xsl:otherwise>
                              <xsl:value-of select="$lsSend"/>
                            </xsl:otherwise>
                          </xsl:choose>
                        </xsl:attribute>
                      </input>
                    </td>
                  </tr>
                </xsl:otherwise>
              </xsl:choose>
            </table>
          </form>
        </xsl:if>
        <xsl:if test="contains(Edit/@link,'m=edit')">
          <hr/>
          <div style="width: 680px; overflow: auto;">
            <table bgcolor="#404040" border="0">
              <tr valign="top" bgcolor="{$tbcolor}">
                <td style="font-size: 11px;">
                  <a href="{//ShowPage/Script}?f={/ShowPage/@id}">ID</a>
                </td>
                <td style="font-size: 11px;">INFO</td>
                <xsl:for-each select="Frage|frage|//table[@class='WF']/tbody/tr[td[2] !='&#160;']">
                  <td style="font-size: 11px;">
                    <xsl:attribute name="title">
                      <xsl:value-of select="Text|text|td[3]"/>
                    </xsl:attribute>
                    <xsl:value-of select="@kurz|td[2]"/>
                  </td>
                </xsl:for-each>
              </tr>
              <xsl:for-each select="Subobj">
                <xsl:apply-templates select="." mode="WF"/>
              </xsl:for-each>
            </table>

          </div>
          <xsl:if test="count(nofooter)=0">
            <hr/>
            <font size="3">
              <b>
                <xsl:value-of select="DoneTitle"/>
                <xsl:apply-templates select="//tr[td[1]='DoneTitle']/td[3]" mode="in"/>
              </b>
            </font>
            <font size="2">
              <br/>
              <br/>
              <xsl:apply-templates select="DoneText"/>
              <xsl:apply-templates select="//tr[td[1]='DoneText']/td[3]" mode="in"/>
              <xsl:value-of select="@now"/>
              <xsl:apply-templates select="DoneNext"/>
              <xsl:apply-templates select="//tr[td[1]='DoneNext']/td[3]" mode="in"/>
            </font>
          </xsl:if>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="td" mode="in">
    <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="User">
    <xsl:choose>
      <xsl:when test="contains(.,'_')">
        <xsl:value-of select="substring-after(.,'_')"/>
      </xsl:when>
      <xsl:when test="contains(.,'\')">
        <xsl:value-of select="substring-after(.,'\')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="."/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="Subobj" mode="WF">
    <xsl:param name="tbcolor">
      <xsl:choose>
        <xsl:when test="count(/ShowPage/tbcolor)">
          <xsl:value-of select="/ShowPage/tbcolor"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$pdcolor"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <!-- Show content -->
    <tr bgcolor="{$tbcolor}" valign="top">
      <td style="font-size: 11px;">
        <a href="{//ShowPage/Script}?f={/ShowPage/@id}&amp;ex={@id}">
          <xsl:value-of select="@id"/>
        </a>
        <a href="javascript:EditPageAdv('{@id}')">
          <img border="0" src="pub/editable.gif" align="textTop"/>
        </a>
      </td>
      <td style="font-size: 11px;">
        <xsl:choose>
          <xsl:when test="User != ''">
            <xsl:attribute name="title">
              <xsl:value-of select="done"/>
            </xsl:attribute>
            <xsl:apply-templates select="User"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="INFO"/>
          </xsl:otherwise>
        </xsl:choose>
      </td>
      <xsl:variable name="obj" select="."/>
      <xsl:for-each select="/ShowPage/Frage|/ShowPage/frage|//table[@class='WF']/tbody/tr">
        <xsl:if test="count(td)=0 or td[2] != '&#160;'">
          <xsl:variable name="pos" select="position()" />
          <td style="font-size: 11px;">
            <xsl:apply-templates select="$obj" mode="xS1">
              <xsl:with-param name="id" select="$pos"/>
            </xsl:apply-templates>
          </td>
        </xsl:if>
      </xsl:for-each>
    </tr>
  </xsl:template>
  <xsl:template match="Subobj" mode="xS1">
    <xsl:param name="id" select="''"/>
    <xsl:apply-templates mode="xS">
      <xsl:with-param name="id" select="$id" />
    </xsl:apply-templates>
  </xsl:template>
  <xsl:template match="node()" mode="xS">
    <xsl:param name="id" select="''"/>
    <xsl:variable name="name" select="name(.)"/>
    <xsl:variable name="this" select="concat('xS',$id)"/>
    <xsl:if test="$name = $this">
      <xsl:attribute name="title">
        <xsl:value-of select="."/>
      </xsl:attribute>
      <xsl:attribute name="align">
        <xsl:value-of select="//ShowPage/Fields/Field[@name=$name]/@align"/>
      </xsl:attribute>
      <xsl:choose>
        <xsl:when test="substring(translate(.,'0123456789#','##########'),1,3)='# -'">
          <xsl:value-of select="substring(.,1,1)"/>
        </xsl:when>
        <xsl:when test=". = /ShowPage/Default or .=/ShowPage/default">
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="substring(.,1,20)"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  <xsl:template match="@super1" mode="Oben">
    <div style="height: 40px; position: absolute; width: 690px; z-index: 5000; text-align: right; padding-top: 8px;">
      <xsl:choose>
        <xsl:when test="contains(../Edit/@link,'m=edit') and count(../done)=0 ">
          <xsl:apply-templates select="." mode="standard"/>
          <a class="tool" href="javascript:EditPageInt('{/ShowPage/@id}')">
            <xsl:value-of select="$lsEditPage"/>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <a class="tool">
            <xsl:attribute name="href">
              <xsl:text>?f=</xsl:text>
              <xsl:choose>
                <xsl:when test="count(/ShowPage/start)">
                  <xsl:value-of select="/ShowPage/start"/>
                </xsl:when>
                <xsl:when test="count(//tr[td[1]='start'])">
                  <xsl:value-of select="//tr[td[1]='start']/td[3]"/>
                </xsl:when>
                <xsl:otherwise>index</xsl:otherwise>
              </xsl:choose>
            </xsl:attribute>
            <xsl:value-of select="$lsHome"/>
          </a>
          <xsl:if test="../done">
            <xsl:text> </xsl:text>
            <a class="tool" href="?f={/ShowPage/@super}&amp;INFO={/ShowPage/INFO}">
              <xsl:value-of select="$lsJustBack"/>
            </a>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>
  <xsl:template match="form">
    <form>
      <xsl:apply-templates select="@*" mode="copy"/>
      <xsl:apply-templates/>
      <xsl:if test="count(input[@name='INFO'])=0">
        <input type="hidden" name="INFO" value="{/ShowPage/INFO}"/>
      </xsl:if>
    </form>
  </xsl:template>
  <xsl:template name="week">
    <xsl:param name="xS"/>
    <xsl:param name="week"/>
    <script language="javascript" type="text/javascript">
      var tableg = <xsl:value-of select="$tableg"/>;
      var timeb = <xsl:value-of select="$timeb"/>;
      var tablee = <xsl:value-of select="($timee - $timeb) * $tableg div 25"/>;

      var objDrag = null;		// Element, über dem Maus bewegt wurde

      var mouseY 	 = 0;				// Y-Koordinate der Maus

      var offY = 0;					// Y-Offset des Elements, das geschoben werden soll
      var height = 0;
      var top = 0;
      var eTop = 0;  // position, -1 = untere Kante, 1 = obere Kante
      var baseX=0;
      var baseY=0;

      // Browserweiche
      <![CDATA[
	IE = document.all&&!window.opera;
	DOM = document.getElementById&&!IE;
	]]>
      // Initialisierungs-Funktion
      window.onload = function init(){
      // Initialisierung der Überwachung der Events
      document.onmousemove = doDrag;
      document.onmouseup = stopDrag;
      var elem = document.getElementById('baseWeek');
      while(elem !=null) {
      baseX += elem.offsetLeft;
      baseY += elem.offsetTop;
      elem = elem.offsetParent;
      };
      var i;
      for(i=1; i<![CDATA[<]]>7; i++){
      var e = document.getElementById('divY'+i);
      e.style.top = e.offsetTop + baseY + 'px';
      e.style.left = e.offsetLeft + baseX + 'px';
      e = document.getElementById('divG'+i);
      e.style.top = e.offsetTop + baseY + 'px';
      e.style.left = e.offsetLeft + baseX + 'px';
      }
      tellme();
      }
      function time60(t100){
      var hour = ((Math.round(t100/100-0.5) + 100) + ':').substring(1,4);
      var minute = ((t100 - 100 * Math.round(t100/100-0.5))*15/25 + 100 + ' ').substring(1,3);
      return (hour + minute);
      }
      function tellme(){
      var tGreen=0;
      var tYellow=0;
      var b;
      var l;
      var status = '';
      for(i=1; i<![CDATA[<]]>7; i++){
      var eYellow = document.getElementById('divY'+i);
      var eGreen = document.getElementById('divG'+i);
      if(eYellow.offsetTop > eGreen.offsetTop){
      eYellow.style.height = eYellow.offsetHeight + eYellow.offsetTop - eGreen.offsetTop + 'px';
      eYellow.style.top = eGreen.offsetTop + 'px';
      }
      if(eYellow.offsetTop + eYellow.offsetHeight <![CDATA[<]]> eGreen.offsetTop + eGreen.offsetHeight)
      eYellow.style.height = eGreen.offsetHeight + eGreen.offsetTop - eYellow.offsetTop + 'px';

      if(eYellow.offsetHeight > 5 * tableg){
      l = eYellow.offsetHeight/tableg*25;
      tYellow += l;
      b = (eYellow.offsetTop - baseY)/tableg*25;
      eYellow.title = "Am diesem Tag möglich: " + time60(timeb + b) + '-' + time60(timeb + b+l);
      }
      else {
      l = 100 ;
      b = (eYellow.offsetTop - baseY)/tableg*25;
      eYellow.title = 'Keine Veranstaltung an diesem Tag möglich';
      }
      status += (timeb + b) + '|' + (timeb + b + l) + '|';

      if(eGreen.offsetHeight > 5 * tableg){
      l = eGreen.offsetHeight/tableg*25;
      tGreen += l;
      b = (eGreen.offsetTop - baseY)/tableg*25;
      eGreen.title = "Am diesem Tag gewünscht: " + time60(timeb + b) + '-' + time60(timeb + b+l);
      }
      else {
      l = 50;
      b = (eGreen.offsetTop - baseY)/tableg*25;
      eGreen.title = 'Keine Veranstaltung an diesem Tag gewünscht';
      }
      status += (timeb + b) + '|' + (timeb + b + l) + ' ';
      }
      document.getElementById('sumGreen').innerHTML = (Math.round(tGreen/25)/4 + ' Std').replace('.',',') + '.';
      document.getElementById('sumYellow').innerHTML = (Math.round(tYellow/25)/4 + ' Std').replace('.',',') + '.';
      //window.status = status;

      document.form1.xS<xsl:value-of select="$xS"/>.value = status;

      }

      // Wird aufgerufen, wenn die Maus über einer Box gedrückt wird
      function startDrag(objElem,pTop) {
      //

      // Objekt der globalen Variabel zuweisen -> hierdurch wird Bewegung möglich
      objDrag = objElem.offsetParent;
      //window.status = objDrag.offsetTop + '/' + objElem.offsetTop;

      height = objDrag.offsetHeight;
      top = objDrag.offsetTop;

      // Offsets im zu bewegenden Element ermitteln
      offY = mouseY;
      eTop = pTop;
      //window.status = 'offY: ' + offY + ' offsetTop: ' + objDrag.offsetTop + ' height: ' + height + ' baseY: ' + baseY;
      }

      // Wird ausgeführt, wenn die Maus bewegt wird
      function doDrag(ereignis) {
      // Aktuelle Mauskoordinaten bei Mausbewegung ermitteln
      mouseY = (IE) ? window.event.clientY : ereignis.pageY;

      // Wurde die Maus über einem Element gedrück, erfolgt eine Bewegung
      if (objDrag != null) {
      // Element neue Koordinaten zuweisen
      var h;
      var t;
      if(eTop==1){
      t = top + mouseY - offY;
      h = height - mouseY + offY;
      }
      else if(eTop==-1) {
      t = top;
      h = mouseY - offY + height;
      }
      else {
      t = top + mouseY - offY;
      h = height;
      }
      <![CDATA[
		 if(t >= baseY && t + h <= baseY + tablee && t <= baseY + tablee - 2*tableg) objDrag.style.top = t + "px";

		 if(h >= 2*tableg && t + h <= baseY + tablee )objDrag.style.height = h + "px";	
     ]]>



      // Position in Statusleiste ausgeben
      // window.status = "Box-Position: " + objDrag.style.top + ", " + objDrag.style.height + ',' + eTop;
      }
      }
      function NoTime(objElem, hFac){
      objElem.style.height = hFac * tableg + 'px';
      tellme();
      }
      // Wird ausgeführt, wenn die Maustaste losgelassen wird
      function stopDrag(ereignis) {
      // Objekt löschen -> beim Bewegen der Maus wird Element nicht mehr verschoben
      if(objDrag){
      var t = tableg * Math.round((objDrag.offsetTop-baseY)/tableg) + baseY;
      var h = tableg * Math.round(objDrag.offsetHeight/tableg);
      objDrag.style.top = t;
      objDrag.style.height = h;

      objDrag = null;
      tellme();
      }
      }
    </script>
    <table id="baseWeek" width="{7*$tablew}" border="0" cellspacing="0" cellpadding="0" style="{$font}" align="center">
      <tbody>
        <tr>
          <xsl:call-template name="day">
            <xsl:with-param name="day" select="0"/>
          </xsl:call-template>
          <xsl:call-template name="day">
            <xsl:with-param name="day" select="1"/>
          </xsl:call-template>
          <xsl:call-template name="day">
            <xsl:with-param name="day" select="2"/>
          </xsl:call-template>
          <xsl:call-template name="day">
            <xsl:with-param name="day" select="3"/>
          </xsl:call-template>
          <xsl:call-template name="day">
            <xsl:with-param name="day" select="4"/>
          </xsl:call-template>
          <xsl:call-template name="day">
            <xsl:with-param name="day" select="5"/>
          </xsl:call-template>
          <xsl:call-template name="day">
            <xsl:with-param name="day" select="6"/>
          </xsl:call-template>
        </tr>
        <tr>
          <td colspan="7">
            <table cellpadding="1" cellspacing="0" border="0" width="100%">
              <tbody>
                <tr>
                  <td>
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">
                      <tbody>
                        <tr>
                          <td width="{$tablew}" style="background-color: {$colorRed};"/>
                          <td height="{4*$tableg}" style="background-color: {$colorRed};"/>
                          <td valign="middle" style="background-color: {$colorRed}; filter: alpha(Opacity={$opacity*100}); opacity: {$opacity};">
                            <div style="text-align: center;width: {$tablew}; background-color: {$colorGreen}; {$font}">Gewünscht:</div>
                          </td>
                          <td valign="middle" style="background-color: {$colorRed};">
                            <div id="sumGreen" style="width: {$tablew}; text-align: center;">12 Std.</div>
                          </td>
                          <td valign="middle" style="background-color: {$colorRed}; filter: alpha(Opacity={$opacity*100}); opacity: {$opacity};">
                            <div style="text-align: center;width: {$tablew}; background-color: {$colorYellow}; {$font}">Möglich:</div>
                          </td>
                          <td valign="middle" style="background-color: {$colorRed};">
                            <div id="sumYellow" style="width: {$tablew};text-align: center;">30 Std.</div>
                          </td>
                          <td colspan="2" style="background-color: {$colorRed};"/>
                          <td width="{2 *$tablew}" style="background-color: {$colorRed};"/>

                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
          </td>

        </tr>
      </tbody>
    </table>
    <xsl:call-template name="zone">
      <xsl:with-param name="day" select="1"/>
      <xsl:with-param name="week" select="$week"/>
    </xsl:call-template>
    <xsl:call-template name="zone">
      <xsl:with-param name="day" select="2"/>
      <xsl:with-param name="week" select="$week"/>
    </xsl:call-template>
    <xsl:call-template name="zone">
      <xsl:with-param name="day" select="3"/>
      <xsl:with-param name="week" select="$week"/>
    </xsl:call-template>
    <xsl:call-template name="zone">
      <xsl:with-param name="day" select="4"/>
      <xsl:with-param name="week" select="$week"/>
    </xsl:call-template>
    <xsl:call-template name="zone">
      <xsl:with-param name="day" select="5"/>
      <xsl:with-param name="week" select="$week"/>
    </xsl:call-template>
    <xsl:call-template name="zone">
      <xsl:with-param name="day" select="6"/>
      <xsl:with-param name="week" select="$week"/>
    </xsl:call-template>

  </xsl:template>
  <xsl:template name="token">
    <xsl:param name="line"/>
    <xsl:param name="index"/>
    <xsl:param name="terminator" select="' '"/>
    <xsl:param name="indexold" select="$index"/>
    <xsl:choose>
      <xsl:when test="$index &gt; 1">
        <xsl:call-template name="token">
          <xsl:with-param name="line" select="substring-after($line,$terminator)"/>
          <xsl:with-param name="index" select="$index - 1"/>
          <xsl:with-param name="terminator" select="$terminator"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="substring-before(concat($line,$terminator),$terminator)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="zone">
    <xsl:param name="day"/>
    <xsl:param name="week"/>
    <xsl:param name="haha">
      <xsl:call-template name="token">
        <xsl:with-param name="index" select="$day"/>
        <xsl:with-param name="line" select="$week"/>
      </xsl:call-template>
    </xsl:param>
    <xsl:param name="yb">
      <xsl:call-template name="token">
        <xsl:with-param name="index" select="1"/>
        <xsl:with-param name="terminator" select="'|'"/>
        <xsl:with-param name="line" select="$haha"/>
      </xsl:call-template>
    </xsl:param>
    <xsl:param name="ye">
      <xsl:call-template name="token">
        <xsl:with-param name="index" select="2"/>
        <xsl:with-param name="terminator" select="'|'"/>
        <xsl:with-param name="line" select="$haha"/>
      </xsl:call-template>
    </xsl:param>
    <xsl:param name="yl" select="$ye - $yb"/>
    <xsl:param name="gb">
      <xsl:call-template name="token">
        <xsl:with-param name="index" select="3"/>
        <xsl:with-param name="terminator" select="'|'"/>
        <xsl:with-param name="line" select="$haha"/>
      </xsl:call-template>
    </xsl:param>
    <xsl:param name="ge">
      <xsl:call-template name="token">
        <xsl:with-param name="index" select="4"/>
        <xsl:with-param name="terminator" select="'|'"/>
        <xsl:with-param name="line" select="$haha"/>
      </xsl:call-template>
    </xsl:param>
    <xsl:param name="gl" select="$ge - $gb"/>
    <table border="0" cellpadding="0" cellspacing="0" id="divY{$day}"  ondblclick="NoTime(this,4);"
            style="filter: alpha(Opacity={$opacity*100}); opacity: {$opacity}; position: absolute; z-index: 1000;
				background-color: {$colorYellow};
				width: {$tablew - 2}px;	
				left: {1 + $tablew * $day}px; 
				height: {$yl div 25 * $tableg}px; 
				top: {($yb - $timeb) div 25 * $tableg}px;">
      <xsl:call-template name="table">
        <xsl:with-param name="color" select="$colorYellowDark"/>
      </xsl:call-template>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" id="divG{$day}"  ondblclick="NoTime(this,2);"
            style="filter: alpha(Opacity={$opacity*100}); opacity: {$opacity}; position: absolute; z-index: 1050;
				background-color: {$colorGreen};
				width: {$tablew - 2}px;	
				left: {1 + $tablew * $day}px; 
				height: {$gl div 25 * $tableg}px; 
				top: {($gb - $timeb) div 25 * $tableg}px;">
      <xsl:call-template name="table">
        <xsl:with-param name="color" select="$colorGreenDark"/>
      </xsl:call-template>
    </table>
  </xsl:template>
  <xsl:template name="table">
    <xsl:param name="color"/>
    <tbody>
      <tr>
        <td height="{$tableg div 2}" style="cursor: s-resize; background-color: {$color}"
            onmousedown="startDrag(this,1);" />
      </tr>
      <tr>
        <td height="100%" style="cursor: move" onmousedown="startDrag(this,0);" />
      </tr>
      <tr>
        <td height="{$tableg div 2}" style="cursor: s-resize; background-color: {$color}"
            onmousedown="startDrag(this,-1);" />
      </tr>
    </tbody>
  </xsl:template>
  <xsl:template name="day">
    <xsl:param name="day"/>
    <td>
      <table bgcolor="{$colorGrey}" cellspacing="1" width="{$tablew}">
        <tbody>
          <xsl:choose>
            <xsl:when test="$day=0">
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="' '"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'08:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'09:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'10:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'11:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'12:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'13:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'14:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'15:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'16:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'17:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'18:00'"/>
              </xsl:call-template>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour" select="'19:00'"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="hour">
                <xsl:with-param name="hour">
                  <xsl:call-template name="weekday">
                    <xsl:with-param name="day" select="$day"/>
                  </xsl:call-template>
                </xsl:with-param>
              </xsl:call-template>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
              <xsl:call-template name="hour"/>
            </xsl:otherwise>
          </xsl:choose>
        </tbody>
      </table>
    </td>
  </xsl:template>
  <xsl:template name="weekday">
    <xsl:param name="day" select="0"/>
    <xsl:choose>
      <xsl:when test="$day=1">Montag</xsl:when>
      <xsl:when test="$day=2">Dienstag</xsl:when>
      <xsl:when test="$day=3">Mittwoch</xsl:when>
      <xsl:when test="$day=4">Donnerstag</xsl:when>
      <xsl:when test="$day=5">Freitag</xsl:when>
      <xsl:when test="$day=6">Samstag</xsl:when>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="hour">
    <xsl:param name="hour"/>
    <tr>
      <td align="center" height="{$tableg*4-1}" style="font-size: 12px;">
        <xsl:attribute name="valign">
          <xsl:choose>
            <xsl:when test="contains($hour,':')">top</xsl:when>
            <xsl:otherwise>middle</xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="bgcolor">
          <xsl:choose>
            <xsl:when test="$hour = ''">
              <xsl:value-of select="$colorRed"/>
            </xsl:when>
            <xsl:otherwise>white</xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
        <xsl:value-of select="$hour"/>
      </td>
    </tr>
  </xsl:template>
  <xsl:param name="lsJustBack">
    <xsl:choose>
      <xsl:when test="$lsLanguage='zh-cn'">

      </xsl:when>
      <xsl:when test="$lsLanguage='de'">
        Zurück
      </xsl:when>
      <xsl:otherwise>
        Back
      </xsl:otherwise>
    </xsl:choose>
  </xsl:param>
  <xsl:param name="tablew" select="95"/>
  <xsl:param name="tableg" select="8"/>
  <xsl:param name="timeb" select="700"/>
  <xsl:param name="timee" select="2000"/>
  <xsl:param name="colorGrey" select="'#888888'"/>
  <xsl:param name="colorRed" select="'#ffffff'"/>
  <xsl:param name="colorYellow" select="'#eeee00'"/>
  <xsl:param name="colorYellowDark" select="'#aaaa22'"/>
  <xsl:param name="colorGreen" select="'#22ee22'"/>
  <xsl:param name="colorGreenDark" select="'#118811'"/>
  <xsl:param name="opacity" select="0.6"/>
  <xsl:param name="font" select="'font-size: 12px;'"/>
</xsl:stylesheet>
