﻿<?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:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:call-template name="TournamentLeftSideBar">
			<xsl:with-param name="TeamsXml" select="AjaxRequest/Tournament"></xsl:with-param>
			<xsl:with-param name="ItemID" select="AjaxRequest/Params/ItemID"></xsl:with-param>
			<xsl:with-param name="HostName" select="AjaxRequest/HostName"></xsl:with-param>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="TournamentLeftSideBar">
		<xsl:param name="TeamsXml" select="'N/A'"></xsl:param>
		<xsl:param name="ItemID" select="'N/A'"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		
		<div id="divLeftBarContainer" style="border:1px solid gray;" class="padding5">
			<xsl:for-each select="$TeamsXml/Round">
				<div class="marginBottom5 labelGoalTopicsText marginLeft10" style="border-bottom:1px solid Gray;">
					<xsl:text>Round </xsl:text>
					<xsl:value-of select="position()"/>
				</div>
				<div class="marginLeft15">
					<xsl:for-each select="Match">

						<xsl:variable name="divStyleTeam1">
							<xsl:choose>
								<xsl:when test="isPlayingNow = 1 and WinnerTeamID = 0">
									<xsl:text>color:blue;</xsl:text>
								</xsl:when>
								<xsl:when test="WinnerTeamID!=0">
									<xsl:choose>
										<xsl:when test="WinnerTeamID = Team1">
											<xsl:text>color:black;font-size:15px;</xsl:text>
										</xsl:when>
										<xsl:otherwise>
											<xsl:text>text-decoration: line-through;</xsl:text>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:when>
							</xsl:choose>
						</xsl:variable>

						<xsl:variable name="divStyleTeam2">
							<xsl:choose>
								<xsl:when test="isPlayingNow = 1 and WinnerTeamID = 0">
									<xsl:text>color:blue;</xsl:text>
								</xsl:when>
								<xsl:when test="WinnerTeamID!=0">
									<xsl:choose>
										<xsl:when test="WinnerTeamID = Team2">
											<xsl:text>color:black;font-size:15px;</xsl:text>
										</xsl:when>
										<xsl:otherwise>
											<xsl:text>text-decoration: line-through;</xsl:text>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:when>
							</xsl:choose>
						</xsl:variable>

						<div class="marginBottom10">
							<div style="{$divStyleTeam1}" class="userWizardLabel" title="{TeamName1}">
								<xsl:choose>
									<xsl:when test="TeamName1">
										<xsl:value-of select="substring(TeamName1,1,24)"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="GameKeyHome"/>
									</xsl:otherwise>
								</xsl:choose>
							</div>
							<div>VS.</div>
							<div style="{$divStyleTeam2}" class="userWizardLabel" title="{TeamName2}">
								<xsl:choose>
									<xsl:when test="TeamName2">
										<xsl:value-of select="substring(TeamName2,1,24)"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="GameKeyAway"/>
									</xsl:otherwise>
								</xsl:choose>
							</div>
						</div>
					</xsl:for-each>
				</div>
			</xsl:for-each>
		</div>
		<div align="center" class="marginTop25 marginBottom10" id="divViewButtonContainer">
			<a onclick="return makePostWindowLoadNewWindow('http://{$HostName}/TournamentAdmin/{$ItemID}','ViewTournament','PageMode','View')" class="decorationNone onMouseOver">
				<div style="line-height:40px;width:170px;" class="TournamentButtonGray" id="divViewBrackets">
					View Bracket
				</div>
			</a>
		</div>
		<div id="divTournamentBracketsViewContainer"></div>
	</xsl:template>
</xsl:stylesheet>
