<?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:variable name="type"><xsl:value-of select="name(document(concat('res_xml.php?id=', $childsite ))/resource/*[8])"/></xsl:variable>
	
<!-- LO PAGE -->
	
	<xsl:template match="resource">
		<div id="header" xmlns="http://www.w3.org/1999/xhtml">
			<ul class="options-tp">
				<xsl:apply-templates select="document(concat('sit_xml.php?id=', $parentsite ))/site/course/navigation/utilitynav"/>
			</ul>	
			<div id="titlebar">					
				<div>
					<h1><xsl:value-of select="document(concat('sit_xml.php?id=', $parentsite ))/site/name"/></h1>
					<h2><xsl:value-of select="name()"/></h2>
					<h3><a href="page.php?id={$currentpage}">&lt; Back to Activity</a></h3>
				</div>			
			</div>	
		</div>
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">
			<h3><xsl:value-of select="/resource/name"/></h3>
		</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">	
		<xsl:param name="width"><xsl:choose><xsl:when test="number(file/width) &gt; 490">490</xsl:when><xsl:otherwise><xsl:value-of select="file/width"/></xsl:otherwise></xsl:choose></xsl:param>
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">			
			<img src="../data/resource/{/resource/@id}/{file/filename}" alt="{/resource/name}" class="galdet" width="{$width}"/>
		</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">	
		<xsl:param name="width">
			<xsl:value-of select="number(hires/width)"/>
		</xsl:param>
		<xsl:param name="height">
			<xsl:value-of select="number(hires/height)+15"/>
		</xsl:param>
		<div xmlns="http://www.w3.org/1999/xhtml" class="component">		
			<embed src="../data/resource/{/resource/@id}/{hires/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="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="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">
							<xsl:choose>
							<xsl:when test="$type = 'link'">
                           		<h4 class="call"><img src="images/call_icon_11.gif" alt="-" class="icon" />Visit</h4>
							</xsl:when>
							<xsl:otherwise>
                          		<h4 class="call"><img src="images/call_icon_2.gif" alt="-" class="icon" />Download</h4>
							</xsl:otherwise>
							</xsl:choose>
                           <div class="callshell">
                              <table class="complist" style="margin-top: 0;">
                                 <tr>
                                    <td><h4>
									<xsl:choose>
									<xsl:when test="$type = 'link'">
                           				<img src="images/icon_url.gif" class="icon left" alt="-"/>
									</xsl:when>
									<xsl:otherwise>
                          				<img src="images/icon_{$icon}.gif" class="icon left" alt="-"/>
									</xsl:otherwise>
									</xsl:choose>
                                       	<xsl:value-of select="/resource/name"/></h4>                                       	
										<div>									
											<xsl:choose>
											<xsl:when test="name() = 'link'">
											<p class="long">Go to: <a href="{url}" target="_new"><xsl:value-of select="url"/></a></p>
											</xsl:when>
											<xsl:when test="name() = 'article'">
											<p class="long"><a href="get_article.php?id={/resource/@id}" target="_new">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="../data/resource/{/resource/@id}/{lowres/filename}" target="_new"><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="../data/resource/{/resource/@id}/{hires/filename}" target="_new"><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="../data/resource/{/resource/@id}/{file/filename}" target="_new"><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>
											<p><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></p>
										</div>
									</td>
								 </tr>
								 </xsl:if>
								 
								 <xsl:if test="$icon = 'mpeg'">
								 <tr>
								 	<td>									
										<div>
											<p><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></p>
										</div>
									</td>
								 </tr>
								 </xsl:if>
								 
								 <xsl:if test="$icon = 'avi'">
								 <tr>
								 	<td>									
										<div>
											<p><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></p>
										</div>
									</td>
								 </tr>
								 </xsl:if>
								 
								 <xsl:if test="$icon = 'pdf'">
								 <tr>
								 	<td>									
										<div>
											<p><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></p>
										</div>
									</td>
								 </tr>
								 </xsl:if>		
								 
								 <xsl:if test="$icon = 'swf'">
								 <tr>
								 	<td>									
										<div>
											<p><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></p>
										</div>
									</td>
								 </tr>
								 </xsl:if>	
								 
								 <xsl:if test="$icon = 'mov'">
								 <tr>
								 	<td>									
										<div>
											<p><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></p>
										</div>
									</td>
								 </tr>
								 </xsl:if>	
								 
								 <xsl:if test="$icon = 'mp3'">
								 <tr>
								 	<td>									
										<div>
											<p><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></p>
										</div>
									</td>
								 </tr>
								 </xsl:if>										 						 
								 
                              </table>
                              <hr class="on" />
                           </div>
                        </div>                        
                     </div>
				<xsl:if test="$type != 'article'"><p><xsl:value-of select="/resource/description" disable-output-escaping="yes"/></p></xsl:if>
				<hr class="on"></hr>
			</div>
	</xsl:template>
	
</xsl:stylesheet>

