<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:scrpt="http://mspress.microsoft.com/mspress">
	<xsl:template match="/Root">
		<xsl:element name="Topics">
			<xsl:apply-templates select="ContentItem" />
		</xsl:element>
	</xsl:template>

	<xsl:template match="ContentItem">
    		<xsl:element name="Topic">
			<xsl:attribute name="Icon"><xsl:value-of select="@ContentWheelIcon" /></xsl:attribute>
    			<xsl:attribute name="State"><xsl:value-of select="scrpt:TranslateStatus(.)" /></xsl:attribute>
			<xsl:attribute name="Available"><xsl:value-of select="scrpt:TranslateAvailability(.)" /></xsl:attribute>
    			<xsl:element name="Text"><xsl:value-of select="@Name" /></xsl:element>
			<xsl:element name="Id"><xsl:value-of select="@ID" /></xsl:element>		
    		</xsl:element>
	</xsl:template>

	<msxsl:script language="javascript" implements-prefix="scrpt">
	<![CDATA[
		function TranslateStatus(_contextNodeList)
		{
			var sStatus = "0";

			try
			{
				var node = _contextNodeList.item(0);
				var sStatusText = node.selectSingleNode("@LessonStatus").text;
				if (sStatusText == "completed") sStatus = "1";

			}
			catch(e)
			{
			}

			return sStatus;
		}

		function TranslateAvailability(_contextNodeList)
		{
			var sAvailable = "1";

			try
			{
				var node = _contextNodeList.item(0);
				var sText = node.selectSingleNode("@Available").text;
				if (sText == "false") sAvailable = "0";

			}
			catch(e)
			{
			}

			return sAvailable;
		}
	]]>
	</msxsl:script>
</xsl:stylesheet>