<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
	<xsl:output method="html"/>
	<xsl:variable name="title" select="/rss/channel/title"/>
	<xsl:variable name="description" select="/rss/channel/description"/>
	<xsl:variable name="author" select="/rss/channel/itunes:author"/>
	<xsl:template match="/">
		<html>
		<head>
			<title><xsl:value-of select="$author"/> Podcast: <xsl:value-of select="$title"/> (XML)</title>
			<link rel="stylesheet" href="http://bigcity.emapdigitalradio.com/bigcity/rss.css" type="text/css"/>
		</head>			
		<xsl:apply-templates select="rss/channel"/>				
		</html>
	</xsl:template>
	<xsl:template match="channel">
		<body>
			<div id="top">
				<img width="180" height="90" border="0" alt="{itunes:author}">
					<xsl:attribute name="src">
						<xsl:choose>
							<xsl:when test="contains(link,'metroradio')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_metroradio.gif</xsl:text>
							</xsl:when>
							<xsl:when test="contains(link,'tfmradio')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_tfmradio.gif</xsl:text>
							</xsl:when>
							<xsl:when test="contains(link,'vikingfm')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_vikingfm.gif</xsl:text>
							</xsl:when>
							<xsl:when test="contains(link,'hallamfm')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_hallamfm.gif</xsl:text>
							</xsl:when>
							<xsl:when test="contains(link,'radioaire')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_radioaire.gif</xsl:text>
							</xsl:when>
							<xsl:when test="contains(link,'radiocity')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_radiocity.gif</xsl:text>
							</xsl:when>
							<xsl:when test="contains(link,'rockfm')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_rockfm.gif</xsl:text>
							</xsl:when>
							<xsl:when test="contains(link,'key103')">
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_key103.gif</xsl:text>
							</xsl:when>						
							<xsl:otherwise>
								<xsl:text>http://bigcity.emapdigitalradio.com/bigcity/logo_emap.gif</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
				</img>
				<h1><a href="{link}"><xsl:value-of select="$author"/> Podcast: <xsl:value-of select="$title"/></a></h1>
				<p><xsl:value-of select="$description"/></p>
			</div>
			<hr/>
			<div id="left">
				<h2>Download</h2>
				<p>You can download the latest the podcast MP3 directly to your computer and play it back through your chosen music media player - Windows Media, Real Player, iTunes or similar. You can then transfer the file to your MP3 player - check your media player Help file for full instructions on how to do this.</p>
				<ul>
					<xsl:apply-templates select="item"/>
				</ul>
				<p>To download the file, use the download button above using the right button on your mouse. You will then be given a series of options, one of which should be 'Save Target As', 'Save File As', 'Save Link As' or similar. Choose a folder where you usually store your audio files and click the 'Save' button. Then simply open the folder where you saved the file, double-click on the file name (or select the file, choose the 'File' option and then select 'Open') and the file will then play in your default media player.</p>
				<p>For Apple Mac users, the process is the same, but to download the file, all you have to do is select 'Ctrl' and click on the link. Then follow the instructions as above.</p>
			</div>
			<div id="right">
				<h2>Subscribe</h2>
				<h3>Subscribe via iTunes</h3>
				<p>Click the button below to subscribe to the '<xsl:value-of select="$title"/>' directly in iTunes. Once the podcast page has loaded in iTunes click the 'Subscribe' button at the top.</p>
				<xsl:variable name="guid" select="/rss/channel/item/guid"/>
				<xsl:variable name="guidurl" select="substring-after($guid,'http://')"/>
				<xsl:variable name="end_string">
					<xsl:call-template name="stringTrim">
						<xsl:with-param name="string" select="$guidurl"/>
					</xsl:call-template>
				</xsl:variable>
				<a href="itpc://{substring-before($guidurl,$end_string)}rss.xml"><img src="http://bigcity.emapdigitalradio.com/bigcity/button_itunes.gif" width="91" height="17" alt="Add to iTunes"/></a>
				<p>iTunes (for Mac and Windows) supports podcasts and also houses the iTunes Music Store which has loads of free podcasts for you to browse and download.</p>
				<p>Subscribing to the '<xsl:value-of select="$title"/>' in iTunes means you will receive each episode as soon as it becomes available, straight into your iTunes Music Library. Please make sure you have the most up-to-date version of iTunes on your computer, available from <a href="http://www.apple.com/itunes" target="top">www.apple.com/itunes</a>.</p> 
				<h3>Subscribe using other Podcasting software</h3>
				<p>You can use the following URL to manually subscribe to the MP3 version of the '<xsl:value-of select="$title"/>'. Copy the URL below and paste it into podcasting software of your choice (such as <a href="http://juicereceiver.sourceforge.net/" target="top">Juice</a> or <a href="http://www.dopplerradio.net/" target="top">Doppler</a> for PC and <a href="http://transistr.com/" target="top">Transistr</a> for Mac.)</p>
				<span style="border:1px solid #000;padding:2px;">http://<xsl:value-of select="substring-before($guidurl,$end_string)"/>rss.xml</span>
			</div>
			<hr/>
			<div id="footer">
				<h2>What is a Podcast?</h2>
				<p>A Podcast is a media file that can be downloaded directly or via syndication feeds to computers or portable media players such as an iPod. These update whenever a new episode is released.  Podcasts can be updated hourly, daily, weekly, monthly or whenever the publisher decides to send out a new episode. You don't need an iPod to listen to one - any MP3 player will do!</p>
			</div>
			<hr/>
			<p>(c) Copyright 2007 Emap Radio.</p>
		</body>
	</xsl:template>
	<xsl:template match="item">
				<li style="list-style type:none;">
					<a href="{guid}" class="item"><xsl:value-of select="title"/></a><br/>
					<xsl:value-of select="description"/>
				</li>
	</xsl:template>
	<xsl:template name="stringTrim">
		<xsl:param name="string"/>
		<xsl:choose>
			<xsl:when test="contains($string,'/')">
				<xsl:call-template name="stringTrim">
					<xsl:with-param name="string" select="substring-after($string,'/')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$string"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
