<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:import href="main.xsl"/>

	<xsl:template match="content/archive">
		<xsl:apply-templates select="section[1]/link[image]" mode="invoked"/>
		
		<dl class="mention" id="posted">
			<dt>Posted </dt>
			<dd>
				<xsl:call-template name="date-generator"/>
			</dd>
		</dl>
		
		<xsl:apply-templates/>
	</xsl:template>

	<!-- suppression -->
	<xsl:template match="archive/section[1]/link[image]"/>

<xsl:template match="archive/section[1]/link[image]" mode="invoked">
	<dl class="framed preview thumb image">
		<dt>
			<a title="{@title}">
				<xsl:attribute name="href">
					<xsl:call-template name="target-handler">
						<xsl:with-param name="target" select="@target"/>
					</xsl:call-template>
				</xsl:attribute>

				<img alt="{image/@title}">
					<xsl:attribute name="src">
						<xsl:call-template name="target-handler">
							<xsl:with-param name="target" select="image/@source"/>
						</xsl:call-template>
					</xsl:attribute>
				</img>
			</a>
		</dt>
		<xsl:apply-templates select="image/*"/>
	</dl>
</xsl:template>

<xsl:template match="archive/section[1]/link/image"/>

<xsl:template match="archive/section[1]/link/image/caption">
	<dd>
		<a href="{ancestor::link/@target}" title="{ancestor::link/@title}">
			<xsl:apply-templates/>
		</a>
	</dd>	
</xsl:template>

	<xsl:template match="related">
		<h5>
			<xsl:text>What</xsl:text>
			<xsl:call-template name="entity-handler">
				<xsl:with-param name="name">rsquo</xsl:with-param>
			</xsl:call-template>
			<xsl:text>s New</xsl:text>
		</h5>
		<ul class="links">
			<li>
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="target-handler">
							<xsl:with-param name="target">/photos/wildlife/</xsl:with-param>	
						</xsl:call-template>
					</xsl:attribute>
					<xsl:text>Wildlife Photo Collection</xsl:text>
				</a>
			</li>
			<li>
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="target-handler">
							<xsl:with-param name="target">/work/sermo/</xsl:with-param>	
						</xsl:call-template>
					</xsl:attribute>
					<xsl:text>Sermo Project</xsl:text>
				</a>
			</li>
			<li>
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="target-handler">
							<xsl:with-param name="target">/photos/ohfall/</xsl:with-param>	
						</xsl:call-template>
					</xsl:attribute>
					<xsl:text>Ohio Fall Photo Collection</xsl:text>
				</a>
			</li>
			<li>
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="target-handler">
							<xsl:with-param name="target">/work/ajax/</xsl:with-param>	
						</xsl:call-template>
					</xsl:attribute>
					<xsl:text>Ajax Libraries</xsl:text>
				</a>
			</li>
			<li>
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="target-handler">
							<xsl:with-param name="target">/profile/Scott_Martin.pdf</xsl:with-param>	
						</xsl:call-template>
					</xsl:attribute>
					<xsl:text>Resume as </xsl:text>
					<acronym title="Portable Document Format">PDF</acronym>
				</a>
			</li>
			
		</ul>
		
		<xsl:if test="archive[not(@title=/page/content/archive/@name)]">
			<h5>
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="target-handler">
							<xsl:with-param name="target">/archives/</xsl:with-param>		
						</xsl:call-template>	
					</xsl:attribute>
					<xsl:text>Archives</xsl:text>
				</a>
			</h5>
			<ul class="links">
				<xsl:apply-templates select="archive[not(@title=/page/content/archive/@name)]">
					<xsl:sort select="@year" data-type="number" order="descending"/>
					<xsl:sort select="@month" data-type="number" order="descending"/>
					<xsl:sort select="@day" data-type="number" order="descending"/>
				</xsl:apply-templates>
			</ul>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="related/archive">
		<li>
			<a>
				<xsl:attribute name="href">
					<xsl:call-template name="target-handler">
						<xsl:with-param name="target">
							<xsl:text>/archives/</xsl:text>
							<xsl:value-of select="@path"/>
							<xsl:text>/</xsl:text>
						</xsl:with-param>		
					</xsl:call-template>
				</xsl:attribute>
				<xsl:value-of select="@title"/>
			</a>
		</li>
	</xsl:template>

</xsl:stylesheet>
