<?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"/>
			<style>
				img { behavior:url('images/pngbehavior.htc'); }
			</style>
		</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" style="background-image: url('images/top_bg.gif'); background-repeat: repeat-x;">
        	<TR>
        		<TD height="305" valign="top" align="center">
				<xsl:attribute name="style"><xsl:call-template name="TOP"/></xsl:attribute>
        		<!-- HEADER -->
        		<!-- TOP -->
        			<table cellpadding="0" cellspacing="0" style="margin-top: 80px;">
        				<tr><td align="center"><a href="./"><img src="images/{LOGO/@NAME}" border="0" style="margin-bottom: 15px;"/></a></td></tr>
        				<tr><td align="center" class="company" width="100%" valign="bottom">&#160;<xsl:value-of select="COMPANY-INFO/NAME" disable-output-escaping="yes"/>&#160;</td></tr>
        				<tr><td align="center" class="slogan" valign="top">&#160;<xsl:value-of select="COMPANY-INFO/SLOGAN" disable-output-escaping="yes"/>&#160;</td></tr>							
        			</table>

           			<!-- CALL MAIN-MENU-->
           			<xsl:call-template name="TOP-MENU"/>

        		<!-- END TOP -->
        		<!-- SUB-MENU -->

       				<!-- CALL SUB-MENU-->
       				<xsl:call-template name="SUB-MENU">
       					<xsl:with-param name="pageID" select="@ID"/>
       				</xsl:call-template>

        		<!-- END SUB-MENU -->
        		<!-- END HEADER -->
        		</TD>
        	</TR>
        	<TR>
        		<TD height="100%" valign="top" class="bg" align="center" style="background-image: url('images/bg.gif'); background-repeat: repeat-x;">
        		<!-- CONTENT -->
        			<table cellpadding="0" cellspacing="0" width="600" height="100%" style="margin: 20px 34px 20px 0px;" align="center">
        				<tr>
        					<td valign="top" width="34"><img src="images/txtheader_bullet.gif" style="margin-right: 5px;" /></td>
        					<td class="text" valign="top">
        						<p class="text-header"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></p>

        						<xsl:apply-templates select="PAGE-CONTENT"/>

        					</td>
        				</tr>			
        			</table>
        		<!-- END CONTENT -->		
        		</TD>
        	</TR>
        	<TR>
        		<TD height="103" valign="top" style="background-image: url('images/footer_bg.gif'); background-repeat: repeat-x;">
        			<table cellpadding="0" cellspacing="0" height="100%" width="100%" style="background-image: url('images/footer.gif'); background-position: center; background-repeat: no-repeat;">
        				<tr>
        					<td align="center" valign="top">
        					<!-- BOTTOM MENU -->

            					<!--CALL BOTTOM-MENU -->
            					<xsl:call-template name="BOTTOM-MENU"/>

        					<!-- END BOOTTOM MENU -->
        					<!-- FOOTER -->
        					<div class="footer" style="margin-top: 30px;"><xsl:value-of select="COPYRIGHT" disable-output-escaping="yes"/></div>
        					<!-- END FOOTER -->
        					</td>
        				</tr>
        			</table>
        		</TD>
        	</TR>
        </TABLE>
        </BODY>
		</html>

	</xsl:template>


	<!--TOP-->


	<xsl:template name="TOP-MENU">
   		<table cellpadding="0" cellspacing="0" style="margin-top: 60px;">
   			<tr>
				<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" style="margin-top: 35px;">
     				<tr>
					<xsl:apply-templates select="//MENU/MENU-ITEM[@ID = $pageID]/MENU-ITEM" mode="sub"/>
     				</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" style="margin-top: 35px;">
     				<tr>
				   <xsl:apply-templates select="//MENU/MENU-ITEM[@ID=$parentID]/MENU-ITEM" mode="sub"/>
     				</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" style="margin-top: 20px;">
   			<tr>
    			<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="bmenu" style="text-decoration:underline;"><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><span class="bmenu" style="text-decoration:underline;"><xsl:value-of select="@TITLE" disable-output-escaping="yes"/></span></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"/></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>	
