﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">

	<xsl:import href="TournamentList.xslt"/>

	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="ItemID" select="normalize-space(AjaxRequest/Params/ItemID)"></xsl:variable>
		<xsl:variable name="Status" select="normalize-space(AjaxRequest/Params/Status)"></xsl:variable>
		<xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:variable>
		<xsl:variable name="templateURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
		<xsl:variable name="Authenticated">
			<xsl:choose>
				<xsl:when test="normalize-space(AjaxRequest/isAuthenticated)">
					<xsl:value-of select="normalize-space(AjaxRequest/isAuthenticated)"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="normalize-space(AjaxRequest/Authenticated)"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<xsl:call-template name="TournamentsList">
			<xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
			<xsl:with-param name="Status" select="$Status"></xsl:with-param>
			<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
			<xsl:with-param name="templateURL" select="$templateURL"></xsl:with-param>
			<xsl:with-param name="Authenticated" select="$Authenticated"></xsl:with-param>
		</xsl:call-template>

	</xsl:template>

	<xsl:template name="TournamentsList">
		<xsl:param name="ItemID" select="'N/A'"></xsl:param>
		<xsl:param name="Status" select="'N/A'"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="templateURL" select="'N/A'"></xsl:param>
		<xsl:param name="Authenticated" select="'N/A'"></xsl:param>
		<xsl:choose>
			<xsl:when test="$Status = 5">
				Terminated Tournaments
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="$Authenticated='True'">
						<div id="div_TournamentList">
							<xsl:call-template name="ListOfTournaments">
								<xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
								<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
								<xsl:with-param name="Status" select="$Status"></xsl:with-param>
								<xsl:with-param name="templateURL" select="$templateURL"></xsl:with-param>
							</xsl:call-template>
						</div>
					</xsl:when>
					<xsl:otherwise>
						<div class="padding10">
							<span class="verticallyMiddle marginLeft25 createGoalWizardHeadlineSubText">You are not logged in/Register.</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>

			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>
</xsl:stylesheet>
