<?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"/>
	
<!-- SESSION PAGE -->
	
	<xsl:template match="item">
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">
			<h2><xsl:value-of select="document(concat('sit_xml.php?id=', /page/@siteid))/site/name"/></h2>		
		</div>
		<xsl:for-each select="component">
			<xsl:call-template name="componentshell"/>	
		</xsl:for-each>
		
	</xsl:template>
	
	<xsl:template match="contentobject">
	<xsl:param name="contentpage" select="document(concat('sit_xml.php?id=', $childsite))/site/*/page/@id"/>

		<div xmlns="http://www.w3.org/1999/xhtml" class="component">
			<h2><xsl:value-of select="document(concat('sit_xml.php?id=', $childsite))/site/name"/></h2>
		</div>

		<div xmlns="http://www.w3.org/1999/xhtml" id="lo-details">
		
		<xsl:for-each select="document(concat('pag_xml.php?id=', $contentpage))/page/item/component">
			<xsl:call-template name="componentshell"><xsl:with-param name="contentpage"><xsl:value-of select="$contentpage"/></xsl:with-param></xsl:call-template>
		</xsl:for-each>	
		
		</div>

	</xsl:template>
	
	<xsl:template match="course">

		<div xmlns="http://www.w3.org/1999/xhtml" class="component">			
			<h2><xsl:value-of select="/site/name"/></h2>
		</div>

		<div xmlns="http://www.w3.org/1999/xhtml" id="lo-details">
		
			<div class="component">
				<img src="{document(concat('sit_xml.php?id=', $childsite ))/site/course/thumbnail/@filename}" class="galdet" alt="{/site/name}"/>
			</div>
		
			<div class="component">
				<p><xsl:value-of select="/site/description"/></p>
				<p><a href="{url}"><xsl:value-of select="url"/></a></p>	
				<hr class="on"></hr>
			</div>
						
		</div>

	</xsl:template>
	
	<xsl:template match="resource">

		<div xmlns="http://www.w3.org/1999/xhtml" class="component">
			<h2><xsl:value-of select="/resource/name"/></h2>
		</div>
		<div xmlns="http://www.w3.org/1999/xhtml" id="lo-details">
		<xsl:apply-templates select="document"/>
		<xsl:apply-templates select="link"/>
		<xsl:apply-templates select="image"/>
		<xsl:apply-templates select="flash"/>
		<xsl:apply-templates select="movie"/>
		<xsl:apply-templates select="sound"/>
		<xsl:apply-templates select="article"/>
						
		</div>		
	</xsl:template>
	
	<xsl:template match="document">	
		<xsl:call-template name="resourceitem"/>
	</xsl:template>
	
	<xsl:template match="link">	
		<xsl:call-template name="resourceitem"/>
	</xsl:template>
	
	<xsl:template match="article">		
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">			
			<xsl:value-of select="body"/>
		</div>
		<xsl:call-template name="resourceitem"/>
	</xsl:template>
	
	<xsl:template match="image">	
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">			
			<img src="../data/resource/{/resource/@id}/{file/filename}" alt="{/resource/name}" class="galdet"/>
		</div>
		<xsl:call-template name="resourceitem"/>
	</xsl:template>
	
	<xsl:template match="flash">	
		<xsl:param name="width">
			<xsl:if test="file/width &gt; 750">
				<xsl:value-of select="number(file/width)*.5"/>
			</xsl:if>
		</xsl:param>
		<xsl:param name="height">
			<xsl:if test="file/width &gt; 750">
				<xsl:value-of select="number(file/height)*.5"/>
			</xsl:if>
		</xsl:param>
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">			
			<embed src="../data/resource/{/resource/@id}/{file/filename}" autoplay="true" width="{$width}" height="{$height}" controller="true" style="background-color:#FFFFFF;"></embed>
		</div>
		<xsl:call-template name="resourceitem"/>
	</xsl:template>
	
	<xsl:template match="movie">	
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">		
			<embed src="../data/resource/{/resource/@id}/{hires/filename}" autoplay="true" controller="true" style="background-color:#FFFFFF;"></embed>
		</div>
		<xsl:call-template name="resourceitem"/>
	</xsl:template>
	
	<xsl:template match="sound">	
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">			
			<embed src="../data/resource/{/resource/@id}/{file/filename}" autoplay="true" controller="true" style="background-color:#FFFFFF;"></embed>
		</div>
		<xsl:call-template name="resourceitem"/>
	</xsl:template>
	
	<xsl:template name="resourceitem">	
	<xsl:param name="type"><xsl:value-of select="name(document(concat('res_xml.php?id=', $childsite ))/resource/*[8])"/></xsl:param>		
			<xsl:param name="filename">
			
			<xsl:choose>
				<xsl:when test="$type = 'movie'">
					<xsl:choose>
						<xsl:when test="lowres/filename/text()">
							<xsl:value-of select="lowres/filename"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="hires/filename"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="file/filename"/>
				</xsl:otherwise>
			</xsl:choose>
			
			</xsl:param>			
			<xsl:param name="iconname"><xsl:value-of select="substring-after($filename,'.')"/></xsl:param>
			<xsl:param name="icon"><xsl:value-of select="translate($iconname, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:param>
		
			<div xmlns="http://www.w3.org/1999/xhtml" class="component">
				<div class="vcallout">
                        <div class="callout sum">
                           <h4 class="call"><img src="images/call_icon_2.gif" alt="-" class="icon" />Download</h4>
                           <div class="callshell">
                              <table class="complist" style="margin-top: 0;">
                                 <tr>
                                    <td>
                                       	<h4><img src="images/icon_{$icon}.gif" class="icon left" alt="-"/> <xsl:value-of select="/resource/name"/></h4>                                       	
										<div>									
											<xsl:choose>
											<xsl:when test="name() = 'link'">
											<p class="long">Go to: <a href="{url}"><xsl:value-of select="url"/></a></p>
											</xsl:when>
											<xsl:when test="name() = 'article'">
											<p class="long"><a href="#">Download as Text</a></p>
											</xsl:when>
											<xsl:when test="name() = 'movie'">
											<xsl:if test="lowres/filename/text()">
											<p>Download Low Resolution Version: <a href="{lowres/filename}"><xsl:value-of select="lowres/filename"/></a> (<xsl:value-of select="/resource/*/lowres/size"/>)</p>
											</xsl:if>
											<xsl:if test="hires/filename/text()">
											<p>Download Hi Resolution Version: <a href="{hires/filename}"><xsl:value-of select="hires/filename"/></a> (<xsl:value-of select="/resource/*/hires/size"/>)</p>
											</xsl:if>
											</xsl:when>
											<xsl:otherwise>
											<p>Download: <a href="{filename}"><xsl:value-of select="$filename"/></a> (<xsl:value-of select="/resource/*/file/size"/>)</p>
											</xsl:otherwise>
											</xsl:choose>
										</div>
                                    </td>
                                 </tr>
								 
								 <xsl:if test="$icon = 'wmv'">
								 <tr>
								 	<td>									
										<div>
											<a href="http://www.microsoft.com/windows/windowsmedia/player/download/download.aspx"><img src="images/plug_wmv.gif" alt="Windows Media Plugin" style="float: none; margin-bottom: 6px;"/></a><br/>Having trouble viewing the movie?<br/><a href="http://www.microsoft.com/windows/windowsmedia/player/download/download.aspx">Download windows media player</a>
										</div>
									</td>
								 </tr>
								 </xsl:if>
								 
								 <xsl:if test="$icon = 'pdf'">
								 <tr>
								 	<td>									
										<div>
											<a href="http://www.adobe.com/products/acrobat/readstep2.html"><img src="images/plug_pdf.gif" alt="Adobe Acrobat Reader" style="float: none; margin-bottom: 6px;"/></a><br/>Having trouble viewing the pdf?<br/><a href="http://www.adobe.com/products/acrobat/readstep2.html">Download Adobe Acrobat Reader</a>
										</div>
									</td>
								 </tr>
								 </xsl:if>		
								 
								 <xsl:if test="$icon = 'swf'">
								 <tr>
								 	<td>									
										<div>
											<a href="http://sdc.shockwave.com/shockwave/download/download.cgi?"><img src="images/plug_swf.gif" alt="Macromedia Flash" style="float: none; margin-bottom: 6px;"/></a><br/>Having trouble viewing the Flash movie?<br/><a href="http://sdc.shockwave.com/shockwave/download/download.cgi?">Download the Macromedia Flash Player</a>
										</div>
									</td>
								 </tr>
								 </xsl:if>	
								 
								 <xsl:if test="$icon = 'mov'">
								 <tr>
								 	<td>									
										<div>
											<a href="http://www.apple.com/quicktime/download/win.html"><img src="images/plug_mov.gif" alt="Quicktime" style="float: none; margin-bottom: 6px;"/></a><br/>Having trouble viewing the movie?<br/><a href="http://www.apple.com/quicktime/download/win.html">Download the Quicktime Player</a>
										</div>
									</td>
								 </tr>
								 </xsl:if>	
								 
								 <xsl:if test="$icon = 'mp3'">
								 <tr>
								 	<td>									
										<div>
											<a href="http://www.apple.com/quicktime/download/win.html"><img src="images/plug_mov.gif" alt="Quicktime" style="float: none; margin-bottom: 6px;"/></a><br/>Having trouble listening to the MP3?<br/><a href="http://www.apple.com/quicktime/download/win.html">Download the Quicktime Player</a>
										</div>
									</td>
								 </tr>
								 </xsl:if>										 						 
								 
                              </table>
                              <hr class="on" />
                           </div>
                        </div>                        
                     </div>
				<p><xsl:value-of select="/resource/description"/></p>
				<hr class="on"></hr>
			</div>
	</xsl:template>
	
	
</xsl:stylesheet>

