<?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"/>
	
<!-- LINKS COMPONENT -->	
	
	<xsl:template match="compgallery">
		<ul class="thumbwrap" xmlns="http://www.w3.org/1999/xhtml">
			<xsl:for-each select="resource">				
			<xsl:for-each select="document(concat('res_xml.php?id=', @id))/resource/movie">		
			<xsl:param name="filename">
			
					<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:param>	
			<xsl:param name="iconname"><xsl:value-of select="substring-after($filename,'.')"/></xsl:param>
			<xsl:param name="icon"><xsl:value-of select="translate($iconname, 'ABCDEFGHIJKLMNOPQRSTUVZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:param>
			<li class="gal">			
				
				<xsl:element name="a">
				<xsl:attribute name="href"><xsl:choose><xsl:when test="$manager = 1">#</xsl:when><xsl:otherwise>page_resource.php?pageID=<xsl:value-of select="$currentpage"/>&amp;resourceID=<xsl:value-of select="/resource/@id"/></xsl:otherwise></xsl:choose></xsl:attribute>
				<img src="images/icon_{$icon}.gif" class="galicon detail" alt="-"/>
				<xsl:element name="img">
					<xsl:attribute name="src"><xsl:choose><xsl:when test="string-length(thumbnail/@filename) &gt; 0"><xsl:value-of select="thumbnail/@filename"/></xsl:when><xsl:otherwise>images/gal_default_<xsl:value-of select="$icon"/>.gif</xsl:otherwise></xsl:choose></xsl:attribute>
					<xsl:attribute name="class">galimg</xsl:attribute>
					<xsl:attribute name="alt"><xsl:value-of select="../name"/></xsl:attribute>
				</xsl:element><h6><xsl:value-of select="../name"/></h6><div class="detail"><xsl:value-of select="../description" disable-output-escaping="yes"/></div></xsl:element>
			</li>
			</xsl:for-each>
			<xsl:for-each select="document(concat('res_xml.php?id=', @id))/resource/image">	
			<xsl:param name="filename"><xsl:value-of select="file/filename"/></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, 'ABCDEFGHIJKLMNOPQRSTUVZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:param>
			<li class="gal">
			
				<xsl:element name="a">
				<xsl:attribute name="href"><xsl:choose><xsl:when test="$manager = 1">#</xsl:when><xsl:otherwise>page_resource.php?pageID=<xsl:value-of select="$currentpage"/>&amp;resourceID=<xsl:value-of select="/resource/@id"/></xsl:otherwise></xsl:choose></xsl:attribute><img src="images/icon_{$icon}.gif" class="galicon detail" alt="-"/>
				<xsl:element name="img">
					<xsl:attribute name="src"><xsl:choose><xsl:when test="string-length(thumbnail/@filename) &gt; 0"><xsl:value-of select="thumbnail/@filename"/></xsl:when><xsl:otherwise>images/gal_default_<xsl:value-of select="$icon"/>.gif</xsl:otherwise></xsl:choose></xsl:attribute>
					<xsl:attribute name="class">galimg</xsl:attribute>
					<xsl:attribute name="alt"><xsl:value-of select="../name"/></xsl:attribute>
				</xsl:element><h6><xsl:value-of select="../name"/></h6><div class="detail"><xsl:value-of select="../description" disable-output-escaping="yes"/></div></xsl:element>
			</li> 	
			</xsl:for-each>
			<xsl:for-each select="document(concat('res_xml.php?id=', @id))/resource/sound">	
			<xsl:param name="filename"><xsl:value-of select="file/filename"/></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, 'ABCDEFGHIJKLMNOPQRSTUVZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:param>
			<li class="gal">
			
				<xsl:element name="a">
				<xsl:attribute name="href"><xsl:choose><xsl:when test="$manager = 1">#</xsl:when><xsl:otherwise>page_resource.php?pageID=<xsl:value-of select="$currentpage"/>&amp;resourceID=<xsl:value-of select="/resource/@id"/></xsl:otherwise></xsl:choose></xsl:attribute><img src="images/icon_{$icon}.gif" class="galicon detail" alt="-"/>
				<xsl:element name="img">
					<xsl:attribute name="src"><xsl:choose><xsl:when test="string-length(thumbnail/@filename) &gt; 0"><xsl:value-of select="thumbnail/@filename"/></xsl:when><xsl:otherwise>images/gal_default_mp3.gif</xsl:otherwise></xsl:choose></xsl:attribute>
					<xsl:attribute name="class">galimg</xsl:attribute>
					<xsl:attribute name="alt"><xsl:value-of select="../name"/></xsl:attribute>
				</xsl:element><h6><xsl:value-of select="../name"/></h6><div class="detail"><xsl:value-of select="../description" disable-output-escaping="yes"/></div></xsl:element>
			</li> 	
			</xsl:for-each>				
			<xsl:for-each select="document(concat('res_xml.php?id=', @id))/resource/flash">
			<xsl:param name="filename"><xsl:value-of select="file/filename"/></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, 'ABCDEFGHIJKLMNOPQRSTUVZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:param>
			<li class="gal">
			
				<xsl:element name="a">
				<xsl:attribute name="href"><xsl:choose><xsl:when test="$manager = 1">#</xsl:when><xsl:otherwise>page_resource.php?pageID=<xsl:value-of select="$currentpage"/>&amp;resourceID=<xsl:value-of select="/resource/@id"/></xsl:otherwise></xsl:choose></xsl:attribute><img src="images/icon_{$icon}.gif" class="galicon detail" alt="-"/>
				<xsl:element name="img">
					<xsl:attribute name="src"><xsl:choose><xsl:when test="string-length(thumbnail/@filename) &gt; 0"><xsl:value-of select="thumbnail/@filename"/></xsl:when><xsl:otherwise>images/gal_default_swf.gif</xsl:otherwise></xsl:choose></xsl:attribute>
					<xsl:attribute name="class">galimg</xsl:attribute>
					<xsl:attribute name="alt"><xsl:value-of select="../name"/></xsl:attribute>
				</xsl:element><h6><xsl:value-of select="../name"/></h6><div class="detail"><xsl:value-of select="../description" disable-output-escaping="yes"/></div></xsl:element>
			</li> 	
			</xsl:for-each>		
			</xsl:for-each>
		</ul>	
	</xsl:template>
	
</xsl:stylesheet>
