<?xml version="1.0" encoding="iso-8859-1"?>


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

	<xsl:template match="processing-instruction('xml-stylesheet')">
		<xsl:param name="target" select="."/>
		<xsl:variable name="quote">"</xsl:variable>
		<xsl:variable name="url"><xsl:value-of select="substring-before( substring-after($target, concat('href=',$quote)), $quote)"/></xsl:variable>
		
		<xsl:if test="contains($url,'css')">
			<style type="text/css">
				@import url(<xsl:value-of select="$url"/>);
			</style>
		</xsl:if>	
	</xsl:template>
	
	<xsl:template match="image">
		<xsl:variable name="url"><xsl:value-of select="url"/></xsl:variable>
      	<xsl:text/>
      	<xsl:choose>
      		<xsl:when test="$url = 'http://www.wetpaint.com/img/logo.gif'">
      		<div style="padding-bottom:10px">
				<a href="{link}" title="Link to original website"><span style="background-color:#ffffff;margin:5px;padding:5px;"><img src="{url}" id="feedimage" alt="Link to {title}"/></span></a>
			</div>
		    </xsl:when>
		   	<xsl:otherwise>
			<a href="{link}" title="Link to original website"><img src="{url}" id="feedimage" alt="Link to {title}"/></a>
		   	</xsl:otherwise>
      	</xsl:choose>
  	</xsl:template>	
	
	<xsl:template match="channel">
	  <xsl:for-each select="item">
	  <div class="item">
	    <h2><a href="{link}" rel="bookmark"><xsl:value-of select="title"/></a></h2>
	      <xsl:choose>
	         <xsl:when xmlns:xhtml="http://www.w3.org/1999/xhtml" test="xhtml:body">
	            <xsl:copy-of select="xhtml:body/*"/>
	         </xsl:when>
	         <xsl:when xmlns:xhtml="http://www.w3.org/1999/xhtml" test="xhtml:div">
	            <xsl:copy-of select="xhtml:div"/>
	         </xsl:when>
	         <xsl:when xmlns:content="http://purl.org/rss/1.0/modules/content/" test="content:encoded">
	            <xsl:value-of select="content:encoded" disable-output-escaping="yes"/>
	         </xsl:when>
	         <xsl:when test="description">
		    	<div class="rssBody">
		            <xsl:value-of select="description" disable-output-escaping="yes"/>
		      	</div>
	         </xsl:when>
	      </xsl:choose>
	  </div>
	  </xsl:for-each>
	</xsl:template>
	
	<xsl:template match="/">
		<xsl:variable name="feedTitle"><xsl:value-of select="rss/channel/title"/> RSS Feed</xsl:variable>	
	<html>
	  <head>
	    <title><xsl:value-of select="$feedTitle"/></title>
	     <xsl:apply-templates select="processing-instruction('xml-stylesheet')"/>
	  </head>
	  <body style="overflow:auto">
		<div id="allcontent" style="position:static;width:auto;height:auto">
			<div id="allcontentInner">	
				<div id="userHeader">
					<div id="userBrand">
				      	<div style="margin-top:2px;float:right"><img alt="RSS" src="/img/item/feed-icon-24x24.png"/></div>
						<div id="userActions">
							<ul>
								<li class="first">Powered by <a href="http://www.wetpaint.com" target="_blank">Wetpaint</a></li>
							</ul>
						</div>
					</div>			
				</div>
				<div id="siteHeader">
			        <xsl:apply-templates select="rss/channel/image">
				        <xsl:with-param name="feedTitle" select="$feedTitle"/>
			        </xsl:apply-templates>
				</div>			
				<div id="outer" style="padding-left:0px">
					<div id="pageContainer">				
						<div id="mainColumn">
							<div id="pageContent">
								<div id="pageContentInner">
									<h1 style="background:url('/img/item/feed-icon-24x24.png') no-repeat 0 3px;padding-left:27px"><xsl:value-of select="$feedTitle"/></h1>
									<br/>												
									<xsl:apply-templates select="rss/channel"/>
								</div>
							</div>
					    </div>
					</div>
			    </div>
		    </div>
	    </div>
	  </body>
	</html>
	</xsl:template>	
</xsl:stylesheet>