﻿<?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:key name="distinctRep" match="CRMOpportunity" use="./SalesUser"></xsl:key>
	<xsl:template name="TemplatePipelineSummaryPanel">
		<xsl:param name="CurrentPortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalReport" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="ReportDefaultCol" select="'N/A'"></xsl:param>
		<xsl:param name="DefaultReport" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>
		<xsl:param name="SettingsXML" select="'N/A'"></xsl:param>



		<table id="tbl_MyPipeline_{$CurrentPortalItemID}_Body_Summary" class="tableMaster tblsPipelineSpace" cellpadding="4" cellspacing="0">
			<tr>
				<td class="pipelineReportSummarySmallCell" id="cell_MyPipeline_{$CurrentPortalItemID}_Body_Summary_Data">
					<div id="div_MyPipeline_{$CurrentPortalItemID}_Body_Summary_Data">
						<xsl:call-template name="TemplateReport">
							<xsl:with-param name="ReportData" select="$PortalReport"></xsl:with-param>
							<xsl:with-param name="Report" select="$DefaultReport"></xsl:with-param>
							<xsl:with-param name="SourceId" select="$CurrentPortalItemID"></xsl:with-param>
							<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
							<xsl:with-param name="ReportDefaultCol" select="$ReportDefaultCol"></xsl:with-param>
							<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
							<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
							<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
							<xsl:with-param name="SettingsXML" select="$SettingsXML"></xsl:with-param>
						</xsl:call-template>
					</div>
				</td>
				<td class="pipelineReportVisibleNumberCell" id="cell_MyPipeline_{$CurrentPortalItemID}_Body_Numbers">
					<xsl:choose>
						<xsl:when test="$EmployeeID &gt; 0">
							<div id="div_MyPipeline_{$CurrentPortalItemID}_Body_Numbers_PipelineBudget"></div>
							<script language="javascript" type="text/javascript">
								Numbers_LoadNumbersDataEntryPanel(<xsl:value-of select="$EmployeeID"></xsl:value-of>
								, 'Pipeline Budget'
								, <xsl:value-of select="$CurrentPortalItemID"></xsl:value-of>
								, 'div_MyPipeline_<xsl:value-of select="$CurrentPortalItemID"></xsl:value-of>_Body_Numbers_PipelineBudget'
								, ''
								, 0
								, 12
								, 1);
							</script>
						</xsl:when>
					</xsl:choose>
				</td>
			</tr>
		</table>




	</xsl:template>
	<xsl:template name="TemplateTwoDimensionalReportData">
		<xsl:param name="ReportData" select="'N/A'"></xsl:param>
		<xsl:param name="ReportDefaultCol" select="'N/A'"></xsl:param>
		<xsl:param name="Report" select="'N/A'"></xsl:param>
		<xsl:param name="SourceId" select="'N/A'"></xsl:param>

		<xsl:variable name="ColWidth">
			<xsl:value-of select="round((95) div  count($ReportDefaultCol/Column))"/>
		</xsl:variable>

		<xsl:variable name="CustomStyleSource" select="$ReportData/CustomStyle/CustomStyleSource"></xsl:variable>

		<xsl:variable name="CustomStyleBackgroundClass">
			<xsl:choose>
				<xsl:when test="$ReportData/CustomStyle/CustomStyleSource">
					<xsl:value-of select="$ReportData/CustomStyle/CustomStyleSource"/>
					<xsl:text>Background</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="CustomStyleHeaderStyle">
			<xsl:choose>
				<xsl:when test="$ReportData/CustomStyle/CustomStyleSource">
					<xsl:value-of select="$ReportData/CustomStyle/CustomStyleSource"/>
					<xsl:text>ReportHeader</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="HeaderFontStyle">
			<xsl:choose>
				<xsl:when test="$ReportData/CustomStyle/CustomStyleSource">
					<xsl:value-of select="$ReportData/CustomStyle/CustomStyleSource"/>
					<xsl:text>ReportHeaderFont</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>packageTitle</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<table id="tbl_MyPipeline_{$SourceId}_Body_Summary_Data" class="tableMaster {$CustomStyleBackgroundClass}" cellpadding="4" cellspacing="0">

			<tr class="{$CustomStyleHeaderStyle}">
				<xsl:for-each select="$ReportDefaultCol/Column">
					<xsl:variable name="TextAlign">
						<xsl:choose>
							<xsl:when test="ColumnDataType = 'Money'">
								<xsl:text>text-align:right;</xsl:text>
							</xsl:when>
							<xsl:when test="ColumnDataType = 'Int'">
								<xsl:text>text-align:center;</xsl:text>
							</xsl:when>
						</xsl:choose>
					</xsl:variable>
					<td style="{$TextAlign}"  width="{$ColWidth}%">
						<span class="{$HeaderFontStyle}">
							<xsl:value-of select="ColumnDisplayName"/>
						</span>
					</td>
				</xsl:for-each>
				<td width="5%"></td>
			</tr>
			<xsl:for-each select="$ReportData/Report/ReportRow">
				<xsl:variable name="ReportCurrentRec" select="."></xsl:variable>


				<xsl:variable name="CustomStyleHighlightRow">
					<xsl:choose>
						<xsl:when test="HighlightRow = 1">
							<xsl:value-of select="$CustomStyleSource"/>
							<xsl:text>HighlightRow</xsl:text>
						</xsl:when>
					</xsl:choose>
				</xsl:variable>

				<xsl:variable name="Cumulative">
					<xsl:value-of select="sum(preceding-sibling::ReportRow/child::node()[name(.) = 'Variance'])
                                  + $ReportCurrentRec/child::node()[name(.) = 'Variance']"/>
				</xsl:variable>

				<tr class="{$CustomStyleHighlightRow}">
					<xsl:for-each select="$ReportDefaultCol/Column">
						<xsl:variable name="CurrentCol" select="ColumnName"></xsl:variable>

						<xsl:variable name="TextAlign">
							<xsl:choose>
								<xsl:when test="ColumnDataType = 'Money'">
									<xsl:text>text-align:right;</xsl:text>
								</xsl:when>
								<xsl:when test="ColumnDataType = 'Int'">
									<xsl:text>text-align:center;</xsl:text>
								</xsl:when>
							</xsl:choose>
						</xsl:variable>

						<xsl:variable name="CustomStyleHighlightColumn">
							<xsl:choose>
								<xsl:when test="$ReportCurrentRec/child::node()[name(.) = $CurrentCol]/@HighlightColumn = 1">
									<xsl:value-of select="$CustomStyleSource"/>
									<xsl:text>HighlightColumn</xsl:text>
								</xsl:when>
							</xsl:choose>
						</xsl:variable>

						<td style="{$TextAlign}" class="{$CustomStyleHighlightColumn}">
							<span class="packageTitle">
								<xsl:choose>
									<xsl:when test="$CurrentCol = 'Cumulative' and $Cumulative &lt; 0">
										<xsl:text>-</xsl:text>
										<xsl:text>$</xsl:text>
										<xsl:variable name="CumulativeValue">
											<xsl:call-template name="replaceCharsInString">
												<xsl:with-param name="stringIn" select="$Cumulative"></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:value-of select="format-number($CumulativeValue,'#,###')"/>
									</xsl:when>
									<xsl:when test="$CurrentCol = 'Cumulative' and $Cumulative &gt; 0">
										<xsl:text>$</xsl:text>
										<xsl:value-of select="format-number($Cumulative,'#,###')"/>
									</xsl:when>
									<xsl:when test="number($ReportCurrentRec/child::node()[name(.) = $CurrentCol]) &lt; 0 and ColumnDataType = 'Money'">
										<xsl:text>-</xsl:text>
										<xsl:text>$</xsl:text>

										<xsl:variable name="MoneyValue">
											<xsl:call-template name="replaceCharsInString">
												<xsl:with-param name="stringIn" select="$ReportCurrentRec/child::node()[name(.) = $CurrentCol]"></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:value-of select="format-number($MoneyValue, '#,###')"/>
									</xsl:when>
									<xsl:when test="ColumnDataType = 'Money'">
										<xsl:if test="string(number($ReportCurrentRec/child::node()[name(.) = $CurrentCol])) != 'NaN'
                                                and number($ReportCurrentRec/child::node()[name(.) = $CurrentCol]) &gt; 0">
											<xsl:text>$</xsl:text>
											<xsl:value-of select="format-number($ReportCurrentRec/child::node()[name(.) = $CurrentCol], '#,###')"/>
										</xsl:if>
									</xsl:when>
									<xsl:when test="ColumnDataType = 'Int'">
										<xsl:if test="string(number($ReportCurrentRec/child::node()[name(.) = $CurrentCol])) != 'NaN'">
											<xsl:value-of select="format-number($ReportCurrentRec/child::node()[name(.) = $CurrentCol], '#,###')"/>
										</xsl:if>
									</xsl:when>
									<xsl:when test="ColumnDataType = 'Percent'">
										<xsl:if test="string(number($ReportCurrentRec/child::node()[name(.) = $CurrentCol])) != 'NaN'">
											<xsl:value-of select="$ReportCurrentRec/child::node()[name(.) = $CurrentCol]"/> %
										</xsl:if>
									</xsl:when>
									<xsl:when test="ColumnDataType = 'PercentWithoutDecimal'">
										<xsl:if test="string(number($ReportCurrentRec/child::node()[name(.) = $CurrentCol])) != 'NaN'">
											<xsl:value-of select="format-number($ReportCurrentRec/child::node()[name(.) = $CurrentCol], '#,###')"/> %
										</xsl:if>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="$ReportCurrentRec/child::node()[name(.) = $CurrentCol]"/>
									</xsl:otherwise>
								</xsl:choose>
							</span>
						</td>
					</xsl:for-each>
					<td width="5%"></td>
				</tr>
			</xsl:for-each>
			<tr>
				<td colspan="{count($ReportDefaultCol/Column)+1}" class="graySeperatorLine_1">
				</td>
			</tr>
			<tr>
				<xsl:for-each select="$ReportDefaultCol/Column">
					<xsl:variable name="CurrentCol" select="ColumnName"></xsl:variable>
					<xsl:variable name="ValueColumnName" select="ValueColumnName"></xsl:variable>
					<xsl:variable name="CountColumnName" select="CountColumnName"></xsl:variable>

					<xsl:variable name="TextAlign">
						<xsl:choose>
							<xsl:when test="ColumnDataType = 'Money'">
								<xsl:text>text-align:right;</xsl:text>
							</xsl:when>
							<xsl:when test="ColumnDataType = 'Int'">
								<xsl:text>text-align:center;</xsl:text>
							</xsl:when>
						</xsl:choose>
					</xsl:variable>

					<xsl:variable name="IsAverageColumn">
						<xsl:choose>
							<xsl:when test="IsAverageColumn">
								<xsl:number value="1"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:number value="0"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>

					<td style="{$TextAlign}">
						<span class="packageTitle">
							<xsl:choose>
								<xsl:when test="$CurrentCol != 'RowLabel' and $IsAverageColumn != 1">
									<xsl:choose>
										<xsl:when test="(
                                                  sum($ReportData/Report/ReportRow/child::node()[name(.) = $CurrentCol and text()]) &lt; 0
                                                  or 
                                                  sum($ReportData/Report/ReportRow/child::node()[name(.) = 'Variance' and $CurrentCol = 'Cumulative' and text()]) &lt; 0
                                                  ) and 
                                                  (ColumnDataType = 'Money' or ColumnDataType = 'Int' or ColumnDataType = 'Percent' or ColumnDataType = 'PercentWithoutDecimal')">
											<xsl:text>-</xsl:text>
										</xsl:when>
									</xsl:choose>
									<xsl:choose>
										<xsl:when test="ColumnDataType = 'Money' 
                                                  and (
                                                        string(number(sum($ReportData/Report/ReportRow/child::node()[name(.) = $CurrentCol and text()]))) != 'NaN'
                                                            or 
                                                        string(number(sum($ReportData/Report/ReportRow/child::node()[name(.) = 'Variance' and $CurrentCol = 'Cumulative' and text()]))) != 'NaN'
                                                       )
                                                  and 
                                                      (
                                                        number(sum($ReportData/Report/ReportRow/child::node()[name(.) = $CurrentCol and text()])) != 0
                                                            or 
                                                        sum($ReportData/Report/ReportRow/child::node()[name(.) = 'Variance' and $CurrentCol = 'Cumulative' and text()]) != 0
                                                       )">
											<xsl:text>$</xsl:text>
										</xsl:when>
									</xsl:choose>
									<xsl:choose>
										<xsl:when test="ColumnDataType = 'Money' or ColumnDataType = 'Int' or ColumnDataType = 'Percent' or ColumnDataType = 'PercentWithoutDecimal'">

											<xsl:variable name="MoneyValue">
												<xsl:choose>
													<xsl:when test="$CurrentCol = 'Cumulative'">
														<xsl:call-template name="replaceCharsInString">
															<xsl:with-param name="stringIn" select="sum($ReportData/Report/ReportRow/child::node()[name(.) = 'Variance' and text()])"></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:when>
													<xsl:otherwise>
														<xsl:call-template name="replaceCharsInString">
															<xsl:with-param name="stringIn" select="sum($ReportData/Report/ReportRow/child::node()[name(.) = $CurrentCol and text()])"></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:otherwise>
												</xsl:choose>
											</xsl:variable>
											<xsl:value-of select="format-number($MoneyValue, '#,###')"/>
										</xsl:when>
									</xsl:choose>
									<xsl:choose>
										<xsl:when test="(ColumnDataType = 'Percent' or ColumnDataType = 'PercentWithoutDecimal') 
                                          and string(number(sum($ReportData/Report/ReportRow/child::node()[name(.) = $CurrentCol  and text()]))) != 'NaN'">
											<xsl:text>%</xsl:text>
										</xsl:when>
									</xsl:choose>
								</xsl:when>
								<xsl:when test="$IsAverageColumn = 1">
									<xsl:choose>
										<xsl:when test="ColumnDataType = 'Money' and string(number(sum($ReportData/Report/ReportRow/child::node()[name(.) = $ValueColumnName and text()]) 
                                                  div sum($ReportData/Report/ReportRow/child::node()[name(.) = $CountColumnName and text()]))) != 'NaN'">
											<xsl:text>$</xsl:text>
										</xsl:when>
									</xsl:choose>
									<xsl:choose>
										<xsl:when test="string(number(sum($ReportData/Report/ReportRow/child::node()[name(.) = $ValueColumnName and text()]) 
                                                  div sum($ReportData/Report/ReportRow/child::node()[name(.) = $CountColumnName and text()]))) != 'NaN'">
											<xsl:value-of select="format-number(sum($ReportData/Report/ReportRow/child::node()[name(.) = $ValueColumnName and text()]) 
                                                  div sum($ReportData/Report/ReportRow/child::node()[name(.) = $CountColumnName and text()]), '#,###')"/>
										</xsl:when>
									</xsl:choose>
								</xsl:when>
							</xsl:choose>
						</span>
					</td>
				</xsl:for-each>
				<td width="5%"></td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template name="TemplateReport">
		<xsl:param name="ReportData" select="'N/A'"></xsl:param>
		<xsl:param name="Report" select="'N/A'"></xsl:param>
		<xsl:param name="ReportDefaultCol" select="'N/A'"></xsl:param>
		<xsl:param name="SourceId" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="FilterRequest">
			<xsl:number value="0"/>
		</xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>
		<xsl:param name="SettingsXML" select="'N/A'"></xsl:param>

		<xsl:variable name="ParsedEmployeeID">
			<xsl:choose>
				<xsl:when test="$EmployeeID[text()]">
					<xsl:value-of select="$EmployeeID"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:number value="-99"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="FiltersVisibility">
			<xsl:choose>
				<xsl:when test="$EmployeeID[text()]">
					<xsl:text>display:table-cell;</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>display:none;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$FilterRequest = 1">
				<xsl:choose>
					<xsl:when test="$ReportDefaultCol/ReportLayout = 'One Dimensional'">
						<xsl:call-template name="TemplateOneDimensionalReportData">
							<xsl:with-param name="ReportData" select="$ReportData"></xsl:with-param>
							<xsl:with-param name="ReportDefaultCol" select="$ReportDefaultCol"></xsl:with-param>
							<xsl:with-param name="Report" select="$Report"></xsl:with-param>
							<xsl:with-param name="SourceId" select="$SourceId"></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$ReportDefaultCol/ReportLayout = 'Two Dimensional'">
						<xsl:call-template name="TemplateTwoDimensionalReportData">
							<xsl:with-param name="ReportData" select="$ReportData"></xsl:with-param>
							<xsl:with-param name="ReportDefaultCol" select="$ReportDefaultCol"></xsl:with-param>
							<xsl:with-param name="Report" select="$Report"></xsl:with-param>
							<xsl:with-param name="SourceId" select="$SourceId"></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<div id="div_{$SourceId}_Report">
					<div id="div_{$SourceId}_Report_Filter" class="marginBottom20">

						<table class="tableMaster" cellpadding="2" cellspacing="4">
							<tr>

								<td width="20%">
									<select class="dropdown" id="opt_{$SourceId}_Report_Filter"
											onChange="Portal_LoadCRMPipelineReport('opt_{$SourceId}_Report_Filter', {$SourceId}, 1, {$ParsedEmployeeID});">

										<xsl:choose>
											<xsl:when test="count($SettingsXML/DashboardTabs/ReportingDashboard/Tab[TabName = 'Pipeline']/Reports/Report) &gt; 0">
												<xsl:for-each select="$SettingsXML/DashboardTabs/ReportingDashboard/Tab[TabName = 'Pipeline']/Reports/Report">
													<option value="{@Key}">
														<xsl:value-of select="."/>
													</option>
												</xsl:for-each>
											</xsl:when>
											<xsl:otherwise>
												<option selected="selected" value="PipelineSummary">Pipeline Summary</option>
												<option value="BudgetVariance">Budget Variance</option>
												<option value="ByStatus">By Status</option>
												<option value="ByLocation">By Location</option>
												<option value="Closed">Closed</option>
												<option value="BySegments">By Segments</option>
												<option value="ByRep">By Represented</option>
												<option value="BySource">By Source</option>
												<option value="BySize">Size by Segment</option>
												<option value="ByCommission">By Commission</option>
												<option value="ByProbability">By Probability</option>
												<option value="ByClient">By Client</option>
												<option value="ByTransactionType">By Transaction Type</option>
												<option value="BadBlood">Probability by Status</option>
											</xsl:otherwise>
										</xsl:choose>
									</select>
								</td>
								<td width="10%" style="{$FiltersVisibility}">
									<div id="div_{$SourceId}_LoadCRMOpportunityRefresh" class="verticallyMiddle onMouseOver divBrowseGradient textCenter spanBrowseGradientTextGray"
												style="width:100px;line-height:20px;"
												onclick="Portal_LoadCRMPipelineReport('opt_{$SourceId}_Report_Filter', {$SourceId}, 1, {$ParsedEmployeeID});">
										<span class="capitalFont">Refresh</span>
									</div>
								</td>
								<td width="30%"></td>
								<td width="40%"></td>
							</tr>
						</table>
					</div>
					<!--<div style="padding-bottom:23px;">
                        <div id="btnGrid" style="float:left;width:12%;" onclick="return ShowChartOrGridView('Grid','{$SourceId}',opt_{$SourceId}_Report_Filter, 1, {$ParsedEmployeeID})"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuSelected " >Grid</div>
                        <div id="btnChart" style="float:left;width:12%;" onclick="return ShowChartOrGridView('Chart','{$SourceId}', 'opt_{$SourceId}_Report_Filter', 1, '{$ParsedEmployeeID}')"  class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" >Chart</div>
                    </div><br/>-->

					<div id="div_{$SourceId}_Report_Data" style="background-color:#ffffff;border:1px solid;" class="marginBottom10">

						<xsl:choose>
							<xsl:when test="$ReportDefaultCol/ReportLayout = 'One Dimensional'">
								<xsl:call-template name="TemplateOneDimensionalReportData">
									<xsl:with-param name="ReportData" select="$ReportData"></xsl:with-param>
									<xsl:with-param name="ReportDefaultCol" select="$ReportDefaultCol"></xsl:with-param>
									<xsl:with-param name="Report" select="$Report"></xsl:with-param>
									<xsl:with-param name="SourceId" select="$SourceId"></xsl:with-param>
								</xsl:call-template>
							</xsl:when>
							<xsl:when test="$ReportDefaultCol/ReportLayout = 'Two Dimensional'">
								<xsl:call-template name="TemplateTwoDimensionalReportData">
									<xsl:with-param name="ReportData" select="$ReportData"></xsl:with-param>
									<xsl:with-param name="ReportDefaultCol" select="$ReportDefaultCol"></xsl:with-param>
									<xsl:with-param name="Report" select="$Report"></xsl:with-param>
									<xsl:with-param name="SourceId" select="$SourceId"></xsl:with-param>
								</xsl:call-template>
							</xsl:when>
						</xsl:choose>

					</div>
					<!--<div id="DivShowChart" style="border: 1px solid; display: none; background-color: rgb(230, 231, 232);"></div>-->
				</div>
				<!--<div>
                    <table  cellpadding="2" cellspacing="4">
                        <tr  >
                            <td colspan="6" >
                                <div id="divActive" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuSelected " onclick="return DisplayOpportunities('Active', 'Closed', 'Lost');" style="float:left" >Active</div>
                                <div id="divClosed" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="return DisplayOpportunities('Closed','Active','Lost');" style="float:left"  >Closed</div>
                                <div id="divLost" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="return DisplayOpportunities('Lost','Closed','Active');" style="float:left"  >Lost</div>
                            </td>
                            <td  style="{$FiltersVisibility};">
                                <span class="packageTitle">Search:</span>
                            </td>
                            <td  style="{$FiltersVisibility}">
                                <input type="text"  id="txt_{$SourceId}_OppDataFilterText"
                                       onKeyUp="portal_FilterCRMOpportunitiesAndReports({$SourceId},'div_MyPipeline_{$SourceId}_Body_Opportunities',{$ParsedEmployeeID}, 0, 25, 1, {$Boxed}, event, 1);"
                                       onBlur="portal_FilterCRMOpportunitiesAndReports({$SourceId},'div_MyPipeline_{$SourceId}_Body_Opportunities',{$ParsedEmployeeID}, 0, 25, 1, {$Boxed}, event, 0);"></input>
                            </td>
                            <td style="{$FiltersVisibility}">
                                <xsl:variable name="CRMUDFDefID" select="$UDFXML/UDFDefinition[Column_Name = 'CustomStatus']/CRMUDFDefID"/>
                                <xsl:variable name="CRMUDFDefColumnHeader" select="$UDFXML/UDFDefinition[Column_Name = 'CustomStatus']/ColumnHeader"/>

                                <select  class="smallDropdown" id="opt_{$SourceId}_OppDataFilterStatusOption"
                                        onChange="portal_FilterCRMOpportunitiesAndReports({$SourceId},'div_MyPipeline_{$SourceId}_Body_Opportunities',{$ParsedEmployeeID}, 0, 25, 1, {$Boxed}, event, 0);">
                                    <option value="">
                                        <xsl:value-of select="$CRMUDFDefColumnHeader"/>
                                    </option>
                                    <xsl:for-each select="$UDFMasterValues/UDFMasterValue[CRMUDFDefID = $CRMUDFDefID]">
                                        <option value="{StoreValue}" relatedValue="{RelatedValue}">
                                            <xsl:value-of select="DisplayValue"/>
                                        </option>
                                    </xsl:for-each>
                                </select>
                            </td>
                        </tr>
                    </table>
                </div>-->

			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>

	<xsl:template name="TemplateOneDimensionalReportData">
		<xsl:param name="ReportData" select="'N/A'"></xsl:param>
		<xsl:param name="ReportDefaultCol" select="'N/A'"></xsl:param>
		<xsl:param name="Report" select="'N/A'"></xsl:param>
		<xsl:param name="SourceId" select="'N/A'"></xsl:param>

		<table id="tbl_MyPipeline_{$SourceId}_Body_Summary_Data" class="tableMaster" cellpadding="4" cellspacing="0">

			<xsl:for-each select="$ReportDefaultCol/Rows/child::node()">
				<xsl:variable name="CurrentHeaderCol" select="."></xsl:variable>
				<xsl:variable name="CurrentCol" select="name(.)"></xsl:variable>

				<tr>
					<td width="32%" style="text-align:right;">
						<span class="packageTitle">
							<xsl:value-of select="$CurrentHeaderCol/ColDisplayName"/>
						</span>
					</td>
					<td width="18%">
					</td>
					<td width="5%">
						<!--<span class="packageTitle">$</span>-->
					</td>
					<td width="30%" style="text-align:right;">
						<span class="packageTitle">
							<xsl:if test="string(number($ReportData/Report/child::node()[name(.) = $CurrentCol])) != 'NaN'">
								$ <xsl:value-of select="format-number($ReportData/Report/child::node()[name(.) = $CurrentCol], '#,###')"/>
							</xsl:if>
						</span>
					</td>
					<td width="15%" style="text-align:right;">
					</td>
				</tr>

			</xsl:for-each>

		</table>
	</xsl:template>
	<xsl:template name="ModuleBoxLayoutTemplate">
		<xsl:param name="Header" select="'N/A'"></xsl:param>
		<xsl:param name="ContentHTML" select="'N/A'"></xsl:param>
		<xsl:param name="BackgroundColor" select="'N/A'"></xsl:param>
		<xsl:param name="TextColor" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="IdPrefix" select ="'div_Item'"></xsl:param>
		<xsl:param name="ContentHTMLIsTexted">
			<xsl:number value="1"/>
		</xsl:param>

		<xsl:variable name="BoxBorderColor">
			<xsl:choose>
				<xsl:when test="$BackgroundColor = 'moduleBoxHeaderBackground'">
					<xsl:text></xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>border:1px solid #D1D3D4;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="BoxBackgroundColor">
			<xsl:choose>
				<xsl:when test="$BackgroundColor = 'moduleBoxHeaderBackground'">
					<xsl:text>moduleBoxBackground</xsl:text>
				</xsl:when>
				<xsl:when test="$BackgroundColor = 'TournamentShareHeaderBox'">
					<xsl:text>TournamentClubBackground</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text></xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="CapitalFont">
			<xsl:choose>
				<xsl:when test="$BackgroundColor = 'moduleBoxHeaderBackground' and contains($Header, 'pro')">
					<xsl:text>text-transform: uppercase;</xsl:text>
				</xsl:when>
				<xsl:when test="$BackgroundColor = 'TournamentShareHeaderBox'">
					<xsl:text></xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>text-transform: capitalize;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="TextClass">
			<xsl:choose>
				<xsl:when test="$BackgroundColor = 'moduleBoxHeaderBackground'">
					<xsl:text>moduleBoxHeader</xsl:text>
				</xsl:when>
				<xsl:when test="$BackgroundColor = 'TournamentShareHeaderBox'">
					<xsl:text></xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>moduleBoxHeaderRightSide</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="displayImage">
			<xsl:choose>
				<xsl:when test="$BackgroundColor != 'moduleBoxHeaderBackground'">
					<xsl:text>display:none;</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>display:inline;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="cellPadding">
			<xsl:choose>
				<xsl:when test="$BackgroundColor != 'moduleBoxHeaderBackground'">
					<xsl:text>5</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>0</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="heightStyle">
			<xsl:choose>
				<xsl:when test="$BackgroundColor = 'TournamentShareHeaderBox'">
					<xsl:text></xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>height:36px;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<div id="{normalize-space($IdPrefix)}_ModuleBox" style="{$BoxBorderColor}" class="{$BoxBackgroundColor}">
			<table class="tableMaster" cellpadding="{$cellPadding}" cellspacing="0">
				<tr >
					<td>
						<div class="section-title " >
							<p style="100%">
								<span style="width:60%">
									<xsl:choose>
										<xsl:when test="contains($Header,'pro')">
											<span class="paddingTop15 sentenceFont">
												<xsl:value-of select="$Header"/>
											</span>
										</xsl:when>
										<xsl:otherwise>
											<span class="paddingTop15" style="{$CapitalFont}">
												<xsl:value-of select="$Header"/>
											</span>
										</xsl:otherwise>
									</xsl:choose>
								</span>
							</p>
						</div>
					</td>
				</tr>
				<tr style="background: #f6f6f6;">
					<td >
						<div id="{normalize-space($IdPrefix)}_ContainerBox" style="">
							<xsl:choose>
								<xsl:when test="$ContentHTMLIsTexted = 1">
									<xsl:value-of select="$ContentHTML" disable-output-escaping="yes"></xsl:value-of>
								</xsl:when>
								<xsl:otherwise>
									<xsl:copy-of select="$ContentHTML"/>
								</xsl:otherwise>
							</xsl:choose>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</xsl:template>

	<xsl:template name="TemplateOpportunitiesForPortal">
		<xsl:param name="CRMOpportunitiesXML" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommissionPercent" select="'N/A'"></xsl:param>
		<xsl:param name="Action" select="'N/A'"></xsl:param>
		<xsl:param name="SortColName" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentOrder" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunityHeader" select="'N/A'"></xsl:param>
		<xsl:param name="PageSize" select="'N/A'"></xsl:param>
		<xsl:param name="PageNumber" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>
		<xsl:param name="SkipRecords" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedTab" select="'N/A'"></xsl:param>
		<xsl:param name="EditingVersion" select="'N/A'"></xsl:param>

		<xsl:variable name="TotalRecords">
			<xsl:choose>
				<xsl:when test="$CRMOpportunitiesXML/CRMOpportunity/TotalRec[text()]">
					<xsl:value-of select="$CRMOpportunitiesXML/CRMOpportunity/TotalRec"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:number value="0"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="CRMOpportunitiesHeaderXML">
			<xsl:choose>
				<xsl:when test="$IsCommissionPercent = 0">
					<xsl:copy-of select="$CRMOpportunityHeader
                                 /child::node()[name(.) != 'CustomTransSize' and  name(.) != 'TransCommissionRate' and name(.) != 'SalesUser'
								 and name(.) !='FeeMultipleYN' and name(.) !='FeePayment01'
										 and name(.) !='FeePayment02' and name(.) !='FeeTarget01' and name(.) !='FeeTarget02']"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:copy-of select="$CRMOpportunityHeader/child::node()[name(.) != 'SalesUser'
								 and name(.) !='FeeMultipleYN' and name(.) !='FeePayment01'
								 and name(.) !='FeePayment02' and name(.) !='FeeTarget01' and name(.) !='FeeTarget02']"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="maxCols">
			<xsl:choose>
				<xsl:when test="$IsCommissionPercent = 1">
					<xsl:number value="8"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:number value="6"/>
				</xsl:otherwise>
			</xsl:choose>

		</xsl:variable>

		<xsl:variable name="ColWidth">
			<xsl:value-of select="round((100-1) div  $maxCols)"/>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$Action = 'AddNewCRMOpportunity'">
				<xsl:call-template name="TemplateOpportunity">
					<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
					<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
					<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
					<xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
					<xsl:with-param name="UDFXML" select="msxsl:node-set($UDFXML)"></xsl:with-param>
					<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
					<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
					<xsl:with-param name="OpportunityMode">
						<xsl:text>EditNewlyAdded</xsl:text>
					</xsl:with-param>
					<xsl:with-param name="CRMOpportunitiesHeaderXML" select="msxsl:node-set($CRMOpportunitiesHeaderXML)"></xsl:with-param>
					<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
					<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
					<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
					<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
					<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
					<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="Action" select="$Action"></xsl:with-param>
					<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<table id="tbl_{$PortalItemID}_Opportunities" class="tableMaster" cellpadding="4" cellspacing="0">
					<tbody id="tbl_{$PortalItemID}_Opportunities_body">
						<xsl:variable name="colspan">
							<xsl:value-of select="$maxCols + 1"/>
						</xsl:variable>
						<!--<tr>
                            <td colspan="6" >
                                <div id="divActive" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuSelected " onclick="return DisplayOpportunities('Active', 'Closed', 'Lost');" style="float:left" >Active</div>
                                <div id="divClosed" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="return DisplayOpportunities('Closed','Active','Lost');" style="float:left"  >Closed</div>
                                <div id="divLost" class="packageTitle textCenter onMouseOver singleCellLayoutSubMenuUnSelected" onclick="return DisplayOpportunities('Lost','Closed','Active');" style="float:left"  >Lost</div>
                            </td>                            
                        </tr>-->
						<tr>
							<td class="textRight" colspan="{$colspan}">
								<a href="http://{$HostName}/LifeSpaceCSV.aspx?ID={$PortalItemID}&amp;EID={$EmployeeID}&amp;Skip={$SkipRecords}&amp;Psize={$PageSize}&amp;Pnum={$PageNumber}&amp;SortColName={$SortColName}" class="link" target="_blank">
									<img width="20" hspace="3" height="20" border="0" alt="Generate CSV" class="verticallyMiddle" src="{$TemplateURL}Web/Images/icon_csv.png"></img>
									<span class="packageTitle verticallyMiddle">Generate CSV</span>
								</a>
							</td>
						</tr>
						<!--<xsl:call-template name="TemplateOppHeader">
                            <xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
                            <xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
                            <xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
                            <xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
                            <xsl:with-param name="UDFXML" select="msxsl:node-set($UDFXML)"></xsl:with-param>
                            <xsl:with-param name="CRMOpportunitiesHeaderXML" select="msxsl:node-set($CRMOpportunitiesHeaderXML)"></xsl:with-param>
                            <xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
                            <xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
                            <xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
                            <xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
                            <xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
                            <xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
                            <xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
                            <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                            <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                        </xsl:call-template>-->

						<xsl:call-template name="TemplateOpportunity">
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
							<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
							<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
							<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
							<xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
							<xsl:with-param name="UDFXML" select="msxsl:node-set($UDFXML)"></xsl:with-param>
							<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
							<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
							<xsl:with-param name="CRMOpportunitiesHeaderXML" select="msxsl:node-set($CRMOpportunitiesHeaderXML)"></xsl:with-param>
							<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
							<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
							<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
							<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
							<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
							<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
							<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
							<xsl:with-param name="Action" select="$Action"></xsl:with-param>
							<xsl:with-param name="SelectedTab" select="$SelectedTab"></xsl:with-param>
							<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
						</xsl:call-template>
					</tbody>
				</table>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:choose>
			<xsl:when test="$Action != 'AddNewCRMOpportunity'">

				<xsl:call-template name="TemplatePaging">
					<xsl:with-param name="TotalRecords" select="$TotalRecords"></xsl:with-param>
					<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
					<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
					<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
					<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
					<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
					<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
				</xsl:call-template>

				<xsl:if test="$TotalRecords = 0">
					<xsl:call-template name="TemplateAddNewOpportunity">
						<xsl:with-param name="UDFXML" select="msxsl:node-set($UDFXML)"></xsl:with-param>
						<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
						<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
						<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
						<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
						<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
					</xsl:call-template>
				</xsl:if>
			</xsl:when>
		</xsl:choose>

	</xsl:template>

	<xsl:template name="TemplatePaging">
		<xsl:param name="TotalRecords" select="'N/A'"></xsl:param>
		<xsl:param name="PageNumber" select="'N/A'"></xsl:param>
		<xsl:param name="PageSize" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>
		<xsl:param name="SortColName" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentOrder" select="'N/A'"></xsl:param>


		<xsl:variable name="TotalPages">
			<xsl:value-of select="ceiling($TotalRecords div $PageSize)"/>
		</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>

		<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="portal_LoadCRMOpportunities({$PortalItemID}, 'div_MyPipeline_{$PortalItemID}_Body_Opportunities', {$EmployeeID}, 0, {$PageSize}
                                      , {$PrevPageNumber}, {$Boxed}, '{$SortColName}', '{$CurrentOrder}')">&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="portal_LoadCRMOpportunities({$PortalItemID}, 'div_MyPipeline_{$PortalItemID}_Body_Opportunities', {$EmployeeID}, 0, {$PageSize}
                                      , {$NextPageNumber}, {$Boxed}, '{$SortColName}', '{$CurrentOrder}')">&gt;</span>
							</xsl:when>
						</xsl:choose>
					</td>
					<td width="94%">
					</td>
				</tr>
			</table>
		</div>
	</xsl:template>

	<xsl:template name="TemplateOppHeader">
		<xsl:param name="CRMOpportunitiesXML" select="'N/A'"></xsl:param>
		<xsl:param name="maxCols" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommissionPercent" select="'N/A'"></xsl:param>
		<xsl:param name="ColWidth" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunitiesHeaderXML" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentOrder">
			<xsl:text></xsl:text>
		</xsl:param>
		<xsl:param name="SortColName" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="EditBoxHeader">
			<xsl:number value="0"/>
		</xsl:param>
		<xsl:param name="EditSourceID" select="'N/A'"></xsl:param>
		<xsl:param name="PageSize" select="'N/A'"></xsl:param>
		<xsl:param name="PageNumber" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>

		<xsl:variable name="HeaderRowClass">
			<xsl:text></xsl:text>
		</xsl:variable>

		<!--<xsl:variable name="HeaderRowClass">
            <xsl:text>opportunityNewlyAdded</xsl:text>
        </xsl:variable>-->

		<xsl:variable name="HeaderRowDisplayStyle">
			<xsl:choose>
				<xsl:when test="$EditBoxHeader = 1">
					<xsl:text>display:none</xsl:text>
				</xsl:when>
				<xsl:when test="$EditBoxHeader = 2 or $EditBoxHeader = 3">
					<xsl:text>display:table-Row</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>display:table-Row</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="HeaderRowID">
			<xsl:choose>
				<xsl:when test="$EditBoxHeader = 1 or $EditBoxHeader = 2 or $EditBoxHeader = 3">
					<xsl:text>tr_</xsl:text>
					<xsl:value-of select="$PortalItemID"></xsl:value-of>
					<xsl:text>_OppData_</xsl:text>
					<xsl:value-of select="$EditSourceID"></xsl:value-of>
					<xsl:text>_EditHeader</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<tr id="{$HeaderRowID}" class="{$HeaderRowClass}" style="{$HeaderRowDisplayStyle}">
			<!--<td width="1%">
            </td>-->
			<xsl:choose>
				<xsl:when test="$EditBoxHeader = 0">
					<xsl:for-each select="$CRMOpportunitiesHeaderXML/child::node()[position() &lt;= $maxCols]">
						<xsl:variable name="CurrentHeaderCol" select="."></xsl:variable>
						<xsl:variable name="CurrentCol" select="name(.)"></xsl:variable>
						<xsl:choose>
							<xsl:when test="$CurrentCol = 'CustomTransSize' or  $CurrentCol = 'TransCommissionRate'">
								<xsl:if test="$IsCommissionPercent = 1">
									<xsl:call-template name="TemplateHeaderColumn">
										<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
										<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
										<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
										<xsl:with-param name="CurrentHeaderCol" select="$CurrentHeaderCol"></xsl:with-param>
										<xsl:with-param name="ColumnFormat" select="$CurrentHeaderCol/child::node()[name(.) = 'ColumnFormat']"></xsl:with-param>
										<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
										<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
										<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
										<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
										<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
										<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
										<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
									</xsl:call-template>
								</xsl:if>
							</xsl:when>
							<xsl:otherwise>
								<xsl:call-template name="TemplateHeaderColumn">
									<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
									<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
									<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
									<xsl:with-param name="CurrentHeaderCol" select="$CurrentHeaderCol"></xsl:with-param>
									<xsl:with-param name="ColumnFormat" select="$CurrentHeaderCol/child::node()[name(.) = 'ColumnFormat']"></xsl:with-param>
									<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
									<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
									<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
									<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
									<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
									<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
									<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
								</xsl:call-template>
							</xsl:otherwise>
						</xsl:choose>

					</xsl:for-each>
				</xsl:when>
				<xsl:otherwise>
					<td colspan="{$maxCols}">
					</td>
				</xsl:otherwise>
			</xsl:choose>

		</tr>
	</xsl:template>

	<xsl:template name="TemplateOpportunity">
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="maxCols" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommissionPercent" select="'N/A'"></xsl:param>
		<xsl:param name="ColWidth" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunitiesXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="OpportunityMode">
			<xsl:text>Listing</xsl:text>
		</xsl:param>
		<xsl:param name="CRMOpportunitiesHeaderXML" select="'N/A'"></xsl:param>
		<xsl:param name="SortColName" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentOrder">
			<xsl:text>descending</xsl:text>
		</xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="PageSize" select="'N/A'"></xsl:param>
		<xsl:param name="PageNumber" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>
		<xsl:param name="Action" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedTab" select="'N/A'"></xsl:param>
		<xsl:param name="EditingVersion" select="'N/A'"></xsl:param>


		<xsl:variable name="ListingDisplay">
			<xsl:choose>
				<xsl:when test="$OpportunityMode = 'Listing'">
					<xsl:text>table-row</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>none</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="EditDisplay">
			<xsl:choose>
				<xsl:when test="$OpportunityMode = 'Edit' or $OpportunityMode = 'EditNewlyAdded'">
					<xsl:text>table-row</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>none</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="ExpandedClass">
			<xsl:choose>
				<xsl:when test="$OpportunityMode = 'Edit' or $OpportunityMode = 'EditNewlyAdded'">
					<xsl:text>ExpandedElement</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="OpportunityEditClass">
			<xsl:text>opportunityNewlyAdded</xsl:text>
		</xsl:variable>

		<xsl:variable name="opportunityListingClass">
			<xsl:choose>
				<xsl:when test="$OpportunityMode = 'EditNewlyAdded'">
					<xsl:text>opportunityNewlyAdded</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<xsl:for-each select="$CRMOpportunitiesXML/CRMOpportunity[generate-id() = generate-id(key('distinctRep', ./SalesUser))]">

			<xsl:variable name="CurrentSalesUser" select="SalesUser"></xsl:variable>

			<tr class="packageTitleWhite" id="tr_{$PortalItemID}_OppData_{$CurrentSalesUser}_Start" style="display:table-row;">
				<td colspan="{$maxCols+1}" class="seperatorLine" style="background-color:#808285;">
					<span class="packageTitleWhite">
						<xsl:value-of select="$Employees/Employee[UserID = $CurrentSalesUser]/DisplayName"/>
					</span>
				</td>
			</tr>

			<xsl:if test="$Action != 'AddNewCRMOpportunity'">
				<xsl:call-template name="TemplateOppHeader">
					<xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
					<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
					<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
					<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
					<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
					<xsl:with-param name="CRMOpportunitiesHeaderXML" select="$CRMOpportunitiesHeaderXML"></xsl:with-param>
					<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
					<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
					<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
					<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
					<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
					<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
				</xsl:call-template>
			</xsl:if>

			<xsl:variable name="SortColDataType">
				<xsl:choose>
					<xsl:when test="$CRMOpportunitiesHeaderXML/child::node()[name(.) = $SortColName]/ColumnFormat = 'Money'
                              or $CRMOpportunitiesHeaderXML/child::node()[name(.) = $SortColName]/ColumnFormat = 'Number'
                              or $CRMOpportunitiesHeaderXML/child::node()[name(.) = $SortColName]/ColumnFormat = 'Percent'
                              or $CRMOpportunitiesHeaderXML/child::node()[name(.) = $SortColName]/ColumnFormat = 'Date'">
						<xsl:text>number</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>text</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>

			<xsl:variable name="SpecializedSortColName">
				<xsl:choose>
					<xsl:when test="$CRMOpportunitiesHeaderXML/child::node()[name(.) = $SortColName]/ColumnFormat = 'Date'">
						<xsl:value-of select="$SortColName"/>
						<xsl:text>Numbered</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$SortColName"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>

			<xsl:variable name="SpecializedOrder">
				<xsl:choose>
					<xsl:when test="$CurrentOrder and $CurrentOrder != ''">
						<xsl:value-of select="$CurrentOrder"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>descending</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>

			<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
			<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

			<xsl:call-template name="TemplateOpporunityBlockContent">
				<xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
				<xsl:with-param name="CurrentSalesUser" select="$CurrentSalesUser"></xsl:with-param>
				<xsl:with-param name="SortColDataType" select="$SortColDataType"></xsl:with-param>
				<xsl:with-param name="SpecializedOrder" select="$SpecializedOrder"></xsl:with-param>
				<xsl:with-param name="SpecializedSortColName" select="$SpecializedSortColName"></xsl:with-param>
				<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
				<xsl:with-param name="ListingDisplay" select="$ListingDisplay"></xsl:with-param>
				<xsl:with-param name="ExpandedClass" select="$ExpandedClass"></xsl:with-param>
				<xsl:with-param name="opportunityListingClass" select="$opportunityListingClass"></xsl:with-param>
				<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
				<xsl:with-param name="CRMOpportunitiesHeaderXML" select="$CRMOpportunitiesHeaderXML"></xsl:with-param>
				<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
				<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
				<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
				<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
				<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
				<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
				<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
				<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
				<xsl:with-param name="OpportunityMode" select="$OpportunityMode"></xsl:with-param>
				<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
				<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
				<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
				<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
				<xsl:with-param name="OpportunityEditClass" select="$OpportunityEditClass"></xsl:with-param>
				<xsl:with-param name="EditDisplay" select="$EditDisplay"></xsl:with-param>
				<xsl:with-param name="Block">
					<xsl:text>Active</xsl:text>
				</xsl:with-param>
				<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
				<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
			</xsl:call-template>

			<tr style="display:table-row;" name="tr-Active">
				<td colspan="{$maxCols+1}" class="verticallyMiddle">
					<xsl:choose>
						<xsl:when test="$Action != 'AddNewCRMOpportunity' and ($SelectedTab != 'Lost' and $SelectedTab != 'Closed')">

							<xsl:call-template name="TemplateAddNewOpportunity">
								<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
								<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
								<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
								<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
								<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
								<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
								<xsl:with-param name="CurrentSalesUser" select="$CurrentSalesUser"></xsl:with-param>
								<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
					</xsl:choose>
				</td>
			</tr>

			<xsl:call-template name="TemplateOpporunityBlockContent">
				<xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
				<xsl:with-param name="CurrentSalesUser" select="$CurrentSalesUser"></xsl:with-param>
				<xsl:with-param name="SortColDataType" select="$SortColDataType"></xsl:with-param>
				<xsl:with-param name="SpecializedOrder" select="$SpecializedOrder"></xsl:with-param>
				<xsl:with-param name="SpecializedSortColName" select="$SpecializedSortColName"></xsl:with-param>
				<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
				<xsl:with-param name="ListingDisplay" select="$ListingDisplay"></xsl:with-param>
				<xsl:with-param name="ExpandedClass" select="$ExpandedClass"></xsl:with-param>
				<xsl:with-param name="opportunityListingClass" select="$opportunityListingClass"></xsl:with-param>
				<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
				<xsl:with-param name="CRMOpportunitiesHeaderXML" select="$CRMOpportunitiesHeaderXML"></xsl:with-param>
				<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
				<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
				<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
				<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
				<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
				<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
				<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
				<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
				<xsl:with-param name="OpportunityMode" select="$OpportunityMode"></xsl:with-param>
				<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
				<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
				<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
				<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
				<xsl:with-param name="OpportunityEditClass" select="$OpportunityEditClass"></xsl:with-param>
				<xsl:with-param name="EditDisplay" select="$EditDisplay"></xsl:with-param>
				<xsl:with-param name="Block">
					<xsl:text>Closed</xsl:text>
				</xsl:with-param>
				<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
				<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
			</xsl:call-template>



			<xsl:call-template name="TemplateOpporunityBlockContent">
				<xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
				<xsl:with-param name="CurrentSalesUser" select="$CurrentSalesUser"></xsl:with-param>
				<xsl:with-param name="SortColDataType" select="$SortColDataType"></xsl:with-param>
				<xsl:with-param name="SpecializedOrder" select="$SpecializedOrder"></xsl:with-param>
				<xsl:with-param name="SpecializedSortColName" select="$SpecializedSortColName"></xsl:with-param>
				<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
				<xsl:with-param name="ListingDisplay" select="$ListingDisplay"></xsl:with-param>
				<xsl:with-param name="ExpandedClass" select="$ExpandedClass"></xsl:with-param>
				<xsl:with-param name="opportunityListingClass" select="$opportunityListingClass"></xsl:with-param>
				<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
				<xsl:with-param name="CRMOpportunitiesHeaderXML" select="$CRMOpportunitiesHeaderXML"></xsl:with-param>
				<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
				<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
				<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
				<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
				<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
				<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
				<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
				<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
				<xsl:with-param name="OpportunityMode" select="$OpportunityMode"></xsl:with-param>
				<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
				<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
				<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
				<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
				<xsl:with-param name="OpportunityEditClass" select="$OpportunityEditClass"></xsl:with-param>
				<xsl:with-param name="EditDisplay" select="$EditDisplay"></xsl:with-param>
				<xsl:with-param name="Block">
					<xsl:text>Lost</xsl:text>
				</xsl:with-param>
				<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
				<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
			</xsl:call-template>

			<tr id="tr_{$PortalItemID}_OppData_{$CurrentSalesUser}_End" style="display:table-row;">
				<td colspan="{$maxCols+1}">
				</td>
			</tr>


		</xsl:for-each>
	</xsl:template>

	<xsl:template name="TemplateOpporunityBlockContent">
		<xsl:param name="CRMOpportunitiesXML" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentSalesUser" select="'N/A'"></xsl:param>
		<xsl:param name="SortColDataType" select="'N/A'"></xsl:param>
		<xsl:param name="SpecializedOrder" select="'N/A'"></xsl:param>
		<xsl:param name="SpecializedSortColName" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="ListingDisplay" select="'N/A'"></xsl:param>
		<xsl:param name="ExpandedClass" select="'N/A'"></xsl:param>
		<xsl:param name="opportunityListingClass" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunitiesHeaderXML" select="'N/A'"></xsl:param>
		<xsl:param name="maxCols" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommissionPercent" select="'N/A'"></xsl:param>
		<xsl:param name="ColWidth" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentOrder" select="'N/A'"></xsl:param>
		<xsl:param name="SortColName" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="OpportunityMode" select="'N/A'"></xsl:param>
		<xsl:param name="PageSize" select="'N/A'"></xsl:param>
		<xsl:param name="PageNumber" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="OpportunityEditClass" select="'N/A'"></xsl:param>
		<xsl:param name="EditDisplay" select="'N/A'"></xsl:param>
		<xsl:param name="Block" select="'N/A'"></xsl:param>
		<xsl:param name="EditingVersion" select="'N/A'"></xsl:param>

		<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
		<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />


		<xsl:if test="$OpportunityMode = 'Listing' or $OpportunityMode = 'EditNewlyAdded'">

			<xsl:variable name="DisplayBlockRow">
				<xsl:choose>
					<xsl:when test="count($CRMOpportunitiesXML/CRMOpportunity[SalesUser = $CurrentSalesUser 
                                  and(                      
                                        ( $Block = 'Active' 
                                            and not(starts-with(translate(CustomStatusDisplayValue, $smallcase, $uppercase), 'CLOSED')) 
                                            and not(starts-with(translate(CustomStatus, $smallcase, $uppercase), 'CLOSED')) 
                                            and not(starts-with(translate(CustomStatusDisplayValue, $smallcase, $uppercase), 'LOST')) 
                                            and not(starts-with(translate(CustomStatus, $smallcase, $uppercase), 'LOST'))
                                        )                             
                                          
                                    )]) &gt; 0">
						<xsl:text>display:table-row</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>display:table-row</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>

			<tr id="tr_{$PortalItemID}_OppData_{$CurrentSalesUser}_{$Block}" style="{$DisplayBlockRow};"
                name="tr-{$Block}-{$PortalItemID}">
				<td colspan="{$maxCols + 1}" class="seperatorLine" style="display:none">
					<span class="packageTitle">
						<xsl:value-of select="$Block"/>
					</span>
				</td>
			</tr>
		</xsl:if>
		<xsl:for-each select="$CRMOpportunitiesXML/CRMOpportunity[SalesUser = $CurrentSalesUser 
                          and(                      
                                ( $Block = 'Active' 
                                    and not(starts-with(translate(CustomStatusDisplayValue, $smallcase, $uppercase), 'CLOSED')) 
                                    and not(starts-with(translate(CustomStatus, $smallcase, $uppercase), 'CLOSED')) 
                                    and not(starts-with(translate(CustomStatusDisplayValue, $smallcase, $uppercase), 'LOST')) 
                                    and not(starts-with(translate(CustomStatus, $smallcase, $uppercase), 'LOST'))
                                )
                  
                                or ( $Block = 'Lost' 
                                        and(
                                                starts-with(translate(CustomStatusDisplayValue, $smallcase, $uppercase), 'LOST') 
                                                    or 
                                                starts-with(translate(CustomStatus, $smallcase, $uppercase), 'LOST')
                                            )
                                    )
                  
                                or ( $Block = 'Closed' 
                                        and (
                                                starts-with(translate(CustomStatusDisplayValue, $smallcase, $uppercase), 'CLOSED') 
                                                    or 
                                                starts-with(translate(CustomStatus, $smallcase, $uppercase), 'CLOSED')
                                            )
                                    )
                            )]">


			<!--<xsl:sort data-type="{$SortColDataType}" order="{$SpecializedOrder}" select="*[name() = $SpecializedSortColName]"/>-->
			<xsl:variable name="ListingDisplayRow">
				<xsl:choose>
					<xsl:when test="$OpportunityMode = 'Listing'">
						<xsl:text>table-row</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>none</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>

			<xsl:variable name="CurrntOpp" select="."></xsl:variable>
			<xsl:variable name="CurrentCRMOpportunityID" select="CRMOpportunityID"></xsl:variable>

			<tr name="tr-{$Block}-{$PortalItemID}"
                id="tr_{$PortalItemID}_OppData_{CRMOpportunityID}_Listing"
                style="display:{$ListingDisplayRow};"
                workingElements="&lt;WorkingElements&gt;&lt;WorkingElement&gt;tr_{$PortalItemID}_OppData_{CRMOpportunityID}_Listing&lt;/WorkingElement&gt;&lt;WorkingElement&gt;tr_{$PortalItemID}_OppData_{CRMOpportunityID}_EditStandard&lt;/WorkingElement&gt;&lt;WorkingElement&gt;tr_{$PortalItemID}_OppData_{CRMOpportunityID}_EditAdditional&lt;/WorkingElement&gt;&lt;WorkingElement&gt;tr_{$PortalItemID}_OppData_{CRMOpportunityID}_EditHeader&lt;/WorkingElement&gt;&lt;/WorkingElements&gt;"
                activeElement="tr_{$PortalItemID}_OppData_{CRMOpportunityID}_Listing"
                class="{$ExpandedClass} {$opportunityListingClass} ExpandRow"
                closecallfunction="setTimeout(&quot;replaceCSSClass(document.getElementById('tr_{$PortalItemID}_OppData_{CRMOpportunityID}_Listing'), 'opportunityNewlyAdded', '')&quot;,5000);">

				<xsl:variable name="TargetDateCheck" select="@TargetDateCheck"></xsl:variable>

				<xsl:for-each select="$CRMOpportunitiesHeaderXML/child::node()[position() &lt;= $maxCols]">

					<xsl:variable name="CurrentCol" select="name(.)"></xsl:variable>
					<xsl:variable name="CurrentHeaderCol" select="."></xsl:variable>

					<xsl:call-template name="TemplateDataColumn">

						<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
						<xsl:with-param name="CurrentColValue" select="$CurrntOpp/child::node()[name(.) = $CurrentCol]"></xsl:with-param>
						<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
						<xsl:with-param name="CurrntOpp" select="$CurrntOpp"></xsl:with-param>
						<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
						<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
						<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
						<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
						<xsl:with-param name="CRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
						<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
						<xsl:with-param name="ColumnFormat" select="$CurrentHeaderCol/child::node()[name(.) = 'ColumnFormat']"></xsl:with-param>
						<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
						<xsl:with-param name="TargetDateCheck" select="$TargetDateCheck"></xsl:with-param>
						<xsl:with-param name="Block" select="$Block"></xsl:with-param>
						<xsl:with-param name="EditingVersion" select="$EditingVersion"></xsl:with-param>
					</xsl:call-template>
				</xsl:for-each>
			</tr>

			<xsl:call-template name="TemplateOppHeader">
				<xsl:with-param name="CRMOpportunitiesXML" select="$CRMOpportunitiesXML"></xsl:with-param>
				<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
				<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
				<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
				<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
				<xsl:with-param name="CRMOpportunitiesHeaderXML" select="$CRMOpportunitiesHeaderXML"></xsl:with-param>
				<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
				<xsl:with-param name="CurrentOrder" select="$CurrentOrder"></xsl:with-param>
				<xsl:with-param name="SortColName" select="$SortColName"></xsl:with-param>
				<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
				<xsl:with-param name="EditBoxHeader">
					<xsl:choose>
						<xsl:when test="$OpportunityMode = 'EditNewlyAdded'">
							<xsl:number value="3"/>
						</xsl:when>
						<xsl:when test="$OpportunityMode = 'Edit'">
							<xsl:number value="2"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:number value="1"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:with-param>
				<xsl:with-param name="EditSourceID" select="CRMOpportunityID"></xsl:with-param>
				<xsl:with-param name="PageSize" select="$PageSize"></xsl:with-param>
				<xsl:with-param name="PageNumber" select="$PageNumber"></xsl:with-param>
				<xsl:with-param name="Boxed" select="$Boxed"></xsl:with-param>
				<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
				<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
			</xsl:call-template>
			<xsl:choose>
				<xsl:when test="$EditingVersion='true'">
				</xsl:when>
				<xsl:otherwise>
					<tr id="tr_{$PortalItemID}_OppData_{CRMOpportunityID}_EditStandard" class="{$OpportunityEditClass}"
						style="display:{$EditDisplay}; border:1px solid;padding:1px;">

						<!--<td width="1%">

                    <span id="span_collapse_{CRMOpportunityID}" class="packageTitle onMouseOver" style="font-size:15px;">
                        <xsl:if test="$Block !='Closed'">
                            <xsl:choose>
                                <xsl:when test="@TargetDateCheck=1">
                                    <span id="span_dot_{$CurrentCRMOpportunityID}_Edit">
                                        <img src="{$TemplateURL}Web/Images/Ver_2_0/alertRedDot.png" height="auto" width="9" style=""></img>
                                    </span>
                                </xsl:when>
                                <xsl:otherwise>
                                    <span id="span_dot_{$CurrentCRMOpportunityID}_Edit" style="display:none">
                                        <img src="{$TemplateURL}Web/Images/Ver_2_0/alertRedDot.png" height="auto" width="9" ></img>
                                    </span>

                                </xsl:otherwise>
                            </xsl:choose>

                        </xsl:if>
                    </span>
                </td>-->

						<td colspan="{$maxCols}">
							<xsl:call-template name="TemplateEditStandard">
								<xsl:with-param name="CRMOpportunitiesHeaderXML" select="$CRMOpportunitiesHeaderXML"></xsl:with-param>
								<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
								<xsl:with-param name="CurrntOpp" select="$CurrntOpp"></xsl:with-param>
								<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>
								<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
								<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
								<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
								<xsl:with-param name="CurrentCRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
								<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
								<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
								<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
								<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
								<xsl:with-param name="TargetDateCheck" select="@TargetDateCheck"></xsl:with-param>
								<xsl:with-param name="Block" select="$Block"></xsl:with-param>
							</xsl:call-template>
						</td>

					</tr>
					<tr id="tr_{$PortalItemID}_OppData_{CRMOpportunityID}_EditAdditional"  class="{$OpportunityEditClass}"
						style="display:{$EditDisplay}; border:1px solid;padding:1px;">

						<xsl:call-template name="TemplateEditColAdditional">
							<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
							<xsl:with-param name="maxCols" select="$maxCols"></xsl:with-param>
							<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
							<xsl:with-param name="CurrentCRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="CurrntOpp" select="$CurrntOpp"></xsl:with-param>
							<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
							<xsl:with-param name="OpportunityMode" select="$OpportunityMode"></xsl:with-param>
							<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
						</xsl:call-template>
					</tr>
				</xsl:otherwise>
			</xsl:choose>

		</xsl:for-each>

		<xsl:if test="$OpportunityMode = 'Listing' or $OpportunityMode = 'EditNewlyAdded'">
			<tr id="tr_{$PortalItemID}_OppData_{$CurrentSalesUser}_{$Block}_End" style="display:none;">
				<td colspan="{$maxCols + 1}">
				</td>
			</tr>
		</xsl:if>

	</xsl:template>

	<xsl:template name="TemplateAddNewOpportunity">
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentSalesUser" select="'N/A'"></xsl:param>
		<xsl:param name="EditingVersion" select="'N/A'"></xsl:param>

		<div id="div_{$PortalItemID}_AddNew">
			<table class="tableMaster" cellpadding="2" cellspacing="4">
				<tr>
					<td width="1%" class="verticallyMiddle">
					</td>
					<td width="150px" class="verticallyMiddle">
						<xsl:call-template name="TemplateAddWidget">
							<xsl:with-param name="CurrentCol">
								<xsl:text>SalesUser</xsl:text>
							</xsl:with-param>
							<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
							<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
							<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
							<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="CurrentSalesUser" select="$CurrentSalesUser"></xsl:with-param>
						</xsl:call-template>
					</td>
					<td class="verticallyMiddle">
						<!--<div id="div_LoadAddNewCRMOpportunity" class="verticallyMiddle onMouseOver divBrowseGradient textCenter spanBrowseGradientTextGray"
                                    style="width:170px;line-height:30px;"
                                    onclick="Portal_AddNewCRMOpportunity({$PortalItemID}, 'opt_{$PortalItemID}_{$CurrentSalesUser}_AddNewOpportunity');"
                                    onmouseover="document.getElementById('img_{$PortalItemID}_AddSource').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                    onmouseout="document.getElementById('img_{$PortalItemID}_AddSource').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';">
							<img id="img_{$PortalItemID}_AddSource" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" class="marginRight5"></img>
							<span id="span_saveSource" class="capitalFont">Add New Opportunity</span>
						</div>-->
						<xsl:choose>
							<xsl:when test="$EditingVersion ='true'">
								<div id="div_LoadAddNewCRMOpportunity" class="verticallyMiddle onMouseOver divBrowseGradient textCenter spanBrowseGradientTextGray"
								style="width:170px;line-height:30px;"
								onclick="Portal_AddNewCRMOpportunityVersion3({$PortalItemID}, 'opt_{$PortalItemID}_{$CurrentSalesUser}_AddNewOpportunity','{$EditingVersion}');"
								onmouseover="document.getElementById('img_{$PortalItemID}_AddSource').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
								onmouseout="document.getElementById('img_{$PortalItemID}_AddSource').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';">
									<img id="img_{$PortalItemID}_AddSource" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" class="marginRight5"></img>
									<span id="span_saveSource" class="capitalFont">Add New Opportunity</span>
								</div>
							</xsl:when>
							<xsl:otherwise>
								<div id="div_LoadAddNewCRMOpportunity" class="verticallyMiddle onMouseOver divBrowseGradient textCenter spanBrowseGradientTextGray"
                                    style="width:170px;line-height:30px;"
                                    onclick="Portal_AddNewCRMOpportunity({$PortalItemID}, 'opt_{$PortalItemID}_{$CurrentSalesUser}_AddNewOpportunity');"
                                    onmouseover="document.getElementById('img_{$PortalItemID}_AddSource').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                    onmouseout="document.getElementById('img_{$PortalItemID}_AddSource').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';">
									<img id="img_{$PortalItemID}_AddSource" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" class="marginRight5"></img>
									<span id="span_saveSource" class="capitalFont">Add New Opportunity</span>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</td>
				</tr>
			</table>
		</div>
	</xsl:template>

	<xsl:template name="TemplateHeaderColumn">
		<xsl:param name="ColWidth" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentHeaderCol" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormat" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentOrder">
			<xsl:text></xsl:text>
		</xsl:param>
		<xsl:param name="SortColName" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="PageSize" select="'N/A'"></xsl:param>
		<xsl:param name="PageNumber" select="'N/A'"></xsl:param>
		<xsl:param name="Boxed" select="'N/A'"></xsl:param>

		<xsl:variable name="CellTextAlign">
			<xsl:call-template name="TemplateCellTextAlignment">
				<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
				<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="SpecializeSortOrder">
			<xsl:choose>
				<xsl:when test="$CurrentCol = $SortColName">
					<xsl:value-of select="$CurrentOrder"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text></xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<td width="{$ColWidth}%" style="{$CellTextAlign}">
			<span style="font-size:12px !important" class="packageTitle link" currentOrder="{$SpecializeSortOrder}"
                      onclick="portal_SortCRMOpportunities('{$PortalItemID}','Employee_Operations_Filters_Opportunities','{$CurrentCol}',this,{$EmployeeID},0,{$PageSize},1,{$Boxed});"
                      onmouseover="this.style.textDecoration = 'underline';"
                      onmouseout="this.style.textDecoration = 'none';">
				<xsl:choose>
					<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/ColumnHeader">
						<xsl:value-of select="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/ColumnHeader"/>
					</xsl:when>
					<xsl:when test="$CurrentHeaderCol/child::node()[name(.) = 'ColDisplayName']">
						<xsl:value-of select="$CurrentHeaderCol/child::node()[name(.) = 'ColDisplayName']"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$CurrentCol"/>
					</xsl:otherwise>
				</xsl:choose>
			</span>
		</td>
	</xsl:template>

	<xsl:template name="TemplateDataColumn">

		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentColValue" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommissionPercent" select="'N/A'"></xsl:param>
		<xsl:param name="CurrntOpp" select="'N/A'"></xsl:param>
		<xsl:param name="ColWidth" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunityID" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormat" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="EditingVersion" select="'N/A'"></xsl:param>
		<xsl:param name="LastElement">
			<xsl:number value="0"/>
		</xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="TargetDateCheck" select="'N/A'"></xsl:param>
		<xsl:param name="Block" select="'N/A'"></xsl:param>
		<xsl:variable name="CRMUDFDefID" select="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/CRMUDFDefID"/>

		<xsl:variable name="CellTextAlign">
			<xsl:call-template name="TemplateCellTextAlignment">
				<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
				<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="DataColCellID">
			<xsl:text>dataColumnCell_</xsl:text>
			<xsl:value-of select="$CRMOpportunityID"/>
			<xsl:text>_</xsl:text>
			<xsl:value-of select="$CurrentCol"/>
		</xsl:variable>

		<xsl:variable name="rowClickFunction">
			<xsl:choose>
				<xsl:when test="$EditingVersion = 'true'">
					<xsl:text>
					var evt = document.createEvent("HTMLEvents");
					evt.initEvent("click", true, true);
					document.getElementById("Panel_Slide").dispatchEvent(evt);		
					portal_LoadCRMOpportunitiesByCRMOpportunitiesID(</xsl:text>
					<xsl:value-of select="$PortalItemID"></xsl:value-of>
					<xsl:text>,'slidepanel', </xsl:text>
					<xsl:value-of select="$EmployeeID"></xsl:value-of>
					<xsl:text>,</xsl:text>
					<xsl:value-of select="$CRMOpportunityID"></xsl:value-of>
					<xsl:text>,'</xsl:text>
					<xsl:value-of select="$Block"/>
					<xsl:text>','</xsl:text>
					<xsl:value-of select="$TargetDateCheck"/>
					<xsl:text>');</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>
					portal_ExpandOpportunity('tr_</xsl:text>
					<xsl:value-of select="$PortalItemID"></xsl:value-of>
					<xsl:text>_OppData_</xsl:text>
					<xsl:value-of select="$CRMOpportunityID"></xsl:value-of>
					<xsl:text>');</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$CurrentCol = 'CustomTransSize' or  $CurrentCol = 'TransCommissionRate' ">
				<xsl:if test="$IsCommissionPercent = 1" >

					<td id="{$DataColCellID}" width="{$ColWidth}%" style="{$CellTextAlign}"  onClick="{$rowClickFunction}">
						<xsl:call-template name="TemplateDataColumnWidget">
							<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
							<xsl:with-param name="CurrentColValue" select="$CurrentColValue"></xsl:with-param>
							<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
							<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
						</xsl:call-template>
					</td>
				</xsl:if>
			</xsl:when>
			<xsl:when test="$CurrentCol = 'FeeEst' and $IsCommissionPercent = 1">

				<xsl:variable name="FeeEst" select="(($CurrntOpp/child::node()[name(.) = 'CustomTransSize']) 
                                                          * ($CurrntOpp/child::node()[name(.) = 'TransCommissionRate'])) div 100"></xsl:variable>

				<td id="{$DataColCellID}" width="{$ColWidth}%" style="{$CellTextAlign}"  onClick="{$rowClickFunction}">

					<xsl:choose>
						<xsl:when test="string(number($CurrentColValue)) != 'NaN'">
							<xsl:call-template name="TemplateDataColumnWidget">
								<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
								<xsl:with-param name="CurrentColValue" select="$CurrentColValue"></xsl:with-param>
								<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
								<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
								<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<xsl:call-template name="TemplateDataColumnWidget">
								<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
								<xsl:with-param name="CurrentColValue">
									<xsl:if test="string(number($FeeEst)) != 'NaN'">
										<xsl:text>$</xsl:text>
										<xsl:value-of select="format-number($FeeEst, '#,###')"/>
									</xsl:if>
								</xsl:with-param>
								<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
								<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
								<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							</xsl:call-template>
						</xsl:otherwise>
					</xsl:choose>

				</td>
			</xsl:when>
			<xsl:when test="$CurrentCol = 'SalesUser'">
				<td id="{$DataColCellID}" width="{$ColWidth}%" style="{$CellTextAlign}"  onClick="{$rowClickFunction}">

					<xsl:call-template name="TemplateDataColumnWidget">
						<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
						<xsl:with-param name="CurrentColValue" select="$Employees/Employee[UserID = $CurrentColValue]/DisplayName"></xsl:with-param>
						<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
						<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					</xsl:call-template>

				</td>
			</xsl:when>
			<xsl:when test="$CurrentCol = 'CustomStatus'">
				<td id="{$DataColCellID}" width="{$ColWidth}%" style="{$CellTextAlign}">
					<xsl:call-template name="TemplateDataColumnWidget">
						<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
						<xsl:with-param name="CurrentColValue">
							<xsl:choose>
								<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/IsDropdown = 1">
									<xsl:value-of select="$UDFMasterValues/UDFMasterValue
                                              [CRMUDFDefID = $CRMUDFDefID and StoreValue = $CurrentColValue]/DisplayValue"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$CurrentColValue"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
						<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
						<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					</xsl:call-template>
					<xsl:if test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/IsDropdown = 1">
						<select id="ddl_{$CRMOpportunityID}_{$CurrentCol}" class="smallDropdown" style="display:none" onChange="Portal_UpdateCRMOpportunityValue({$CRMOpportunityID}, {$PortalItemID}, this, 'CustomStatus', {$LastElement}, '{$ColumnFormat}');" >
							<xsl:for-each select="$UDFMasterValues/UDFMasterValue[CRMUDFDefID = $CRMUDFDefID]">
								<xsl:choose>
									<xsl:when test="StoreValue = $CurrentColValue and RelatedValue">
										<option value="{StoreValue}" selected="selected" relatedValue="{RelatedValue}">
											<xsl:value-of select="DisplayValue"/>
										</option>
									</xsl:when>
									<xsl:when test="RelatedValue">
										<option value="{StoreValue}" relatedValue="{RelatedValue}">
											<xsl:value-of select="DisplayValue"/>
										</option>
									</xsl:when>
									<xsl:when test="StoreValue = $CurrentColValue">
										<option value="{StoreValue}" selected="selected">
											<xsl:value-of select="DisplayValue"/>
										</option>
									</xsl:when>
									<xsl:otherwise>
										<option value="{StoreValue}">
											<xsl:value-of select="DisplayValue"/>
										</option>
									</xsl:otherwise>
								</xsl:choose>

							</xsl:for-each>
						</select>
					</xsl:if>
				</td>
			</xsl:when>
			<xsl:when test="$CurrentCol='TargetCloseDate'">
				<td id="{$DataColCellID}" width="{$ColWidth}%" style="{$CellTextAlign}">
					<xsl:call-template name="TemplateDataColumnWidget">
						<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
						<xsl:with-param name="CurrentColValue">
							<xsl:choose>
								<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/IsDropdown = 1">
									<xsl:value-of select="$UDFMasterValues/UDFMasterValue
                                              [CRMUDFDefID = $CRMUDFDefID and StoreValue = $CurrentColValue]/DisplayValue"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$CurrentColValue"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
						<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
						<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					</xsl:call-template>
				</td>
			</xsl:when>
			<xsl:when test="$CurrentCol='ClientCompany'">
				<td id="{$DataColCellID}" width="{$ColWidth}%" style="{$CellTextAlign}"  onClick="{$rowClickFunction}">
					<xsl:if test="$Block!='Closed'">
						<xsl:choose>
							<xsl:when test="$TargetDateCheck=1">
								<span id="span_dot_{$CRMOpportunityID}" style="margin-right:2px">
									<img src="{$TemplateURL}Web/Images/Ver_2_0/alertRedDot.png" height="auto" width="9" style=""></img>
								</span>
							</xsl:when>
							<xsl:otherwise>
								<span style="display:none;margin-right:2px" id="span_dot_{$CRMOpportunityID}">
									<img src="{$TemplateURL}Web/Images/Ver_2_0/alertRedDot.png" height="auto" width="9" style=""></img>
								</span>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:if>
					<xsl:call-template name="TemplateDataColumnWidget">
						<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
						<xsl:with-param name="CurrentColValue">
							<xsl:choose>
								<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/IsDropdown = 1">
									<xsl:value-of select="$UDFMasterValues/UDFMasterValue
                                              [CRMUDFDefID = $CRMUDFDefID and StoreValue = $CurrentColValue]/DisplayValue"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$CurrentColValue"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
						<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
						<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					</xsl:call-template>
				</td>
			</xsl:when>
			<xsl:otherwise>
				<td id="{$DataColCellID}" width="{$ColWidth}%" style="{$CellTextAlign}"  onClick="{$rowClickFunction}">

					<xsl:call-template name="TemplateDataColumnWidget">
						<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
						<xsl:with-param name="CurrentColValue">
							<xsl:choose>
								<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/IsDropdown = 1">
									<xsl:value-of select="$UDFMasterValues/UDFMasterValue
                                              [CRMUDFDefID = $CRMUDFDefID and StoreValue = $CurrentColValue]/DisplayValue"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$CurrentColValue"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
						<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
						<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					</xsl:call-template>
				</td>

			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>

	<xsl:template name="TemplateEditStandard">
		<xsl:param name="CRMOpportunitiesHeaderXML" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommissionPercent" select="'N/A'"></xsl:param>
		<xsl:param name="CurrntOpp" select="'N/A'"></xsl:param>
		<xsl:param name="ColWidth" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentCRMOpportunityID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="maxCols" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="TargetDateCheck" select="'N/A'"></xsl:param>
		<xsl:param name="Block" select="'N/A'"></xsl:param>

		<table cellpadding="2" cellspacing="4" class="tableMaster" style="display:inline-table;">
			<xsl:for-each select="$CRMOpportunitiesHeaderXML/child::node()[position() &lt;= $maxCols]">

				<xsl:variable name="CurrentCol" select="name(.)"></xsl:variable>
				<xsl:variable name="CurrentHeaderCol" select="."></xsl:variable>


				<xsl:if test="(position() mod 3) = 1">
					<tr>

						<td width="15%">
							<span class="publicationSummary">

								<xsl:choose>
									<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]">
										<xsl:value-of select="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/ColumnHeader"/>
									</xsl:when>
									<xsl:when test="$CurrentHeaderCol/child::node()[name(.) = 'ColDisplayName']">
										<xsl:if test="$CurrentCol='ClientCompany'">
											<xsl:if test="$Block !='Closed'">
												<xsl:choose>
													<xsl:when test="$TargetDateCheck=1">
														<span id="span_dot_{$CurrentCRMOpportunityID}_Edit" style="margin-right:2px">
															<img src="{$TemplateURL}Web/Images/Ver_2_0/alertRedDot.png" height="auto" width="9" style=""></img>
														</span>
													</xsl:when>
													<xsl:otherwise>
														<span id="span_dot_{$CurrentCRMOpportunityID}_Edit" style="display:none;margin-right:2px">
															<img src="{$TemplateURL}Web/Images/Ver_2_0/alertRedDot.png" height="auto" width="9" ></img>
														</span>

													</xsl:otherwise>
												</xsl:choose>

											</xsl:if>
										</xsl:if>
										<xsl:value-of select="$CurrentHeaderCol/child::node()[name(.) = 'ColDisplayName']"/> :
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="name($CurrentHeaderCol)"/> :
									</xsl:otherwise>
								</xsl:choose>
							</span>
						</td>
						<!--</xsl:if>-->
						<xsl:call-template name="TemplateEditColumn">
							<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
							<xsl:with-param name="CurrentColValue" select="$CurrntOpp/child::node()[name(.) = $CurrentCol]"></xsl:with-param>
							<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
							<xsl:with-param name="CurrntOpp" select="$CurrntOpp"></xsl:with-param>
							<!--<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>-->
							<xsl:with-param name="ColWidth">
								<xsl:number value="17"/>
							</xsl:with-param>
							<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
							<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
							<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
							<xsl:with-param name="CRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="LastElement">
								<xsl:choose>
									<xsl:when test="position() = last() and count($UDFXML/UDFDefinition) = 0">
										<xsl:number value="1"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:number value="0"/>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:with-param>
							<xsl:with-param name="ColumnFormat" select="$CurrentHeaderCol/child::node()[name(.) = 'ColumnFormat']"></xsl:with-param>
							<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
							<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
						</xsl:call-template>
						<td width="15%" style="padding-left:10px;">
							<xsl:if test="following-sibling::node()[1] and (position()+1) &lt;= $maxCols">
								<span class="publicationSummary">

									<xsl:variable name="CurrentCol_1" select="name(following-sibling::node()[1])"></xsl:variable>
									<xsl:choose>
										<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol_1]">
											<xsl:value-of select="$UDFXML/UDFDefinition[Column_Name = $CurrentCol_1]/ColumnHeader"/>
										</xsl:when>
										<xsl:when test="following-sibling::node()[1]/child::node()[name(.) = 'ColDisplayName']">
											<xsl:value-of select="following-sibling::node()[1]/child::node()[name(.) = 'ColDisplayName']"/> :
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="name(following-sibling::node()[1])"/> :
										</xsl:otherwise>
									</xsl:choose>
								</span>
							</xsl:if>
						</td>
						<xsl:choose>
							<xsl:when test="(position()+1) &lt;= $maxCols">

								<xsl:variable name="CurrentCol_1" select="name(following-sibling::node()[1])"></xsl:variable>
								<xsl:variable name="CurrentHeaderCol_1" select="following-sibling::node()[1]"></xsl:variable>

								<xsl:call-template name="TemplateEditColumn">
									<xsl:with-param name="CurrentCol" select="$CurrentCol_1"></xsl:with-param>
									<xsl:with-param name="CurrentColValue" select="$CurrntOpp/child::node()[name(.) = $CurrentCol_1]"></xsl:with-param>
									<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
									<xsl:with-param name="CurrntOpp" select="$CurrntOpp"></xsl:with-param>
									<!--<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>-->
									<xsl:with-param name="ColWidth">
										<xsl:number value="17"/>
									</xsl:with-param>
									<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
									<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
									<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
									<xsl:with-param name="CRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
									<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
									<xsl:with-param name="LastElement">
										<xsl:choose>
											<xsl:when test="position() = last() and count($UDFXML/UDFDefinition) = 0">
												<xsl:number value="1"/>
											</xsl:when>
											<xsl:otherwise>
												<xsl:number value="0"/>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:with-param>
									<xsl:with-param name="ColumnFormat" select="$CurrentHeaderCol_1/child::node()[name(.) = 'ColumnFormat']"></xsl:with-param>
									<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
									<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
								</xsl:call-template>



							</xsl:when>
							<xsl:otherwise>
								<td width="17%"></td>
							</xsl:otherwise>
						</xsl:choose>
						<td width="15%"  style="padding-left:10px;">
							<xsl:if test="following-sibling::node()[2] and (position()+2) &lt;= $maxCols">
								<xsl:variable name="CurrentCol_2" select="name(following-sibling::node()[2])"></xsl:variable>
								<span class="publicationSummary">
									<xsl:choose>
										<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol_2]">
											<xsl:value-of select="$UDFXML/UDFDefinition[Column_Name = $CurrentCol_2]/ColumnHeader"/>
										</xsl:when>
										<xsl:when test="following-sibling::node()[2]/child::node()[name(.) = 'ColDisplayName']">
											<xsl:value-of select="following-sibling::node()[2]/child::node()[name(.) = 'ColDisplayName']"/> :
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="name(following-sibling::node()[2])"/> :
										</xsl:otherwise>
									</xsl:choose>

								</span>
							</xsl:if>
						</td>

						<xsl:choose>
							<xsl:when test="(position()+2) &lt;= $maxCols">

								<xsl:variable name="CurrentCol_2" select="name(following-sibling::node()[2])"></xsl:variable>
								<xsl:variable name="CurrentHeaderCol_2" select="following-sibling::node()[2]"></xsl:variable>

								<xsl:call-template name="TemplateEditColumn">
									<xsl:with-param name="CurrentCol" select="$CurrentCol_2"></xsl:with-param>
									<xsl:with-param name="CurrentColValue" select="$CurrntOpp/child::node()[name(.) = $CurrentCol_2]"></xsl:with-param>
									<xsl:with-param name="IsCommissionPercent" select="$IsCommissionPercent"></xsl:with-param>
									<xsl:with-param name="CurrntOpp" select="$CurrntOpp"></xsl:with-param>
									<!--<xsl:with-param name="ColWidth" select="$ColWidth"></xsl:with-param>-->
									<xsl:with-param name="ColWidth">
										<xsl:number value="17"/>
									</xsl:with-param>
									<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
									<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
									<xsl:with-param name="Employees" select="$Employees"></xsl:with-param>
									<xsl:with-param name="CRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
									<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
									<xsl:with-param name="LastElement">
										<xsl:choose>
											<xsl:when test="position() = last() and count($UDFXML/UDFDefinition) = 0">
												<xsl:number value="1"/>
											</xsl:when>
											<xsl:otherwise>
												<xsl:number value="0"/>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:with-param>
									<xsl:with-param name="ColumnFormat" select="$CurrentHeaderCol_2/child::node()[name(.) = 'ColumnFormat']"></xsl:with-param>
									<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
									<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
								</xsl:call-template>


							</xsl:when>
							<xsl:otherwise>
								<td width="17%"></td>
							</xsl:otherwise>
						</xsl:choose>

					</tr>
				</xsl:if>

			</xsl:for-each>
		</table>

	</xsl:template>

	<xsl:template name="TemplateEditColumn">
		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentColValue" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommissionPercent" select="'N/A'"></xsl:param>
		<xsl:param name="CurrntOpp" select="'N/A'"></xsl:param>
		<xsl:param name="ColWidth" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunityID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="LastElement">
			<xsl:number value="0"/>
		</xsl:param>
		<xsl:param name="ColumnFormatID" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormat" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>

		<xsl:variable name="CellTextAlign">
			<xsl:text></xsl:text>
			<!--<xsl:call-template name="TemplateCellTextAlignment">
                <xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
                <xsl:with-param name="ColumnFormatID" select="$ColumnFormatID"></xsl:with-param>
                <xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
            </xsl:call-template>-->
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$CurrentCol = 'CustomTransSize' or  $CurrentCol = 'TransCommissionRate'">
				<xsl:if test="$IsCommissionPercent = 1">
					<td width="{$ColWidth}%" style="{$CellTextAlign}">
						<xsl:call-template name="TemplateEditWidget">
							<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
							<xsl:with-param name="CurrentColValue" select="$CurrentColValue"></xsl:with-param>
							<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
							<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
							<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="LastElement" select="$LastElement"></xsl:with-param>
							<xsl:with-param name="ColumnFormatID" select="$ColumnFormatID"></xsl:with-param>
							<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
							<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
							<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
						</xsl:call-template>
					</td>
				</xsl:if>
			</xsl:when>
			<xsl:when test="$CurrentCol = 'FeeEst' and $IsCommissionPercent = 1">

				<xsl:variable name="FeeEst" select="(($CurrntOpp/child::node()[name(.) = 'CustomTransSize']) 
                                                          * ($CurrntOpp/child::node()[name(.) = 'TransCommissionRate'])) div 100"></xsl:variable>

				<td width="{$ColWidth}%" style="{$CellTextAlign}">

					<xsl:choose>
						<xsl:when test="string(number($CurrentColValue)) != 'NaN'">
							<xsl:call-template name="TemplateEditWidget">
								<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
								<xsl:with-param name="CurrentColValue" select="$CurrentColValue"></xsl:with-param>
								<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
								<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
								<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
								<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
								<xsl:with-param name="LastElement" select="$LastElement"></xsl:with-param>
								<xsl:with-param name="ColumnFormatID" select="$ColumnFormatID"></xsl:with-param>
								<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
								<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
								<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<xsl:call-template name="TemplateEditWidget">
								<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
								<xsl:with-param name="CurrentColValue">
									<xsl:if test="string(number($FeeEst)) != 'NaN'">
										<xsl:value-of select="$FeeEst"/>
									</xsl:if>
								</xsl:with-param>
								<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
								<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
								<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
								<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
								<xsl:with-param name="LastElement" select="$LastElement"></xsl:with-param>
								<xsl:with-param name="ColumnFormatID" select="$ColumnFormatID"></xsl:with-param>
								<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
								<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
								<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
							</xsl:call-template>
						</xsl:otherwise>
					</xsl:choose>

				</td>
			</xsl:when>
			<xsl:when test="$CurrentCol = 'SalesUser'">
				<td width="{$ColWidth}%" style="{$CellTextAlign}">
					<select class="smallDropdown" style="width:100%;"
                            onChange="Portal_UpdateCRMOpportunityValue({$CRMOpportunityID}, {$PortalItemID}, this, 'SalesUser', {$LastElement}, '{$ColumnFormat}');"
                            onblur="Portal_ShowCRMOpportunityListing({$CRMOpportunityID}, {$PortalItemID}, this, 'SalesUser', {$LastElement}, '{$EmployeeID}');">
						<option value="-99">
						</option>
						<xsl:for-each select="$Employees/Employee">
							<xsl:choose>
								<xsl:when test="UserID = $CurrentColValue">
									<option value="{UserID}" selected="selected">
										<xsl:value-of select="DisplayName"/>
									</option>
								</xsl:when>
								<xsl:otherwise>
									<option value="{UserID}">
										<xsl:value-of select="DisplayName"/>
									</option>
								</xsl:otherwise>
							</xsl:choose>

						</xsl:for-each>
					</select>
				</td>
			</xsl:when>
			<xsl:otherwise>

				<td width="{$ColWidth}%" style="{$CellTextAlign}">
					<xsl:call-template name="TemplateEditWidget">
						<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
						<xsl:with-param name="CurrentColValue" select="$CurrentColValue"></xsl:with-param>
						<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
						<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
						<xsl:with-param name="CRMOpportunityID" select="$CRMOpportunityID"></xsl:with-param>
						<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
						<xsl:with-param name="LastElement" select="$LastElement"></xsl:with-param>
						<xsl:with-param name="ColumnFormatID" select="$ColumnFormatID"></xsl:with-param>
						<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
						<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
						<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
					</xsl:call-template>
				</td>
				<!--</xsl:if>-->
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="TemplateEditColAdditional">
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="maxCols" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentCRMOpportunityID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="CurrntOpp" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="OpportunityMode" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>


		<xsl:variable name="UDFXMLAdditional">
			<xsl:copy-of select="$UDFXML/UDFDefinition
                                                      [Column_Name != 'CustomStatus' and Column_Name != 'CustomTransSize' 
                                                        and Column_Name != 'ClientCompany' and Column_Name != 'OpportunityName' 
                                                        and Column_Name != 'TransCommissionRate' and Column_Name != 'FeeEst' 
                                                        and Column_Name != 'TargetCloseDate' and Column_Name != 'Probability']"/>
		</xsl:variable>

		<!--<td width="1%">
        </td>-->
		<td colspan="{$maxCols}">
			<table cellpadding="2" cellspacing="4" class="tableMaster" style="display:inline-table;">
				<!--<xsl:for-each select="$UDFXML/UDFDefinition
                                                      [Column_Name != 'CustomStatus' and Column_Name != 'CustomTransSize' 
                                                        and Column_Name != 'ClientCompany' and Column_Name != 'OpportunityName' 
                                                        and Column_Name != 'TransCommissionRate' and Column_Name != 'FeeEst' 
                                                        and Column_Name != 'TargetCloseDate']">-->
				<xsl:for-each select="msxsl:node-set($UDFXMLAdditional)/UDFDefinition">


					<xsl:variable name="CurrentCol" select="Column_Name"></xsl:variable>

					<xsl:if test="(position() mod 3) = 1">

						<tr>
							<td width="15%">
								<span class="publicationSummary">
									<xsl:value-of select="ColumnHeader"/> :
								</span>
							</td>
							<td width="17%">
								<span>
									<xsl:call-template name="TemplateEditWidget">
										<xsl:with-param name="CurrentCol" select="Column_Name"></xsl:with-param>
										<xsl:with-param name="CurrentColValue"
                                                        select="$CurrntOpp/child::node()[name(.) = $CurrentCol]"></xsl:with-param>
										<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
										<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
										<xsl:with-param name="CRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
										<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
										<xsl:with-param name="LastElement">
											<xsl:choose>
												<xsl:when test="position() = last()">
													<xsl:number value="1"/>
												</xsl:when>
												<xsl:otherwise>
													<xsl:number value="0"/>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:with-param>
										<xsl:with-param name="ColumnFormatID" select="ColumnFormatID"></xsl:with-param>
										<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
										<xsl:with-param name="ColumnHeader" select="ColumnHeader"></xsl:with-param>
										<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
									</xsl:call-template>
								</span>
							</td>
							<td width="15%" style="padding-left:10px;">
								<xsl:if test="following-sibling::UDFDefinition[1]">
									<span class="publicationSummary">
										<xsl:value-of select="following-sibling::UDFDefinition[1]/ColumnHeader"/> :
									</span>
								</xsl:if>
							</td>
							<td width="17%">
								<xsl:if test="following-sibling::UDFDefinition[1]">
									<xsl:variable name="CurrentCol_1" select="following-sibling::UDFDefinition[1]/Column_Name"></xsl:variable>
									<span>
										<xsl:call-template name="TemplateEditWidget">
											<xsl:with-param name="CurrentCol" select="following-sibling::UDFDefinition[1]/Column_Name"></xsl:with-param>
											<xsl:with-param name="CurrentColValue"
                                                            select="$CurrntOpp/child::node()[name(.) = $CurrentCol_1]"></xsl:with-param>
											<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
											<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
											<xsl:with-param name="CRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
											<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
											<xsl:with-param name="LastElement">
												<xsl:choose>
													<xsl:when test="position()+1 = last()">
														<xsl:number value="1"/>
													</xsl:when>
													<xsl:otherwise>
														<xsl:number value="0"/>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:with-param>
											<xsl:with-param name="ColumnFormatID" select="following-sibling::UDFDefinition[1]/ColumnFormatID"></xsl:with-param>
											<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
											<xsl:with-param name="ColumnHeader" select="following-sibling::UDFDefinition[1]/ColumnHeader"></xsl:with-param>
											<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
										</xsl:call-template>
									</span>
								</xsl:if>
							</td>
							<td width="15%" style="padding-left:10px;">
								<xsl:if test="following-sibling::UDFDefinition[2]">
									<span class="publicationSummary">
										<xsl:value-of select="following-sibling::UDFDefinition[2]/ColumnHeader"/> :
									</span>
								</xsl:if>
							</td>
							<td width="18%">
								<xsl:if test="following-sibling::UDFDefinition[2]">
									<xsl:variable name="CurrentCol_2" select="following-sibling::UDFDefinition[2]/Column_Name"></xsl:variable>
									<span>
										<xsl:call-template name="TemplateEditWidget">
											<xsl:with-param name="CurrentCol" select="following-sibling::UDFDefinition[2]/Column_Name"></xsl:with-param>
											<xsl:with-param name="CurrentColValue"
                                                            select="$CurrntOpp/child::node()[name(.) = $CurrentCol_2]"></xsl:with-param>
											<xsl:with-param name="UDFXML" select="$UDFXML"></xsl:with-param>
											<xsl:with-param name="UDFMasterValues" select="$UDFMasterValues"></xsl:with-param>
											<xsl:with-param name="CRMOpportunityID" select="$CurrentCRMOpportunityID"></xsl:with-param>
											<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
											<xsl:with-param name="LastElement">
												<xsl:choose>
													<xsl:when test="position()+2 = last()">
														<xsl:number value="1"/>
													</xsl:when>
													<xsl:otherwise>
														<xsl:number value="0"/>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:with-param>
											<xsl:with-param name="ColumnFormatID" select="following-sibling::UDFDefinition[2]/ColumnFormatID"></xsl:with-param>
											<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
											<xsl:with-param name="ColumnHeader" select="following-sibling::UDFDefinition[2]/ColumnHeader"></xsl:with-param>
											<xsl:with-param name="EmployeeID" select="$EmployeeID"></xsl:with-param>
										</xsl:call-template>
									</span>
								</xsl:if>
							</td>
						</tr>

					</xsl:if>
				</xsl:for-each>
			</table>
			<table cellpadding="2" cellspacing="4" style="display:block;">
				<tr>
					<td>

						<div id="btnAddNewCRMOpportunity_{$CurrentCRMOpportunityID}"
                             class="verticallyMiddle onMouseOver divBrowseGradient textCenter spanBrowseGradientTextGray"
                             style="width:120px;line-height:20px;display:block;"
                             onClick="Portal_ShowCRMOpportunityListing({$CurrentCRMOpportunityID}, {$PortalItemID}, this, '', 1,'{$EmployeeID}');">
							<span id="span_saveSource" class="capitalFont">Save</span>
						</div>

					</td>
					<td>
						<div id="div_LoadAddNewCRMOpportunity"
                             class="verticallyMiddle onMouseOver divBrowseGradient textCenter spanBrowseGradientTextGray"
                             style="width:120px;line-height:20px;"
                             onclick="portal_DeleteCRMOpportunity({$PortalItemID}, {$CurrentCRMOpportunityID},'{$EmployeeID}');">
							<span id="span_saveSource" class="capitalFont">Delete this Item</span>
						</div>
					</td>
				</tr>
			</table>
		</td>
	</xsl:template>

	<xsl:template name="TemplateAddWidget">
		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentColValue" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="Employees" select="'N/A'"></xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentSalesUser" select="'N/A'"></xsl:param>

		<xsl:variable name="CRMUDFDefID" select="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/CRMUDFDefID"/>

		<select id="opt_{$PortalItemID}_{$CurrentSalesUser}_AddNewOpportunity" class="smallDropdown" style="width:100%;">
			<option value="-99">
			</option>
			<xsl:for-each select="$Employees/Employee">
				<xsl:choose>
					<xsl:when test="UserID = $CurrentColValue or UserID = $EmployeeID">
						<option value="{UserID}" selected="selected">
							<xsl:value-of select="DisplayName"/>
						</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="{UserID}">
							<xsl:value-of select="DisplayName"/>
						</option>
					</xsl:otherwise>
				</xsl:choose>

			</xsl:for-each>
		</select>
	</xsl:template>

	<xsl:template name="TemplateEditWidget">
		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentColValue" select="'N/A'"></xsl:param>
		<xsl:param name="UDFXML" select="'N/A'"></xsl:param>
		<xsl:param name="UDFMasterValues" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunityID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="LastElement">
			<xsl:number value="0"/>
		</xsl:param>
		<xsl:param name="ColumnFormatID" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormat" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnHeader">
			<xsl:text></xsl:text>
		</xsl:param>
		<xsl:param name="EmployeeID" select="'N/A'"></xsl:param>

		<xsl:variable name="CRMUDFDefID" select="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/CRMUDFDefID"/>

		<xsl:variable name="WidgetWidth">
			<xsl:call-template name="TemplateWidgetWidth">
				<xsl:with-param name="CurrentCol" select="$CurrentCol"></xsl:with-param>
				<xsl:with-param name="ColumnFormatID" select="$ColumnFormatID"></xsl:with-param>
				<xsl:with-param name="ColumnFormat" select="$ColumnFormat"></xsl:with-param>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="ColPostFix">
			<xsl:choose>
				<xsl:when test="$ColumnFormat = 'Percent'">
					<xsl:text>%</xsl:text>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="EditColCtrlID">
			<xsl:text>ctrl_</xsl:text>
			<xsl:value-of select="$CRMOpportunityID"/>
			<xsl:text>_</xsl:text>
			<xsl:value-of select="$CurrentCol"/>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$UDFXML/UDFDefinition[Column_Name = $CurrentCol]/IsDropdown = 1">
				<select id="{$EditColCtrlID}" class="smallDropdown" style="width:{$WidgetWidth};"
                        onChange="Portal_UpdateCRMOpportunityValue({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', {$LastElement}, '{$ColumnFormat}');"
                        onblur="Portal_ShowCRMOpportunityListing({$CRMOpportunityID}, {$PortalItemID}, this, 'SalesUser', {$LastElement}, '{$EmployeeID}');">
					<option value="-99">
						<xsl:value-of select="$ColumnHeader"/>
					</option>
					<xsl:for-each select="$UDFMasterValues/UDFMasterValue[CRMUDFDefID = $CRMUDFDefID]">
						<xsl:choose>
							<xsl:when test="StoreValue = $CurrentColValue and RelatedValue">
								<option value="{StoreValue}" selected="selected" relatedValue="{RelatedValue}">
									<xsl:value-of select="DisplayValue"/>
								</option>
							</xsl:when>
							<xsl:when test="RelatedValue">
								<option value="{StoreValue}" relatedValue="{RelatedValue}">
									<xsl:value-of select="DisplayValue"/>
								</option>
							</xsl:when>
							<xsl:when test="StoreValue = $CurrentColValue">
								<option value="{StoreValue}" selected="selected">
									<xsl:value-of select="DisplayValue"/>
								</option>
							</xsl:when>
							<xsl:otherwise>
								<option value="{StoreValue}">
									<xsl:value-of select="DisplayValue"/>
								</option>
							</xsl:otherwise>
						</xsl:choose>

					</xsl:for-each>
				</select>
				<xsl:value-of select="$ColPostFix"/>
			</xsl:when>
			<xsl:when test="$ColumnFormatID = 4 or $ColumnFormat = 'Date'">
				<div>
					<input id="{$EditColCtrlID}" type="text"
                           onblur="Portal_UpdateCRMOpportunityValue({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', {$LastElement}, '{$ColumnFormat}');
                           Portal_ShowCRMOpportunityListing({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', {$LastElement}, '{$EmployeeID}');"
                           value ="{$CurrentColValue}" style="width:65px"
                           name="&lt;OperationalData&gt;&lt;CRMOpportunityID&gt;{$CRMOpportunityID}&lt;/CRMOpportunityID&gt;&lt;PortalItemID&gt;{$PortalItemID}&lt;/PortalItemID&gt;&lt;Mode&gt;OpportunitiesDate&lt;/Mode&gt;&lt;SourceControlID&gt;{$EditColCtrlID}&lt;/SourceControlID&gt;&lt;CurrentCol&gt;{$CurrentCol}&lt;/CurrentCol&gt;&lt;LastElement&gt;{$LastElement}&lt;/LastElement&gt;&lt;ColumnFormat&gt;{$ColumnFormat}&lt;/ColumnFormat&gt;&lt;/OperationalData&gt;"/>
					<img id="{$EditColCtrlID}_StartDate" height="10px" width="10px"
                         src="{normalize-space($TemplateURL)}Web/Images/CalendarIcon.gif"
                         onclick="dp('{$EditColCtrlID}', '{$EditColCtrlID}_StartDate');"></img>
				</div>
			</xsl:when>
			<xsl:when test="$ColumnFormatID = 2 or $ColumnFormatID = 3 or $ColumnFormat = 'Percent' or $ColumnFormat = 'Money' or $ColumnFormat = 'Number'">
				<input id="{$EditColCtrlID}" type="text" style="width:{$WidgetWidth};text-align:right;" value="{$CurrentColValue}"
                       onblur="Portal_UpdateCRMOpportunityValue({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', {$LastElement}, '{$ColumnFormat}');
                       Portal_ShowCRMOpportunityListing({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', {$LastElement}, '{$EmployeeID}');"></input>
				<xsl:value-of select="$ColPostFix"/>
			</xsl:when>
			<xsl:when test="$CurrentCol='OpportunityMarket'">
				<input id="{$EditColCtrlID}" type="text" style="width:{$WidgetWidth};" value="{$CurrentColValue}"
                        onblur="Portal_UpdateCRMOpportunityValue({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', 0, '{$ColumnFormat}');
                       "></input>
				<xsl:value-of select="$ColPostFix"/>
			</xsl:when>
			<xsl:otherwise>
				<input id="{$EditColCtrlID}" type="text" style="width:{$WidgetWidth};" value="{$CurrentColValue}"
                        onblur="Portal_UpdateCRMOpportunityValue({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', {$LastElement}, '{$ColumnFormat}');
                       Portal_ShowCRMOpportunityListing({$CRMOpportunityID}, {$PortalItemID}, this, '{$CurrentCol}', {$LastElement}, '{$EmployeeID}');"></input>
				<xsl:value-of select="$ColPostFix"/>

			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="TemplateCellTextAlignment">
		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormatID" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormat" select="'N/A'"></xsl:param>

		<xsl:choose>
			<xsl:when test="$CurrentCol = 'SalesUser'">
				<xsl:text>text-align:left;</xsl:text>
			</xsl:when>
			<xsl:when test="$ColumnFormat = 'Percent' or $ColumnFormat = 'Number' or $ColumnFormat = 'Money'">
				<xsl:text>text-align:right;</xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="TemplateWidgetWidth">
		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormatID" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormat" select="'N/A'"></xsl:param>

		<xsl:choose>
			<xsl:when test="$ColumnFormatID = 2 or $ColumnFormatID = 3 or $ColumnFormat = 'Money' or $ColumnFormat = 'Number'">
				<xsl:text>80px</xsl:text>
			</xsl:when>
			<xsl:when test="$ColumnFormat = 'Percent'">
				<xsl:text>50px</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>100%</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="TemplateDataColumnWidget">
		<xsl:param name="CurrentCol" select="'N/A'"></xsl:param>
		<xsl:param name="CurrentColValue" select="'N/A'"></xsl:param>
		<xsl:param name="ColumnFormat" select="'N/A'"></xsl:param>
		<xsl:param name="CRMOpportunityID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="N/A"></xsl:param>

		<xsl:variable name="DataColSpanID">
			<xsl:text>spn_</xsl:text>
			<xsl:value-of select="$CRMOpportunityID"/>
			<xsl:text>_</xsl:text>
			<xsl:value-of select="$CurrentCol"/>
		</xsl:variable>

		<xsl:variable name="ColFormattedValue">
			<xsl:choose>
				<xsl:when test="$ColumnFormat = 'Money' and string(format-number($CurrentColValue, '#')) != 'NaN'">
					<xsl:text>$</xsl:text>
					<xsl:value-of select="format-number($CurrentColValue, '#,###')"/>
				</xsl:when>
				<xsl:when test="$ColumnFormat = 'Percent'">
					<xsl:if test="string(number($CurrentColValue)) != 'NaN'">
						<xsl:value-of select="$CurrentColValue"/>
						<xsl:text>%</xsl:text>
					</xsl:if>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$CurrentColValue"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$CurrentCol='CustomStatus'">
				<span class="publicationSummary onMouseOver MouseOverUnderline" onclick="OpportunityClickChange('CustomStatus','{$CRMOpportunityID}','{$CurrentCol}')" id="{$DataColSpanID}">
					<xsl:value-of select="$ColFormattedValue"/>
				</span>

			</xsl:when>
			<xsl:when test="$CurrentCol='TargetCloseDate'">
				<div class="publicationSummary onMouseOver MouseOverUnderline" onclick="dp('{$DataColSpanID}','{$DataColSpanID}');" id="{$DataColSpanID}" name="&lt;OperationalData&gt;&lt;CRMOpportunityID&gt;{$CRMOpportunityID}&lt;/CRMOpportunityID&gt;&lt;PortalItemID&gt;{$PortalItemID}&lt;/PortalItemID&gt;&lt;Mode&gt;OpportunitiesDate&lt;/Mode&gt;&lt;SourceControlID&gt;{$DataColSpanID}&lt;/SourceControlID&gt;&lt;CurrentCol&gt;{$CurrentCol}&lt;/CurrentCol&gt;&lt;LastElement&gt;0&lt;/LastElement&gt;&lt;ColumnFormat&gt;{$ColumnFormat}&lt;/ColumnFormat&gt;&lt;/OperationalData&gt;">
					<xsl:value-of select="$ColFormattedValue"/>
				</div>

			</xsl:when>
			<xsl:otherwise>
				<span class="publicationSummary" id="{$DataColSpanID}">
					<xsl:value-of select="$ColFormattedValue"/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
		<!--<span class="publicationSummary" id="{$DataColSpanID}">
            <xsl:value-of select="$ColFormattedValue"/>
        </span>-->
	</xsl:template>
</xsl:stylesheet>
