<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>

<xsl:template match="results">
    <table width="100%" cellpadding="2" cellspacing="0" border="0">
		<!-- Display each job in the xml -->
		<xsl:for-each select="jobs/job">
		<tr>
			<!-- date -->
			<td valign="top" align="left" width="10%" >
					<xsl:call-template name="DateFormat">
						<xsl:with-param name="date" select="posting_date"/>
					</xsl:call-template>
			</td>
			<!-- Position, classified, salary and vacancies -->
			<td valign="top" class="jpCompanyName">
				<xsl:element name="a">
					<xsl:attribute name="href"><xsl:value-of select="url"/></xsl:attribute>
					<xsl:attribute name="class">jobspost</xsl:attribute>
					<xsl:attribute name="onclick">javascript:ow('<xsl:value-of select="url"/>',this);return false;</xsl:attribute>
					<xsl:attribute name="title">View Job Details</xsl:attribute>
					<xsl:value-of select="position"/>
				</xsl:element>	
				<br/>
				<font style="font-family:verdana; font-size: 11px;">
					<div style="line-height: 1.4">
					  <font style="color:#6666cc;"><xsl:value-of select="industry_name"/> Industry</font><br/>
					  <font style="color:#58595b;">
						<xsl:choose>
							<xsl:when test="(location != '') and (salary != '')">
								<xsl:value-of select="substring-before(salary,')')"/>, <xsl:value-of select="location"/>)
							</xsl:when>
							<xsl:when test="(location != '') and (salary != '') and vacancies > 1">
								<xsl:value-of select="substring-before(salary,')')"/>, <xsl:value-of select="location"/>, <xsl:value-of select="vacancies"/> vacancies)
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="salary"/>
							</xsl:otherwise>
						</xsl:choose>
					  </font>
					</div>
				</font>
				<br/>
		  </td>	
		</tr>
		</xsl:for-each>		
	 </table>
</xsl:template>

<!-- Function to manipulate date/time -->
<xsl:template name="DateFormat">
<xsl:param name="posting_date"/>

	<xsl:variable name="strPostingDate" select="posting_date"/>
	<xsl:variable name="strPostingMonth" select="substring-before($strPostingDate, '/')"/>
	<xsl:variable name="strPostingDay" select="substring-before(substring-after($strPostingDate, '/'), '/')"/>
	<xsl:variable name="strPostingYear" select="substring(substring-after(substring-after($strPostingDate, '/'), '/'), 1, 4)"/>
	<xsl:value-of select="$strPostingDay"/>
	<xsl:variable name="monthInName">
		<xsl:choose>
			<xsl:when test="$strPostingMonth = 1"> Jan </xsl:when>
			<xsl:when test="$strPostingMonth = 2"> Feb </xsl:when>
			<xsl:when test="$strPostingMonth = 3"> Mar </xsl:when>
			<xsl:when test="$strPostingMonth = 4"> Apr </xsl:when>
			<xsl:when test="$strPostingMonth = 5"> May </xsl:when>
			<xsl:when test="$strPostingMonth = 6"> Jun </xsl:when>
			<xsl:when test="$strPostingMonth = 7"> Jul </xsl:when>
			<xsl:when test="$strPostingMonth = 8"> Aug </xsl:when>
			<xsl:when test="$strPostingMonth = 9"> Sep </xsl:when>
			<xsl:when test="$strPostingMonth = 10"> Oct </xsl:when>
			<xsl:when test="$strPostingMonth = 11"> Nov </xsl:when>
			<xsl:when test="$strPostingMonth = 12"> Dec </xsl:when>
		</xsl:choose>
	</xsl:variable>
	<!--xsl:value-of select="$monthInName"/> <xsl:value-of select="$strPostingYear"/-->
	<xsl:value-of select="$monthInName"/>
		
</xsl:template>
</xsl:stylesheet>
