<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="xml" indent="no"/>
	
	<xsl:include href="course_th4_com.xsl"/>	
	
	<xsl:variable name="comptype">component</xsl:variable>
	
	<xsl:variable name="manager" select="0"/>
		
<!-- COMPONENT -->	
	
	<xsl:template name="componentshell">	
	<xsl:param name="contentpage"/>
	<xsl:param name="currentcomp"><xsl:value-of select="@id"/></xsl:param>
		<div xmlns="http://www.w3.org/1999/xhtml" class="holly">
		<xsl:element name="div">
			<xsl:choose>
			<xsl:when test="$state = 'item'">			
			<xsl:attribute name="class"><xsl:text>component </xsl:text>
				<xsl:choose>
					<xsl:when test="document(concat('pag_xml.php?id=', $contentpage ))/descendant::component[@id = $currentcomp]/@display = 'details'">det</xsl:when>
					<xsl:otherwise>sum</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>			
			<xsl:attribute name="class"><xsl:text>component </xsl:text>
				<xsl:choose>
					<xsl:when test="document(concat('pag_xml.php?id=', $currentpage ))/descendant::component[@id = $currentcomp]/@display = 'details'">det</xsl:when>
					<xsl:otherwise>sum</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			</xsl:otherwise>
			</xsl:choose>	
			<xsl:call-template name="componentcoretitle"><xsl:with-param name="currentcomp"><xsl:value-of select="$currentcomp"/></xsl:with-param></xsl:call-template>
			<xsl:if test="$import = 1"><div class="component clearfix"><ul class="options-sm right"><li><a href="javascript:top.embed_add('c{@id}')"><img src="../manager/images/icon_add.gif" alt="Import Icon"/> Import Component</a></li></ul></div></xsl:if>
			<xsl:if test="string-length(component/@id) &gt; 0">			
			<xsl:element name="div">
				<xsl:attribute name="class">
					<xsl:if test="document(concat('com_xml.php?id=', $currentcomp ))/component/@featureformat = 'vertical'">vcallout</xsl:if>
					<xsl:if test="document(concat('com_xml.php?id=', $currentcomp ))/component/@featureformat = 'horizontal'">hcallout</xsl:if>
				</xsl:attribute>
				<xsl:choose>
				<xsl:when test="$state = 'item'">	
				<xsl:for-each select="document(concat('pag_xml.php?id=', $contentpage ))/descendant::component[@id = $currentcomp]/component">
					<xsl:param name="count" select="position()"/>
					<xsl:apply-templates select="document(concat('com_xml.php?id=', @id ))/component">
						<xsl:with-param name="comptype">callout</xsl:with-param>
						<xsl:with-param name="display">
							<xsl:choose>
								<xsl:when test="document(concat('pag_xml.php?id=', $currentpage ))/descendant::component[@id = $currentcomp]/component[$count]/@display = 'details'">det</xsl:when>
								<xsl:otherwise>sum</xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
					</xsl:apply-templates>
				</xsl:for-each>
				</xsl:when>
				<xsl:otherwise>		
				<xsl:for-each select="document(concat('pag_xml.php?id=', $currentpage ))/descendant::component[@id = $currentcomp]/component">
					<xsl:param name="count" select="position()"/>
					<xsl:apply-templates select="document(concat('com_xml.php?id=', @id ))/component">
						<xsl:with-param name="comptype">callout</xsl:with-param>
						<xsl:with-param name="display">
							<xsl:choose>
								<xsl:when test="document(concat('pag_xml.php?id=', $currentpage ))/descendant::component[@id = $currentcomp]/component[$count]/@display = 'details'">det</xsl:when>
								<xsl:otherwise>sum</xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
					</xsl:apply-templates>
				</xsl:for-each>
				</xsl:otherwise>
				</xsl:choose>				
			</xsl:element>
			</xsl:if>
			<xsl:apply-templates select="document(concat('com_xml.php?id=', $currentcomp))/component"/>
		</xsl:element>
		</div>
	</xsl:template>
	
</xsl:stylesheet>

