<?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="no"/>
<xsl:strip-space elements="*"/>
<xsl:include href="buttons.xsl"/>

<xsl:template match="LAYOUT">
	<xsl:variable name="cID" select="@ID"/>
	<HTML>
    <head>
		<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"/>
		<link href="css/styles.css" rel="stylesheet" type="text/css"/>

</head>

<body style="margin:0;" >
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top" height="248" background="images/top-bg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/blank.gif" width="1" height="48" alt="" /></td>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><img name="" src="images/blank.gif" width="32" height="1" alt="" /></td>
                <td><table border="0" align="center" cellpadding="0" cellspacing="0">
                     <!--Menu-->
 <xsl:call-template name="TOP-MENU"/>
<!--End Menu-->
                </table></td>
                <td><img name="" src="images/blank.gif" width="32" height="1" alt="" /></td>
              </tr>
            </table></td>
            <td><img name="" src="images/blank.gif" width="1" height="48" alt="" /></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="200" valign="top" style="background-image:url(images/headers.jpg); background-position:left; background-repeat:no-repeat;"><table border="0" width="400" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/blank.gif" width="1" height="150" alt="" /></td>
            <td><div align="center"><div align="center"><a href="./"><img src="images/{LOGO/@NAME}" hspace="10" border="0" alt=""/></a></div></div></td>
            <td class="company"><!--Company-->
<div class="company"><xsl:value-of select="COMPANY-INFO/NAME" disable-output-escaping="yes"/></div>
<!--End Company--></td>
          </tr>
          <tr>
            <td width="10%"><img name="" src="images/blank.gif" width="100" height="1" alt="" /></td>
            <td width="18%"></td>
            <td width="72%"></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="32"></td>
  </tr>
  <tr>
    <td valign="top"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50"><img name="" src="images/blank.gif" width="50" height="1" alt="" /></td>
        <td width="200" valign="top"><table width="200" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="24" background="images/sub-8.gif"><img src="images/sub-1.gif" width="24" height="25" /></td>
                <td width="91%" background="images/sub-8.gif"><img src="images/sub-8.gif" width="19" height="25" /></td>
                <td width="27" background="images/sub-8.gif"><div align="right"><img src="images/sub-4.gif" width="27" height="25" /></div></td>
              </tr>
              <tr>
                <td style="background-image:url(images/sub-2.gif); background-position:left; background-repeat:repeat-y;"><img src="images/sub-2.gif" width="24" height="108" /></td>
                <td bgcolor="#F3F3F3" valign="top"><table width="100%" border="0" cellspacing="6" cellpadding="0">
                     <!--Sub Menu-->
<xsl:call-template name="SUB-MENU">	<xsl:with-param name="pageID" select="@ID"/></xsl:call-template> 
<!--End Menu-->
                </table></td>
                <td style="background-image:url(images/sub-5.gif); background-position:right; background-repeat:repeat-y;"><div align="right"><img src="images/sub-5.gif" width="27" height="56" /></div></td>
              </tr>
              <tr>
                <td background="images/sub-7.gif"><img src="images/sub-3.gif" width="27" height="28" /></td>
                <td background="images/sub-7.gif"></td>
                <td background="images/sub-7.gif"><div align="right"><img src="images/sub-6.gif" width="27" height="28" /></div></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><img name="" src="images/blank.gif" width="1" height="32" alt="" /></td>
          </tr>
          <tr>
            <td><img name="" src="images/blank.gif" width="1" height="32" alt="" /></td>
          </tr>
        </table></td>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="4%"><img name="" src="images/blank.gif" width="32" height="1" alt="" /></td>
            <td width="91%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="text-header"><span class="text-header"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></span></td>
              </tr>
              <tr>
                <td><img name="" src="images/blank.gif" width="1" height="20" alt="" /></td>
              </tr>
              <tr>
                 <td  name="SB_stretch"><div class="pageContent"><xsl:apply-templates select="PAGE-CONTENT"/></div></td>
              </tr>
            </table></td>
            <td width="5%"><img name="" src="images/blank.gif" width="32" height="1" alt="" /></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="119" valign="top" style="background-image:url(images/footer.gif); background-position:left; background-repeat:no-repeat;"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
      <td width="1"><img name="" src="images/blank.gif" width="1" height="80" alt="" /></td>
        <td width="200" valign="bottom"><span class="footer"><xsl:value-of select="COPYRIGHT" disable-output-escaping="yes"/></span></td>
      </tr>
      <tr>
	  <td class="footer"><img name="" src="images/blank.gif" width="1" height="12" alt="" /></td>
     
      </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 height="40" >
    		<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
    			<tr>
    				<td class="asubmenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></td>
    				<td width="12" align="right"><img src="images/submenu.gif" border="0" /></td>
    			</tr>
    		</table>
    	</td>
  		</tr>
  		
		</xsl:when>
		
		<xsl:otherwise>	
			<xsl:if test="../MENU-ITEM[@ID=/LAYOUT/@ID] or ../../MENU-ITEM[@ID=/LAYOUT/@ID]">
			<tr>
    	<td height="40" >
    		<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
    			<tr>
    				<td style="border-bottom: 1px solid white;"><a href="{@HREF}" class="submenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
    				<td width="12" align="right"><a href="{@HREF}"><img src="images/submenu.gif" border="0" /></a></td>
    			</tr>
    		</table>
    	</td>
  		</tr>
			</xsl:if>
			
		</xsl:otherwise>
	</xsl:choose>
	<xsl:if test="position()!=last()">
	<tr>
    <td height="1" background="images/submenu-hr.gif" ></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]" >
			<td align="center"><a href="{@HREF}" class="bmenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
            <td><img src="images/bmenu.gif" width="4" height="4" hspace="4" border="0" /></td>
           </xsl:when>
           <!-- when active-->
           <xsl:when test="MENU-ITEM[@ID=/LAYOUT/@ID] or @ID=/LAYOUT/@ID" >
			<td align="center"><a href="{@HREF}" class="bmenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
            <td><img src="images/bmenu.gif" hspace="4" border="0" /></td>
           </xsl:when>
           <xsl:otherwise>
 			<td align="center"><a href="{@HREF}" class="abmenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
            <td><img src="images/bmenu.gif" hspace="4" border="0" /></td>
           </xsl:otherwise>
       </xsl:choose>
  		<xsl:if test="position()!=last()">
			<td><img name="" src="images/blank.gif" width="0" height="0" alt="" /></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="."/></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>
