<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <xsl:output method="html" indent="yes" encoding="utf-8" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
  <xsl:strip-space elements="*"/>
  <xsl:include href="buttons.xsl"/>

  <xsl:template match="LAYOUT">
    <xsl:variable name="cID" select="@ID"/>
    <html>
<!-- zsk-06 -->
      <head>
        <link href="css/styles.css" rel="stylesheet" type="text/css" />
<title>
          <xsl:value-of select="@SITE-TITLE" disable-output-escaping="yes"/> - <xsl:value-of select="@TITLE" disable-output-escaping="yes"/>
        </title>
        <xsl:apply-templates select="META-TAGS"/>
      </head>
      <body rightmargin="0" topmargin="0" leftmargin="0" bottommargin="0">
        <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
          <tr>
            <td height="276px" width="100%">
              <table cellpadding="0" cellspacing="0" border="0" width="100%" height="276px">
                <tr>
                  <td width="100%" height="200px" class="header">
                    <table cellpadding="0" cellspacing="0" border="0" width="100%" height="200px">
                      <tr>
                        <td width="100%" height="100%" style="background-image:url(images/h.jpg);background-position:left; background-repeat:no-repeat">
                          <table cellpadding="0" cellspacing="0" border="0" width="100%" height="200px">
                            <tr>
                              <td width="100%" height="100%" style="background-image:url(images/header.jpg);background-position:right; background-repeat:no-repeat; padding-left:85px; padding-right:500px">
                                <table cellpadding="0" cellspacing="0" border="0">
                                  <tr>
                                    <td style="padding-right:10px">
                                      <a href="./"><img src="images/{LOGO/@NAME}" border="0" /></a>
                                    </td>
                                    <td class="company">
                                      <xsl:value-of select="COMPANY-INFO/NAME" disable-output-escaping="yes"/> 
                                    </td>
                                  </tr>
                                </table>
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td width="100%" height="76px" style="background-image:url(images/m2.jpg)">
                    <table cellpadding="0" cellspacing="0" border="0" width="100%" height="76px" style="background-image:url(images/m3.jpg); background-position:right; background-repeat:no-repeat;">
                      <tr>
                        <td width="100%" height="76px" align="left" style="padding-left:123px;padding-right:50px;background-image:url(images/m1.jpg);background-position:left; background-repeat:no-repeat">
                          <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                              <xsl:call-template name="TOP-MENU"/>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td height="100%" width="100%" style="background-image: url(images/bg.jpg)">
              <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
                <tr>
                  <td width="38px" height="100%">
                    <div style="width:38px"></div>
                  </td>
                  <td width="148px" height="100%" valign="top" style="padding-top:55px; padding-bottom:68px">
                    <table cellpadding="0" cellspacing="0" border="0" width="148px">
                      <tr>
                        <td width="10px" height="8" style="background-image: url(images/1.jpg)">
                        </td>
                        <td width="128px" height="8" style="background-image: url(images/2.jpg)">
                        </td>
                        <td width="10px" height="8" style="background-image: url(images/3.jpg)">
                        </td>
                      </tr>
                      <tr>
                        <td width="10px" height="11px" style="background-image: url(images/4.jpg)">
                        </td>
                        <td width="128px" height="11px" style="background-image: url(images/4.jpg)">
                          <table cellpadding="0" cellspacing="0" border="0" width="128px">
                            <xsl:call-template name="SUB-MENU">
                              <xsl:with-param name="pageID" select="@ID"/>
                            </xsl:call-template>
                          </table>
                        </td>
                        <td width="10px" height="11px" style="background-image: url(images/4.jpg)">
                        </td>
                      </tr>
                      <tr>
                        <td width="10px" height="8" style="background-image: url(images/5.jpg)">
                        </td>
                        <td width="128px" height="8" style="background-image: url(images/2.jpg)">
                        </td>
                        <td width="10px" height="8" style="background-image: url(images/6.jpg)">
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="100%" height="100%" >
                    <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
                      <tr>
                        <td width="117px" height="100%">
                          <div style="width:117px"></div>
                        </td>
                        <td width="100%" height="100%" valign= "top" style="padding-top:50px">
                          <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
                            <tr>
                              <td class="text-header" align="left">
                                <xsl:value-of select="@TITLE" disable-output-escaping="yes"/>
                              </td>
                            </tr>
                            <tr>
                              <td width="100%" height="100%" style="padding-top:5px; padding-bottom:10px" class="pageContent" valign="top" align="left" name="SB_stretch">
                                <xsl:apply-templates select="PAGE-CONTENT"/>
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="102px" height="100%">
                    <div style="width:102px"></div>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td width="100%" height="75px" style="background-image: url(images/bbg.jpg)" align="center" valign="middle">
              <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                  <xsl:call-template name="BOTTOM-MENU"/>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </body>
    </html>

  </xsl:template>



  <xsl:template name="TOP-MENU">
    <xsl:apply-templates select="MENU" mode="top"/>
  </xsl:template>


  <xsl:template name="SUB-MENU">
    <xsl:param name="pageID"/>
    <xsl:choose>
      <xsl:when test="//MENU/MENU-ITEM[@ID = $pageID]/MENU-ITEM">
        <xsl:apply-templates select="//MENU/MENU-ITEM[@ID = $pageID]/MENU-ITEM" mode="sub"/>
      </xsl:when>
      <xsl:when test="//MENU/MENU-ITEM/MENU-ITEM[@ID = $pageID]">
        <xsl:variable name="parentID" select="//MENU/MENU-ITEM/MENU-ITEM[@ID = $pageID]/../@ID"/>
        <xsl:apply-templates select="//MENU/MENU-ITEM[@ID=$parentID]/MENU-ITEM" mode="sub"/>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="MENU-ITEM" mode="sub">
    <xsl:choose>
      <xsl:when test="@ID=/LAYOUT/@ID" >
        <tr>
          <td width="112px" height="37px" class="asubmenu">
            <xsl:value-of select="@TITLE" disable-output-escaping="yes"/>
          </td>
          <td width="16px" height="37px" style="background-image: url(images/8.jpg)"></td>
        </tr>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="../MENU-ITEM[@ID=/LAYOUT/@ID] or ../../MENU-ITEM[@ID=/LAYOUT/@ID]">
          <tr>
            <td width="112px" height="37px">
              <a href="{@HREF}"  class="submenu">
                <xsl:value-of select="@TITLE" disable-output-escaping="yes"/>
              </a>
            </td>
            <td width="16px" height="37px">
              <a href="{@HREF}">
                <img src="images/8.jpg" border="0"/>
              </a>
            </td>
          </tr>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="position()!=last()">
      <tr>
        <td width="128px" height="1px" cowspan="2" style="background-image: url(images/7.jpg)"></td>
      </tr>
    </xsl:if>
  </xsl:template>

  <xsl:template name="BOTTOM-MENU">
    <xsl:apply-templates select="MENU" mode="bottom"/>
  </xsl:template>

  <xsl:template match="MENU" mode="bottom">
    <xsl:apply-templates select="MENU-ITEM"  mode="bottom"/>
  </xsl:template>

  <xsl:template match="MENU-ITEM"  mode="bottom">
    <xsl:choose>
      <!-- when vizited inside-->
      <xsl:when test="MENU-ITEM[@ID=/LAYOUT/@ID] or @ID=/LAYOUT/@ID">
        <td align="center" valign="middle">
          <a href="{@HREF}" class="abmenu" id="abmenu">
            <xsl:value-of select="@TITLE" disable-output-escaping="yes"/>
          </a>
        </td>
      </xsl:when>
      <!-- when active-->
      
      <xsl:otherwise>
        <td align="center" valign="middle">
          <a href="{@HREF}" class="bmenu" id="bmenu{position()}">
            <xsl:value-of select="@TITLE" disable-output-escaping="yes"/>
          </a>
        </td>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="position()!=last()">
      <td align="center" valign="middle" style="padding-left:23px; padding-right:23px">
        <img src="images/bb.jpg" border="0"/>
      </td>
    </xsl:if>
  </xsl:template>

  <xsl:template match="META-TAGS">
    <xsl:apply-templates mode="meta-tags"/>
  </xsl:template>

  <xsl:template match="*" mode="meta-tags">
    <meta name="{local-name(.)}">
      <xsl:attribute name="content">
        <xsl:value-of select="." disable-output-escaping="yes"/>
      </xsl:attribute>
    </meta>
  </xsl:template>


  <xsl:template match="PAGE-CONTENT">
    <xsl:comment> EDITABLE CONTENT </xsl:comment>
    <xsl:apply-templates mode="meta-tags"/>
  </xsl:template>

</xsl:stylesheet>
