﻿<?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="../GenericTemplates/StringReplace.xslt"/>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="ID" select="AjaxRequest/Params/ID"></xsl:variable>
		<xsl:variable name="Action" select="AjaxRequest/Action"></xsl:variable>
		<xsl:variable name="MasterPortalID" select="AjaxRequest/Params/MasterPortalID"></xsl:variable>
		<xsl:variable name="Level" select="AjaxRequest/Params/Level"></xsl:variable>
		<xsl:variable name="SettingsXML" select="AjaxRequest/Settings/."></xsl:variable>
		<xsl:variable name="ItemID" select="AjaxRequest/ActivityDashboardContentXML/ItemID"></xsl:variable>
		<xsl:variable name="ItemName" select="AjaxRequest/ActivityDashboardContentXML/ItemName"></xsl:variable>
		<xsl:variable name="FullName" select="AjaxRequest/ActivityDashboardContentXML/FullName"></xsl:variable>
		<xsl:variable name="ImageURL" select="AjaxRequest/ActivityDashboardContentXML/ImageURL"></xsl:variable>
		<xsl:variable name="DefaultImage" select="AjaxRequest/DefaultImage"/>
		<xsl:variable name="PermissionID" select="AjaxRequest/Params/PermissionID"></xsl:variable>
		<xsl:variable name="SelectedName" select="AjaxRequest/SelectedName"></xsl:variable>
		<xsl:variable name="ImageSRC">
			<xsl:choose>
				<xsl:when test="$ImageURL !=''">
					<xsl:value-of select="$ImageURL"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$DefaultImage"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div>

			<xsl:choose>
				<xsl:when test="$Action = 'LoadCoachAdminActivityDashboardContent'">
					<script>
						LoadCoachAdminActivityReport(<xsl:value-of select="$MasterPortalID"/>, <xsl:value-of select="$ID"/>
						, '<xsl:value-of select="$Level"/>', 'Div_ScoreCardFrame');
					</script>
				</xsl:when>
			</xsl:choose>

			<table class="tableMaster" cellpadding="0" cellspacing="0" >
				<tr>
					<td width="2%"></td>
					<td width="5%">
						<div>
							<img src="{$ImageSRC}"
								 onload='setWidthAndHeightImage(this,"100");' class='marginTop5 onMouseOver'></img>
						</div>
					</td>
					<td width="58%" class="verticallyMiddle textLeft">
						<span  class="labelGoalTitle sentenceFont marginLeft5">
							<xsl:value-of select="$SelectedName"/>
						</span>
						<div class="publicationSummary marginLeft5">
							<xsl:value-of select="$ItemName"/>
						</div>
					</td>

					<td width="35%">
						<table class="tableMaster" cellpadding="2" cellspacing="1">
							<tr>
								<td width="20%" class="vertcallyMiddle">
									<div class="packageTitle marginRight5 textRight" style="padding-top:3px;">
										<!--Coach/Manager:-->
									</div>
								</td>
								<td class="vertcallyMiddle" style="padding-top:3px;">
									<table id="" class="tableMaster" cellpadding="0" cellspacing="1">
										<tr id="">
											<td class="verticallyMiddle">
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td colspan="4">
						<table class="tableMaster" cellpadding="0" cellspacing="0">
							<tr>
								<td width="1%" style="border-bottom:1px solid #5E5E5E;"></td>
								<td width="85%">
									<div class="goalTabsBackground marginTop10">
										<table class="tableMaster textCenter verticallyMiddle capitalFont" height="32px"
                                                cellSpacing="0" cellPadding="0" >
											<xsl:choose>
												<xsl:when test="$Level='AllPortals'">
													<xsl:for-each select="$SettingsXML/ProfileTabs/AllPortalsProfileTabs/Tab">
														<xsl:call-template name="ProfileMenuTabs">
															<xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
															<xsl:with-param name="MasterPortalID" select="$MasterPortalID"></xsl:with-param>
															<xsl:with-param name="ID" select="$ID"></xsl:with-param>
															<xsl:with-param name="Level" select="$Level"></xsl:with-param>
														</xsl:call-template>
													</xsl:for-each>
												</xsl:when>
												<xsl:when test="$Level='PortalSpecific' or $Level='CoachesSpecific_Selected'">
													<xsl:for-each select="$SettingsXML/ProfileTabs/TeamPortalProfileTabs/Tab">
														<xsl:call-template name="ProfileMenuTabs">
															<xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
															<xsl:with-param name="MasterPortalID" select="$MasterPortalID"></xsl:with-param>
															<xsl:with-param name="ID" select="$ID"></xsl:with-param>
															<xsl:with-param name="Level" select="$Level"></xsl:with-param>
														</xsl:call-template>
													</xsl:for-each>
												</xsl:when>
												<xsl:when test="$Level='AllCoaches'">
													<xsl:for-each select="$SettingsXML/ProfileTabs/AllCoachesProfileTabs/Tab">
														<xsl:call-template name="ProfileMenuTabs">
															<xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
															<xsl:with-param name="MasterPortalID" select="$MasterPortalID"></xsl:with-param>
															<xsl:with-param name="ID" select="$ID"></xsl:with-param>
															<xsl:with-param name="Level" select="$Level"></xsl:with-param>
														</xsl:call-template>
													</xsl:for-each>
												</xsl:when>
												<xsl:when test="$Level='CoachesSpecific'">
													<xsl:for-each select="$SettingsXML/ProfileTabs/CoachRollupProfileTabs/Tab">
														<xsl:call-template name="ProfileMenuTabs">
															<xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
															<xsl:with-param name="MasterPortalID" select="$MasterPortalID"></xsl:with-param>
															<xsl:with-param name="ID" select="$ID"></xsl:with-param>
															<xsl:with-param name="Level" select="$Level"></xsl:with-param>
														</xsl:call-template>
													</xsl:for-each>
												</xsl:when>
												<xsl:when test="$Level='AllUsers'">
													<xsl:for-each select="$SettingsXML/ProfileTabs/AllUsersProfileTabs/Tab">
														<xsl:call-template name="ProfileMenuTabs">
															<xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
															<xsl:with-param name="MasterPortalID" select="$MasterPortalID"></xsl:with-param>
															<xsl:with-param name="ID" select="$ID"></xsl:with-param>
															<xsl:with-param name="Level" select="$Level"></xsl:with-param>
														</xsl:call-template>
													</xsl:for-each>
												</xsl:when>
											</xsl:choose>
										</table>
									</div>
								</td>
								<td width="14%" style="border-bottom:1px solid #5E5E5E;">
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
		<div  id="Div_ScoreCardFrame">
			<div class="col-md-12 col-sm-12" style="margin-top: 20px;">
				<xsl:choose>
					<xsl:when test="$Action = 'LoadActivityDashboardContent'">
						<img src="images/RollupDemo.jpg" class="img-responsive"></img>
					</xsl:when>
				</xsl:choose>
			</div>
		</div>
	</xsl:template>
	<xsl:template name="ProfileMenuTabs">
		<xsl:param name="SettingsXML" select="'N/A'"></xsl:param>
		<xsl:param name="MasterPortalID" select="'N/A'"></xsl:param>
		<xsl:param name="ID" select="'N/A'"></xsl:param>
		<xsl:param name="Level" select="'N/A'"></xsl:param>
		<xsl:variable name="MenuTabClass">
			<xsl:choose>
				<xsl:when test="position() = 1">
					<xsl:text>selectedMenuGoalTabs</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>defaultMenuGoal</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="TDIDs">
			<xsl:choose>
				<xsl:when test="Name = 'Scorecard'">
					<xsl:text>cell_Scoreboard_Ad</xsl:text>
				</xsl:when>
				<xsl:when test="Name = 'AllPortalsReport' or Name='AllUsersReport' or Name='AllCoachesReport' or Name='CoachReport' or Name='TeamPortalReport'
					or Name='ClientPortalReport'">
					<xsl:text>cell_Report_Ad</xsl:text>
				</xsl:when>
				<xsl:when test="Name = 'Opportunities'">
					<xsl:text>cell_Opportunities_Ad</xsl:text>
				</xsl:when>
				<xsl:when test="Name = 'Admin'">
					<xsl:text>cell_Admin_Ad</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="OnClickFunction">
			<xsl:choose>
				<xsl:when test="Name = 'AllPortalsReport' or Name = 'ClientPortalReport' or Name = 'TeamPortalReport'">
					<xsl:text>LoadCoachAdminActivityReport(</xsl:text>
					<xsl:value-of select="$MasterPortalID"/>
					<xsl:text>,</xsl:text>
					<xsl:value-of select="$ID"/>
					<xsl:text>, '</xsl:text>
					<xsl:value-of select="$Level"/>
					<xsl:text>', 'Div_ScoreCardFrame');</xsl:text>
				</xsl:when>
				<xsl:when test="Name = 'Scorecard'">
					<xsl:text>LoadActivityDashboard_ScoreCardFrame('</xsl:text>
					<xsl:value-of select="$MasterPortalID"></xsl:value-of>
					<xsl:text>','Div_ScoreCardFrame','</xsl:text>
					<xsl:value-of select="$Level"></xsl:value-of>
					<xsl:text>','</xsl:text>
					<xsl:value-of select="$ID"/>
					<xsl:text>','Monthly');</xsl:text>
				</xsl:when>
				<xsl:when test="Name = 'Opportunities'">
					<xsl:text> LoadSalesActivityRollUp(</xsl:text>
					<xsl:value-of select="$MasterPortalID"></xsl:value-of>
					<xsl:text>, 'Div_ScoreCardFrame','</xsl:text>
					<xsl:value-of select="$ID"></xsl:value-of>
					<xsl:text>', 0, 20, 1, 0,'</xsl:text>
					<xsl:value-of select="$Level"/>
					<xsl:text>');</xsl:text>
				</xsl:when>
				<xsl:when test="Name = 'Admin'">
					<xsl:text> dashboardAdminMenu('</xsl:text>
					<xsl:value-of select="$MasterPortalID"></xsl:value-of>
					<xsl:text>');</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<td width="10.625%" id="{$TDIDs}" class="textCenter verticallyMiddle {$MenuTabClass} padding2"
                    name="GoalMenuAction" onClick="{$OnClickFunction} goal_HightlightSelectedLink('{$TDIDs}','defaultMenuGoal','selectedMenuGoalTabs','GoalMenuAction',0);">
			<span id="span_Goals" class="onMouseOver" >

				<xsl:choose>
					<xsl:when test="DisplayName and DisplayName != ''">
						<xsl:value-of select="DisplayName"/>
					</xsl:when>
					<xsl:when test="Name = 'goals'">
						<xsl:text>Programs</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="Name"/>
					</xsl:otherwise>
				</xsl:choose>
			</span>
		</td>
	</xsl:template>
</xsl:stylesheet>
