﻿<?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="MakeTeam.xslt"/>
	<xsl:include href="PlayerCountBoard.xslt"/>

	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="Origin" select="normalize-space(AjaxRequest/Origin)"></xsl:variable>
		<xsl:variable name="TournamentItemID" select="normalize-space(AjaxRequest/Params/ItemID)"></xsl:variable>
		<xsl:variable name="TemplateURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
		<xsl:variable name="TeamCount" select="normalize-space(AjaxRequest/TournamentCount/TeamCount)"></xsl:variable>
		<xsl:variable name="CheckedIn" select="normalize-space(AjaxRequest/TournamentCount/CheckedIn)"></xsl:variable>
		<xsl:variable name="CountPlayer" select="count(AjaxRequest/Tournament/TournamentPlayer)"></xsl:variable>
		<xsl:variable name="TournamentName" select="normalize-space(AjaxRequest/TournamentDetail/Tournament/Name)"></xsl:variable>
		<xsl:variable name="BrandName" select="normalize-space(AjaxRequest/TournamentDetail/Tournament/BrandName)"></xsl:variable>

		<div class="padding5 labelGoalTopicsText">
			<div style="float:left;">
				<xsl:value-of select="$TournamentName"/>
			</div>
			<div style="float:right;">
				<xsl:value-of select="$BrandName"/>
			</div>
		</div>

		<div style="width:900px">
			<div class="marginBottom20 paddingTop20 textCenter">
				<span class="brandTopHeaderTitle">
					Create Teams for Tournament
				</span>
			</div>
			<div style="height:500px;">
				<div style="width:200px;float:left;" id="divPlayerCountBoard">
					<xsl:call-template name="TournamentPlayerCount">
						<xsl:with-param name="Guaranteed" select="AjaxRequest/TournamentCount/Guaranteed"></xsl:with-param>
						<xsl:with-param name="TotalGuaranteed" select="AjaxRequest/TournamentCount/TotalGuaranteed"></xsl:with-param>
						<xsl:with-param name="PlayerCount" select="64"></xsl:with-param>
						<xsl:with-param name="TeamCount" select="$TeamCount"></xsl:with-param>
						<xsl:with-param name="TotalTeams" select="32"></xsl:with-param>
						<xsl:with-param name="CheckedInCount" select="$CheckedIn"></xsl:with-param>
						<xsl:with-param name="WaitCount" select="AjaxRequest/TournamentCount/Waiting"></xsl:with-param>
						<xsl:with-param name="TournamentItemID" select="$TournamentItemID"></xsl:with-param>
						<xsl:with-param name="Origin">team</xsl:with-param>
					</xsl:call-template>
				</div>
				<div style="float:right;">
					<table style="width:630px;" cellpadding="0" cellspacing="0">
						<tr style="height:40px;">
							<td class="textCenter" style="vertical-align:bottom;" width="42%">
								<span class="SinglePlayerHead">
									Unassigned Players
								</span>
							</td>
							<td width="14%">
								&#xa0;
							</td>
							<td class="textCenter" style="vertical-align:bottom;" width="44%">
								<span class="SinglePlayerHead">
									Create a Team
								</span>
							</td>
						</tr>
						<tr style="height:45px;">
							<td>
								&#xa0;
							</td>
						</tr>
						<tr>
							<xsl:choose>
								<xsl:when test="$CountPlayer = 0">
									<td class="textCenter">
										<div class="labelDarkGrayMedium">
											There are no single Players in this Tournament.
										</div>
									</td>
								</xsl:when>
								<xsl:otherwise>
									<td width="42%">
										<div id="div_TournamentPlayerList">
											<xsl:for-each select="AjaxRequest/Tournament/TournamentPlayer">
												<div selection="no" userid="{UserID}" id="divPlayerDetail_{UserID}" name="TournamentPlayerHighlight"
													 class="onMouseOver" style="height:60px;overflow:hidden;"
													 onClick="SelectPlayers('divPlayerDetail_{UserID}');">
													<table cellpadding="0" cellspacing="0" class="tableMaster margin5">
														<tr>
															<td width="25%" class="textCenter verticallyMiddle">
																<xsl:choose>
																	<xsl:when test="UserImage !=''">
																		<img class="verticallyMiddle" src="{UserImage}" onload="setWidthAndHeightImage(this, 50);"></img>
																	</xsl:when>
																	<xsl:otherwise>
																		<img class="verticallyMiddle" src="{$TemplateURL}Web/Images/Ver_2_0/DefaultUserPic.jpg" onload="setWidthAndHeightImage(this, 50);"></img>
																	</xsl:otherwise>
																</xsl:choose>
															</td>
															<td width="75%" class="">
																<div class="labelGoalTitle" style="width:175px;height:30px;overflow:hidden;">
																	<xsl:value-of select="UserName"/>
																</div>
																<div class="templateMemoText" style="width:175px;overflow:hidden;">
																	<xsl:value-of select="Email"/>
																</div>
															</td>
														</tr>
													</table>
													<!--<div style="float:left;margin:5px;width:50px;height:100%;">

													</div>
													<div style="float:right;margin:5px;width:170px;height:100%;">

													</div>-->
												</div>
											</xsl:for-each>
										</div>
									</td>
								</xsl:otherwise>
							</xsl:choose>

							<td class="textCenter" width="14%">
								<div style="margin-top:100px;"></div>
								<span style="line-height:50px;padding:10px;" id="txtFindPlayer" class="onMouseOver whiteTextLarge greenButton"
									 onClick="SelectTournamentPlayers('{$TournamentItemID}','divChooseTeamMateBox','{$CountPlayer}');">
									<img align="absmiddle" src="{$TemplateURL}Web/Images/Ver_2_0/Tournament_arrow.png" style=""
													  class="verticallyMiddle" id="img_Arrow"></img>
								</span>
							</td>
							<td width="44%">
								<div id="div_SelectedPlayer1" player1="" class="divPlayer1 marginBottom10" selection="no">
									<span id="span_Player1" class="divSinglePlayerText paddingLeft10">Player 1</span>
								</div>
								<div id="div_SelectedPlayer2" player2="" class="divPlayer2 marginBottom15" selection="no">
									<span id ="span_Player2" class="divSinglePlayerText paddingLeft10">Player 2</span>
								</div>
								<div id="divChooseTeamMateBox">
									<xsl:call-template name="MakeTeamBox">
										<xsl:with-param name="Player1Xml" select="AjaxRequest/Player1/User"></xsl:with-param>
										<xsl:with-param name="Player2Xml" select="AjaxRequest/Player2/User"></xsl:with-param>
										<xsl:with-param name="TournamentItemID" select="AjaxRequest/Params/ItemID"></xsl:with-param>
										<xsl:with-param name="TeamCount" select="AjaxRequest/TournamentCount/TeamCount"></xsl:with-param>
										<xsl:with-param name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:with-param>
										<xsl:with-param name="Origin">team</xsl:with-param>
									</xsl:call-template>
								</div>
								<div id="divPlayersOperations" class="marginTop25">
									<xsl:if test="$CheckedIn &lt; 64">
										<div class="onMouseOver smallGreenButton"
											 onclick="loadTournament_AdminContent('{$TournamentItemID}', 'divTournamentAdminContent');"
											 style="line-height:30px; width:120px;float:left;">Add More Players</div>
									</xsl:if>
									<xsl:choose>
										<xsl:when test="$CountPlayer &gt; 0 or $TeamCount = 0">
											<div class="divNoteGradient" align="center" style="line-height:33px; width:120px;float:right;">Create Matchups</div>
										</xsl:when>
										<xsl:otherwise>
											<div class="onMouseOver smallGreenButton"
												 onclick="if({$CountPlayer} > 0)alert('You have single players in Tournament.');else tournament_CreateMatchups('{$TournamentItemID}', 'divRightContent');"
												 style="line-height:30px; width:120px;float:right;">Create Matchups</div>
										</xsl:otherwise>
									</xsl:choose>
								</div>
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</xsl:template>

</xsl:stylesheet>
