<?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:include href="headers.xsl"/>
	<!-- LAYOUT -->
	<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 MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" RIGHTMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0">
        <TABLE WIDTH="100%" HEIGHT="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0" bgcolor="White">
        	<TR><TD colspan="2" height="4" valign="top" style="background-image: url('images/main_top.gif'); background-repeat: repeat-x;"></TD></TR>
        	<TR>
        		<TD colspan="2" height="42" style="background-image: url('images/menu_bg.gif'); background-repeat: repeat-x;">
        		<!-- MENU -->
				<xsl:call-template name="TOP-MENU"/>
        		<!-- END MENU -->
        		</TD>
        	</TR>
        	<TR>
        		<TD colspan="2" height="145" style="background-image: url('images/hbg.gif'); background-repeat: repeat-x;">
				<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" style="background-image: url('images/header.jpg'); background-position: right; background-repeat: no-repeat;"><tr><td>
        		<!-- LOGO -->
        			<table cellpadding="0" cellspacing="0" style="margin-left: 30px;">
        				<tr><td align="right"><a href="./"><img src="images/{LOGO/@NAME}" border="0"/></a></td></tr>
        				<tr><td class="company" valign="bottom" style="padding-right: 60px;"><xsl:value-of select="COMPANY-INFO/NAME" disable-output-escaping="yes"/></td></tr>				
        				<tr><td class="slogan" align="right" valign="top" style="padding-right: 50px;"><xsl:value-of select="COMPANY-INFO/SLOGAN" disable-output-escaping="yes"/></td></tr>
        			</table>
        		<!-- END LOGO -->
				</td></tr></table>
        		</TD>
        	</TR>
        	<TR>
        		<TD valign="top" width="100%" height="100%" style="padding-left: 10px;">
        		<!-- CONTENT -->	
        			<table cellpadding="0" cellspacing="0" width="100%">
        				<tr><td height="22" colspan="2"></td></tr>
        				<tr>
        					<td><img src="images/txtheader_bullet.gif" style="margin-right: 5px;"/></td>
        					<td class="text-header" width="100%"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></td>
        				</tr>
        				<tr><td height="15" colspan="2"></td></tr>
        				<tr>
        					<td class="pageContent" colspan="2">
        						<xsl:apply-templates select="PAGE-CONTENT"/>
        					</td>
        				</tr>
        				<tr><td height="20" colspan="2"></td></tr>
        			</table>				
        		<!-- END CONTENT -->		
        		</TD>
        		<TD valign="top" width="270" height="100%"><div style="height:1px;width:270px;"></div>
        		<!-- SUBMENU -->
        			<table cellpadding="0" cellspacing="0" width="206" height="208" style="background-image: url('images/submenu_bg.gif'); background-repeat: repeat-y;">
        				<tr>
        					<td valign="top" style="background-image: url('images/submenu_bbg.gif'); background-position: bottom left; background-repeat: no-repeat;">
        					<!-- CALL SUB-MENU -->
        					<xsl:call-template name="SUB-MENU">
        						<xsl:with-param name="pageID" select="@ID"/>
        					</xsl:call-template>
        					</td>
        				</tr>				
        			</table>
        		<!-- END SUBMENU -->
        		</TD>
        	</TR>
        	<TR><TD colspan="2" height="1" bgcolor="#DBDBDB"></TD></TR>
        	<TR><TD colspan="2" height="1"></TD></TR>
        	<TR>
        		<TD colspan="2" height="30" bgcolor="#F3DFC3" valign="bottom">
        		<!-- BOTTOM MENU -->
        		<!-- CALL BOTTOM-MENU -->
        		<xsl:call-template name="BOTTOM-MENU"/>
        		<!-- END BOOTTOM MENU -->
        		</TD>
        	</TR>
        	<TR>
        		<TD colspan="2" height="30" bgcolor="#F3DFC3" valign="top" align="center" class="footer" style="padding-top: 3px;">
        		<!-- FOOTER -->
        			<xsl:value-of select="COPYRIGHT" disable-output-escaping="yes"/>
        		<!-- END FOOTER -->
        		</TD>
        	</TR>
        </TABLE>
        </BODY>
		</html>

	</xsl:template>

   				
	<!--TOP-MENU-->
   				
	<xsl:template name="TOP-MENU">
   		<table cellpadding="0" cellspacing="0">
   			<tr>
   				<td width="23"></td>
				<xsl:apply-templates select="MENU" mode="top"/>			
   			</tr>
   		</table>
	</xsl:template>
  

	<xsl:template name="SUB-MENU">
		<xsl:param name="pageID"/>
		<xsl:choose>
			<xsl:when test="//MENU/MENU-ITEM[@ID = $pageID]/MENU-ITEM">
   				<table cellpadding="0" cellspacing="0" width="160" align="center">
					<xsl:apply-templates select="//MENU/MENU-ITEM[@ID = $pageID]/MENU-ITEM" mode="sub"/>
   					<tr><td height="30"></td></tr>
    			</table>
			</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"/>
   				<table cellpadding="0" cellspacing="0" width="160" align="center">
					<xsl:apply-templates select="//MENU/MENU-ITEM[@ID=$parentID]/MENU-ITEM" mode="sub"/>
   					<tr><td height="30"></td></tr>
    			</table>
			</xsl:when>
		<xsl:otherwise>
			<!-- no op -->
			&#160;
		</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

   				
	<xsl:template name="BOTTOM-MENU">
   		<table cellpadding="0" cellspacing="0" align="center">
   			<tr>		
   				<td width="10"></td>			
				<xsl:apply-templates select="MENU" mode="bottom"/>			
   			</tr>
   		</table>
	</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><a href="{@HREF}" class="abmenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
            </xsl:when>
            <!-- when active-->
            <xsl:when test="MENU-ITEM[@ID=/LAYOUT/@ID] or @ID=/LAYOUT/@ID" >
   				<td class="abmenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></td>
            </xsl:when>
            <xsl:otherwise>
   				<td><a href="{@HREF}" class="bmenu"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></a></td>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="position()!=last()">
   			<td width="10"></td>
   			<td><img src="images/bmenu_separator.gif" border="0"/></td>
   			<td width="10"></td>
        </xsl:if>
	</xsl:template>


	<!--META-TAGS-->
	<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>
	<!--PAGE-CONTENT-->
	<xsl:template match="PAGE-CONTENT">
		<xsl:comment> EDITABLE CONTENT </xsl:comment>
		<xsl:apply-templates mode="meta-tags"/>
	</xsl:template>
	     	
</xsl:stylesheet>	
