<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="xml" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>
	<xsl:param name="message"/>
	<xsl:param name="pageTitle">CA</xsl:param>
	<xsl:param name="name"/>
	<xsl:include href="namedtemplates.xsl"/>
	<xsl:template match="/">
		<html>
			<head>
				<title>
					<xsl:value-of select="$web_title"/>
				</title>
				<xsl:if test="configuration/user_data/auto_logout_time != 0">
					<xsl:element name="meta">
						<xsl:attribute name="http-equiv">refresh</xsl:attribute>
						<xsl:attribute name="content"><xsl:value-of select="(configuration/user_data/auto_logout_time * 60)+ 5"/>;URL=advca.py</xsl:attribute>
					</xsl:element>
				</xsl:if>
				<xsl:call-template name="common_imports"/>
				<script type="text/javascript" src="/javascript/ca.js"/>
			</head>
			<body onload="StartFloat(); init();">
				<xsl:call-template name="initPage">
					<xsl:with-param name="pageName">advca.py</xsl:with-param>
					<xsl:with-param name="message" select="$message"/>
					<xsl:with-param name="applyClick">validateKeys();</xsl:with-param>
				</xsl:call-template>
				<div id="displayresults">
					<form action="advca.py" method="post" name="applyform">
					<input type="hidden" name="action" value="apply"/>
					<table class="clear" style="margin: 0px 0px 5px 0px">
						<tr>
							<td>
								<div id="title">CA</div>
							</td>
							<td style="width: 50px"></td>
							<td>
								<div class="detailOptions">
									<div id="nav_ca">
										<xsl:for-each select="/configuration/ca">
											<div id="nav_ca{@index}" onclick="show_ca('nav_ca{@index}')">
												CA<xsl:value-of select="@index"/>
											</div>
										</xsl:for-each>
									</div>
								</div>
							</td>
						</tr>
					</table>
					<xsl:apply-templates mode="globalca"/>
					<!--xsl:apply-templates mode="portca"/-->
					</form>
				</div>
			</body>
		</html>
	</xsl:template>
	<!-- CA content goes here -->
	<xsl:template match="/configuration/ca" mode="globalca">
		<xsl:variable name="caIndex" select="@index"/>
		<div id="ca{@index}_container">
			<div class="row"><hr width="485" size="1" align="left"/></div>
			<div class="mperow" style="position: relative; left: 2px">
				<div id="ca{@index}_enableNameContainer" class="generalcell">
					<b>Enable:</b>
				</div>
				<div class="generalcell">
					<xsl:choose>
						<xsl:when test="/configuration/system/features/feature[@name='cond_acc']='Enabled'">
							<select id="ca{@index}_selector" name="xpath:/configuration/ca[@index='{@index}']/enable" onchange="checkBiss(this.value, {$caIndex})">
								<xsl:call-template name="printOptions">
									<xsl:with-param name="optionName">enable</xsl:with-param>
									<xsl:with-param name="defaultValue" select="/configuration/ca[@index=$caIndex]/enable"/>
									<xsl:with-param name="ignoredValue">
										<xsl:if test="@index != '1'">BISS1</xsl:if>
									</xsl:with-param>
								</xsl:call-template>
							</select>
						</xsl:when>
						<xsl:otherwise>Feature Locked</xsl:otherwise>
					</xsl:choose>
				</div>
			</div>
			<div style="float: left; clear:both">	
				<table class="clear">
					<tr>
						<td id="ca{@index}_not_biss" style="vertical-align: top; width: 400px">
							<div class="mperow">
								<div class="generalcell">
									<b>Super CAS ID:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/super_cas_id</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="super_cas_id"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>CAS System ID:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/cas_system_id</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="cas_system_id"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>ECMG IP:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/ecmg/inet_addr</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="ecmg/inet_addr"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>ECMG Port:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/ecmg/connection_port</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="ecmg/connection_port"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>ECMG Channel ID:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/ecmg/ecmg_channel_id</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="ecmg/ecmg_channel_id"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>ECMG Crypto Period:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/ecmg/ecmg_crypto_period</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="ecmg/ecmg_crypto_period"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>ECMG Keep Alive:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/ecmg/ecmg_keep_alive</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="ecmg/ecmg_keep_alive"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>EMMG Mode:</b>
								</div>
								<div class="generalcell">
									<select name="xpath:/configuration/ca[@index='{@index}']/emmg/connection_mode">
										<xsl:call-template name="printOptions">
											<xsl:with-param name="optionName">emmg</xsl:with-param>
											<xsl:with-param name="defaultValue" select="/configuration/ca[@index=$caIndex]/emmg/connection_mode"/>
										</xsl:call-template>
									</select>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>EMMG Port:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/emmg/connection_port</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="emmg/connection_port"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>EMMG Maximum Bandwidth:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/emmg/max_bandwidth</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="emmg/max_bandwidth"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>EMMG PID:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/emmg/emm_pid_config</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="emmg/emm_pid_config"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>EMMG Data Channel ID:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/emmg/emmg_data_channel_id</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="emmg/emmg_data_channel_id"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>EMMG Keep Alive:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/emmg/emmg_keep_alive</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="emmg/emmg_keep_alive"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>Private Data Length:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/private_data/@private_data_length?create=1</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="private_data/@private_data_length"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
							<div class="mperow">
								<div class="generalcell">
									<b>Private Data:</b>
								</div>
								<div class="generalcell">
									<xsl:element name="input">
										<xsl:attribute name="type">text</xsl:attribute>
										<xsl:attribute name="name">xpath:/configuration/ca[@index='<xsl:value-of select="@index"/>']/private_data?create=1</xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="private_data"/></xsl:attribute>
									</xsl:element>
								</div>
							</div>
						</td>
						<td id="ca{@index}_biss" style="display: none; vertical-align: top; width: 400px">
							<xsl:call-template name="biss_key_loop">
								<xsl:with-param name="count" select="1"/>
								<xsl:with-param name="max" select="15"/>
							</xsl:call-template>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</xsl:template>
	<xsl:template name="biss_key_loop">
		<xsl:param name="count"/>
		<xsl:param name="max"/>
		<div class="mperow">
			<div class="shortgeneralcell">
				<b>Key <xsl:value-of select="$count"/>: </b>
			</div>
			<div class="generalcell">
				<xsl:element name="input">
					<xsl:attribute name="type">text</xsl:attribute>
					<xsl:attribute name="name">xpath:/configuration/ca_biss_keys/key[@index='<xsl:value-of select="$count"/>']?create=1</xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="/configuration/ca_biss_keys/key[@index=string($count)]/."/></xsl:attribute>
					<xsl:attribute name="onblur">updateBissKey(this.value, <xsl:value-of select="$count"/>)</xsl:attribute>
					<xsl:attribute name="maxlength">12</xsl:attribute>
				</xsl:element>
			</div>
		</div>
		<xsl:if test="$count != $max">
			<xsl:call-template name="biss_key_loop">
				<xsl:with-param name="count" select="$count + 1"/>
				<xsl:with-param name="max" select="$max"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<!--xsl:template match="/configuration/port" mode="portca">
		<div class="row">
			<div class="generalcell">
				<b>Port <xsl:value-of select="@index"/> Scramble All:</b>
			</div>
			<div class="generalcell">
				<xsl:if test="ca/scramble_all='Yes'">
					<xsl:element name="select">
						<xsl:attribute name="name">configuration/port[@index="<xsl:value-of select="@index"/>"]/ca/scramble_all</xsl:attribute>
						<option value="Yes">Yes</option>
						<option value="No">No</option>
					</xsl:element>
				</xsl:if>
				<xsl:if test="ca/scramble_all='No'">
					<xsl:element name="select">
						<xsl:attribute name="name">configuration/port[@index="<xsl:value-of select="@index"/>"]/ca/scramble_all</xsl:attribute>
						<option value="No">No</option>
						<option value="Yes">Yes</option>
					</xsl:element>
				</xsl:if>
			</div>
		</div>
	</xsl:template-->
	<xsl:template match="text()" mode="globalca">
	</xsl:template>
	<xsl:template match="text()">
	</xsl:template>
</xsl:stylesheet>
