﻿<?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:output method="xml" indent="yes"/>

	<xsl:template name="AddMetricToTemplate">
		<xsl:param name="TemplateItemID" select="'N/A'"></xsl:param>
		<xsl:param name="BrandID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalMetrics" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="MetricInputType" select="'N/A'"></xsl:param>
		<xsl:param name="MetricPeriodTypes" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedPeriodType" select="'N/A'"></xsl:param>
		<table class="tableMaster">
			<tr>
				<td>
					<div id="div_AddMetricButton">
						<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray textCenter" style="width:80px;line-height:25px;"
                             onclick="return ClientPortal_DisplayAddNewTemplateMetric('div_AddMetricButton','div_AddNewMetric','txt_{$TemplateItemID}_Metric');">
							<span id="span_SaveTopic" class="capitalFont">Add Metric</span>
						</div>
					</div>
					<div id="div_AddNewMetric" style="display:none;border:2px solid rgb(217, 217, 217);padding:10px;">
						<!--<table class="tableMaster" cellpadding="1" cellspacing="1">
                            <tr>
                                <td width="15%" style="margin-bottom:10px;">
                                    <span class="publicationSummary">
                                        Metric
                                    </span>
                                </td>
                                <td>
                                    <xsl:choose>
                                        <xsl:when test="$PortalMetrics/Metrics">
                                            <select id="ddlPortalMetrics" class="smallDropdown"
                                                    onchange="DisplayTextBoxOnCustomMetric('ddlPortalMetrics','txt_{$TemplateItemID}_Metric','img_CrossButton');">
                                                <option>-Select-</option>
                                                <xsl:for-each select="$PortalMetrics/Metrics">
                                                    <option value="{PortalMetricID}">
                                                        <xsl:value-of select="MetricKey"/>
                                                    </option>
                                                </xsl:for-each>
                                                <option value="-99">Add Custom...</option>
                                            </select>
                                            <input id="txt_{$TemplateItemID}_Metric" type="text" class="text" style="display:none;width:180px;"></input>
                                            <img id="img_CrossButton" title="Cancel" src="{$TemplateURL}/Web/Images/Ver_2_0/BT_x.png"
                                                 width="10" height="10" style="display:none;margin-left:5px;" class="onMouseOver"
                                                 onclick="DisplayPortalMetricsDD('ddlPortalMetrics','txt_{$TemplateItemID}_Metric','img_CrossButton');"></img>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <input id="txt_{$TemplateItemID}_Metric" type="text" class="text" style="width:180px;"></input>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </td>
                            </tr>
                            <tr>
                                <td width="15%">
                                    <span class="publicationSummary">
                                        Sort
                                    </span>
                                </td>
                                <td>
                                    <input id="txt_{$TemplateItemID}_MetricSort" type="text" class="text" style="width:90px;"></input>
                                </td>
                            </tr>
                            <tr>
                                <td width="15%">
                                    <span class="publicationSummary">
                                        Default Value
                                    </span>
                                </td>
                                <td>
                                    <input id="txt_{$TemplateItemID}_MetricDefaultValue" type="text" class="text" style="width:90px;"
                                           onblur="numberOnlyForNumbers('txt_{$TemplateItemID}_MetricDefaultValue');"></input>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray textCenter" style="width:60px;line-height:20px;"
                                         onclick="clientPortal_saveTemplateMetric('ddlPortalMetrics','txt_{$TemplateItemID}_Metric',
                                                                                        'txt_{$TemplateItemID}_MetricSort', 'txt_{$TemplateItemID}_MetricDefaultValue',
                                                                                        '{$TemplateItemID}',
                                                                                        'div_TemplateDetailNumbersAndMetrics','{$BrandID}');">
                                        <span id="span_SaveTopic" class="capitalFont">Save</span>
                                    </div>
                                </td>
                                <td>
                                    <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray textCenter" style="width:60px;line-height:20px;"
                                         onclick="return ClientPortal_DisplayAddNewTemplateMetric('div_AddNewMetric','div_AddMetricButton','txt_{$TemplateItemID}_Metric');">
                                        <span id="span_CancelTopic" class="capitalFont">Cancel</span>
                                    </div>
                                </td>
                            </tr>
                        </table>-->


						<table class="tableMaster" cellpadding="1" cellspacing="1">
							<tr>
								<td width="15%" style="margin-bottom:10px;">
									<span class="publicationSummary">
										Metric
									</span>
								</td>
								<td>
									<xsl:choose>
										<xsl:when test="$PortalMetrics/Metrics">
											<select id="ddlPortalMetrics" class="smallDropdown"
                                                    onchange="DisplayTextBoxOnCustomMetric('ddlPortalMetrics','txt_{$TemplateItemID}_Metric','img_CrossButton');">
												<option value="">-Select-</option>
												<xsl:for-each select="$PortalMetrics/Metrics">
													<option value="{PortalMetricID}">
														<xsl:value-of select="MetricKey"/>
													</option>
												</xsl:for-each>
												<option value="-99">Add Custom...</option>
											</select>
											<input id="txt_{$TemplateItemID}_Metric" type="text" class="text" style="display:none;width:180px;"></input>
											<img id="img_CrossButton" title="Cancel" src="{$TemplateURL}/Web/Images/Ver_2_0/BT_x.png"
                                                 width="10" height="10" style="display:none;margin-left:5px;" class="onMouseOver"
                                                 onclick="DisplayPortalMetricsDD('ddlPortalMetrics','txt_{$TemplateItemID}_Metric','img_CrossButton');"></img>
										</xsl:when>
										<xsl:otherwise>
											<input id="txt_{$TemplateItemID}_Metric" type="text" class="text" style="width:180px;"></input>
										</xsl:otherwise>
									</xsl:choose>
								</td>
							</tr>
							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Controll Key
									</span>
								</td>
								<td>
									<input id="txt_{$TemplateItemID}_ControllKey" type="text" class="text" style="width:100px;"></input>
								</td>
							</tr>
							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Sort
									</span>
								</td>
								<td>
									<input id="txt_{$TemplateItemID}_MetricSort" type="text" class="text" style="width:100px;"></input>
								</td>
							</tr>

							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Default Value
									</span>
								</td>
								<td>
									<input id="txt_{$TemplateItemID}_MetricDefaultValue" type="text" class="text" style="width:100px;"
                                           onblur="numberOnlyForNumbers('txt_{$TemplateItemID}_MetricDefaultValue');"></input>
								</td>
							</tr>
							
							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Period Type
									</span>
								</td>
								<td>
									<select id="ddlPeriodType" class="smallDropdown">
										<option value="">-Select-</option>
										<xsl:for-each select="$MetricPeriodTypes/PeriodType">
											<xsl:variable name="CurrPeridType" select="."></xsl:variable>
											<xsl:choose>
												<xsl:when test="$CurrPeridType=$SelectedPeriodType">
													<option value="{$CurrPeridType}" selected="">
														<xsl:value-of select="$CurrPeridType"/>
													</option>
												</xsl:when>
												<xsl:otherwise>
													<option value="{$CurrPeridType}">
														<xsl:value-of select="$CurrPeridType"/>
													</option>
												</xsl:otherwise>
											</xsl:choose>

										</xsl:for-each>
									</select>
								</td>
							</tr>
							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Input Type
									</span>
								</td>
								<td>
									<xsl:choose>
										<xsl:when test="$MetricInputType/InputType">
											<select id="ddlMetricInputType" class="smallDropdown">
												<option value="">-Select-</option>
												<xsl:for-each select="$MetricInputType/InputType">
													<xsl:choose>
														<xsl:when test="MetricInputType='Incremental'">
															<option value="{MetricInputType}" selected="">
																<xsl:value-of select="MetricInputType"/>
															</option>
														</xsl:when>
														<xsl:otherwise>
															<option value="{MetricInputType}">
																<xsl:value-of select="MetricInputType"/>
															</option>
														</xsl:otherwise>
													</xsl:choose>
												</xsl:for-each>

											</select>
											<input id="txt_{$TemplateItemID}_MetricInputType" type="text" class="text" style="display:none;width:180px;"></input>
											<img id="img_CrossButton" title="Cancel" src="{$TemplateURL}/Web/Images/Ver_2_0/BT_x.png"
                                                 width="10" height="10" style="display:none;margin-left:5px;" class="onMouseOver"
                                                 onclick="DisplayPortalMetricsDD('ddlPortalMetrics','txt_{$TemplateItemID}_Metric','img_CrossButton');"></img>
										</xsl:when>
										<xsl:otherwise>
											<input id="txt_{$TemplateItemID}_MetricInputType" type="text" class="text" style="width:100px;"></input>
										</xsl:otherwise>
									</xsl:choose>
								</td>
							</tr>
							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Description
									</span>
								</td>
								<td>
									<input id="txt_{$TemplateItemID}_Description" type="text" class="text" style="width:100px;"></input>
								</td>
							</tr>
							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Metric Score
									</span>
								</td>
								<td>
									<input id="txt_{$TemplateItemID}_MetricScore" type="text" class="text" style="width:100px;"
                                           onkeydown="checkNumericAndDecimal(event,'txt_{$TemplateItemID}_MetricScore')"></input>
								</td>
							</tr>

							<tr>
								<td width="15%">
									<span class="publicationSummary">
										Detail
									</span>
								</td>
								<td>
									<input id="chk_{$TemplateItemID}_Detail" type="checkbox" class="text" style="width:100px;"></input>
								</td>
							</tr>

							<tr>
								<td>
									<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray textCenter" style="width:60px;line-height:20px;"
                                         onclick="clientPortal_saveTemplateMetric('ddlPortalMetrics','txt_{$TemplateItemID}_Metric',
                                                                                        'txt_{$TemplateItemID}_MetricSort', 'txt_{$TemplateItemID}_MetricDefaultValue',
                                                                                        '{$TemplateItemID}',
                                                                                        'div_TemplateDetailNumbersAndMetrics','{$BrandID}','txt_{$TemplateItemID}_ControllKey','ddlPeriodType','ddlMetricInputType',
																						'txt_{$TemplateItemID}_MetricScore','txt_{$TemplateItemID}_Description','chk_{$TemplateItemID}_Detail');">
										<span id="span_SaveTopic" class="capitalFont">Save</span>
									</div>
								</td>
								<td>
									<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray textCenter" style="width:60px;line-height:20px;"
                                         onclick="return ClientPortal_DisplayAddNewTemplateMetric('div_AddNewMetric','div_AddMetricButton','txt_{$TemplateItemID}_Metric');">
										<span id="span_CancelTopic" class="capitalFont">Cancel</span>
									</div>
								</td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
		</table>
	</xsl:template>
</xsl:stylesheet>
