﻿<?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:import href="../Modules/CorporateGoals/CRMGoalList.xslt"/>

	<xsl:output method="xml" indent="yes" omit-xml-declaration ="yes"/>



	<xsl:template match="/">
		<!--Paging Logic-->
		<xsl:param name="TotalRecords" select="AjaxRequest/CompletedCRMProjects/Project/TotalCount"></xsl:param>
		<xsl:param name="PageNumber"  select="normalize-space(AjaxRequest/Params/PageNumber)"></xsl:param>
		<xsl:param name="PageSize" select="normalize-space(AjaxRequest/CompletedCRMProjects/PageSize)"></xsl:param>

		<xsl:variable name="TotalPages">
			<xsl:choose>
				<xsl:when test="$TotalRecords &gt;=1">
					<xsl:value-of select="ceiling($TotalRecords div $PageSize)"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="0"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="NextPageNumber">
			<xsl:value-of select="$PageNumber + 1"/>
		</xsl:variable>

		<xsl:variable name="PrevPageNumber">
			<xsl:value-of select="$PageNumber - 1"/>
		</xsl:variable>

		<xsl:variable name="PageVisibility">
			<xsl:choose>
				<xsl:when test="$TotalPages &lt;= 0">display:none;</xsl:when>
				<xsl:otherwise>display:block;</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<!---->
		<xsl:variable name ="FilterValue" select ="normalize-space(AjaxRequest/Params/FilterValue)"></xsl:variable>
		<xsl:variable name ="SelectedTab" select ="normalize-space(AjaxRequest/Params/selectedTab)"></xsl:variable>
		<xsl:variable name ="Lead" select ="normalize-space(AjaxRequest/CompletedCRMProjects/Lead)"></xsl:variable>
		<xsl:variable name ="Active" select ="normalize-space(AjaxRequest/CompletedCRMProjects/Active)"></xsl:variable>
		<xsl:variable name ="Complete" select ="normalize-space(AjaxRequest/CompletedCRMProjects/Complete)"></xsl:variable>
		<xsl:variable name ="Terminated" select ="normalize-space(AjaxRequest/CompletedCRMProjects/Terminated)"></xsl:variable>
		<xsl:variable name ="Prospect" select ="normalize-space(AjaxRequest/CompletedCRMProjects/Prospect)"></xsl:variable>
		<xsl:variable name ="ProspectContracted" select ="normalize-space(AjaxRequest/CompletedCRMProjects/ProspectContracted)"></xsl:variable>
		<xsl:variable name ="ProspectWaiting" select ="normalize-space(AjaxRequest/CompletedCRMProjects/ProspectWait)"></xsl:variable>
		<xsl:variable name ="ProspectDiscussion" select ="normalize-space(AjaxRequest/CompletedCRMProjects/ProspectDiscuss)"></xsl:variable>
		<xsl:variable name ="ProspectContract" select ="normalize-space(AjaxRequest/CompletedCRMProjects/ProsContract)"></xsl:variable>
		<xsl:variable name ="HostName" select ="normalize-space(AjaxRequest/HostName)"></xsl:variable>
		<xsl:variable name ="ItemID" select ="normalize-space(AjaxRequest/Params/PortalID)"></xsl:variable>
		<xsl:variable name ="PortalTypeID" select ="normalize-space(AjaxRequest/Params/PortalTypeID)"></xsl:variable>
		<xsl:variable name ="Version" select ="normalize-space(AjaxRequest/Version)"></xsl:variable>
		<xsl:variable name ="TemplateURL" select ="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
		<xsl:variable name ="SelectedUserID" select ="normalize-space(AjaxRequest/Params/UserID)"></xsl:variable>
		<xsl:variable name ="SelectedUserName" select ="normalize-space(AjaxRequest/UserName)"></xsl:variable>
		<xsl:variable name ="CommunityAdmin" select ="normalize-space(AjaxRequest/UserRoles/Role[RoleName = 'Community Admin'])"></xsl:variable>
		<xsl:variable name="IsSecureConnection" select="AjaxRequest/IsSecureConnection"></xsl:variable>
		<xsl:variable name="BetaVersion" select="normalize-space(AjaxRequest/Settings/BetaVersion)"></xsl:variable>


		<xsl:variable name="Protocol">
			<xsl:choose>
				<xsl:when test="$IsSecureConnection = 1">
					<xsl:text>https://</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>http://</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="StringSuggestName">
			<xsl:call-template name="replaceCharsInString">
				<xsl:with-param name="stringIn" select="$SelectedUserName"></xsl:with-param>
				<xsl:with-param name="charsIn">
					<xsl:text>'</xsl:text>
				</xsl:with-param>
				<xsl:with-param name="charsOut">
					<xsl:text>\'</xsl:text>
				</xsl:with-param>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="HeaderClass">
			<xsl:choose>
				<xsl:when test="$Version = 2">
					<xsl:text>userName13</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>labelHeader</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test ="$PortalTypeID = 4">

				<div id="divStatusTab" style="">
					<xsl:choose>
						<xsl:when test="$SelectedTab='0'">
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuSelected " onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'0',1)" >Active</div>
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'11',1)">Pending</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'4',1)">Completed</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'9',1)">Waiting</div>

						</xsl:when>
						<xsl:when test="$SelectedTab='4'">
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected "  onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'0',1)">Active</div>
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'11',1)">Pending</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'4',1)">Completed</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'9',1)">Waiting</div>
						</xsl:when>
						<xsl:when test="$SelectedTab='9'">
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected "  onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'0',1)">Active</div>
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'11',1)">Pending</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'4',1)">Completed</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'9',1)">Waiting</div>
						</xsl:when>
						<xsl:otherwise>
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected " onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'0',1)">Active</div>
							<div style="float:left;width:80px;" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'11',1)">Pending</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'4',1)">Completed</div>
							<div style="float:left;width:80px;"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},'9',1)">Waiting</div>
						</xsl:otherwise>
					</xsl:choose>
				</div>
				<div  style="float:left;margin-left:10px ;margin-top:10px">
					<span class="packageTitle" style="" >Search:</span>
					<input style="" type="text"  id="txt_{$ItemID}_GoalFilter" onblur="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},{$SelectedTab},1)" onkeyup="Corporate_getCorporateEmployeeDetailsSearch('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},{$SelectedTab},event)" value="{$FilterValue}" ></input>
				</div>
				<div align="right" style="margin-top:5px">
					<div  class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:130px;line-height:30px;text-align:center;"
					 onmouseover="document.getElementById('img_Cancel').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
					 onmouseout="document.getElementById('img_Cancel').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
					 onclick="brandAutoSuggest_selectAutoSuggetData('{$ItemID}','{$SelectedUserID}', '{$StringSuggestName}', 'PortalAddGoalWizardForSelectedUser', 'div_ClientPortal_Contact_{$ItemID}_Container','-99','-99');">
						<img id="img_Cancel" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
						<span id="span_Cancel" >ADD PROGRAM </span>
					</div>
				</div>

				<xsl:call-template name="GoalsList">
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="Version" select="$Version"></xsl:with-param>
					<xsl:with-param name="Status">
						<xsl:text>3</xsl:text>
					</xsl:with-param>
					<xsl:with-param name="GoalsXml" select="AjaxRequest/CompletedCRMProjects/Project"></xsl:with-param>
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
					<xsl:with-param name="SelectedUserID" select="$SelectedUserID"></xsl:with-param>
					<xsl:with-param name="SelectedUserName" select="$SelectedUserName"></xsl:with-param>
					<xsl:with-param name="CommunityAdmin" select="$CommunityAdmin"></xsl:with-param>
					<xsl:with-param name="PermissionID" select="AjaxRequest/CompletedCRMProjects/PermissionID"></xsl:with-param>
					<xsl:with-param name="PortalTypeID" select="$PortalTypeID"></xsl:with-param>
					<xsl:with-param name="Protocol" select="$Protocol"></xsl:with-param>
					<xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
					<xsl:with-param name="BetaVersion" select="$BetaVersion"></xsl:with-param>
				</xsl:call-template>

				<xsl:call-template name="GoalsList">
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="Version" select="$Version"></xsl:with-param>
					<xsl:with-param name="Status">
						<xsl:text>9</xsl:text>
					</xsl:with-param>
					<xsl:with-param name="GoalsXml" select="AjaxRequest/CompletedCRMProjects/Project"></xsl:with-param>
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
					<xsl:with-param name="SelectedUserID" select="$SelectedUserID"></xsl:with-param>
					<xsl:with-param name="SelectedUserName" select="$SelectedUserName"></xsl:with-param>
					<xsl:with-param name="CommunityAdmin" select="$CommunityAdmin"></xsl:with-param>
					<xsl:with-param name="PermissionID" select="AjaxRequest/CompletedCRMProjects/PermissionID"></xsl:with-param>
					<xsl:with-param name="PortalTypeID" select="$PortalTypeID"></xsl:with-param>
					<xsl:with-param name="Protocol" select="$Protocol"></xsl:with-param>
					<xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
					<xsl:with-param name="BetaVersion" select="$BetaVersion"></xsl:with-param>
				</xsl:call-template>

				<xsl:call-template name="GoalsList">
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="Version" select="$Version"></xsl:with-param>
					<xsl:with-param name="Status">
						<xsl:text>4</xsl:text>
					</xsl:with-param>
					<xsl:with-param name="GoalsXml" select="AjaxRequest/CompletedCRMProjects/Project"></xsl:with-param>
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
					<xsl:with-param name="SelectedUserID" select="$SelectedUserID"></xsl:with-param>
					<xsl:with-param name="SelectedUserName" select="$SelectedUserName"></xsl:with-param>
					<xsl:with-param name="CommunityAdmin" select="$CommunityAdmin"></xsl:with-param>
					<xsl:with-param name="PermissionID" select="AjaxRequest/CompletedCRMProjects/PermissionID"></xsl:with-param>
					<xsl:with-param name="PortalTypeID" select="$PortalTypeID"></xsl:with-param>
					<xsl:with-param name="Protocol" select="$Protocol"></xsl:with-param>
					<xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
					<xsl:with-param name="BetaVersion" select="$BetaVersion"></xsl:with-param>
				</xsl:call-template>

				<xsl:call-template name="GoalsList">
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="Version" select="$Version"></xsl:with-param>
					<xsl:with-param name="Status">
						<xsl:text>11</xsl:text>
					</xsl:with-param>
					<xsl:with-param name="GoalsXml" select="AjaxRequest/CompletedCRMProjects/Project"></xsl:with-param>
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
					<xsl:with-param name="SelectedUserID" select="$SelectedUserID"></xsl:with-param>
					<xsl:with-param name="SelectedUserName" select="$SelectedUserName"></xsl:with-param>
					<xsl:with-param name="CommunityAdmin" select="$CommunityAdmin"></xsl:with-param>
					<xsl:with-param name="PermissionID" select="AjaxRequest/CompletedCRMProjects/PermissionID"></xsl:with-param>
					<xsl:with-param name="PortalTypeID" select="$PortalTypeID"></xsl:with-param>
					<xsl:with-param name="Protocol" select="$Protocol"></xsl:with-param>
					<xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
					<xsl:with-param name="BetaVersion" select="$BetaVersion"></xsl:with-param>
				</xsl:call-template>
				<xsl:if test="not($TotalRecords)">

					<div style="width:700px"></div>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>

				<table class="tableMaster" cellpadding="0" cellspacing="5">
					<tr>
						<td width="50%">
							<table class="tableMaster" cellpadding="5" cellspacing="5">
								<tr>
									<td style="text-align:center;">
										<span class="labelHeader">
											<u>New Leads</u>
										</span>
									</td>
								</tr>
								<xsl:for-each select ="AjaxRequest/CompletedCRMProjects/Project">
									<tr>
										<td>
											<span class="label">
												<xsl:choose>
													<xsl:when test ="Client != ''">
														<xsl:value-of select ="Client"/>
													</xsl:when>
													<xsl:otherwise>
														<a href="" id= "ancAcc_{normalize-space(CRMProjectID)}"
                                                           onClick = "return portal_EditAccount('ancAcc_{normalize-space(CRMProjectID)}','ddlAcc_{normalize-space(CRMProjectID)}')">
															<xsl:value-of select ="Account"/>
														</a>
													</xsl:otherwise>
												</xsl:choose>
											</span>
											<span style="margin-left:10px;">
												<a id="projectName_{CRMProjectID}" href="{$Protocol}{$HostName}/Goal.aspx?ID={ItemID}" target="_blank" style="cursor:pointer;" class="link">
													<xsl:value-of select="Name"/>
												</a>
											</span>
										</td>
									</tr>
								</xsl:for-each>
							</table>
						</td>
						<td width="50%" style="border-left:1px solid #376092;">
							<table class="tableMaster" cellpadding="5" cellspacing="5">
								<tr>
									<td style="text-align:center;">
										<span class="labelHeader">
											<u>Open Projects</u>
										</span>
									</td>
								</tr>
								<tr>
									<td>
										<span class="link" style="margin-top:10px;"
                                           onClick = "return Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'1','-99','-99','1');">
											Lead&#xa0;(<xsl:value-of select ="$Lead"/>)
										</span>
									</td>
								</tr>
								<tr>
									<td>
										<span class="link" style="margin-top:10px;"
                                          onClick = "return Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'3','-99','-99','1');">
											Active&#xa0;(<xsl:value-of select ="$Active"/>)
										</span>
									</td>
								</tr>
								<tr>
									<td>
										<span class="link" style="margin-top:10px;"
                                          onClick = "return Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'2','-99','-99','1');">
											Prospect&#xa0;(<xsl:value-of select ="$Prospect"/>)
										</span>
									</td>
								</tr>
								<tr>
									<td>
										<span class="link" style="margin-top:10px;"
                                          onClick = "return Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'7','-99','-99','1');">
											Prospect Contracted&#xa0;(<xsl:value-of select ="$ProspectContracted"/>)
										</span>
									</td>
								</tr>
								<tr>
									<td>
										<span class="link" style="margin-top:10px;"
                                          onClick = "return Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'8','-99','-99','1');">
											Prospect Waiting&#xa0;(<xsl:value-of select ="$ProspectWaiting"/>)
										</span>
									</td>
								</tr>
								<tr>
									<td>
										<span class="link" style="margin-top:10px;"
                                          onClick = "return Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'9','-99','-99','1');">
											Prospect Discussion&#xa0;(<xsl:value-of select ="$ProspectDiscussion"/>)
										</span>
									</td>
								</tr>
								<tr>
									<td>
										<span class="link" style="margin-top:10px;"
                                          onClick = "return Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'10','-99','-99','1');">
											Prospect Contract&#xa0;(<xsl:value-of select ="$ProspectContract"/>)
										</span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</xsl:otherwise>
		</xsl:choose>


		<!--Pagging logic-->
		<xsl:choose>
			<xsl:when test="$TotalRecords>$PageSize">
				<div class="publicationSummary" style="{$PageVisibility}">
					<table class="tableMaster" cellpadding="2" cellspacing="0" align="center">
						<tr>
							<td class="verticallyMiddle textCenter" width="1%">
								<xsl:choose>
									<xsl:when test="$TotalPages &gt; 1 and $PageNumber &gt; 1">
										<span class="labelGoalTitle  onMouseOver" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},{$SelectedTab},{$PrevPageNumber})">&lt;</span>

									</xsl:when>
								</xsl:choose>
							</td>
							<td class="verticallyMiddle textCenter" width="1%">
								<span>Page</span>
							</td>
							<td class="verticallyMiddle textCenter" width="1%">
								<span>
									<xsl:value-of select="$PageNumber"></xsl:value-of>
								</span>
							</td>
							<td class="verticallyMiddle textCenter" width="1%">
								<span>of</span>
							</td>
							<td class="verticallyMiddle textCenter" width="1%">
								<span>
									<xsl:value-of select="$TotalPages"/>
								</span>

							</td>
							<td class="verticallyMiddle textCenter" width="1%">
								<xsl:choose>
									<xsl:when test="$PageNumber &lt; $TotalPages">
										<span class="labelGoalTitle  onMouseOver" onclick="Corporate_getCorporateEmployeeDetails('Employee_Operations_Filters','{$ItemID}','{$PortalTypeID}',{$SelectedUserID},{$SelectedTab},{$NextPageNumber})" >&gt;</span>
									</xsl:when>
								</xsl:choose>
							</td>
							<td width="94%">
							</td>
						</tr>
					</table>
				</div>
			</xsl:when>

		</xsl:choose>
		<!---->
	</xsl:template>
	<xsl:template name="GoalsList">
		<xsl:param name="TotalRecords" select="AjaxRequest/CompletedCRMProjects/Project/TotalCount"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="Status" select="'N/A'"></xsl:param>
		<xsl:param name="GoalsXml" select="'N/A'"></xsl:param>
		<xsl:param name="Version" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="ItemID" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedUserID" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedUserName" select="'N/A'"></xsl:param>
		<xsl:param name="CommunityAdmin" select="'N/A'"></xsl:param>
		<xsl:param name="PermissionID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalTypeID" select="'N/A'"></xsl:param>
		<xsl:param name="Protocol" select="'N/A'"></xsl:param>
		<xsl:param name="IsSecureConnection" select="'N/A'"></xsl:param>
		<xsl:param name="PageSize" select="normalize-space(AjaxRequest/CompletedCRMProjects/PageSize)"></xsl:param>
		<xsl:param name="BetaVersion" select="'N/A'"></xsl:param>

		<xsl:variable name ="SelectedTab" select ="normalize-space(AjaxRequest/Params/selectedTab)"></xsl:variable>



		<xsl:variable name="GoalCount" select="count($GoalsXml[Status = $Status])"></xsl:variable>

		<xsl:variable name="HeaderClass">
			<xsl:choose>
				<xsl:when test="$Version = 2">
					<xsl:text>userName13</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>labelHeader</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="GoalClass">
			<xsl:choose>
				<xsl:when test="$Version = 2">
					<xsl:text>mediumUserName</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>link</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:if test="$GoalCount &gt; 0">
			<div class="{$HeaderClass} marginTop10 onMouseOver" style="border-bottom:1px solid gray;" onclick="expandCollapseByGroup('tab_{$Status}_GoalsList');">
				<xsl:choose>
					<xsl:when test="$Status = 3">
						<xsl:text>Active Goals</xsl:text>
					</xsl:when>
					<xsl:when test="$Status = 9">
						<xsl:text>Waiting Goals</xsl:text>
					</xsl:when>
					<xsl:when test="$Status = 4">
						<xsl:text>Completed Goals</xsl:text>
					</xsl:when>
					<xsl:when test="$Status = 11">
						<xsl:text>Pending Goals</xsl:text>
					</xsl:when>
					<!--</xsl:choose>&#xa0;(<xsl:value-of select="$GoalCount"/>)-->
				</xsl:choose>&#xa0;(<xsl:value-of select="$TotalRecords"/>)
			</div>

			<table id="tab_{$Status}_GoalsList"  class="tableMaster marginBottom10" cellpadding="5" cellspacing="5">
				<xsl:for-each select="$GoalsXml[Status = $Status]">
					<xsl:variable name="Stage" select="ProjectStage"></xsl:variable>

					<xsl:variable name="FormattedImageURL">
						<xsl:choose>
							<xsl:when test="$IsSecureConnection = 1">
								<xsl:call-template name="replaceCharsInString">
									<xsl:with-param name="stringIn" select="ImageURL"></xsl:with-param>
									<xsl:with-param name="charsIn">
										<xsl:text>http://</xsl:text>
									</xsl:with-param>
									<xsl:with-param name="charsOut">
										<xsl:text>https://</xsl:text>
									</xsl:with-param>
								</xsl:call-template>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="ImageURL"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>

					<div id="divOpenProjects_{CRMProjectID}" name="collapsed" itemID="{CRMProjectID}">
						<itemExpansionStatus id="divOpenProjects_{CRMProjectID}_expansionStatus" status="collapsed"></itemExpansionStatus>
						<tr id="tr_Goal_{CRMProjectID}">
							<td width="5%" class="verticallyMiddle">
								<xsl:choose>
									<xsl:when test="ImageURL != ''">
										<img src="{$FormattedImageURL}" class="verticallyMiddle onMouseOver" style="display:none;" onload="setWidthAndHeightImage(this, 50);"
                                             onclick="OpenSpecifiedURL('{$Protocol}{$HostName}/Goal.aspx?ID={ItemID}')"></img>
									</xsl:when>
								</xsl:choose>
							</td>
							<td width="75%" class="verticallyMiddle">
								<div>
									<span class="label">
										<xsl:choose>
											<xsl:when test="$Version = 2">
												<xsl:text></xsl:text>
											</xsl:when>
											<xsl:otherwise>
												<xsl:choose>
													<xsl:when test ="Client != ''">
														<xsl:value-of select ="Client"/>
													</xsl:when>
													<xsl:otherwise>
														<a href="" id= "ancAcc_{normalize-space(CRMProjectID)}"
                                                           onClick = "return portal_EditAccount('ancAcc_{normalize-space(CRMProjectID)}','ddlAcc_{normalize-space(CRMProjectID)}')">
															<xsl:value-of select ="Account"/>
														</a>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:otherwise>
										</xsl:choose>
									</span>
									<span id="span_{CRMProjectID}_ProjectName" style="font-size:14px;" class="verticallyMiddle">
										<xsl:variable name="EscapedGoalName">
											<xsl:call-template name="replaceCharsInString">
												<xsl:with-param name="stringIn" select="Name"></xsl:with-param>
												<xsl:with-param name="charsIn">
													<xsl:text>'</xsl:text>
												</xsl:with-param>
												<xsl:with-param name="charsOut">
													<xsl:text>\'</xsl:text>
												</xsl:with-param>
											</xsl:call-template>
										</xsl:variable>
										
										<xsl:choose>
											<xsl:when test="$BetaVersion &gt; 2.5">
												<a id="projectName_{CRMProjectID}" href="javascript:void(0);"
												   onclick="loadGoal_3_0('{ItemID}','Employee_Operations_Filters','{$EscapedGoalName}','{$FormattedImageURL}','{SuccessKey}','{$PortalTypeID}','{$ItemID}','{$SelectedUserID}','SameWindow');"
												   style="cursor:pointer;font-family: 'PT Sans Narrow' , sans-serif; font-size: 22px; color: #6D6E71;">
													<xsl:value-of select="Name"/>
												</a>
												<a href="{$Protocol}{$HostName}/Goal.aspx?ID={ItemID}" target="_blank"
												   style="margin-left:15px;cursor:pointer;font-family: 'PT Sans Narrow' , sans-serif; font-size: 12px; color: #6D6E71;">Open Goal</a>
											</xsl:when>
											<xsl:otherwise>
												<a id="projectName_{CRMProjectID}" href="{$Protocol}{$HostName}/Goal.aspx?ID={ItemID}" target="_blank"
												   style="cursor:pointer;font-family: 'PT Sans Narrow' , sans-serif; font-size: 22px; color: #6D6E71;">
													<xsl:value-of select="Name"/>
												</a>
											</xsl:otherwise>
										</xsl:choose>
										<img src="{$TemplateURL}Web/Images/Edit_icon.png" style="cursor:pointer;margin-bottom:10px;" title="Edit" align="absmiddle"
                                             onClick="displayEditProjectName('txt_{CRMProjectID}_ProjectName','span_{CRMProjectID}_ProjectName');"></img>
									</span>
									<input id="txt_{CRMProjectID}_ProjectName" class="text" value="{Name}" style="display:none;width:230px;"
                                                                           onBlur="updateCRMProjectName('{$ItemID}','{CRMProjectID}','{ItemID}','txt_{CRMProjectID}_ProjectName','projectName_{CRMProjectID}','span_{CRMProjectID}_ProjectName');"></input>
								</div>
								<div style="width:500px;">
									<div style="float:left;" class="marginRight10">
										<span class="publicationSummary verticallyMiddle">
											<xsl:value-of select="KeyDate"/>
										</span>
									</div>
									<div style="float:left;">
										<!--<xsl:choose>
                                            <xsl:when test ="$PermissionID = 4">-->
										<a href="" id = "anc_{normalize-space(CRMProjectID)}"
                                           onClick = "return portal_EditStage('anc_{normalize-space(CRMProjectID)}','ddl_{normalize-space(CRMProjectID)}');">
											<span class="publicationSummary">
												<xsl:value-of select="ProjectStage"/>
											</span>
										</a>
										<select class="smallDropdown" style="display:none;width:120px"
                                                Origin="{ProjectStage}" id="ddl_{normalize-space(CRMProjectID)}"
                                                onChange="return portal_UpdateGoalStage('{$ItemID}','{normalize-space(CRMProjectID)}',
                                                        'anc_{normalize-space(CRMProjectID)}','ddl_{normalize-space(CRMProjectID)}',
                                                        '{TypeID}','{$PortalTypeID}','{$SelectedUserID}', '{ItemID}','{$SelectedTab}',1);">
											<xsl:for-each select="../../ProjectStages/Stage[CRMProjectStageID = 3 or CRMProjectStageID = 4 
                                                        or CRMProjectStageID = 6 or CRMProjectStageID = 11]">
												<xsl:choose>
													<xsl:when test="ProjectStage = $Stage">
														<option value="{CRMProjectStageID}" selected="selected"  >
															<xsl:value-of select="ProjectStage"/>
														</option>
													</xsl:when>
													<xsl:otherwise>
														<option value="{CRMProjectStageID}" >
															<xsl:value-of select="ProjectStage"/>
														</option>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:for-each>
										</select>

										<!--</xsl:when>
                                            <xsl:otherwise>
                                                <span class="publicationSummary">
                                                    <xsl:value-of select="ProjectStage"/>
                                                </span>
                                            </xsl:otherwise>
                                        </xsl:choose>-->
									</div>
								</div>
							</td>
							<td width="20%">
								<select id="ddlAction_{normalize-space(CRMProjectID)}" class="smallDropdown" style="width:112px;font-size:8pt;"
                                        onChange="clientPortal_SelectAction('{$ItemID}','divOpenProjects_{CRMProjectID}','{TemplateSourceID}',
                                                                                            '{ItemID}','{BrandID}','ddlAction_{normalize-space(CRMProjectID)}','{normalize-space(ClientUserID)}',
                                                                                            '{normalize-space(CRMProjectID)}','3');">
									<option value="-99" >
										--Select Action--
									</option>
									<xsl:choose>
										<xsl:when test="ClientUserID != 0 and ($CommunityAdmin = 1 and TemplateSourceID &gt; 0) and Name != ''">
											<option value="1">Send Response</option>
											<option value="2">Re-apply Template</option>
											<option value="3">Add Me</option>
											<option value="4">Delete</option>
										</xsl:when>
										<xsl:when test ="ClientUserID != 0 and ($CommunityAdmin = 1 and TemplateSourceID &gt; 0)">
											<option value="1">Send Response</option>
											<option value="2">Re-apply Template</option>
											<option value="4">Delete</option>
										</xsl:when>
										<xsl:when test="($CommunityAdmin = 1 and TemplateSourceID &gt; 0) and Name != ''">
											<option value="2">Re-apply Template</option>
											<option value="3">Add Me</option>
											<option value="4">Delete</option>
										</xsl:when>
										<xsl:when test="ClientUserID != 0 and Name != ''">
											<option value="1">Send Response</option>
											<option value="2">Re-apply Template</option>
											<option value="3">Add Me</option>
											<option value="4">Delete</option>
										</xsl:when>
										<xsl:when test="ClientUserID != 0">
											<option value="1">Send Response</option>
										</xsl:when>
										<xsl:when test="($CommunityAdmin = 1 and TemplateSourceID &gt; 0) and ClientUserID = 0 and Name = ''">
											<option value="2">Re-apply Template</option>
											<option value="4">Delete</option>
										</xsl:when>
										<xsl:when test="Name != ''">
											<option value="3">Add Me</option>
										</xsl:when>
									</xsl:choose>
								</select>
								<div class="marginLeft10">
									<xsl:if test="SendResponseDate != ''">
										<span class="publicationSummary" style="color: rgb(115, 111, 110);">
											<xsl:value-of select="SendResponseDate"/>
										</span>
									</xsl:if>
								</div>
							</td>
						</tr>
					</div>
					<div id="divOpenProjects_{CRMProjectID}_detail_container" style="position:absolute;display:none;border: 1px solid black;padding: 5px;
                                             background-color:#FFFFFF;visibility: visible;width:600px;"></div>
				</xsl:for-each>

			</table>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>