<?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 class="block vcallout">
			<h2><span><xsl:value-of select="/resource/name"/></span></h2>
			<h4><a href="page.php?id={$currentpage}">&lt; Back to <xsl:value-of select="document(concat('pag_xml.php?id=', $currentpage))/page/name"/></a></h4>
			
			<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>
		<!--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">		
		<xsl:call-template name="resourceitem"/>
		<!--div xmlns="http://www.w3.org/1999/xhtml" class="block"-->			
			<xsl:value-of select="body"/>
		<!--/div-->
	</xsl:template>
	
	<xsl:template match="image">	
		<xsl:call-template name="resourceitem"/>
			<img src="../data/resource/{/resource/@id}/{file/filename}" alt="{/resource/name}" class="galdet"/>
		<!--div xmlns="http://www.w3.org/1999/xhtml" class="block"-->			
		<!--/div-->
	</xsl:template>
	
	<xsl:template match="flash">	
		<xsl:call-template name="resourceitem"/>
		<xsl:param name="width">
			<xsl:choose>
			<xsl:when test="file/width &gt; 750">
				<xsl:value-of select="number(file/width)*.5"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="file/width"/>
			</xsl:otherwise>
			</xsl:choose>
		</xsl:param>
		<xsl:param name="height">
			<xsl:choose>
			<xsl:when test="file/width &gt; 750">
				<xsl:value-of select="number(file/height)*.5"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="file/height"/>
			</xsl:otherwise>
			</xsl:choose>
		</xsl:param>
		<!--div xmlns="http://www.w3.org/1999/xhtml" class="block"-->			
			<embed src="../data/resource/{/resource/@id}/{file/filename}" autoplay="true" width="{$width}" height="{$height}" controller="true" style="background-color:#FFFFFF;"></embed>
		<!--/div-->
	</xsl:template>
	
	<xsl:template match="movie">	
		<xsl:call-template name="resourceitem"/>
		<!--div xmlns="http://www.w3.org/1999/xhtml" class="block"-->		
			<embed src="../data/resource/{/resource/@id}/{hires/filename}" autoplay="true" controller="true" style="background-color:#FFFFFF;"></embed>
		<!--/div-->
	</xsl:template>
	
	<xsl:template match="sound">	
		<xsl:call-template name="resourceitem"/>
		<!--div xmlns="http://www.w3.org/1999/xhtml" class="block"-->			
			<embed src="../data/resource/{/resource/@id}/{file/filename}" autoplay="true" controller="true" style="background-color:#FFFFFF;"></embed>
		<!--/div-->
	</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>
		
				<ul class="content-list">
			                        <li class="sum">
			                        	<h3><span>Download</span></h3>
			                        	<div class="block">
			                                       	<h4><img src="images/icon_{$icon}.gif" class="icon left" alt="-"/> <xsl:value-of select="/resource/name"/></h4>
						<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:otherwise>
								<p>Download: <a href="../data/resource/{/resource/@id}/{file/filename}"><xsl:value-of select="file/filename"/></a> (<xsl:value-of select="/resource/*/file/size"/>)</p>
							</xsl:otherwise>
						</xsl:choose>
						 <xsl:if test="$icon = 'wmv'">
							<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>
						 </xsl:if>
						 
						 <xsl:if test="$icon = 'pdf'">
							<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>
						 </xsl:if>		
						 
						 <xsl:if test="$icon = 'swf'">
							<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>
						 </xsl:if>	
						 
						 <xsl:if test="$icon = 'mov'">
							<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>
						 </xsl:if>	
						 
						 <xsl:if test="$icon = 'mp3'">
							<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>
						 </xsl:if>
			                        	</div>
			                        </li>                        
			                     </ul>
				<xsl:if test="$type != 'article'"><p><xsl:value-of select="/resource/description" disable-output-escaping="yes"/></p></xsl:if>
	</xsl:template>
	
</xsl:stylesheet>

