﻿<?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:include href="../../../Version_2_0/PopUpHeader.xslt"/>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="TournamentItemID" select="AjaxRequest/Params/ItemID"></xsl:variable>
		<xsl:variable name="Round" select="AjaxRequest/Params/Round"></xsl:variable>
		<xsl:variable name="WinnerID" select="AjaxRequest/Params/Winner"></xsl:variable>
		<xsl:variable name="LoserID" select="AjaxRequest/Params/Loser"></xsl:variable>
		<xsl:variable name="Winner" select="AjaxRequest/TournamentTeam/WinnerTeam/TeamName"></xsl:variable>
		<xsl:variable name="Loser" select="AjaxRequest/TournamentTeam/LoserTeam/TeamName"></xsl:variable>
		<xsl:variable name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:variable>

		<xsl:variable name="WinnerPoints" select="AjaxRequest/TournamentTeam/WinnerPoints"></xsl:variable>
		<xsl:variable name="LoserPoints" select="AjaxRequest/TournamentTeam/LoserPoints"></xsl:variable>

		<xsl:variable name="WinnerPlayer1Multiplier" select="AjaxRequest/MultiplierXML/Multiplier[TournamentCount = ../../TournamentTeam/WinnerTeam/Player1Count]/MultiplierNumber"></xsl:variable>
		<xsl:variable name="WinnerPlayer2Multiplier" select="AjaxRequest/MultiplierXML/Multiplier[TournamentCount = ../../TournamentTeam/WinnerTeam/Player2Count]/MultiplierNumber"></xsl:variable>
		<xsl:variable name="LoserPlayer1Multiplier" select="AjaxRequest/MultiplierXML/Multiplier[TournamentCount = ../../TournamentTeam/LoserTeam/Player1Count]/MultiplierNumber"></xsl:variable>
		<xsl:variable name="LoserPlayer2Multiplier" select="AjaxRequest/MultiplierXML/Multiplier[TournamentCount = ../../TournamentTeam/LoserTeam/Player2Count]/MultiplierNumber"></xsl:variable>

		<xsl:variable name="WinnerPlayer1Name" select="AjaxRequest/TournamentTeam/WinnerTeam/Player1Name"></xsl:variable>
		<xsl:variable name="WinnerPlayer2Name" select="AjaxRequest/TournamentTeam/WinnerTeam/Player2Name"></xsl:variable>
		<xsl:variable name="LoserPlayer1Name" select="AjaxRequest/TournamentTeam/LoserTeam/Player1Name"></xsl:variable>
		<xsl:variable name="LoserPlayer2Name" select="AjaxRequest/TournamentTeam/LoserTeam/Player2Name"></xsl:variable>

		<xsl:call-template name="PopUpHeader">
			<xsl:with-param name="ItemID" select="$TournamentItemID"></xsl:with-param>
			<xsl:with-param name="HeaderText"></xsl:with-param>
			<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
		</xsl:call-template>

		<div id="divConfirm" align="center">
			<div id="tabConfirmation">
				<div class="marginTop15">
					<div class="TournamentWinnerRound1Header" style="width:550px;overflow:hidden;">
						<xsl:value-of select="$Winner"/>
					</div>
				</div>
				<table align="center" class="paddingBottom20">
					<tr>
						<td colspan="3" class="textCenter">
							<div class="brandTopHeaderTitle marginBottom20">
								Wins?
							</div>
						</td>
					</tr>
					<tr>
						<td width="100px" class="textCenter TournamentButtonGray onMouseOver" 
                            onclick="document.getElementById('divWinnerTeamMessage').style.display='block';
					 document.getElementById('tabConfirmation').style.display='none';
                            popupWhiteLayerContainerForDiv('divConfirm', 600);">
							<span>Yes</span>
						</td>
						<td width="30px"></td>
						<td width="100px" class="TournamentButtonGray textCenter onMouseOver" onclick="startRound('{$TournamentItemID}', 'divTournamentBracketsContainer');
							closePopupWhiteLayerContainer();">
							<span>Cancel</span>
						</td>
					</tr>
				</table>
			</div>

			<div id="divWinnerTeamMessage" align="center" class="textCenter marginTop20 paddingBottom20" style="display:none;">
				<xsl:choose>
					<xsl:when test="$WinnerPoints &gt; 0">
						<div class="marginBottom10">
							<span style="font-family:Blue hand writing; font-size:32px; font-style:Italic; font-weight:700;color:#4697A8">
								Congratulations
							</span>
						</div>
						<div class="marginBottom20" align="center">
							<div class="TournamentWinnerRound1Header" style="width:550px;overflow:hidden;">
								<xsl:value-of select="$Winner"/>
							</div>
							<span class="brandTopHeaderTitle">
								Wins!
							</span>
						</div>
						<table align="center" class="marginBottom10">
							<tr>
								<td class="brandTopHeaderTitle paddingRight10">
									<xsl:value-of select="substring($WinnerPlayer1Name,1,16)"></xsl:value-of>
								</td>
								<td class="brandTopHeaderTitle">
									Awarded&#xa0;
									<xsl:choose>
										<xsl:when test="$WinnerPlayer1Multiplier">
											<xsl:value-of select="$WinnerPlayer1Multiplier * $WinnerPoints"/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="$WinnerPoints * 1"/>
										</xsl:otherwise>
									</xsl:choose>
									&#xa0;points
								</td>
							</tr>
							<tr>
								<td class="brandTopHeaderTitle paddingRight10">
									<xsl:value-of select="substring($WinnerPlayer2Name,1,16)"></xsl:value-of>
								</td>
								<td class="brandTopHeaderTitle">
									Awarded&#xa0;
									<xsl:choose>
										<xsl:when test="$WinnerPlayer2Multiplier">
											<xsl:value-of select="$WinnerPlayer2Multiplier * $WinnerPoints"/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="$WinnerPoints * 1"/>
										</xsl:otherwise>
									</xsl:choose>
									&#xa0;points
								</td>
							</tr>
						</table>
					</xsl:when>
					<xsl:otherwise>
						<div class="marginBottom10" align="center">
							<div style="width:550px;overflow:hidden;" class="TournamentWinnerRound1Header">
								<xsl:value-of select="$Winner"/>
							</div>
							<span class="brandTopHeaderTitle">
								Advances!
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
				<div class="marginBottom10" align="center">
					<div class="TournamentWinnerRound1Header" style="width:550px;overflow:hidden;">
						<xsl:value-of select="$Loser"/>
					</div>
					<span class="brandTopHeaderTitle">Loses</span>
				</div>
				<table align="center" class="marginBottom10">
					<tr>
						<td class="brandTopHeaderTitle paddingRight10">
							<xsl:value-of select="substring($LoserPlayer1Name,1,16)"></xsl:value-of>
						</td>
						<td class="brandTopHeaderTitle">
							Awarded&#xa0;
							<xsl:choose>
								<xsl:when test="$LoserPlayer1Multiplier">
									<xsl:value-of select="$LoserPlayer1Multiplier * $LoserPoints"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$LoserPoints * 1"/>
								</xsl:otherwise>
							</xsl:choose>
							&#xa0;points
						</td>
					</tr>
					<tr>
						<td class="brandTopHeaderTitle paddingRight10">
							<xsl:value-of select="substring($LoserPlayer2Name,1,16)"></xsl:value-of>								
						</td>
						<td class="brandTopHeaderTitle">
							Awarded&#xa0;
							<xsl:choose>
								<xsl:when test="$LoserPlayer2Multiplier">
									<xsl:value-of select="$LoserPlayer2Multiplier * $LoserPoints"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$LoserPoints * 1"/>
								</xsl:otherwise>
							</xsl:choose>
							&#xa0;points
						</td>
					</tr>
				</table>
				<div align="center">
					<div class="TournamentButtonGray onMouseOver" style="width:120px;" onclick="
						 SaveTournamentWinner('{$TournamentItemID}', '{$Round}', '{$WinnerID}', '{$LoserID}');
						 refreshTournamentLeftSideBar('{$TournamentItemID}', 'divTournamentGamesDisplay');closePopupWhiteLayerContainer();">
						<span>Continue</span>
					</div>
				</div>
			</div>
		</div>
	</xsl:template>

</xsl:stylesheet>
