<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:simple="http://my.netscape.com/rdf/simple/0.9/" xmlns:rss="http://purl.org/rss/1.0/"
	xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:atom="http://purl.org/atom/ns#"
	xmlns:atom1="http://www.w3.org/2005/Atom" xmlns:foaf="http://xmlns.com/foaf/0.1/"
	xmlns:admin="http://webns.net/mvcb/" xmlns:icbm="http://postneo.com/icbm"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	xmlns:enc="http://purl.oclc.org/net/rss_2.0/enc#"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:unic="http://www.uni-c.dk/namespace/"
	exclude-result-prefixes="rdf simple rss dc dcterms content syn atom atom1 foaf admin icbm geo enc wfw unic">
	<xsl:output method="html" omit-xml-declaration="yes"/>

	<xsl:template match="/">
		<xsl:apply-templates select="/rss[@version]/channel"/>
	</xsl:template>

	<xsl:template match="rss/channel">
		<xsl:variable name="antal_kurser" select="count(item)"/>
		<div class="box norm">
			<div class="box-i">
				<h4 class="box-first-h dt">
					<xsl:value-of select="title"/>
				</h4>
				<xsl:choose>
					<xsl:when test="$antal_kurser = 0">
						<p>Der er ingen aktuelle tilbud i dette udtræk fra
							Efteruddannelseskataloget for de gymnasiale uddannelser.<br/>
              Se alle tilbud i <a href="http://efteruddgym.emu.dk/">Efteruddannelseskataloget</a>.
            </p>
					</xsl:when>
					<xsl:otherwise>
						<p>
							<xsl:call-template name="string-replace-all-by-bullet">
								<xsl:with-param name="text"><xsl:value-of select="description"/></xsl:with-param>
								<xsl:with-param name="replace" select="'- '" />
							</xsl:call-template>
						</p>
						<table class="unic_eub">
							<thead>
								<tr>
									<th>Titel</th>
									<th>Dato</th>
									<th align="center">Status</th>
								</tr>
							</thead>
							<tbody>
								<xsl:call-template name="listItem"/>
							</tbody>
						</table>
						<p class="minimal">
							<img src="http://css.emu.dk/images/eub/ledig.gif"/> - Der er ledige pladser<br/>
							<img src="http://css.emu.dk/images/eub/aflyst.gif"/> - Kurset er aflyst </p>
					</xsl:otherwise>
				</xsl:choose>
				<p class="box-f">
					<a href="{link}" title="{title}">L&#230;s&#160;mere&#160;...</a>
				</p>
			</div>
		</div>
	</xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<xsl:template name="listItem">
		<xsl:for-each select="item">
			<xsl:variable name="start" select="unic:course/@fdate"/>
			<xsl:variable name="slut" select="unic:course/@tdate"/>
			<xsl:variable name="tilm" select="unic:course/@ddate"/>
			<xsl:variable name="status" select="unic:course/@status"/>
			<tr class="vevent">
				<td class="summary">
					<a href="{link}" title="Vis detaljer for kurset" class="url">
						<xsl:value-of select="title"/>
					</a>
				</td>
				<td align="right">
					<span title="Kursets start- og evt. slutdato" class="nobr">
						<abbr class="dtstart">
							<span class="dtstart">
								<xsl:call-template name="listUnicDate2">
									<xsl:with-param name="date" select="$start"/>
								</xsl:call-template>
							</span>
						</abbr>
						<xsl:if test="($start != $slut) and ($slut != '')">
							<abbr class="dtend">
								<span class="dtend"> - <xsl:call-template name="listUnicDate2">
										<xsl:with-param name="date" select="$slut"/>
									</xsl:call-template>
								</span>
							</abbr>
						</xsl:if>
					</span>
				</td>
				<td align="center">
					<xsl:call-template name="listUnicDate2">
						<xsl:with-param name="date" select="$tilm"/>
					</xsl:call-template>
					<xsl:choose>
						<xsl:when test="$status = 'Kurset er aflyst'">
							<img src="http://css.emu.dk/images/eub/aflyst.gif"
								alt="Kurset er aflyst." title="Status: Kurset er aflyst!"
								class="dtreg"/>
						</xsl:when>
						<xsl:when test="$status = 'Der er ingen ledige pladser'">
							<img src="http://css.emu.dk/images/eub/ledig.gif"
								alt="Der er ingen ledige pladser."
								title="Status: Der er ingen ledige pladser" class="dtreg"/>
						</xsl:when>
						<xsl:when test="$status = 'Der er ledige pladser'">
							<img src="http://css.emu.dk/images/eub/ledig.gif"
								alt="Der er ledige pladser." title="Status: Der er ledige pladser"
								class="dtreg"/>
						</xsl:when>
					</xsl:choose>
				</td>
			</tr>
		</xsl:for-each>
	</xsl:template>
	
	<!--#####################      FUNCTION 	#####################-->
	<xsl:template name="string-replace-all-by-bullet">
		<xsl:param name="text" />
		<xsl:param name="replace" />
		<xsl:choose>
			<xsl:when test="contains($text, $replace)">
				<xsl:value-of select="substring-before($text,$replace)" />
				<br />&#160;<strong>&#8226;</strong>&#160;
				<xsl:call-template name="string-replace-all-by-bullet">
					<xsl:with-param name="text"
						select="substring-after($text,$replace)" />
					<xsl:with-param name="replace" select="$replace" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template> 

	<!--#####################      FUNCTION 	#####################-->
	<xsl:template name="listUnicDate1">
		<xsl:param name="date">1900-01-01</xsl:param>
		<xsl:if test="$date != ''">
			<xsl:value-of select="$date"/>
		</xsl:if>
	</xsl:template>

	<!--#####################      FUNCTION 	#####################-->
	<xsl:template name="listUnicDate2">
		<xsl:param name="date">1900-01-01</xsl:param>
		<xsl:if test="$date != ''">
			<xsl:variable name="year" select="substring($date, 1, 4)"/>
			<xsl:variable name="month" select="substring($date, 5, 2)"/>
			<xsl:variable name="day" select="substring($date, 7, 2)"/>
			<xsl:value-of select="$day"/><xsl:text>/</xsl:text><xsl:value-of select="$month"
				/>&#160;<xsl:value-of select="$year"/>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>

