<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE stylesheet [
<!ENTITY em "&#8195;" >
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
version="1.0"
xmlns:user="urn:GAASI-stuff" exclude-result-prefixes="user rdf dc"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://www.purl.org/dc/elements/1.1/" 
>

<xsl:output indent="yes" encoding="utf-8"  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />


  <ms:script implements-prefix="user" xmlns:ms="urn:schemas-microsoft-com:xslt" language="C#">
    public string getEntityURI(System.Xml.XPath.XPathNodeIterator node, string entityName, string rootPath) {
    if (node == null ) {
    return "NODE IS NULL";
    }
    if (node.MoveNext()) {
    System.Xml.XmlDocument document = ((System.Xml.IHasXmlNode)node.Current).GetNode().OwnerDocument;
    XmlEntity entity = (XmlEntity)document.DocumentType.Entities.GetNamedItem(entityName);
    if (entity == null ) {
    return "ENTITY NOT FOUND: " + entityName;
    }
    return rootPath + "\\Files\\" + entity.SystemId;
    }
    return "MOVE NEXT FAILED";
    }
  </ms:script>

<xsl:template match="inform"/>
<xsl:template match="sbc"/>
<xsl:template match="techstd"/>
<xsl:template match="actref"/>

<!-- Deleted elements should not show content, just the word Deleted OR
	not be shown at all, need to add this fuctionality -->
<xsl:template name="changed-element">
	<xsl:choose>
		<xsl:when test="@change='add' and not($no-change-markings)">
			<xsl:attribute name="class">add</xsl:attribute>
		</xsl:when>
			<xsl:when test="@change='modify' and not($no-change-markings)">
			<xsl:attribute name="class">modify</xsl:attribute>
		</xsl:when>
			<xsl:when test="@change='delete' and not($no-change-markings)">
			<xsl:attribute name="class">delete</xsl:attribute>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="@rfc">
		<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
	</xsl:if>
</xsl:template>

<xsl:template match="rfu">
           <tr>
                <td width="20%" valign="top">REASON FOR UPDATE: </td>
                <td valign="top"><xsl:apply-templates/></td>
            </tr>
</xsl:template>

    <xsl:template match="figure">
		<div>
			<xsl:call-template name="changed-element"/>

		<xsl:choose>
			<xsl:when test="count(graphic)&gt; 1">
				<xsl:apply-templates select="graphic" mode="multisheet"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="graphic" mode="singlesheet"/>
			</xsl:otherwise>
		</xsl:choose>
		</div>
	</xsl:template>

<xsl:template match="graphic" mode="multisheet">
	
<div class="image">
    <object height="400" width="600" type="application/x-isoview" classid="CLSID:865B2280-2B71-11D1-BC01-006097AC382A" 
    			id="ivx1" imageType="graphic">
    		<param value="1" name="border"/>
      		<param name="src" value="{user:getEntityURI(., @boardno, $paramPath)}"/>
			<!-- <param name="src" value="C:\Documents and Settings\dvint\Desktop\IETP bike 3.0\Files\ICN-S1000DBIKE-AAA-D000000-0-U8025-00536-A-04-1.CGM"/> -->
    </object>
    <script language="javascript">
	     function configEvent() {
	     		document.ivx1.ConfigEvents(1+2+4+8+16+32+1024);
	     }
	     </script>
	     <script language="javascript" for="ivx1" 
	     		event="HsHit(nMouseBtn, lRefID, strName, strViewPortName, strViewPortFile)">
	        myHsHit(nMouseBtn, lRefID, strName, strViewPortName, strViewPortFile);
    </script>
</div>

<p><b>Figure <xsl:value-of select="count(preceding::figure)+1"/>
 <xsl:text>(Sheet </xsl:text>
            <xsl:value-of select="count(preceding-sibling::figure)+1"/>
            <xsl:text>of </xsl:text>
            <xsl:value-of select="count(preceding-sibling::sheet)+ count(following-sibling::sheet)+1"/>
            <xsl:text>)</xsl:text>
			&em;<xsl:value-of select="title"/></b></p>
</xsl:template>


<xsl:template match="graphic" mode="singlesheet">
<div class="image">
    <object height="400" width="600" type="application/x-isoview" classid="CLSID:865B2280-2B71-11D1-BC01-006097AC382A" 
    			id="ivx1" imageType="graphic">
    		<param value="1" name="border"/>
      		<param name="src" value="{user:getEntityURI(., @boardno, $paramPath)}"/>
			<!-- <param name="src" value="C:\Documents and Settings\dvint\Desktop\IETP bike 3.0\Files\ICN-S1000DBIKE-AAA-D000000-0-U8025-00536-A-04-1.CGM"/> -->
    </object>
    <script language="javascript">
	     function configEvent() {
	     		document.ivx1.ConfigEvents(1+2+4+8+16+32+1024);
	     }
	     </script>
	     <script language="javascript" for="ivx1" 
	     		event="HsHit(nMouseBtn, lRefID, strName, strViewPortName, strViewPortFile)">
	        myHsHit(nMouseBtn, lRefID, strName, strViewPortName, strViewPortFile);
    </script>
</div>

	<p><b><a href="R4I_CANCEL">
                    <xsl:attribute name="onclick">window.external.ShowImage('<xsl:value-of select="string(@boardno)"/>', <xsl:value-of select="count(preceding::figure)+1"/>)</xsl:attribute> 
Figure <xsl:value-of select="count(preceding::figure)+1"/>&em;<xsl:value-of select="../title"/></a></b></p>
</xsl:template>

<xsl:template match="rdf:*"/>

<!-- ................................................... parameters ................................................... -->
    
   <xsl:param name="paramPath" />
   <xsl:param name="param1"/>
   <xsl:param name="param2"/>
   <xsl:param name="param3"/>
   <xsl:param name="param4"/>

    

<!-- ................................................... dmodule ................................................... -->


    <xsl:template name="dmodule-body-attrs">
        <xsl:attribute name="onload">StartUp_DM()</xsl:attribute>
        <xsl:attribute name="onresize">DModule_Init()</xsl:attribute>
        <xsl:attribute name="onscroll">document_Scroll()</xsl:attribute>
    </xsl:template>

    <xsl:template name="dmodule-table-attrs">
        <xsl:attribute name="width">100%</xsl:attribute>
    </xsl:template>

    <xsl:template name="dmodule-table-header"/>

    <xsl:template name="dmodule-body-pre"/>


    <!-- .......................................... 
        remove header from applic table in descript Doctype  : Only for CBP
        10/6/11 Ticket #268
        .................................... -->
    
    <xsl:template match="applic" mode="applic-header-cbp"/>
    



    <xsl:template match="supplies">
        <xsl:choose>
            <xsl:when test="count(child::nosupply)>0">
                <tr>
                    <td class="tablestart" valign="top" colspan="2"> 
                        <xsl:apply-templates/>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
                <tr>
                    <td class="tablestart" valign="top" colspan="2">Consumables:</td>
                </tr>
                <tr>
                    <td  valign="top" colspan="2">
                        <center>
                            <table width="80%" border="1" cellpadding="5" cellspacing="0">
                                <tr>
                                    <td>Nomenclature</td>
                                    <td>Specification/PN</td>
                                </tr>
                                <xsl:apply-templates/>
                            </table>
                        </center>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        <tr>
            <td align="center" valign="top" colspan="2"> </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="spares">
        <xsl:choose>
            <xsl:when test="count(child::nospares)>0">
                <tr>
                    <td class="tablestart" valign="top" colspan="2"> 
                        <xsl:apply-templates/>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
                <tr>
                    <td class="tablestart" valign="top" colspan="2">Spares:</td>
                </tr>
                <tr>
                    <td  valign="top" colspan="2">
                        <center>
                            <table width="80%" border="1" cellpadding="5" cellspacing="0">
                                <tr>
                                    <td>Nomenclature</td>
                                    <td>Cage</td>
                                    <td>Part No.</td>
                                    <td>Part No.</td>
                                </tr>
                                <xsl:apply-templates/>
                            </table>
                        </center>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        <tr>
            <td align="center" valign="top" colspan="2"> </td>
        </tr>
    </xsl:template>



    <!-- ................................................... COMMONS ................................................... -->
    
    

    <!-- .................................................. variables .................................................. -->
    
    <xsl:variable name="root" select="/"/>
    <xsl:variable name="caveats" select="//security/@caveat"/>

    <xsl:variable name="is-wp" select="boolean(/dmodule/idstatus/dmaddres/dmc/avee[modelic = 'GAASIB0' and sdc = '06'])"/>
    
    <xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
    <xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
    <xsl:variable name="letters">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
    
    <xsl:variable name="distrib">DISTRIBUTION STATEMENT - Distribution authorized to the Department of Defense and US DoD contractors only (administrative or operational use) (30 April 1998). Questions concerning technical content or any other requests for this document shall be referred to DET 3, 658 AESS, 16761 Via Del Campo Court, San Diego, CA 92127.</xsl:variable>
    <xsl:variable name="expcont">WARNING - This document contains technical data whose export is restricted by the Arms Export Control Act (Title 22, U.S.C., Sec 2751 et seq) or the Export Administration Act of 12979, as amended (Title 50, U.S.C., App 2401 et seq). Violations of these export laws are subject to severe criminal penalties.</xsl:variable>
    <xsl:variable name="handling"></xsl:variable>
    <xsl:variable name="destruct">HANDLING AND DESTRUCTION NOTICE - Comply with distribution statement and destroy by any method that will prevent disclosure of contents or reconstruction of the document.</xsl:variable>
    <xsl:variable name="disclose">DISCLOSURE NOTICE - This information is furnished upon the condition that it will not be released to another nation without the specific authority of DET 3, 658 AESS, 16761 Via Del Campo Court, San Diego, CA 92127, or higher DoD authority, that it will be used for military purposes only, that the individual or corporate rights originating in the information, whether patented or not, will be respected, that the recipient will report promptly to the United States, any known or suspected compromises, and that the information will be provided substantially the same degree of security afforded it by the Department of Defense of the United States. Also regardless of any other markings on the document, it will not be downgraded or declassified without written approval of the originating United States agency.</xsl:variable>

    <xsl:variable name="paramFile" select="'SystemXML\CDContent.xml'"/>
    <xsl:variable name="paramFull" select="concat(translate($paramPath, '/', '\'), $paramFile)"/>
    <xsl:variable name="params" select="document($paramFull)/*"/>

    <xsl:variable name="customer">
        <xsl:variable name="bannerimage" select="$params/preferences/bannerimage"/>
        <xsl:variable name="banner" select="translate($bannerimage, $upper, $lower)"/>
        <xsl:choose>
            <xsl:when test="starts-with($banner, 'airforce')">AF</xsl:when>
            <xsl:when test="starts-with($banner, 'cbp')">CBP</xsl:when>
            <xsl:when test="starts-with($banner, 'it')">IT</xsl:when>
            <xsl:otherwise>AF</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="coverFile" select="'Transform\Cover.xml'"/>
    <xsl:variable name="coverFull" select="concat(translate($paramPath, '/', '\'), $coverFile)"/>
    <xsl:variable name="cover" select="document($coverFull)/*"/>

    
    
    <!-- ................................................ Root template ................................................... -->
    
    
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <!-- 
        PURPOSE: Start processing, match top element
        PROMISE: only called from root template
        REQUIREMENTS: None
    -->
    <xsl:template match="dmodule">
        <html>
            <head>
<!--                <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>-->
   			<!--	<link rel="stylesheet" type="text/css" href="style.css" /> -->
                <xsl:call-template name="CSS_Styles">
                    <xsl:with-param name="paramPath" select="$paramPath"/>
                </xsl:call-template>

               <script type="script" language="JavaScript" src="scripts.js"></script>
                
               
                <title>
         <xsl:apply-templates select="descendant::dmtitle/techname"/>
				<xsl:if test="normalize-space(descendant::dmtitle/techname) and
				              normalize-space(descendant::dmtitle/infoname)">
					<xsl:text>&#160;-&#160;</xsl:text>
				</xsl:if>
        <xsl:apply-templates select="descendant::dmtitle/infoname"/>
                 
                </title>
                
             </head>
            
            <body>
				<div class="content">
                <xsl:variable name="disc-text" select="'WARNING - GA-ASI PROPRIETARY AND EXPORT CONTROLLED TECHNICAL DATA. USE OR DISCLOSURE SUBJECT TO RESTRICTIONS ON THE TITLE PAGE OF THIS DOCUMENT.'"/>
                <xsl:variable name="do-disclaimer" select="$customer = 'IT'"/>
                <xsl:call-template name="dmodule-body-attrs"/>
                <xsl:if test="$do-disclaimer"><div class="dis-spacer"><xsl:value-of select="$disc-text"/></div></xsl:if>
                <table>
                    <xsl:call-template name="dmodule-table-attrs"/>
                    <xsl:call-template name="dmodule-table-header"/>
                    <tfoot  style="display: table-footer-group">
                        <tr>
                            <th>
                                <xsl:choose>
                                    <xsl:when test="$do-disclaimer"><xsl:value-of select="$disc-text"/></xsl:when>
                                    <xsl:otherwise>UNCONTROLLED WHEN PRINTED</xsl:otherwise>
                                </xsl:choose>
                            </th>
                        </tr>
                    </tfoot>
                    <tbody>
                        <tr>
                            <td valign="top">
                                <form method="post" name="frmdetail">
                                    <input type="hidden" name="StepNumber" value="1"></input>
                                    <input type="hidden" name="ImageDisplayStyle" value="3"></input>
                                    <input type="hidden" name="NumberOfSteps" value="1"></input>
                                    <input type="hidden" name="NewTarget" value="1"></input>
                                    <input type="hidden" name="RecordID">
                                        <xsl:attribute name="value">
                                            <xsl:value-of select="$param1"/>
                                        </xsl:attribute>
                                    </input>
<!-- ADDED YELLOW BANNER FOR ONE OFF DMODULES IDENTIFIED AS NOT VERIFIED.                                   -->
                                    <xsl:call-template name="dmodule-body-pre"/>
                                    <xsl:if test="@id='unVer'">
                                        <table width="100%" bgcolor="yellow">
                                            <tr align="center" style="font:bold; font-size:18pt;">
                                                <td>UNVERIFIED DATA MODULE</td>
                                            </tr>
                                        </table>
                                    </xsl:if>
                                    <!-- PROCESS IDSTATUS AND CONTENT -->
                                    <xsl:apply-templates/>
                                    
                                    <!-- GLOBAL (NON-TABLE) FOOTNOTES -->
                                    <xsl:variable name="global-ftnotes" select=".//ftnote[not(ancestor::table) or @caveat='cv55']"/>
                                    <xsl:if test="$global-ftnotes">
                                        <hr size="1" width="100%" />
                                        <table width="{80 + 20 * boolean(../@pgwide = 1)}%" border="0">
                                            <col width="36pt"/><col/>
                                            <tbody>
                                                <xsl:for-each select="$global-ftnotes">
                                                    <tr>
                                                        <xsl:if test="@id">
                                                            <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
                                                        </xsl:if>
                                                        <td valign="top"><sup><xsl:apply-templates select="." mode="number"/></sup></td>
                                                        <td valign="top"><xsl:apply-templates/></td>
                                                    </tr>
                                                </xsl:for-each>
                                            </tbody>
                                        </table>
                                    </xsl:if>

                                    <!-- END OF DATA MODULE -->
                                    <hr size="1" width="100%" />
                                    <table width="100%">
                                        <tr>
                                            <td  valign="top" align="center"><h2>End of Data Module</h2></td>
                                        </tr>
                                    </table>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <xsl:if test="$do-disclaimer"><div class="disclaimer"><xsl:value-of select="$disc-text"/></div></xsl:if>
				</div>
            </body>
        </html>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>
    
    <!-- .................................................... suppressions ..................................................... -->
    
    
    <xsl:template name="anchor"/>
    <xsl:template name="dbhtml-attribute"/>
    <xsl:template match="fault"/>
    <xsl:template match="describe"/>
    <xsl:template match="isn"/>
    
    <!-- Not displayed yet -->
    <xsl:template match="dmtitle"/>
    <xsl:template match="issno"/>
    <xsl:template match="issdate"/>
    <xsl:template match="rpc"/>
    <xsl:template match="orig"/>
    <xsl:template match="copyright"/>
    
    <!-- XREF Only -->

    <xsl:template match="hotspot"/>
    <xsl:template match="inline"/>
    <xsl:template match="retrofit"/>
    <xsl:template match="authblk"/>
    <xsl:template match="notes"/>
    <xsl:template match="brexref"/>
    <xsl:template match="qa"/>
    
    <xsl:template match="graphic"/>
    <xsl:template match="graphic" mode="xref"/>
    
    <!-- ................................................... defaults ................................................... -->
    
    
    <!-- CHANGE BARS -->


    <xsl:variable name="no-change-markings" select="$cover/change/@markings = '0'"/>

    <xsl:template match="*" mode="max-level" name="max-level">
        <xsl:param name="changes" select="descendant::*[@level]"/>
        <xsl:param name="max" select="0"/>
        <!-- level(n) = if $n/@level >= 1000 then $n/@level                               -
           -               else $n/@level * 1000 + (if $n/@mark > 0 then $n/@mark else 0) -->
        <xsl:variable name="lev" select="$changes[1]/@level"/>
        <xsl:variable name="mark" select="concat('0', $changes[1]/@mark)"/>
        <!--                     select="level($changes[1])" -->
        <xsl:variable name="cur" select="$lev + ($lev * 999 + $mark) * ($lev &lt; 1000)"/>
        <xsl:choose>
            <xsl:when test="$changes">
                <xsl:call-template name="max-level">
                    <xsl:with-param name="changes" select="$changes[position() &gt; 1]"/>
                    <xsl:with-param name="max" select="$max + ($cur - $max) * ($cur &gt; $max)"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise><xsl:value-of select="$max"/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="isChangeBar">
            
            	<xsl:choose>
	    			<xsl:when test="@change='add' and not($no-change-markings)">
	    				<span>
	    					<xsl:attribute name="style">background:#99FF00</xsl:attribute>   
	    					<xsl:if test="@rfc">
	    						<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
	    					</xsl:if>
	    					<xsl:apply-templates/>
	    				</span>
	    			</xsl:when>
	    			<xsl:when test="@change='modify' and not($no-change-markings)">
	    				<span>
	    					<xsl:attribute name="style">background:#33FFFF</xsl:attribute> 
	    					<xsl:if test="@rfc">
	    						<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
	    					</xsl:if>
	    					<xsl:apply-templates/>
	    				</span>
	    			</xsl:when>
	    			<xsl:when test="@change='delete' and not($no-change-markings)">
	    				<span>
	    				<xsl:attribute name="style">background:#FF0000</xsl:attribute>
	    					<xsl:if test="@rfc">
	    						<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
	    					</xsl:if>
	    					DELETED
	    				</span>
	    		</xsl:when>
	    			<xsl:otherwise>
	    			<!--	<xsl:apply-templates/>-->
	    			</xsl:otherwise>
	    		</xsl:choose>

    </xsl:template>

    <xsl:template name="isChangeText">
        <xsl:param name="check-others" select="/.."/>
        <xsl:param name="checklist" select="false()"/>
        <xsl:param name="content">
            <xsl:apply-templates>
                <xsl:with-param name="checklist" select="$checklist"/>
            </xsl:apply-templates>
        </xsl:param>
        <xsl:choose>
            <xsl:when test="($check-others | .)/@change = 'delete'">Deleted</xsl:when>
            <xsl:otherwise><xsl:copy-of select="$content"/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="isChangedNCW">
        <xsl:call-template name="isChanged">
            <xsl:with-param name="check-ancestors" select="/.."/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="isChanged">
        <xsl:param name="check-others" select="/.."/>
        <xsl:param name="check-ancestors" select="ancestor::*"/>
        <xsl:param name="content"><xsl:apply-templates/></xsl:param>
        <xsl:variable name="max-level">
            <xsl:apply-templates select="ancestor::dmodule" mode="max-level"/>
        </xsl:variable>
        <xsl:choose>
            <!-- Change markup disabled -->
            <xsl:when test="$no-change-markings and @change = 'delete'"/>
            <xsl:when test="$no-change-markings"><xsl:copy-of select="$content"/></xsl:when>
            <!--      test="(self::table | self::figure) and descendant-or-self::*[@change and (@change = 'delete' or level(.) &gt;= $max-level)]" -->
            <xsl:when test="(self::table | self::figure) and descendant-or-self::*[@change and (@change = 'delete' or (@level + (@level * 999 + concat('0', @mark)) * (@level &lt; 1000)) &gt;= $max-level)]">
                <div>
                    <xsl:call-template name="isChangeBar">
                        <xsl:with-param name="check-others" select="$check-others"/>
                        <xsl:with-param name="check-ancestors" select="$check-ancestors"/>
                    </xsl:call-template>
                    <xsl:if test="@change = 'delete'"><p>Deleted</p></xsl:if>
                    <xsl:if test="not(@change = 'delete')"><xsl:copy-of select="$content"/></xsl:if>
                </div>
            </xsl:when>
            <!--      test="not(self::table | self::figure) and (self::*[@change] | self::*[not(self::mainfunc)]/descendant::change | $check-others[@change])[@change = 'delete' or level(.) &gt;= $max-level]" -->
            <xsl:when test="not(self::table | self::figure) and (self::*[@change] | self::*[not(self::mainfunc)]/descendant::change | $check-others[@change])[@change = 'delete' or (@level + (@level * 999 + concat('0', @mark)) * (@level &lt; 1000)) &gt;= $max-level]">
                <xsl:call-template name="isChangeBar">
                    <xsl:with-param name="check-others" select="$check-others"/>
                    <xsl:with-param name="check-ancestors" select="$check-ancestors"/>
                </xsl:call-template>
                <xsl:if test="@change = 'delete'">Deleted</xsl:if>
                <xsl:if test="not(@change = 'delete')"><xsl:copy-of select="$content"/></xsl:if>
            </xsl:when>
            <xsl:otherwise><xsl:copy-of select="$content"/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="change">
		<xsl:choose>
			<xsl:when test="@change='add' and not($no-change-markings)">
				<a class="add"   title="{@rfc}"><xsl:apply-templates/></a>
			</xsl:when>
			<xsl:when test="@change='modify' and not($no-change-markings)">
				<a class="modify"   title="{@rfc}"><xsl:apply-templates/></a>
			</xsl:when>
			<xsl:when test="@change='delete' and not($no-change-markings)">
				<a class="deleted"  title="{@rfc}"></a>
			</xsl:when>
		</xsl:choose>
    </xsl:template>

    <xsl:template match="*" mode="genid">
        <xsl:choose>
            <xsl:when test="string(@id)"><xsl:value-of select="@id"/></xsl:when>
            <xsl:otherwise>
                <xsl:text>ID</xsl:text>
                <xsl:number level="multiple" count="*" format="A-A"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template name="setid">
        <xsl:if test="@id">
            <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
            <a id="{@id}"/>
        </xsl:if>
    </xsl:template>
    
    
    <xsl:template match="*" mode="moved">
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="*" mode="xref">
        <span class="ERROR"><xsl:text>[unhandled xref to </xsl:text><xsl:value-of select="name(.)"/><xsl:text>]</xsl:text></span>
    </xsl:template>
    <!-- this is child applic? then it's term? 
        <xsl:template match="*" mode="xref">
        <xsl:apply-templates select="//applic[@id=$xrefid]/term" mode="xref"/>
        </xsl:template>
    -->
    
    
    <!-- 
        PURPOSE: Adds value = "TECHNAME - INFONAME" to output tree
        PROMISE: Only proceses one (1) dmtitle element
        (Only one (1) dmtitle element is allowed in idstatus)
        REQUIREMENTS: 
        Param: titleElement = "/dmodule/idstatus/dmaddress/dmtitle"
        USED BY: head/title, and dmaddress
    -->
    <xsl:template name="dmtitletext">
        <xsl:param name="titleElement"/>
        <xsl:apply-templates select="$titleElement/techname"/>
				<xsl:if test="normalize-space($titleElement/techname) and
				              normalize-space($titleElement/infoname)">
					<xsl:text>&#160;-&#160;</xsl:text>
				</xsl:if>
        <xsl:apply-templates select="$titleElement/infoname"/>
    </xsl:template>
    

<!-- ................................................... idstatus ................................................... -->
    

<!-- ................................................... dmaddress .................................................... -->
    
    
    <xsl:template match="dmaddres">
        <table border="0" cellspacing="2" cellpadding="4" width="100%">
            <tr>
                <td  valign="top" colspan="2" align="center">
                    <xsl:call-template name="dmmaintitle">
                        <xsl:with-param name="titleElement" select="dmtitle"/>
                    </xsl:call-template>
                </td>
            </tr>
            <xsl:apply-templates select="dmc" mode="moved"/>
            <xsl:call-template name="change-no"/>
            <xsl:apply-templates/>
        </table>
    </xsl:template>

    <xsl:template match="dmc"/>
        
    <xsl:template match="dmc" mode="moved">
        <tr>
            <td width="20%" valign="top">SSSN: </td>
            <td valign="top">
                <xsl:apply-templates/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="change-no">
        <xsl:variable name="changes" select="../following-sibling::content//*[@level]"/>
        <xsl:variable name="max-level">
            <xsl:apply-templates select="../following-sibling::content" mode="max-level"/>
        </xsl:variable>
        <!--                         select="$changes[level(.) &gt;= $max-level][1]" -->
        <xsl:variable name="highest" select="$changes[(@level + (@level * 999 + concat('0', @mark)) * (@level &lt; 1000)) &gt;= $max-level][1]"/>
        <xsl:if test="not($no-change-markings) and $highest">
            <xsl:variable name="level">
                <xsl:choose>
                    <xsl:when test="$highest/@level &gt;= 1000">
                        <xsl:value-of select="concat(floor($highest/@level div 1000), '.', $highest/@level mod 1000)"/>
                    </xsl:when>
                    <xsl:when test="$highest/@mark &gt; 0">
                        <xsl:value-of select="concat(number($highest/@level), '.', number($highest/@mark))"/>
                    </xsl:when>
                    <xsl:otherwise><xsl:value-of select="number($highest/@level)"/></xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <tr>
                <td width="20%" valign="top">CHANGE NO: </td>
                <td valign="top"><b>CHANGE <xsl:value-of select="$level"/></b></td>
            </tr>
        </xsl:if>
    </xsl:template>
    
    <!--
        PURPOSE: Adds value to output tree:
                "<center><h1>[value of dmtitle element]</h1></center>"
        PROMISE: Uses template named "dmtitletext" to produce "value of dmtitle element"
        REQUIREMENTS: 
            Param: titleElement = "/dmodule/idstatus/dmaddress/dmtitle"
    -->
    <xsl:template name="dmmaintitle">
        <xsl:param name="titleElement"/>
            <h1>
                <xsl:call-template name="dmtitletext">
                    <xsl:with-param name="titleElement" select="$titleElement"/>                        
                </xsl:call-template>
            </h1>
    </xsl:template>
    
    <xsl:template match="refdm/applic"/>
    <xsl:template match="refdm/applic" mode="xref"/>
    <xsl:template match="refdm/applic" mode="xreftarget"/>

    <xsl:template match="avee" mode="xreftarget">
        <xsl:text>DMC-</xsl:text>
        <xsl:value-of select="normalize-space(modelic)"/><xsl:text>-</xsl:text>
        <xsl:value-of select="normalize-space(sdc)"/><xsl:text>-</xsl:text>
        <xsl:value-of select="normalize-space(chapnum)"/><xsl:text>-</xsl:text>
        <xsl:value-of select="normalize-space(section)"/>
        <xsl:value-of select="normalize-space(subsect)"/><xsl:text>-</xsl:text>
        <xsl:value-of select="normalize-space(subject)"/><xsl:text>-</xsl:text>
        <xsl:value-of select="normalize-space(discode)"/>
        <xsl:value-of select="normalize-space(discodev)"/><xsl:text>-</xsl:text>
        <xsl:value-of select="normalize-space(incode)"/>
        <xsl:value-of select="normalize-space(incodev)"/><xsl:text>-</xsl:text>
        <xsl:value-of select="normalize-space(itemloc)"/>
    </xsl:template>
    
    <xsl:template match="avee">
        <xsl:apply-templates select="sdc"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="chapnum"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="section"/>
        <xsl:apply-templates select="subsect"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="subject"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="discode" mode="display"/>
        <xsl:apply-templates select="discodev"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="incode"/>
    </xsl:template>
    
    <xsl:template match="avee/discode" mode="display">
        <xsl:apply-templates/>
    </xsl:template>
    
   <!-- 
        XREF = visible portion; Want it to show only SNS + INFO 
        SNS:  Section + Subsection
        Info: incode + incodev
    -->
<!--  May 20, 2011 Changed xref linking to reflect same as others. Max 
    
    <xsl:template match="avee" mode="xref">
        <xsl:apply-templates select="section"/>
        <xsl:apply-templates select="subsect"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="incode"/>
        <xsl:apply-templates select="incodev"/>
        </xsl:template>-->
    
    <xsl:template match="avee" mode="xref">
        <xsl:apply-templates select="sdc"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="chapnum"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="section"/>
        <xsl:apply-templates select="subsect"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="subject"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="discode" mode="display"/>
        <xsl:apply-templates select="discodev"/><xsl:text>-</xsl:text>
        <xsl:apply-templates select="incode"/>
    </xsl:template>
    
    <xsl:template match="refdm">
        <xsl:variable name="cust" select="applic/model/customer"/>
        <xsl:variable name="filter" select="not($cust) or $cust = $customer"/>
        <xsl:if test="string-length(descendant::chapnum) &gt; 0 and $filter and not($no-change-markings and @change = 'delete')">
            <span>
                <xsl:call-template name="isChangeBar"/>
                <xsl:text>&#160;</xsl:text>
                <xsl:choose>
                    <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                    <xsl:otherwise>
                        <a href="R4I_CANCEL">
                            <xsl:attribute name="onclick">
                                <xsl:text>ShowDoc('</xsl:text><xsl:apply-templates mode="xreftarget"/><xsl:text>')</xsl:text>
                            </xsl:attribute>
                            <xsl:choose>
                                <xsl:when test="ancestor::prelreqs">
                                    <xsl:apply-templates mode="xref"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:apply-templates/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </a>        
                    </xsl:otherwise>
                </xsl:choose>
            </span>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="refdm" mode="listitem">
        <xsl:variable name="cust" select="applic/model/customer"/>
        <xsl:variable name="filter" select="not($cust) or $cust = $customer"/>
        <xsl:if test="string-length(descendant::chapnum) &gt; 0 and $filter and not($no-change-markings and @change = 'delete')">
            <li>
                <xsl:call-template name="isChangeBar"/>
                <xsl:choose>
                    <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                    <xsl:otherwise>
                        <a href="R4I_CANCEL">
                            <xsl:attribute name="onclick">
                                <xsl:text>ShowDoc('</xsl:text>
                                <xsl:apply-templates mode="xreftarget"/><xsl:text>')</xsl:text>
                            </xsl:attribute>
                            <xsl:apply-templates select="preceding-sibling::reqcond[1]"/>
                        </a>
                    </xsl:otherwise>
                </xsl:choose>
            </li>
        </xsl:if>
    </xsl:template>
    
    
    <xsl:template match="age" mode="xref">
        <a><xsl:attribute name="href">
            <xsl:text>http://</xsl:text>
            <xsl:value-of select="$paramPath"/>
            <xsl:text>r4iv_view.asp?fn=DMC-</xsl:text>
            <xsl:apply-templates select="modelic"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="supeqvc"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="ecscs"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="eidc"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="cidc"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="discode"/>
            <xsl:apply-templates select="discodev"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="incode"/>
            <xsl:apply-templates select="incodev"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="itemloc"/>
        </xsl:attribute>
            <xsl:apply-templates select="modelic"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="supeqvc"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="ecscs"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="eidc"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="cidc"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="discode"/>
            <xsl:apply-templates select="discodev"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="incode"/>
            <xsl:apply-templates select="incodev"/><xsl:text>-</xsl:text>
            <xsl:apply-templates select="itemloc"/>
        </a>
    </xsl:template>
    
    <xsl:template match="language">
        <tr>
            <td  valign="top" colspan="2">
                <p>Language: 
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:apply-templates select="@language"/>-<xsl:apply-templates select="@country"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    

    <!-- ................................................... status ................................................... -->
    
    
    <xsl:template match="status">
        <div id="Section_1">
            <span name="FullProcedure">
                <table border="0" cellspacing="2" cellpadding="4" width="100%">
                    <tr>
                        <td  valign="top" colspan="2" align="center">
                            <h2>Status</h2>
                        </td>
                    </tr>
                    <xsl:apply-templates/>
                </table>
            </span>
        </div>
    </xsl:template>
    
    <xsl:template match="security">
        <tr>
            <td width="20%" valign="top">SECURITY CLASSIFICATION: </td>
            <td valign="top">
                <xsl:choose>
                    <xsl:when test="number(./@class)=1">UNCLASSIFIED</xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="@class"/>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="distrib"/>
    <xsl:template match="expcont"/>
    <xsl:template match="handling"/>
    <xsl:template match="destruct"/>
    <xsl:template match="disclose"/>
    
    <xsl:template match="datacond">
        <xsl:for-each select="@*">
            <tr>
                <td  valign="top" colspan="2">
                    <p><xsl:value-of select="name(.)"/>:
                        <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                        <xsl:value-of select="string(.)"/>
                    </p>
                </td>
            </tr>
        </xsl:for-each>
    </xsl:template>


	<!-- .......................................... 
		remove header from applic table in descript Doctype only for CBP. 
		applic-header mode CBP in all top-level files; when not special, they revert to normal
		10/8/11 Ticket #268
	     .................................... -->
	    <xsl:template match="applic" mode="applic-header">
		    <xsl:choose>
		        <xsl:when test="$customer = 'CBP'">
		            <xsl:apply-templates select="." mode="applic-header-cbp"/>
			    </xsl:when>
		        <xsl:otherwise>
		            <xsl:apply-templates select="." mode="applic-header-normal"/>
		       </xsl:otherwise>
		    </xsl:choose>
	    </xsl:template>

    <xsl:template match="applic" mode="applic-header-normal">
        <tr>
            <td  valign="top" colspan="2" align="center">
                <h2>Input Conditions</h2>
            </td>
        </tr>
    </xsl:template>
    

    <xsl:template match="applic">
        <xsl:if test="ancestor::idstatus">

            <!-- header extracted per Ticket #268 -->
            <xsl:apply-templates select="." mode="applic-header"/>

            <xsl:choose>
                <xsl:when test="count(child::type)>0">
                    <tr>
                        <td  valign="top" colspan="2">
                            <p>APPLICABILTY:
                                <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                                <xsl:apply-templates/>
                            </p>
                        </td>
                    </tr>
                </xsl:when>
                <xsl:otherwise>
                    <tr>
                        <td  valign="top" colspan="2">
                            <p>APPLICABILITY:</p>
                            <ul>
                                <xsl:apply-templates/>
                            </ul>
                        </td>
                    </tr>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>
    
    <!-- Applic can appear anywhere, show it after titling... -->
    <xsl:template match="applic" mode="moved">
        <xsl:if test="ancestor::idstatus">
            <tr>
                <td  valign="top" colspan="2">
                    <p>Applicability:
                        <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                        <xsl:apply-templates/>
                    </p>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>
        
    <xsl:template match="qa[unverif]">
        <tr>
            <td width="20%" valign="top">Quality Assurance Status:</td>
            <td valign="top" style="font-weight:bold; color:red;">
                <xsl:text>THIS PROCEDURE IS UNVERIFIED</xsl:text>
            </td>
        </tr>
    </xsl:template>
        
		<!--- drv changes should probably sort the version information before output -->
    <xsl:template match="model">
        <xsl:choose>
            <xsl:when test="ancestor::idstatus">
                <li>
                    <p>
					<xsl:apply-templates/>
                    </p>
                </li>    
            </xsl:when>
            <xsl:otherwise>
                <tr>
                    <td  valign="top" colspan="2">
                        <p>Model:
                            <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                            <xsl:value-of select="string(@model)"/>
                        </p>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>
    
	<!-- drv changes
    <xsl:template match="version">
        <tr>
            <td  valign="top" colspan="2">
                <p>Version:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(@version)"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    -->

   <xsl:template match="version[1]">
   		<xsl:text>&#160;</xsl:text>
                    <xsl:value-of select="string(@version)"/>
					<xsl:apply-templates/>
  </xsl:template>

   <xsl:template match="version">
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="string(@version)"/>
					<xsl:apply-templates/>
      </xsl:template>
    
    <xsl:template match="csnref">
        <tr>
            <td  valign="top" colspan="2">
                <p>CSNREF:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(@refcsn)"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="nsn">
        <tr>
            <td  valign="top" colspan="2">
                <p>NATO Stock Number:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(.)"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="mfc">
        <xsl:choose>
            <xsl:when test="ancestor::idstatus">
                <tr>
                    <td  valign="top" colspan="2">
                        <p>Manufacturer:
                            <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                            <xsl:value-of select="string(.)"/>
                        </p>
                    </td>
                </tr>
            </xsl:when>
            <xsl:when test="ancestor::supequi"/>
            <xsl:when test="ancestor::csn">
                <td align="right" class="ipb" nowrap="true">
                    <xsl:choose>
                        <xsl:when test="string-length() > 0">
                            <xsl:apply-templates/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>&#160;&#160;&#160;</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
            </xsl:when>
            <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="pnr">
        <xsl:choose>
            <xsl:when test="$no-change-markings and @change = 'delete'"/>
            <xsl:when test="ancestor::idstatus">
                <tr>
                    <td  valign="top" colspan="2">
                        <xsl:call-template name="isChangeBar"/>
                        <xsl:choose>
                            <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                            <xsl:otherwise>
                                <p>Part Number:
                                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                                    <xsl:value-of select="string(.)"/>
                                </p>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                </tr>
            </xsl:when>
            <xsl:when test="ancestor::supequi | ancestor::supply">
                <td>
                    <xsl:call-template name="isChangeBar"/>
                    <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                    <xsl:choose>
                        <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                        <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
                    </xsl:choose>
                </td>
            </xsl:when>
            <xsl:when test="ancestor::csn">
                <td align="left" class="ipb" nowrap="true">
                    <xsl:variable name="ThisID" select="parent::isn/@id"/>
                    <xsl:variable name="HotspotID">
                        <xsl:value-of select="//hotspot[xref/@xrefid=$ThisID]/@id"/>
                    </xsl:variable>
                    <xsl:call-template name="isChangeBar"/>
                    <xsl:choose>
                        <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                        <xsl:otherwise>
                            <a style="hotspot" href="R4I_CANCEL" onmousedown="window.external.HSMouseDown('{$HotspotID}')" onmouseup="window.external.HSMouseUp()">
                                <xsl:choose>
                                    <xsl:when test="string-length() > 0">
                                        <xsl:apply-templates/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:text>&#160;&#160;&#160;</xsl:text>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </a>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
            </xsl:when>
            <xsl:otherwise>
                <span>
                    <xsl:call-template name="isChangeBar"/>
                    <xsl:choose>
                        <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                        <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
                    </xsl:choose>
                </span>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="uce">
    	<xsl:choose>
    		<xsl:when test="ancestor::csn">
            <td align="center" class="ipb" nowrap="true">
                    <xsl:choose>
                        <xsl:when test="string-length() > 0">
                            <xsl:apply-templates/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>&#160;&#160;&#160;</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
            </td>    		
    		</xsl:when>
    		<xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
    	</xsl:choose>
    </xsl:template>
   
       <xsl:template match="smr">
    	<xsl:choose>
    		<xsl:when test="ancestor::csn">
            <td align="center" class="ipb" nowrap="true">
                    <xsl:choose>
                        <xsl:when test="string-length() > 0">
                            <xsl:apply-templates/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>&#160;&#160;&#160;</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
            </td>    		
    		</xsl:when>
    		<xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
    	</xsl:choose>
    </xsl:template>
    
    <xsl:template match="qna">
        <xsl:choose>
            <xsl:when test="ancestor::csn">
            <td align="center" class="ipb" nowrap="true">
                    <xsl:choose>
                        <xsl:when test="string-length() > 0">
                            <xsl:apply-templates/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>&#160;&#160;&#160;</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
            </td>
            </xsl:when>
            <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>

		<xsl:template name="for.loop">
			<xsl:param name="i" />
			<xsl:param name="count" />
			<xsl:if test="$i &lt;= $count">
				<xsl:text>&#183;&#160;</xsl:text>
			</xsl:if>
	
			<xsl:if test="$i &lt;= $count">
				<xsl:call-template name="for.loop">
					<xsl:with-param name="i">
						<xsl:value-of select="$i + 1" />
					</xsl:with-param>
					<xsl:with-param name="count">
						<xsl:value-of select="$count" />
					</xsl:with-param>
				</xsl:call-template>
			</xsl:if>
		</xsl:template>

		<xsl:template match="dfp">
			<xsl:choose>
				<xsl:when test="ancestor::csn">
					<td class="ipb" nowrap="true">
						<xsl:call-template name="for.loop">
							<xsl:with-param name="i">1</xsl:with-param>
							<xsl:with-param name="count"><xsl:value-of select="ancestor::csn/@ind" /></xsl:with-param>
						</xsl:call-template>
						<xsl:apply-templates />
					</td>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates />
					</xsl:otherwise>
				</xsl:choose>
			</xsl:template>
    
    <xsl:template match="serialno">
        <tr>
            <td  valign="top" colspan="2">
                <p>Serial Number:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(.)"/>
                </p>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="batchno">
        <tr>
            <td  valign="top" colspan="2">
                <p>Batch Number:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(.)"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="moduleno">
        <tr>
            <td  valign="top" colspan="2">
                <p>Engine Module Number:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(.)"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="customer">
        <tr>
            <td  valign="top" colspan="2">
                <p>Customer:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(.)"/>
                </p>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="softprog">
        <tr>
            <td  valign="top" colspan="2">
                <p>Software Program Edition:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(.)"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="mntlvl" mode="moved">
        <li><xsl:value-of select="@mntlvl"/></li>
    </xsl:template>
    
    <xsl:template match="mntlvl">
        <xsl:choose>
            <!--  Repeatable, 2nd+ instance -->
            <xsl:when test="count(preceding-sibling::mntlvl)>0"/>
            
            <!-- Repeatable, 1st instance -->
            <xsl:otherwise>
                <tr>
                    <td  valign="top" colspan="2">
                        <p>Maintenance Level:</p>
                        <ul>
                            <li><xsl:value-of select="@mntlvl"/></li>
                            <xsl:for-each select="following-sibling::mntlvl">
                                <xsl:apply-templates select="." mode="moved"/>
                            </xsl:for-each>
                        </ul>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="sb">
        <tr>
            <td  valign="top" colspan="2">
                <p>Service Bulletin:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="string(.)"/>
                </p>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="mod">
        <xsl:choose>
            <xsl:when test="count(child::modtitle)>0">
                <dl>
                    <dt><xsl:value-of select="modtitle"/></dt>
                    <xsl:if test="@authno"><dd>Retrofit Order Number: <xsl:apply-templates select="authno"/></dd></xsl:if>
                    <xsl:if test="@modtype='pre'"><dd>Pre-modification</dd></xsl:if>
                    <xsl:if test="@modtype='post'"><dd>Post modification</dd></xsl:if>
                    <xsl:if test="@modtype='prandpo'"><dd>Pre and Post modifications</dd></xsl:if>
                </dl>
            </xsl:when>
            <xsl:otherwise>
                <dl>
                    <dt>Modification</dt>
                    <xsl:if test="@authno"><dd>Retrofit Order Number: <xsl:apply-templates select="authno"/></dd></xsl:if>
                    <xsl:if test="@modtype='pre'"><dd>Pre-modification</dd></xsl:if>
                    <xsl:if test="@modtype='post'"><dd>Post modification</dd></xsl:if>
                    <xsl:if test="@modtype='prandpo'"><dd>Pre and Post modifications</dd></xsl:if>
                </dl>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    
<!-- ................................................... raw elements ................................................... -->


    <xsl:template match="range">
        <xsl:apply-templates select="@from"/> - <xsl:apply-templates select="@to"/>
    </xsl:template>
    
    
    <xsl:template match="single">
        <xsl:apply-templates/>
    </xsl:template>
    
    
<!-- ................................................... content ................................................... -->
    
    
    <xsl:template match="descript">
        <table border="0" cellspacing="2" cellpadding="4" width="100%">
            <tr>
                <td  valign="top" align="center"><h2>Descriptive Information</h2></td>
            </tr>
            <!-- Rest of content appears inside the single TD, no more rows required at the top level -->
            <tr>
                <td  valign="top"><xsl:apply-templates/></td>
            </tr>
        </table>
    </xsl:template>
    
    <xsl:template match="afi">
        <table border="0" cellspacing="2" cellpadding="4" width="100%">
            <tr>
                <td  valign="top" align="center" colspan="2"><h2>Faults</h2></td>
            </tr>
            <tr>
                <td valign="top" colspan="2"><h3>All Fault Isolation</h3></td>
            </tr>
            <xsl:apply-templates select="fault" mode="moved"/>
            <xsl:apply-templates select="describe" mode="moved"/>
        </table>
        <table border="0" cellspacing="2" cellpadding="4" width="100%">
            <!-- Rest of content appears inside the single TD, no more rows required at the top level -->
            <tr>
                <td  valign="top"><xsl:apply-templates/></td>
            </tr>
        </table>
    </xsl:template>
    
    <xsl:template match="ipc">
        <table border="0" width="100%">
            <tr>
                <td  valign="top"><xsl:apply-templates select="child::figure" mode="moved"/></td>
            </tr>
            <!-- Rest of content appears as rows in a table in the single TD -->
            <tr>
                <td  valign="top">
                    <table border="0" cellspacing="0" cellpadding="5" width="100%">
                        <colgroup>
                            <col width="0*"/>    
                            <col width="0*"/>    
                            <col width="0*"/>    
                            <col width="100%"/>    
                            <col width="0*"/> 
                            <col width="0*"/>
                            <col width="0*"/>
                        </colgroup>
                        <xsl:apply-templates/>
                        <tr>
                            <td class="ipb">&#160;</td>
                            <td class="ipb">&#160;</td>
                            <td class="ipb">&#160;</td>
                            <td class="ipb" align="center">
                                <table border="0" cellspacing="0" cellpadding="5">
                                    <tr>
                                        <td><u>CODE</u></td>
                                        <td><u>USABLE ON</u></td>
                                    </tr>
                                    <tr>
                                        <td>Blank</td>
                                        <td>All</td>
                                    </tr>
                                    <xsl:for-each select="descendant::uce[not(translate(normalize-space(.), concat($letters, '0123456789'), ''))][not(. = ancestor::csn/preceding-sibling::csn//uce)]">
                                        <tr>
                                            <td><xsl:apply-templates/></td>
                                            <td>
                                                <xsl:call-template name="usable-on"/>
                                            </td>
                                        </tr>
                                    </xsl:for-each>
                                </table>
                            </td>
                            <td class="ipb">&#160;</td>
                            <td class="ipb">&#160;</td>
                            <td class="ipb">&#160;</td>
                        </tr>
                        <tr>
                            <td align="center" colspan="5">
                                <xsl:text>&#160;</xsl:text>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </xsl:template>
    
    <xsl:template name="usable-on">
        <xsl:param name="icy-list" select="ancestor::ipc//ccs[uce = current()]/icy[normalize-space(.)]"/>
        <xsl:param name="sep" select="''"/>
        <xsl:if test="$icy-list">
            <xsl:value-of select="$sep"/>
            <xsl:apply-templates select="$icy-list[1]"/>
            <xsl:call-template name="usable-on">
                <xsl:with-param name="icy-list" select="$icy-list[position() &gt; 1]"/>
                <xsl:with-param name="sep" select="substring(' and , ', 1 + 5 * (count($icy-list) &gt; 2), 5)"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    
    
<!-- .............................................. references .............................................. -->

    <xsl:template match="refs">
        <table border="0" cellspacing="2" cellpadding="4" width="100%">
            <tr>
                <td  valign="top" align="center"><h2>References</h2></td>
            </tr>
            <tr>
                <td  valign="top">
                    <xsl:apply-templates mode="refs"/>
                    <hr size="1" />
                </td>
            </tr>
        </table>
    </xsl:template>
    
    <xsl:template match="refdm" mode="refs">
            <div>
                <xsl:call-template name="changed-element"/>
                <xsl:text>&#160;</xsl:text>
                <xsl:choose>
                    <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                    <xsl:otherwise>
                        <a href="R4I_CANCEL">
                            <xsl:attribute name="onclick">
                                <xsl:text>ShowDoc('</xsl:text><xsl:apply-templates mode="xreftarget"/><xsl:text>')</xsl:text>
                            </xsl:attribute>
                            <xsl:choose>
                                <xsl:when test="ancestor::prelreqs">
                                    <xsl:apply-templates mode="xref"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:apply-templates/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </a>        
                    </xsl:otherwise>
                </xsl:choose>
            </div>
    </xsl:template>
<!-- ................................................... inlines ................................................... -->

    <!-- TO BE FILLED IN -->
    <!--
        WHAT FUNCTION SHOULD BE CALLED TO R4I_CANCEL to display table?
        
        <xsl:if test="count(//acronym)>0">
        window.external.CustomButton("DocumentState", "Acronym", "ShowAcronym", "True");
        </xsl:if>
    -->
    <xsl:template name="acronymTableButton"/>
    
    
    <xsl:template match="acronym">
        <!-- 12/9/08: Move to acroterm/xrefid only
        <label>
            <xsl:attribute name="onclick">
                <xsl:text>window.external.AcronymHover('</xsl:text>
                <xsl:apply-templates select="acroterm"/>
                <xsl:text>', '</xsl:text>
                <xsl:apply-templates select="acrodef"/>
                <xsl:text>')</xsl:text>
            </xsl:attribute>
        -->
            <!-- 12/05/08 : want hover behavior on click
            <xsl:attribute name="onclick">
                <xsl:text>window.external.AcronymClick('</xsl:text>
                <xsl:apply-templates select="acroterm"/>
                <xsl:text>', '</xsl:text>
                <xsl:apply-templates select="acrodef"/>
                <xsl:text>')</xsl:text>
            </xsl:attribute>
            <xsl:attribute name="onmouseover">
                <xsl:text>window.external.AcronymHover('</xsl:text>
                <xsl:apply-templates select="acroterm"/>
                <xsl:text>', '</xsl:text>
                <xsl:apply-templates select="acrodef"/>
                <xsl:text>')</xsl:text>
            </xsl:attribute>
            -->
            <xsl:apply-templates select="acrodef"/>
            <xsl:text> (</xsl:text>
            <xsl:apply-templates select="acroterm"/>
            <xsl:text>)</xsl:text>
        <!-- 12/9/08: Move to acroterm/xrefid only
        </label>
        -->
    </xsl:template>
    
    <xsl:template match="acronym" mode="xref">
        <label>
            <xsl:attribute name="onclick">
                <xsl:text>window.external.AcronymHover('</xsl:text>
                <xsl:value-of select="normalize-space(acroterm)"/>
                <xsl:text>', '</xsl:text>
                <xsl:value-of select="normalize-space(acrodef)"/>
                <xsl:text>')</xsl:text>
            </xsl:attribute>
            <!-- 12/05/08 : want hover behavior on click
                <xsl:attribute name="onclick">
                <xsl:text>window.external.AcronymClick('</xsl:text>
                <xsl:apply-templates select="acroterm"/>
                <xsl:text>', '</xsl:text>
                <xsl:apply-templates select="acrodef"/>
                <xsl:text>')</xsl:text>
                </xsl:attribute>
                <xsl:attribute name="onmouseover">
                <xsl:text>window.external.AcronymHover('</xsl:text>
                <xsl:apply-templates select="acroterm"/>
                <xsl:text>', '</xsl:text>
                <xsl:apply-templates select="acrodef"/>
                <xsl:text>')</xsl:text>
                </xsl:attribute>
            -->
            <xsl:apply-templates select="acroterm"/>
        </label>
        <!--
        <xsl:apply-templates select="acroterm"/>
        -->
    </xsl:template>

    <xsl:template match="acroterm">
        <xsl:choose>
            <xsl:when test="count(parent::acronym)=0">
                <xsl:variable name="Xref" select="@xrefid"/>
                <xsl:variable name="target" select="//acronym[@id=$Xref]"/>
                <xsl:apply-templates select="$target" mode="xref"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="deflist">
        <xsl:if test="count(child::title)>0">
            <h4><xsl:apply-templates select="title" mode="moved"/></h4>
        </xsl:if>
        <table width="100%">
            <xsl:if test="@caveat='cv65'">
                <xsl:attribute name="cellpadding">2mm</xsl:attribute>
                <thead>
                    <tr><td valign="middle" align="right">Term</td><td valign="top" align="center">&#160;&#160;</td><td valign="middle" align="center">Definition</td></tr>
                </thead>
            </xsl:if>
            <xsl:apply-templates/>
        </table>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    
    <xsl:template match="term">
        <tr valign="top" align="right" width="25%">
            <td valign="top">
                <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                <b><xsl:apply-templates/></b><td valign="top" align="center">&#160;-&#160;</td>
            </td>
            <td valign="bottom">
                <xsl:for-each select="following-sibling::*[1][self::def]">
                    <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                    <xsl:apply-templates/>
                </xsl:for-each>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="term" mode="xref">
        <xsl:variable name="id" select="parent::applic/@id"/>
        <a class="BoxHeading" href="#$id"><xsl:apply-templates/></a>
    </xsl:template>
    
    <xsl:template match="def"/>
    
    <!-- 
        EM01 = Bold
        EM02 - Underline
        EM03 - Italics
        EM04 - Bold + Underline
				EM60 - Fill-in field
        NONE - Default to Bold
    -->
    <xsl:template match="emphasis[@emph='EM01']">
        <b><xsl:apply-templates/></b>
    </xsl:template>
    <xsl:template match="emphasis[@emph='EM02']">
        <u><xsl:apply-templates/></u>
    </xsl:template>
    <xsl:template match="emphasis[@emph='EM03']">
        <i><xsl:apply-templates/></i>
    </xsl:template>
    <xsl:template match="emphasis[@emph='EM04']">
        <b><u><xsl:apply-templates/></u></b>
    </xsl:template>
    <xsl:template match="emphasis[@emph='em60']">
        <input type="text" name="textfield" style="width:2in;"/>
    </xsl:template>
    <xsl:template match="emphasis">
        <b><xsl:apply-templates/></b>
    </xsl:template>
    
    <xsl:template match="ftnref">
        <xsl:variable name="Xref" select="@xrefid"/>
        <xsl:variable name="target" select="//*[@id=$Xref]"/>
        <xsl:apply-templates select="$target" mode="xref"/>
    </xsl:template>
    
    <xsl:template match="table//ftnote">
        <xsl:apply-templates select="." mode="xref"/>
    </xsl:template>
    
    <xsl:template match="table//ftnote" mode="xref">
        <xsl:variable name="num">
            <sup><xsl:apply-templates select="." mode="number"/></sup>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="@id"><a href="#{@id}"><xsl:copy-of select="$num"/></a></xsl:when>
            <xsl:otherwise><xsl:copy-of select="$num"/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:variable name="local-footnote-max-num">
        <xsl:for-each select="//table">
            <xsl:sort select="count(.//ftnote[not(@caveat='cv55')][not(@ftnmark) or @ftnmark='num'])"/>
            <xsl:if test="position() = last()"><xsl:value-of select="count(.//ftnote[not(@caveat='cv55')][not(@ftnmark) or @ftnmark='num'])"/></xsl:if>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="local-footnote-max-alpha">
        <xsl:for-each select="//table">
            <xsl:sort select="count(.//ftnote[not(@caveat='cv55')][@ftnmark='alpha'])"/>
            <xsl:if test="position() = last()"><xsl:value-of select="count(.//ftnote[not(@caveat='cv55')][@ftnmark='alpha'])"/></xsl:if>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="local-footnote-max-sym">
        <xsl:for-each select="//table">
            <xsl:sort select="count(.//ftnote[not(@caveat='cv55')][@ftnmark='sym'])"/>
            <xsl:if test="position() = last()"><xsl:value-of select="count(.//ftnote[not(@caveat='cv55')][@ftnmark='sym'])"/></xsl:if>
        </xsl:for-each>
    </xsl:variable>

    <xsl:template match="table//ftnote[not(@caveat='cv55')][not(@ftnmark) or @ftnmark='num']" mode="number">
        <xsl:number count="ftnote[not(@caveat='cv55')][not(@ftnmark) or @ftnmark='num']" from="table" level="any" format="1"/>
    </xsl:template>

    <xsl:template match="table//ftnote[not(@caveat='cv55')][@ftnmark='alpha']" mode="number">
        <xsl:number count="ftnote[not(@caveat='cv55')][@ftnmark='alpha']" from="table" level="any" format="a"/>
    </xsl:template>

    <xsl:template match="table//ftnote[not(@caveat='cv55')][@ftnmark='sym']" mode="number">
        <xsl:variable name="tid" select="generate-id(current()/ancestor::table)"/>
        <xsl:variable name="sym-fns" select="preceding::ftnote[not(@caveat='cv55')][@ftnmark = 'sym']"/>
        <xsl:call-template name="ftnote-sym">
            <xsl:with-param name="num" select="count($sym-fns[generate-id(ancestor::table) = $tid])"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template match="ftnote[not(ancestor::table) or @caveat='cv55'][not(@ftnmark) or @ftnmark='num']" mode="number">
        <xsl:number value="$local-footnote-max-num + 1 + count(preceding::ftnote[not(ancestor::table) or @caveat='cv55'][not(@ftnmark) or @ftnmark='num'])" format="1"/>
    </xsl:template>

    <xsl:template match="ftnote[not(ancestor::table) or @caveat='cv55'][@ftnmark='alpha']" mode="number">
        <xsl:number value="$local-footnote-max-alpha + 1 + count(preceding::ftnote[not(ancestor::table) or @caveat='cv55'][@ftnmark='alpha'])" format="1"/>
    </xsl:template>

    <xsl:template match="ftnote[not(ancestor::table) or @caveat='cv55'][@ftnmark='sym']" mode="number" name="ftnote-sym">
        <xsl:param name="num" select="$local-footnote-max-sym + count(preceding::ftnote[not(ancestor::table) or @caveat='cv55'][@ftnmark = 'sym'])"/>
        <xsl:call-template name="copy-string">
            <xsl:with-param name="string">
                <xsl:choose>
                    <xsl:when test="$num mod 4 = 0">*</xsl:when>
                    <xsl:when test="$num mod 4 = 1">&#xA7;</xsl:when>
                    <xsl:when test="$num mod 4 = 2">&#x2020;</xsl:when>
                    <xsl:when test="$num mod 4 = 3">&#x2021;</xsl:when>
                </xsl:choose>
            </xsl:with-param>
            <xsl:with-param name="count" select="floor($num div 4) + 1"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template match="legend">
        <table width="100%">
            <tr>
                <td  valign="top" width="40%"><h1>Legend:</h1></td>
                <td  valign="top" align="left"><xsl:apply-templates/></td>
            </tr>
        </table>
    </xsl:template>    
    
    <xsl:template match="randlist">
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <ul type="square"><xsl:call-template name="isChangeBar"/>
                <xsl:choose>
                    <xsl:when test="@change = 'delete'"><li>Deleted</li></xsl:when>
                    <xsl:otherwise><xsl:apply-templates/></xsl:otherwise></xsl:choose></ul>
        </xsl:if>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    
    <xsl:template match="item">
        <xsl:variable name="cbp-seq-item" select="parent::seqlist and $customer = 'CBP'"/>
        <xsl:if test="not(($no-change-markings or $cbp-seq-item) and @change = 'delete')">
            <li>
                <xsl:if test="ancestor-or-self::*/@caveat='cv62'">
                    <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                </xsl:if>
                <!--<xsl:call-template name="isChangeBar"/>-->
                <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                <xsl:call-template name="isChangeText"/>
            </li>
        </xsl:if>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    
    <xsl:template match="reftp">
        <table width="100%">
            <tr>
                <td  valign="top" width="50%">Reference Technical Publications</td>
                <td  valign="top" width="50%"><xsl:apply-templates /></td>
            </tr>
        </table>
    </xsl:template>
    
    <xsl:template match="seqlist">
        <xsl:if test="title and not(@change = 'delete')">
            <h4><xsl:call-template name="isChangeBar"/>
                <xsl:apply-templates select="title" mode="moved"/></h4>
        </xsl:if>
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <ol>
                <xsl:attribute name="class">
                    <xsl:choose>
                        <xsl:when test="count(ancestor::seqlist)>3">l4</xsl:when>
                        <xsl:when test="count(ancestor::seqlist)>2">l3</xsl:when>
                        <xsl:when test="count(ancestor::seqlist)>1">l2</xsl:when>
                        <xsl:otherwise>l1</xsl:otherwise>
                    </xsl:choose>
                </xsl:attribute>
                <xsl:if test="not(title)"><xsl:call-template name="isChangeBar"/></xsl:if>
                <xsl:choose>
                    <xsl:when test="@change = 'delete'"><li>Deleted</li></xsl:when>
                    <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
                </xsl:choose>
            </ol>
        </xsl:if>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    
    <xsl:template match="seqlist/title"/>
    
    <xsl:template match="supscrpt">
        <sup><xsl:apply-templates/></sup>
    </xsl:template>
    
    <xsl:template match="subscrpt">
        <sub><xsl:apply-templates/></sub>
    </xsl:template>
    
    <xsl:template name="symbolalt">
        <xsl:param name="string"/>
        <xsl:choose>
            <xsl:when test="contains($string, '/')">
                <xsl:call-template name="symbolalt">
                    <xsl:with-param name="string" select="substring-after($string,'/')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="contains($string, '\')">
                <xsl:call-template name="symbolalt">
                    <xsl:with-param name="string" select="substring-after($string,'\')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="contains($string, '.jpg')">
                <xsl:call-template name="symbolalt">
                    <xsl:with-param name="string" select="substring-before($string,'.jpg')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise><xsl:value-of select="$string"/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="symbol">
        <xsl:choose>
            <xsl:when test="@fileref">
                <img id="symbol" name="symbol" src="{@fileref}">
                    <xsl:attribute name="alt">
                        <xsl:call-template name="symbolalt">
                            <xsl:with-param name="string" select="substring-before(string(@fileref),'.jpg')"/>
                        </xsl:call-template>
                    </xsl:attribute>
                </img>
                <xsl:call-template name="ncw-relocation"/>
            </xsl:when>
            <xsl:when test="@boardno">
                <img id="symbol" name="symbol" src="{@boardno}">
                    <xsl:attribute name="alt">
                        <xsl:call-template name="symbolalt">
                            <xsl:with-param name="string" select="string(@boardno)"/>
                        </xsl:call-template>
                    </xsl:attribute>
                </img>
                <xsl:call-template name="ncw-relocation"/>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="xref">
        <xsl:param name="checklist" select="false()"/>
        <xsl:variable name="Xref" select="@xrefid"/>
        <xsl:variable name="target" select="//*[@id=$Xref]"/>
        <xsl:choose>
            <!-- never test against the empty string; count to see if there were no matches. (figures don't have text nodes) -->
            <xsl:when test="count($target)=0">
                <xsl:apply-templates/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="$target" mode="xref">
                    <xsl:with-param name="xref" select="."/>
                    <xsl:with-param name="checklist" select="$checklist"/>
                </xsl:apply-templates>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template> 


<!-- ....................................... notes, cautions, and warnings ........................................ -->
    

    <xsl:template match="warning | caution | note">
        <xsl:if test="not(@xrefid)">
			 <div alert_type="{@alert_type}">
				<!--<xsl:call-template name="ncw"/>-->
				<!--<xsl:apply-templates/>-->
				<xsl:apply-templates select="." mode="moved"/>
            </div>
			      <span id="end_of_alert"/>
        </xsl:if>
    </xsl:template>


	<xsl:template match="warning | caution | note" mode="moved">
       <div style="margin-left: auto; margin-right: auto; width: 30em">
			<xsl:call-template name="changed-element"/>
			<xsl:choose>
				<xsl:when test="local-name() = 'warning'">
                	<img src="{$paramPath}\Files\warning.jpg"  style="display: block; margin-left: auto; margin-right: auto"/>
				</xsl:when>
				<xsl:when test="local-name() = 'caution'">
                	<img src="{$paramPath}\Files\caution.jpg"  style="display: block; margin-left: auto; margin-right: auto"/>
				</xsl:when>
				<xsl:when test="local-name() = 'note'">
                	<img src="{$paramPath}\Files\note.jpg"  style="display: block; margin-left: auto; margin-right: auto"/>
				</xsl:when>
			</xsl:choose>
				<xsl:apply-templates/>
                <!-- <p align="justify" >This is a warning here to test the Warning popups here.</p> -->
        </div>
      <span id="end_of_alert"></span>
    </xsl:template>



    <xsl:template name="ncw-checklist-relocation">
        <xsl:call-template name="ncw-relocation">
            <xsl:with-param name="checklist" select="true()"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="ncw-relocation">
        <xsl:param name="checklist" select="false()"/>
        <xsl:param name="target" select="@id"/>
        <xsl:for-each select="ancestor::dmodule/content//warning[@xrefid = $target][($checklist and not(@type = 'ck') and para[not(@caveat = 'cv02')]) or (not($checklist) and para[not(@caveat = 'cv03' or @caveat = 'cv07' or @caveat = 'ck')])]">
            <xsl:call-template name="ncw">
                <xsl:with-param name="checklist" select="$checklist"/>
            </xsl:call-template>
        </xsl:for-each>
        <xsl:for-each select="ancestor::dmodule/content//caution[@xrefid = $target][($checklist and not(@type = 'ck') and para[not(@caveat = 'cv02')]) or (not($checklist) and para[not(@caveat = 'cv03' or @caveat = 'cv07' or @caveat = 'ck')])]">
            <xsl:call-template name="ncw">
                <xsl:with-param name="checklist" select="$checklist"/>
            </xsl:call-template>
        </xsl:for-each>
        <xsl:for-each select="ancestor::dmodule/content//note[@xrefid = $target][($checklist and not(@type = 'ck') and para[not(@caveat = 'cv02')]) or (not($checklist) and para[not(@caveat = 'cv03' or @caveat = 'cv07' or @caveat = 'ck')])]">
            <xsl:call-template name="ncw">
                <xsl:with-param name="checklist" select="$checklist"/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="ncw">
        <xsl:param name="checklist" select="false()"/>
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <xsl:if test="not(ancestor::mainfunc)">
                <xsl:for-each select="symbol">
                    <img src="{@boardno}"/>
                </xsl:for-each>
            </xsl:if>
            <center>
                <table width="500px">
                    <xsl:call-template name="isChangeBar">
                        <xsl:with-param name="check-ancestors" select="/.."/>
                        <xsl:with-param name="check-descendants" select="/.."/>
                    </xsl:call-template>
                    <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                    <xsl:choose>
                        <xsl:when test="@change = 'delete'">
                            <tr><td valign="top">Deleted</td></tr>
                        </xsl:when>
                        <xsl:otherwise>
                            <tr>
                                <td align="center" valign="top">
                                    <xsl:apply-templates select="." mode="moved"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="ncw">
                                    <xsl:choose>
                                        <xsl:when test="$checklist and count(para[not($no-change-markings and @change = 'delete')][not(@caveat = 'cv02')])>1">
                                            <ul>
                                                <xsl:apply-templates mode="ncw-li-checklist"/>
                                            </ul>
                                        </xsl:when>
                                        <xsl:when test="not($checklist) and count(para[not($no-change-markings and @change = 'delete')][not(@caveat = 'cv03' or @caveat = 'cv07' or @caveat = 'ck')])>1">
                                            <ul>
                                                <xsl:apply-templates mode="ncw-li"/>
                                            </ul>
                                        </xsl:when>
                                        <xsl:when test="$checklist">
                                            <xsl:apply-templates mode="ncw-checklist"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:apply-templates mode="ncw"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </td>
                            </tr>
                        </xsl:otherwise>
                    </xsl:choose>
                </table>
            </center>
        </xsl:if>
    </xsl:template>

    <xsl:template match="*[self::warning | self::caution | self::note][@type = 'ck' or not(para[not(@caveat = 'cv03' or @caveat = 'cv07' or @caveat = 'ck')])]"/>
    
 
<!-- ................................ figures, graphics, and other related items .................................. -->


    <!-- This new version of "hotspot" template added 04 May 2007 GA-ASI/sj -->
    <xsl:template match="hotspot" mode="xref">
        <a style="hotspot" href="R4I_CANCEL"
            onmousedown="window.external.HSMouseDown('{@id}')"
            onmouseup="window.external.HSMouseUp()">(<xsl:apply-templates select="@apsname"/>)</a>
    </xsl:template>
    
    <xsl:template match="figure" mode="xref">
        <xsl:param name="xref" select="/.."/>
        <xsl:param name="checklist" select="false()"/>
        <xsl:choose>
            <!-- Handled by the sheet -->
            <xsl:when test="count(child::sheet)>0"/>
            <xsl:when test="@caveat='cv17'">
                <xsl:variable name="srcImage">
                    <xsl:value-of select="concat(translate($paramPath, '/', '\'),'Images\IOS.png')"/>
                </xsl:variable>
                <a class="tooltip" href="R4I_CANCEL">
                    <xsl:attribute name="onclick">
                        <xsl:text>window.external.ShowImage('</xsl:text>
                        <xsl:value-of select="string(graphic[1]/@boardno)"/>
                        <xsl:text>', </xsl:text><xsl:value-of select="count(preceding::figure)+1"/><xsl:text>);return false;</xsl:text>
                    </xsl:attribute>
                    <img border="0">
                        <xsl:attribute name="src">
                            <xsl:value-of select="$srcImage"/>
                        </xsl:attribute>
                    </img><b><em></em><ul><li>IOS</li><li><xsl:text>NO:  </xsl:text><xsl:value-of select="title"/></li><li><font color='#FF0000'>CLICK BUTTON TO VIEW</font></li></ul></b></a>
            </xsl:when>
            <xsl:when test="$is-wp and @caveat='cv60' and not($checklist)"/>
            <xsl:otherwise>
                <a href="R4I_CANCEL">
                    <xsl:attribute name="onclick">window.external.ShowImage('<xsl:value-of select="string(graphic[1]/@boardno)"/>', <xsl:value-of select="count(preceding::figure)+1"/>)</xsl:attribute> 
                    <xsl:call-template name="isChangeBar">
                        <xsl:with-param name="check-ancestors" select="$xref/ancestor::*"/>
                    </xsl:call-template>
                    <xsl:text>(Figure </xsl:text><xsl:value-of select="count(preceding::figure)+1"/>)</a>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    
    <xsl:template match="figure/title">
        <xsl:value-of select="."/>
    </xsl:template>
    
    <xsl:template match="figure[parent::mainfunc]" mode="moved">
        <xsl:param name="xref" select="/.."/>
        <xsl:apply-templates select="." mode="xref">
            <xsl:with-param name="xref" select="$xref"/>
        </xsl:apply-templates>
    </xsl:template>
        
    <xsl:template match="figure[parent::ipc]" mode="moved">
        <xsl:param name="xref" select="/.."/>
        <center>
            <h1>
            <a href="R4I_CANCEL">
                <xsl:attribute name="onclick">window.external.ShowImage('<xsl:value-of select="string(graphic[1]/@boardno)"/>', <xsl:value-of select="count(preceding::figure)+1"/>)</xsl:attribute> 
                <xsl:call-template name="isChangeBar">
                    <xsl:with-param name="check-ancestors" select="$xref/ancestor::*"/>
                </xsl:call-template>
                <xsl:text>(Figure </xsl:text><xsl:value-of select="count(preceding-sibling::figure)+1"/><xsl:text>) </xsl:text>
                <xsl:apply-templates select="title"/></a>
            </h1>
        </center>
    </xsl:template>
            
    <xsl:template match="sheet" mode="xref">
        <xsl:param name="xref" select="/.."/>
        <a href="R4I_CANCEL">
            <xsl:attribute name="onclick">window.external.ShowImage('<xsl:value-of select="string(following-sibling::graphic[1]/@boardno)"/>', <xsl:value-of select="count(preceding::figure)+1"/>)</xsl:attribute> 
            <xsl:call-template name="isChangeBar">
                <xsl:with-param name="check-others" select=".."/>
                <xsl:with-param name="check-ancestors" select="$xref/ancestor::*"/>
            </xsl:call-template>
            <xsl:text>(</xsl:text>
            <xsl:value-of select="count(preceding-sibling::figure)+1"/>
            <xsl:text>, Sheet </xsl:text>
            <xsl:value-of select="count(preceding-sibling::sheet)+1"/>
            <xsl:text>)</xsl:text>
        </a>
    </xsl:template>
    
    
<!-- .............................................. tables .............................................. -->
    
    
    <xsl:template match="table">
        <xsl:call-template name="isChanged"/>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    <!-- EF: IS capgrp a table? -->
        
    <!-- No template for table, the table is generated by its children -->
    
    <!--we create a hyperlink object and supply it the id of the 
        object that it's going to link to, preceded by a hash 
        (to indicate an internal link) -->
    <!--We generate a textual reference to the table. 
        THIS WILL BE DISPLAYED BACK AT THE ORIGINAL XREF LOCATION -->
    <xsl:template match="table | capgrp" mode="xref"> 
        <xsl:variable name="title">
            <xsl:for-each select="child::title[1]/text()">
                <xsl:value-of select="string(.)"/>
                <xsl:if test="position()!=last()"><xsl:text> </xsl:text></xsl:if>
            </xsl:for-each>
        </xsl:variable>
        <a><xsl:attribute name="href">#<xsl:apply-templates select="@id"/></xsl:attribute> 
            <xsl:text>Table </xsl:text><xsl:number count="table[not(@tabstyle='haz' or @caveat='cv52')]" from="dmodule" level="any"/>
            <!-- 
            <xsl:if test="count(child::title)>0"><xsl:text>: </xsl:text><xsl:value-of select="$title"/></xsl:if>
            -->
        </a>
    </xsl:template> 
    
    <xsl:template match="capgrp/capbody">
        <a id="{parent::capgrp/@id}"/>
        <xsl:choose>
            <xsl:when test="count(preceding-sibling::title)>0"/>
            <xsl:otherwise><a id="{parent::table/@id}"/></xsl:otherwise>
        </xsl:choose>
        
        <!-- Fetch @frame attribute value from parent 'table' element  --> 
        <xsl:variable name="frame" select="string(parent::capgrp/@frame)"/>
        
        <!-- br only because this table is not 100%  --> 
        <br/>
        <table cellspacing="0" cellpadding="5" width="95%">
            <xsl:choose> 
                <xsl:when test="contains($frame,'none')">
                    <xsl:attribute name="frame">none</xsl:attribute> 
                    <xsl:attribute name="border">0</xsl:attribute> 
                </xsl:when> 
                <xsl:otherwise> 
                    <xsl:attribute name="frame">box</xsl:attribute> 
                    <xsl:attribute name="border">1</xsl:attribute> 
                </xsl:otherwise> 
            </xsl:choose> 
            <xsl:apply-templates/> 
        </table> 
        <br/>
    </xsl:template> 
    
    <xsl:template match="caprow">
        <tr>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates/>
        </tr>
    </xsl:template> 


    
    <xsl:template match="capentry">
        <td  valign="top">
            <xsl:attribute name="rowspan">
                <xsl:variable name="rspan" select="number(@morerows)"/>
                <xsl:value-of select="$rspan + 1"/>
            </xsl:attribute>
            <xsl:attribute name="align">
                <xsl:apply-templates select="@align"/>
            </xsl:attribute>
            <xsl:attribute name="colspan">
                <xsl:variable name="cstart" select="number(translate(@namest,'col', ''))"/>
                <xsl:variable name="cend" select="number(translate(@nameend,'col', ''))"/>
                <xsl:value-of select="$cend - $cstart  + 1"/>
            </xsl:attribute>
            <xsl:apply-templates/>
        </td>
    </xsl:template>
    
    <xsl:template match="CAPPCON">
        <xsl:apply-templates/>
    </xsl:template>
<!-- .............................................. paras .............................................. -->
    
    <xsl:template match="para" mode="xref">
        <a href="R4I_CANCEL">
            <xsl:text>[xref to paragraph </xsl:text><xsl:value-of select="count(preceding::para)+1"/>]</a>
    </xsl:template>


    <xsl:template match="para0 | subpara1 | subpara2 | subpara3 | subpara4" mode="xref">
        <xsl:variable name="title">
            <xsl:for-each select="child::title[1]/text()">
                <xsl:value-of select="string(.)"/>
                <xsl:if test="position()!=last()"><xsl:text> </xsl:text></xsl:if>
            </xsl:for-each>
        </xsl:variable>
        <a href="#{@id}"><xsl:value-of select="$title"/></a>
    </xsl:template>
    
    <xsl:template match="capgrp | paracon">
        <xsl:apply-templates/>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    
    <xsl:template match="para0 | subpara1 | subpara2 | subpara3 | subpara4">
        <div>
 			<xsl:call-template name="changed-element"/>
          <!-- <xsl:call-template name="isChangeBar"/>
            <xsl:call-template name="isChangeText"/>-->
		<xsl:apply-templates/>
			
        </div>
      <!--  <xsl:call-template name="ncw-relocation"/> -->
    </xsl:template>
    
    <xsl:template match="para0/title | subpara1/title | subpara2/title | subpara3/title | subpara4/title"> 
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <xsl:if test="count(parent::*/@id)>0"><a id="{parent::*/@id}"></a></xsl:if>
            <h1>
               <!-- <xsl:call-template name="isChangeBar"/> -->
                <xsl:apply-templates select="parent::*" mode="numbering"/>
                <xsl:text>&#160;&#160;&#160;</xsl:text>
                <u><xsl:call-template name="isChangeText"/></u>.</h1> 
        </xsl:if>
    </xsl:template> 

    <xsl:template match="para0" mode="numbering"><xsl:number format="1." count="para0" level="multiple"/></xsl:template>     
    <xsl:template match="subpara1" mode="numbering"><xsl:number format="1.1." count="para0 | subpara1" level="multiple"/></xsl:template> 
    <xsl:template match="subpara2" mode="numbering"><xsl:number format="1.1.1." count="para0 | subpara1 | subpara2" level="multiple"/></xsl:template> 
    <xsl:template match="subpara3" mode="numbering"><xsl:number format="1.1.1.1." count="para0 | subpara1 | subpara2 | subpara3" level="multiple"/></xsl:template> 
    <xsl:template match="subpara4" mode="numbering"><xsl:number format="1.1.1.1.1." count="para0 | subpara1 | subpara2 | subpara3 | subpara4" level="multiple"/></xsl:template> 

    <!-- Other Paras -->    
        
    <xsl:template match="unverif"><xsl:call-template name="isChangeBar"/>Unverified</xsl:template>
    <xsl:template match="firstver"><xsl:call-template name="isChangeBar"/>First Level Verification</xsl:template>
    <xsl:template match="secver"><xsl:call-template name="isChangeBar"/>Second Level Verification</xsl:template>
    <xsl:template match="noconds">No Required Conditions</xsl:template>
    <xsl:template match="nosupply">No Supplies</xsl:template>
    <xsl:template match="nospares">No Spares</xsl:template>
    <xsl:template match="nosafety">No Safety Conditions</xsl:template>

    <xsl:template match="nosupply[ancestor::proced]"><p>Consumables: None</p></xsl:template>
    <xsl:template match="nospares[ancestor::proced]"><p>Spares: None</p></xsl:template>
    <xsl:template match="nosafety[ancestor::proced]"><p>Safety Conditions: None</p></xsl:template>
    <xsl:template match="nosupeq[ancestor::proced]"><p>Support Equipment: None</p></xsl:template>

    <!-- Paras and elements that act like paras 
	
	-->

	<!-- This works ok for inline and para sorts of markup. Following items need supprt on specific 
		structures:
	- Rows in a table, set on tr
	- randlist
	- item
	-->
	  <xsl:template name="changehighlight">
		<xsl:choose>
			<xsl:when test="@change='add' and not($no-change-markings)">
				<span class="add">  
					<xsl:if test="@rfc">
						<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
					</xsl:if>
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="@change='modify' and not($no-change-markings)">
				<span class="modify"> 
					<xsl:if test="@rfc">
						<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
					</xsl:if>
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="@change='delete' and not($no-change-markings)">
				<span class="delete">
					<xsl:if test="@rfc">
						<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
					</xsl:if>
					DELETED
				</span>
		</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>
    </xsl:template>

    <xsl:template match="p | 
        capline |
        exmod   |
        addmod  | 
        para ">

            <p>
						<xsl:call-template name="changed-element"/>

                <xsl:if test="@id"><a id="{@id}"/></xsl:if>
	                <!-- <xsl:call-template name="isChangeText"/>-->
	<!--			<xsl:choose>
					<xsl:when test="@change = 'delete' or @change = 'add' or @change = 'modify'"> 
						<xsl:call-template name="changehighlight"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates/>
					</xsl:otherwise>
				</xsl:choose>-->
						<xsl:apply-templates/>

				</p>
    </xsl:template>
    
    <xsl:template match="para" mode="ncw">
        <xsl:call-template name="ncw-para"/>
    </xsl:template>
    
    <xsl:template name="ncw-para">
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <p class="ncw">
                <xsl:if test="ancestor-or-self::*/@caveat='cv62'">
                    <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                </xsl:if>
                <xsl:call-template name="isChangedNCW"/>
            </p>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="para[@caveat = 'cv03' or @caveat = 'cv07' or @caveat = 'ck']" mode="ncw"/>

    <xsl:template match="para" mode="ncw-li">
        <xsl:call-template name="ncw-li-para"/>
    </xsl:template>
    
    <xsl:template name="ncw-li-para">
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <li>
                <p class="ncw">
                    <xsl:if test="ancestor-or-self::*/@caveat='cv62'">
                        <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                    </xsl:if>
                    <xsl:call-template name="isChangedNCW"/>
                </p>
            </li>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="para[@caveat = 'cv03' or @caveat = 'cv07' or @caveat = 'ck']" mode="ncw-li"/>
    
    <!-- Paras that act like steps : FULL PROC MODE -->
    <xsl:template match="para[parent::step1] | 
        para[parent::step2] | 
        para[parent::step3] | 
        para[parent::step4] ">
        <xsl:variable name="caveat" select="translate( string(@caveat), $upper, $lower)"/>
        <xsl:variable name="asteps" select="ancestor::step1 | ancestor::step2 | ancestor::step3 | ancestor::step4 | ancestor::step5"/>
        <xsl:choose>
            <xsl:when test="$no-change-markings and @change = 'delete'"/>
            
            <!-- by caveat -->
            <xsl:when test="@caveat='cv02'">
                <li><p>
                    <xsl:if test="ancestor-or-self::*/@caveat='cv62'">
                        <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                    </xsl:if>
                    <xsl:call-template name="isChangeBar">
                        <xsl:with-param name="check-others" select="$asteps"/>
                    </xsl:call-template>
                    <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                    <xsl:call-template name="isChangeText">
                        <xsl:with-param name="check-others" select="$asteps"/>
                    </xsl:call-template></p></li>
            </xsl:when>
            
            <xsl:when test="@caveat='cv03'"/>

            <!-- included for backwards compatablity  -->
            <xsl:when test="@caveat='cv07'"/>
            <xsl:when test="@caveat='ck'"/>
            
            <!-- By Paragraph number: #1 = JG -->
            <xsl:when test="count(preceding-sibling::para)=0">
                <xsl:choose>
                    <xsl:when test="normalize-space(.)=''"/>
                    <xsl:otherwise>
                        <li><p>
                            <xsl:if test="ancestor-or-self::*/@caveat='cv62'">
                                <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                            </xsl:if>
                            <xsl:call-template name="isChangeBar">
                                <xsl:with-param name="check-others" select="$asteps"/>
                            </xsl:call-template>
                            <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                            <xsl:call-template name="isChangeText">
                                <xsl:with-param name="check-others" select="$asteps"/>
                            </xsl:call-template></p></li>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            
            <!-- By Paragraph number: #2 = CL -->
            <xsl:when test="count(preceding-sibling::para)=1"/>
            
            <!-- By Paragraph number: #3 handled in #2 -->
            <xsl:when test="count(preceding-sibling::para)=2"/>

            <!-- All Others... -->
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="normalize-space(.)=''"/>
                    <xsl:otherwise>
                        <li><p>
                            <xsl:if test="ancestor-or-self::*/@caveat='cv62'">
                                <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                            </xsl:if>
                            <xsl:call-template name="isChangeBar">
                                <xsl:with-param name="check-others" select="$asteps"/>
                            </xsl:call-template>
                            <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                            <xsl:call-template name="isChangeText">
                                <xsl:with-param name="check-others" select="$asteps"/>
                            </xsl:call-template></p></li>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <!-- 
    <xsl:template match="step1/para | step2/para | step3/para | step4/para | para" mode="checklist">
    -->
    <xsl:template match="para" mode="checklist">
        <xsl:variable name="caveat" select="translate( string(@caveat), $upper, $lower)"/>
        <xsl:choose>
            <xsl:when test="$no-change-markings and ancestor-or-self::*/@change = 'delete'"/>
            
            <!-- by caveat -->
            <xsl:when test="@caveat='cv02'"/>

            <xsl:when test="@caveat='cv03'">
                <xsl:call-template name="checklist-expanding-row"/>                
            </xsl:when>
            
            <!-- included for backwards compatablity  -->
            <xsl:when test="@caveat='cv07'">
                <xsl:call-template name="checklist-expanding-row"/>                
            </xsl:when>
            <xsl:when test="@caveat='ck'">
                <xsl:call-template name="checklist-expanding-row"/>                
            </xsl:when>
            
            <!-- By Paragraph number: #1 = JG -->
            <xsl:when test="count(preceding-sibling::para)=0"/>

            <!-- By Paragraph number: #2 = CL -->
            <xsl:when test="count(preceding-sibling::para)=1">
                <xsl:call-template name="checklist-expanding-row"/>                
            </xsl:when>
            
            <!-- By Paragraph number: #3 handled in #2 -->
            <xsl:when test="count(preceding-sibling::para)=2"/>
            
            <!-- All Others... -->
            <!-- Checklist needs to be all expanding rows or you get weird right margin and no ability to scroll? -->
            <xsl:otherwise>
                <xsl:call-template name="checklist-expanding-row"/>                
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
  
    
    <!-- .............................................. FI .............................................. -->
    
    
    <xsl:template match="isolatep">
        <!-- Should there be a header here? -->
        <!-- 
        <tr>
            <td  valign="top" colspan="2">
                <center>
                    <h3></h3>
                </center>
            </td>
        </tr>
        -->
        <tr>
            <td  valign="top" colspan="2">
                <table border="0" cellspacing="2" cellpadding="4" width="100%">
                    <tr>
                        <td>
                            <xsl:apply-templates/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="fault" mode="moved">
        <tr>
            <td  valign="top" colspan="2">
                <table border="0" cellspacing="2" cellpadding="4" width="100%">
                    <tr>
                        <td valign="top" colspan="2">
                            <p>Fault Code:
                                <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                                <xsl:value-of select="string(@fcode)"/>
                            </p>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="describe" mode="moved">
        <tr>
            <td valign="top" colspan="2">
                <table border="0" cellspacing="2" cellpadding="4" width="100%">
                    <tr>
                        <td valign="top" colspan="2">
                            <p>Fault Description:
                                <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                                <xsl:value-of select="string(fdesc)"/>
                            </p>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="prelreqs">
        <xsl:variable name="isWP" select="boolean(ancestor::dmodule/idstatus/dmaddres/dmc/avee[modelic = 'GAASIB0' and sdc = '06'])"/>
        <xsl:if test="not($isWP) or reqconds/reqcondm">
            <div id="Section_2">
				<xsl:call-template name="changed-element"/>

                <!--  name="{if $isWP then 'Checklist' else 'FullProcedure'}" -->
                <span name="{substring('Checklist', 1 div $isWP)}{substring('FullProcedure', 1 div not($isWP))}">
                    <table border="0" cellspacing="2" cellpadding="4" width="100%">
                        <!-- prelreq elements are formatted like idstatus elements -->
                        <xsl:apply-templates select="node()[not($isWP)] | reqconds"/>
                    </table>
                </span>
            </div>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="reqconds">
        <xsl:choose>
            <xsl:when test="count(child::noconds)>0">
                <tr>
                    <td class="tablestart" valign="top" colspan="2">Required Conditions:&#160;
                        <xsl:apply-templates/>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
			        <xsl:apply-templates select="reqcondm"/> 
            </xsl:otherwise>
        </xsl:choose>
        <tr>
            <td align="center" valign="top" colspan="2"> </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="reqcondm">
	      <tr>
	      		<xsl:choose>
	      			<xsl:when test="count(preceding-sibling::reqcond[1]) = 0">
	            <td class="tablestart" valign="top" colspan="2">Required Conditions:</td>
	          </xsl:when>
	          <xsl:otherwise>
							<td class="tablestart" valign="bottom" colspan="2">
								<xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;</xsl:text>
								<xsl:value-of select="preceding-sibling::reqcond[1]"/>
							</td>
	          </xsl:otherwise>
	      		</xsl:choose>
	      </tr>
	      <tr>
	          <td  valign="top" colspan="2">
	              <ul>
	       <xsl:for-each select="child::refdm">
	   							<xsl:apply-templates select="." mode="listitem"/>
								</xsl:for-each>
	              </ul>
	          </td>
	      </tr>
    </xsl:template>
        
    <xsl:template match="reqpers">
        <xsl:choose>
            <xsl:when test="count(child::noconds)>0">
                <tr>
								<xsl:call-template name="changed-element"/>

                    <td class="tablestart" valign="top" colspan="2">Personnel Recommended: <xsl:value-of select="sum(child::person/@man)"/>
                        <xsl:apply-templates/>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
                <tr>
								<xsl:call-template name="changed-element"/>

                    <td class="tablestart" valign="top" colspan="2">Personnel Recommended: <xsl:value-of select="sum(child::person/@man)"/></td>
                </tr>
                <tr>
								<xsl:call-template name="changed-element"/>

                    <td  valign="top" colspan="2">
                        <ul>
                            <xsl:for-each select="child::trade[not($no-change-markings and @change = 'delete')]">
                                <li>
                                    <xsl:call-template name="isChangeBar"/>
                                    <xsl:choose>
                                        <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                                        <xsl:otherwise>
                                            <xsl:apply-templates select="preceding-sibling::perscat[1]/@category"/>
                                            <xsl:text>&#160;</xsl:text>
                                            <xsl:apply-templates select="."/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </li>
                            </xsl:for-each>
                        </ul>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        <tr>
            <td align="center" valign="top" colspan="2"> </td>
        </tr>
    </xsl:template>

    <xsl:template match="esttime">
        <tr>
            <td  valign="top" colspan="2">
                <p>Estimated Time Spent:
                    <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
                    <xsl:value-of select="."/>
                </p>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="supequi">
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <tr>
				<xsl:call-template name="changed-element"/>
            </tr>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="supequip">
        <xsl:choose>
            <xsl:when test="count(child::nosupeq)>0">
                <tr>
								<xsl:call-template name="changed-element"/>

                    <td class="tablestart" valign="top" colspan="2"> 
                        <xsl:apply-templates/>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
                <tr>
								<xsl:call-template name="changed-element"/>

                    <td class="tablestart" valign="top" colspan="2">Support Equipment:</td>
                </tr>
                <tr>
								<xsl:call-template name="changed-element"/>

                    <td  valign="top" colspan="2" align="center">
                            <table width="80%" border="1" cellpadding="5" cellspacing="0">
                                <tr>
                                    <td>Nomenclature</td>
                                    <td>Part Number</td>
                                    <td>Quantity</td>
                                </tr>
                                <xsl:apply-templates/>
                            </table>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        <tr>
            <td align="center" valign="top" colspan="2"> </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="supply">
        <tr>
						<xsl:call-template name="changed-element"/>

            <xsl:apply-templates/>
        </tr>
    </xsl:template>
    
    <xsl:template match="nomen">
        <xsl:if test="not($no-change-markings and @change = 'delete')">
            <td><xsl:call-template name="isChangeBar"/>
                <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                <xsl:choose>
                    <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                    <xsl:otherwise><xsl:apply-templates/></xsl:otherwise></xsl:choose></td>
        </xsl:if>
    </xsl:template>

    <xsl:template match="qty">
        <xsl:choose>
            <xsl:when test="$no-change-markings and @change = 'delete'"/>
            <xsl:when test="ancestor::supply"/>
            <xsl:otherwise>
                <td><xsl:call-template name="isChangeBar"/>
                    <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                    <xsl:choose>
                        <xsl:when test="@change = 'delete'">Deleted</xsl:when>
                        <xsl:otherwise><xsl:apply-templates/></xsl:otherwise></xsl:choose></td>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    
    <xsl:template match="safety">
        <xsl:choose>
            <xsl:when test="count(child::nosafety)>0">
                <tr>
                    <td class="tablestart" valign="top" colspan="2"> 
                        <xsl:apply-templates/>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
                <tr>
                    <td class="tablestart" valign="top" colspan="2">Safety Conditions:</td>
                </tr>
                <tr>
                    <xsl:choose>
                        <xsl:when test="count(child::nosafety)>0">
                            <td class="tableend" valign="top" colspan="2">
                                <xsl:apply-templates/>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <td align="center" class="tableend" valign="top" colspan="2">
                                <xsl:apply-templates/>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:apply-templates select="." mode="additional-notices"/>
    </xsl:template>

    <xsl:template match="*" mode="additional-notices"/>
    
    <xsl:template match="isostep|isoend" mode="makeArray"><xsl:value-of select="@id"/><xsl:if test="count(following::isostep | following::isoend)>0"><xsl:text>, </xsl:text></xsl:if></xsl:template>
    
    <xsl:template match="isostep|isoend" mode="xref">
        <a href="#{@id}">Step <xsl:number count="isostep|isoend"/></a>
    </xsl:template>
    
    <xsl:template match="isostep|isoend">
        <span id='{@id}' title="isostep">
            <xsl:if test="count(preceding-sibling::isostep | preceding-sibling::isoend)>0">
                <xsl:attribute name="style">
                    <xsl:text>DISPLAY: none</xsl:text>
                </xsl:attribute>
            </xsl:if>
            <xsl:apply-templates>
                <xsl:with-param name="indent" select="1" />
            </xsl:apply-templates>
            <xsl:call-template name="ncw-relocation"/>
        </span>
    </xsl:template>
    
    <xsl:template match="action">
        <xsl:param name="indent"/>
        <xsl:if test="$indent=1">
            <p class="prompt"><xsl:if test="@id"><a id="{@id}"/></xsl:if><xsl:apply-templates /></p>
            <xsl:call-template name="ncw-relocation"/>
        </xsl:if>
    </xsl:template>

    <xsl:template match="question">
        <ul>
            <li><xsl:if test="@id"><a id="{@id}"/></xsl:if>
                <p class="promptindent">
                    <xsl:apply-templates/>
                    <xsl:text>&#160;&#160;&#160;</xsl:text>
                    <xsl:apply-templates select="following-sibling::answer" mode="moved"/>
                </p>
            </li>
        </ul>
    </xsl:template>
    
    <xsl:template match="answer"/>
    
    <xsl:template match="answer" mode="moved">
        <xsl:apply-templates/>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>

    <!-- function name is: HIDEBLOCKxxxC ; xxx is filled in and matches ID for each element. 
        Building unique scripts for each button (yes, no, choice) -->
    <xsl:template match="yes|no">
        <xsl:variable name="gid" select="generate-id(.)"/>
        <xsl:variable name="fn">HideBlock<xsl:value-of select="$gid"/>C</xsl:variable>
        <!-- UNCLICKED YES -->
        <input type="button" class="unclicked" style="DISPLAY: inline">
            <xsl:attribute name="id">U-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="name">U-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="value"><xsl:choose>
                <xsl:when test="self::yes">Yes</xsl:when>
                <xsl:otherwise>No</xsl:otherwise>
            </xsl:choose></xsl:attribute>
            <xsl:attribute name="onclick"><xsl:value-of select="$fn"/><xsl:text>()</xsl:text></xsl:attribute><xsl:text>&#160;</xsl:text>
        </input>
        <!-- CLICKED YES -->
        <input type="button" class="clicked" style="DISPLAY: none">
            <xsl:attribute name="id">C-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="name">C-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="value"><xsl:choose>
                <xsl:when test="self::yes">Yes</xsl:when>
                <xsl:otherwise>No</xsl:otherwise>
            </xsl:choose></xsl:attribute>
            <xsl:attribute name="onclick"><xsl:value-of select="$fn"/><xsl:text>()</xsl:text></xsl:attribute><xsl:text>&#160;</xsl:text>
        </input>
    </xsl:template>
    
    
    <xsl:template match="yes" mode="buildscript">
        <xsl:variable name="gid" select="generate-id(.)"/>
        <xsl:variable name="fn">HideBlock<xsl:value-of select="$gid"/>C</xsl:variable>
        <!-- BUILD CLICKED SCRIPT -->
        <xsl:text>
            function </xsl:text><xsl:value-of select="$fn"/><xsl:text>() 
                { 
            </xsl:text>
        
        <!-- Show clicked yes, hide unclicked yes -->
        <xsl:text>
            document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'none';</xsl:text>
        <xsl:text>
            document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'inline';</xsl:text>
        
        <!-- Show unclicked no, hide clicked no -->
        <xsl:text>
            document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(following-sibling::no)"/><xsl:text>').style.display = 'inline';</xsl:text>
        <xsl:text>
            document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(following-sibling::no)"/><xsl:text>').style.display = 'none';</xsl:text>
        
        <xsl:apply-templates select="ancestor::isostep" mode="buildscript">
            <xsl:with-param name="targetstep" select="@refid"/>
        </xsl:apply-templates>
        <xsl:text>
            }
        </xsl:text>
    </xsl:template>
    
    
    <xsl:template match="no" mode="buildscript">
        <xsl:variable name="gid" select="generate-id(.)"/>
        <xsl:variable name="fn">HideBlock<xsl:value-of select="$gid"/>C</xsl:variable>
        <!-- BUILD CLICKED SCRIPT -->
        <xsl:text>
            function </xsl:text><xsl:value-of select="$fn"/><xsl:text>() 
                { 
            </xsl:text>
        
        <!-- Show unclicked yes, hide clicked yes -->
        <xsl:text>
            document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(preceding-sibling::yes)"/><xsl:text>').style.display = 'inline';</xsl:text>
        <xsl:text>
            document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(preceding-sibling::yes)"/><xsl:text>').style.display = 'none';</xsl:text>
        
        <!-- Show clicked no, hide unclicked no -->
        <xsl:text>
            document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'none';</xsl:text>
        <xsl:text>
            document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'inline';</xsl:text>
        
        <xsl:apply-templates select="ancestor::isostep" mode="buildscript">
            <xsl:with-param name="targetstep" select="@refid"/>
        </xsl:apply-templates>
        <xsl:text>
            }
        </xsl:text>
    </xsl:template>
    
    
    <xsl:template match="*" mode="clear">
        <xsl:apply-templates mode="clear"/>
    </xsl:template>
    
    
    <xsl:template match="yes|no" mode="clear">
        <xsl:text>
            document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'inline';</xsl:text>
        <xsl:text>
            document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'none';</xsl:text>
    </xsl:template>
    <xsl:template match="choice" mode="clear">
        <xsl:text>
            document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'block';</xsl:text>
        <xsl:text>
            document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'none';</xsl:text>
    </xsl:template>
    
    
    <xsl:template match="isostep" mode="buildscript">
        <xsl:param name="targetstep"/>
    
        <xsl:for-each select="following-sibling::isostep | following-sibling::isoend">
            <xsl:variable name="id" select="@id"/>

            <xsl:choose>
                <xsl:when test="$id=$targetstep">
                    <xsl:apply-templates select="descendant::answer" mode="clear"/>
                    <xsl:text>
                        document.getElementById('</xsl:text><xsl:value-of select="$id"/><xsl:text>').style.display = 'block';</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="descendant::answer" mode="clear"/>
                    <xsl:text>
                        document.getElementById('</xsl:text><xsl:value-of select="$id"/><xsl:text>').style.display = 'none';</xsl:text>
                    <!-- CLEAR YES/NO in each step: set each yes no to unclicked -->
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>
    

    <xsl:template match="choice" mode="buildscript">
        <xsl:variable name="gid" select="generate-id(.)"/>
        <xsl:variable name="fn">HideBlock<xsl:value-of select="$gid"/>C</xsl:variable>
        <!-- BUILD CLICKED SCRIPT -->
        <xsl:text>
            function </xsl:text><xsl:value-of select="$fn"/><xsl:text>() 
            { 
        </xsl:text>
        <xsl:for-each select="preceding-sibling::choice">
            <xsl:text>
                document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'block';</xsl:text>
            <xsl:text>
                document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'none';</xsl:text>
        </xsl:for-each>

        <xsl:text>
            document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'none';</xsl:text>
        <xsl:text>
            document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'block';</xsl:text>
        
        <xsl:for-each select="following-sibling::choice">
            <xsl:text>
                document.getElementById('U-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'block';</xsl:text>
            <xsl:text>
                document.getElementById('C-</xsl:text><xsl:value-of select="generate-id(.)"/><xsl:text>').style.display = 'none';</xsl:text>
        </xsl:for-each>

        <xsl:apply-templates select="ancestor::isostep" mode="buildscript">
            <xsl:with-param name="targetstep" select="@refid"/>
        </xsl:apply-templates>
        <xsl:text>
            }
        </xsl:text>
    </xsl:template>


    <xsl:template match="choice">
        <xsl:variable name="gid" select="generate-id(.)"/>
        <xsl:variable name="fn">HideBlock<xsl:value-of select="$gid"/>C</xsl:variable>
        <!-- UNCLICKED YES -->
        <input type="button" class="unclickedChoice" style="DISPLAY: block">
            <xsl:attribute name="id">U-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="name">U-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            <xsl:attribute name="onclick"><xsl:value-of select="$fn"/><xsl:text>()</xsl:text></xsl:attribute><xsl:text>&#160;</xsl:text>
        </input>
        <!-- CLICKED YES -->
        <input type="button" class="clickedChoice" style="DISPLAY: none">
            <xsl:attribute name="id">C-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="name">C-<xsl:value-of select="$gid"/></xsl:attribute>
            <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            <xsl:attribute name="onclick"><xsl:value-of select="$fn"/><xsl:text>()</xsl:text></xsl:attribute><xsl:text>&#160;</xsl:text>
        </input>
    </xsl:template>

    
    
    <!-- .............................................. IPB .............................................. -->
    
    
    <xsl:template match="csn">
        <xsl:variable name="sheets" select="count(../figure/graphic)"/>
        <xsl:if test="count(preceding-sibling::csn)=0">
            <tr>
							<xsl:call-template name="changed-element"/>

                <td class="ipbhead">FIGURE &amp; INDEX/SHEET NO.</td>
                <td class="ipbhead">PART&#160;NUMBER</td>
                <td class="ipbhead">CAGE</td>
                <td class="ipbhead2">DESCRIPTION<br/>1&#160;2&#160;3&#160;4&#160;5&#160;6&#160;7</td>
                <td class="ipbhead">UNITS PER ASSY</td>
                <td class="ipbhead">USABLE ON&#160;CODE</td>
                <td class="ipbhead">SMR CODE</td>
            </tr>
            <tr>
				<xsl:call-template name="changed-element"/>
            <td class="ipb">1<!--<xsl:value-of select="count(parent::node()/child::csn)"/>--></td>
            <td class="ipb">&#160;</td>
            <td class="ipb">&#160;</td>
            <td class="ipb"><xsl:value-of select="preceding-sibling::figure/title"/></td>
            <td class="ipb">&#160;</td>
            <td class="ipb">&#160;</td>
            <td class="ipb">&#160;</td>
            </tr>
        </xsl:if>
        <xsl:for-each select="isn">
            <xsl:variable name="ThisID" select="@id"/>
            <xsl:variable name="HotspotID">
                <xsl:value-of select="//hotspot[xref/@xrefid=$ThisID]/@apsname"/>
            </xsl:variable>
            <tr id="{$HotspotID}">
							<xsl:call-template name="changed-element"/>

                <td align="right" class="ipb" nowrap="true">
                    <xsl:if test="@ind"><a id="{@ind}"/></xsl:if>
                    <xsl:choose>
                      <xsl:when test="number(../@csn) > 0">
                        <xsl:value-of select="number(../@csn)"/><xsl:text>/</xsl:text>
                      </xsl:when>
                      <xsl:otherwise>-/</xsl:otherwise>
                    </xsl:choose>
                    <xsl:if test="$sheets &lt;= 1">1</xsl:if>
                    <!-- FIXME: Determine sheet by examining graphics (ISO, CGM too?) -->
                    <xsl:if test="$sheets &gt;= 2">?</xsl:if>
                </td>
                <xsl:apply-templates select="descendant::pnr"/>
                <xsl:apply-templates select="descendant::mfc"/>
                <xsl:apply-templates select="descendant::dfp"/>
                <xsl:apply-templates select="descendant::qna"/>
                <xsl:apply-templates select="descendant::uce"/>
                <xsl:apply-templates select="descendant::smr"/>
            </tr>
        </xsl:for-each>
    </xsl:template>
        
    <!-- .............................................. PROCED .............................................. -->
    
    <xsl:template match="mainfunc">
        <xsl:variable name="discode" select="/dmodule/idstatus/dmaddres/dmc/avee/discode[1]"/>
        <div id="Section_3">
            <xsl:call-template name="isChanged">
                <xsl:with-param name="content">
                    <table border="0" cellspacing="2" cellpadding="4" width="100%">
                        <tr>
                            <td  valign="top" align="center"><h2>Procedures</h2></td>
                        </tr>
                        <tr>
                            <td  valign="top">
                                <!-- Everything appears in this list in the single td -->
                                <xsl:choose>
                                    <xsl:when test="starts-with(normalize-space(/dmodule/idstatus/dmaddres/dmc/avee/discode[1]), 'C')">
                                        <span name="Checklist">
                                            <table width="90%">
                                                <colgroup>
                                                    <col width="90%"/>    
                                                </colgroup>
                                                <tr>
                                                    <td align="left">
                                                        <xsl:apply-templates mode="checklist"/>
                                                    </td>
                                                </tr>
                                            </table>
                                        </span>
                                        <span name="FullProcedure">
                                            <ol>
                                                <xsl:apply-templates/>
                                            </ol>
                                        </span>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <span name="FullProcedure">
                                            <ol>
                                                <xsl:apply-templates/>
                                            </ol>
                                        </span>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                        </tr>
                    </table>
                </xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template match="closereqs">
        <xsl:variable name="isWP" select="boolean(ancestor::dmodule/idstatus/dmaddres/dmc/avee[modelic = 'GAASIB0' and sdc = '06'])"/>
        <xsl:if test="not($isWP) or reqconds/reqcondm">
            <div id="Section_4">
							<xsl:call-template name="changed-element"/>

                <!--  name="{if $isWP then 'Checklist' else 'FullProcedure'}" -->
                <span name="{substring('Checklist', 1 div $isWP)}{substring('FullProcedure', 1 div not($isWP))}">
                    <table border="0" cellspacing="2" cellpadding="4" width="100%">
                        <xsl:if test="not($isWP)">
                            <tr>
                                <td  valign="top" align="center" colspan="2"><h2>Follow-on Maintenance</h2></td>
                            </tr>
                        </xsl:if>
                        <!-- closereq elements are formatted like idstatus elements -->
                        <xsl:apply-templates/>
                    </table>
                </span>
            </div>
        </xsl:if>
    </xsl:template>
   
    <!-- This section handles the Crew doctype -->
    <!-- The para0/title, para0/para, ... elements in /dmodule/content/acrw/descacrw are matched -->
    <!-- by a more general template which numbers the title and places the paragraphs below it.  -->
    <xsl:template match="drill | subdrill">
        <ol>
						<xsl:call-template name="changed-element"/>

            <xsl:apply-templates/>
        </ol>
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    
    <!-- Place the steps of a drill or subdrill in numbered list items -->
    <xsl:template match="drill/step | subdrill/step">
        <li>
						<xsl:call-template name="changed-element"/>

            <xsl:apply-templates/>
            <xsl:call-template name="ncw-relocation"/>
        </li>
    </xsl:template>
    
    <xsl:template match="step/challrsp">
        <xsl:apply-templates select="challeng/para/node()"/>
        <!-- emit a space, emdash, space -->
        <xsl:text> &#x2014; </xsl:text>
        <xsl:apply-templates select="response/para/node()"/>
    </xsl:template> 
    
    <xsl:template match="step1">
        <xsl:if test="not(@change = 'delete' and $customer = 'CBP')">
            <xsl:if test="@id"><a id="{@id}"/></xsl:if>
            <xsl:apply-templates />
        </xsl:if>
        <xsl:call-template name="ncw-relocation"/>
        <xsl:if test="count(child::step2)>0 and not(@change = 'delete')">
            <ol class="l2">
                <xsl:for-each select="child::step2">
                    <xsl:apply-templates select="." mode="moved"/>                    
                </xsl:for-each>
            </ol>
        </xsl:if>
    </xsl:template>

    <xsl:template match="step2"/>
    
    <xsl:template match="step2" mode="moved">
        <xsl:if test="@id"><a id="{@id}"/></xsl:if>
        <xsl:apply-templates />
        <xsl:call-template name="ncw-relocation"/>
        <xsl:if test="count(child::step3)>0 and not(@change = 'delete')">
            <ol class="l3">
                <xsl:for-each select="child::step3">
                    <xsl:apply-templates select="." mode="moved"/>                    
                </xsl:for-each>
            </ol>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="step3"/>
    
    <xsl:template match="step3" mode="moved">
        <xsl:if test="@id"><a id="{@id}"/></xsl:if>
        <xsl:apply-templates />
        <xsl:call-template name="ncw-relocation"/>
        <xsl:if test="count(child::step4)>0 and not(@change = 'delete')">
            <ol class="l4">
                <xsl:for-each select="child::step4">
                    <xsl:apply-templates select="." mode="moved"/>                    
                </xsl:for-each>
            </ol>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="step4"/>
    
    <xsl:template match="step4" mode="moved">
        <xsl:if test="@id"><a id="{@id}"/></xsl:if>
        <xsl:apply-templates />
        <xsl:call-template name="ncw-relocation"/>
        <xsl:if test="count(child::step5)>0 and not(@change = 'delete')">
            <ol class="l5">
                <xsl:for-each select="child::step5">
                    <xsl:apply-templates select="." mode="moved"/>                    
                </xsl:for-each>
            </ol>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="step5"/>
    
    <xsl:template match="step5" mode="moved">
        <xsl:if test="@id"><a id="{@id}"/></xsl:if>
        <xsl:apply-templates />
        <xsl:call-template name="ncw-relocation"/>
    </xsl:template>
    

    
    <!-- Work Cards (marked up with <frc> in Crew doctype) -->
    <xsl:template match="dmodule[content/acrw/frc]/idstatus" priority="10"/>

    <xsl:template match="frc/drill[not(step)]">
        <xsl:variable name="issno" select="ancestor::dmodule/idstatus/dmaddres/issno/@issno"/>
        <table width="100%" border="2" cellpadding="4" class="wc" style="margin-bottom: 18;">
            <tr>
                <td class="wc" align="left" valign="top" width="36%">
                    <div style="font-size: 6pt;">PUBLICATION NUMBER</div>
                    <div>-</div>
                </td>
                <td class="wc" align="left" valign="top" width="38%">
                    <div style="font-size: 6pt;">INSPECTION REQUIREMENTS</div>
                    <div><xsl:apply-templates select="title/node()"/></div>
                </td>
                <td class="wc" align="left" valign="top" width="6%">
                    <div style="font-size: 6pt;">FIGURE</div>
                    <div><xsl:apply-templates select="applic/model[@model = 'figure']/moduleno/node()"/></div>
                </td>
                <td class="wc" align="left" valign="top" width="10%">
                    <div style="font-size: 6pt;">CHANGE NO.</div>
                    <div><xsl:value-of select="substring(number($issno), 1 div ($issno > 0))"/></div>
                </td>
                <td class="wc" align="left" valign="top" width="10%">
                    <div style="font-size: 6pt;">CARD NO.</div>
                    <div>-</div>
                </td>
            </tr>
            <tr>
                <td class="wc" align="left" colspan="5">
                    <xsl:apply-templates/>
                </td>
            </tr>
        </table>
    </xsl:template>

    <xsl:template match="frc/drill[step]">
        <xsl:variable name="mods" select="applic/model/moduleno"/>
        <xsl:variable name="issno" select="ancestor::dmodule/idstatus/dmaddres/issno/@issno"/>
        <xsl:variable name="headfoot">
            <tr>
                <td class="wc" align="center" valign="top" width="10%" colspan="2">
                    <div style="font-size: 6pt;">CARD NO.</div>
                    <div>-</div>
                </td>
                <td class="wc" align="center" valign="top" width="18%" colspan="3">
                    <div style="font-size: 6pt;">WORK AREA(S)</div>
                    <div><xsl:apply-templates select="$mods[../@model = 'area']/node()"/></div>
                </td>
                <td class="wc" align="center" valign="top" width="11%">
                    <div style="font-size: 6pt;">TYPE MECH RQR</div>
                    <div><xsl:apply-templates select="$mods[../@model = 'mechtype']/node()"/></div>
                </td>
                <td class="wc" align="center" valign="top" width="7%">
                    <div style="font-size: 6pt;">MECH NO.</div>
                </td>
                <td class="wc" align="center" valign="top" width="10%" colspan="2">
                    <div style="font-size: 6pt;">CARD TIME</div>
                </td>
                <td class="wc" align="left" valign="top" width="34%" colspan="4">
                    <div style="font-size: 6pt;">PUBLICATION NUMBER</div>
                    <div>-</div>
                </td>
                <td class="wc" align="center" valign="top" width="10%">
                    <div style="font-size: 6pt;">CHANGE NO.</div>
                </td>
            </tr>
        </xsl:variable>
        <table width="100%" border="2" cellpadding="4" class="wc" style="margin-bottom: 18;">
            <xsl:copy-of select="$headfoot"/>
            <tr>
                <td class="wc" align="center" width="5%" rowspan="2">
                    <div style="font-size: 6pt;">MAN<br/>MIN</div>
                </td>
                <td class="wc" align="center" width="5%" rowspan="2">
                    <div style="font-size: 6pt;">WORK<br/>AREA</div>
                </td>
                <td class="wc" align="center" valign="top" width="12%" colspan="2">
                    <div style="font-size: 6pt;">WORK UNIT CODE</div>
                </td>
                <td class="wc" align="center" width="29%" colspan="4" rowspan="2" style="border-right-style: none;">
                    <div><xsl:apply-templates select="title/node()"/></div>
                </td>
                <td class="wc" align="left" width="11%" colspan="2" rowspan="2" style="border-left-style: none;">
                    <div style="font-size: 6pt;">INSPECTION<br/>REQUIREMENTS</div>
                </td>
                <td class="wc" align="center" valign="top" width="14%" rowspan="2">
                    <div style="font-size: 6pt;">ELECTRICAL POWER</div>
                    <div><xsl:value-of select="translate($mods[../@model = 'power'], $lower, $upper)"/></div>
                </td>
                <td class="wc" align="center" valign="top" width="8%" rowspan="2">
                    <div style="font-size: 6pt;">SERVICE</div>
                    <div><xsl:apply-templates select="$mods[../@model = 'service']/node()"/></div>
                </td>
                <td class="wc" align="center" valign="top" width="6%" rowspan="2">
                    <div style="font-size: 6pt;">FIGURE</div>
                    <div><xsl:apply-templates select="$mods[../@model = 'figure']/node()"/></div>
                </td>
                <td class="wc" align="center" valign="top" width="10%" rowspan="2">
                    <div style="font-size: 6pt;">CARD NO.</div>
                    <div>-</div>
                </td>
            </tr>
            <tr>
                <td class="wc" align="center" width="6%">
                    <div style="font-size: 6pt;">SYS</div>
                </td>
                <td class="wc" align="center" width="6%">
                    <div style="font-size: 6pt;">SUB</div>
                </td>
            </tr>
            <xsl:apply-templates/>
            <xsl:copy-of select="$headfoot"/>
        </table>
    </xsl:template>

    <xsl:template match="frc/drill/title"/>
    <xsl:template match="frc/drill//applic"/>

    <xsl:template match="foreword//frc/drill" mode="number">
        <xsl:number level="any" from="foreword" format="i"/>
    </xsl:template>

    <xsl:template match="book_chapter//frc/drill" mode="number">
        <xsl:for-each select="ancestor::book_chapter">
            <xsl:number level="single" format="1-"/>
        </xsl:for-each>
        <xsl:number level="any" from="book_chapter" format="001"/>
    </xsl:template>

    <xsl:template match="frc/drill//randlist/item" mode="number">
        <xsl:text>&#8226;</xsl:text><!-- Bullet -->
    </xsl:template>

    <xsl:template match="frc/drill/para" mode="number">
        <xsl:number format="1."/>
    </xsl:template>

    <xsl:template match="frc/drill/step/para" mode="number">
        <xsl:for-each select=".."><xsl:number format="1."/></xsl:for-each>
    </xsl:template>

    <xsl:template match="frc/drill/step/step/para" mode="number">
        <xsl:for-each select=".."><xsl:number format="A."/></xsl:for-each>
    </xsl:template>

    <xsl:template match="frc/drill/step/step/step/para" mode="number">
        <xsl:for-each select=".."><xsl:number format="(1)"/></xsl:for-each>
    </xsl:template>

    <xsl:template match="frc/drill/step/step/step/step/para" mode="number">
        <xsl:for-each select=".."><xsl:number format="(A)"/></xsl:for-each>
    </xsl:template>

    <xsl:template match="frc/drill//randlist">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="frc/drill/para | frc/drill//step/para | frc/drill//item">
        <xsl:variable name="numbered" select="self::item or not(parent::step) or not(preceding-sibling::para)"/>
        <xsl:variable name="depth" select="count(self::para/ancestor::step | ancestor::randlist) - 1"/>
        <xsl:variable name="left" select="0.25 + 0.25 * boolean(self::para) + 0.25 * ($depth >= 0) * $depth - 0.25 * $numbered"/>
        <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin-top: 0; margin-bottom: 0;">
            <tr valign="top">
                <xsl:if test="$left &gt; 0"><td width="{$left * 128}"></td></xsl:if>
                <xsl:if test="$numbered">
                    <td width="32"><xsl:apply-templates select="." mode="number"/></td>
                </xsl:if>
                <td><xsl:apply-templates/></td>
                <td width="38"></td>
            </tr>
        </table>
    </xsl:template>

    <xsl:template match="frc/drill//figure">
        <xsl:param name="xref" select="/.."/>
        <xsl:variable name="depth" select="count(ancestor::step | ancestor::randlist) - 1"/>
        <xsl:variable name="left" select="0.5 + 0.25 * ($depth >= 0) * $depth"/>
        <xsl:variable name="x-ref">
            <div style="margin-left: {$left * 96}; margin-top: 12; margin-bottom: 6;">
                <xsl:apply-templates select="." mode="xref">
                    <xsl:with-param name="xref" select="$xref"/>
                </xsl:apply-templates>
            </div>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="ancestor::drill//xref[@xrefid = current()/@id]"/>
            <xsl:when test="../step">
                <tr>
                    <td class="wcstep"/><td class="wcstep"/><td class="wcstep"/><td class="wcstep"/>
                    <td class="wcstep" colspan="10" style="padding-left: 96;">
                        <xsl:copy-of select="$x-ref"/>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise><xsl:copy-of select="$x-ref"/></xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="frc/drill//step">
        <xsl:variable name="mods" select="applic/model/moduleno"/>
        <xsl:variable name="pre" select="warning | caution | *[self::note | self::figure | self::foldout | self::table][not(preceding-sibling::para)]"/>
        <xsl:if test="$pre">
            <tr>
                <td class="wcstep"/><td class="wcstep"/><td class="wcstep"/><td class="wcstep"/>
                <td class="wcstep" colspan="10" style="padding-left: 96;">
                    <xsl:apply-templates select="$pre"/>
                </td>
            </tr>
        </xsl:if>
        <tr>
            <td class="wcstep" align="center" valign="top">
                <xsl:apply-templates select="$mods[../@model = 'minute']/node()"/>
            </td>
            <td class="wcstep" align="center" valign="top">
                <xsl:apply-templates select="@check"/>
            </td>
            <td class="wcstep" align="center" valign="top">
                <xsl:apply-templates select="$mods[../@model = 'wucsys']/node()"/>
            </td>
            <td class="wcstep" align="center" valign="top">
                <xsl:apply-templates select="$mods[../@model = 'wucsub']/node()"/>
            </td>
            <td class="wcstep" valign="top" colspan="10" style="padding-top: 0;">
                <xsl:apply-templates select="para[1] | para[1]/following-sibling::*[not(self::step | self::if | self::elseif | self::case)]"/>
            </td>
        </tr>
        <xsl:apply-templates select="step | if | elseif | case"/>
    </xsl:template>

    <!-- CHECKLIST VERSIONS -->
    
    <!-- WHICH SHOULD IT BE? GET ISSUES WHEN NO CHILDREN
    <xsl:template match="*" mode="checklist"/>
    <xsl:template match="*" mode="checklist">
        <xsl:apply-templates select="."/>
    </xsl:template> 
    -->
    
    <xsl:template match="*" mode="checklist">
        <xsl:apply-templates select="."/>
    </xsl:template> 
    
    <xsl:template match="figure" mode="checklist"/>
    <xsl:template match="table[@caveat='cv02']" mode="checklist"/>    
    
    <xsl:template match="xref" mode="checklist">
        <xsl:variable name="xrefid" select="@xrefid"/>
        <xsl:choose>
            <xsl:when test=" starts-with($xrefid,'fig')"/>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>    
    

    <xsl:template match="warning | caution | note" mode="checklist">
        <xsl:if test="not(@xrefid)">
            <xsl:call-template name="ncw">
                <xsl:with-param name="checklist" select="true()"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>

    <xsl:template match="*[self::warning | self::caution | self::note][not(para[not(@caveat = 'cv02')])]" mode="checklist"/>
    
    <xsl:template match="para" mode="ncw-checklist">
        <xsl:call-template name="ncw-para"/>
    </xsl:template>
    
    <xsl:template match="para[@caveat = 'cv02']" mode="ncw-checklist"/>

    <xsl:template match="para" mode="ncw-li-checklist">
        <xsl:call-template name="ncw-li-para"/>
    </xsl:template>
    
    <xsl:template match="para[@caveat = 'cv02']" mode="ncw-li-checklist"/>
    
    <xsl:template match="step1" mode="checklist">
        <div class="step1">
            <xsl:if test="not(@change = 'delete' and $customer = 'CBP')">
                <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                <xsl:for-each select="child::*">
                    <xsl:choose>
                        <xsl:when test="self::step2"/>
                        <xsl:otherwise>
                            <xsl:apply-templates select="." mode="checklist"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:if>
            <xsl:call-template name="ncw-checklist-relocation"/>
        </div>
        <xsl:if test="count(child::step2/para[2]) > 0 and not(@change = 'delete')">
            <xsl:for-each select="child::step2">
                <xsl:apply-templates select="." mode="checklist"/>                    
            </xsl:for-each>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="step2" mode="checklist">
        <div class="step2">
            <xsl:if test="@id"><a id="{@id}"/></xsl:if>
            <xsl:for-each select="child::*">
                <xsl:choose>
                    <xsl:when test="self::step3"/>
                    <xsl:otherwise>
                        <xsl:apply-templates select="." mode="checklist"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
            <xsl:call-template name="ncw-checklist-relocation"/>
        </div>
            <xsl:if test="count(child::step3/para[2])>0">
                <xsl:for-each select="child::step3">
                    <xsl:apply-templates select="." mode="checklist"/>                    
                </xsl:for-each>
            </xsl:if>
    </xsl:template>
    
    <xsl:template match="step3" mode="checklist">
        <div class="step3">
            <xsl:if test="@id"><a id="{@id}"/></xsl:if>
            <xsl:for-each select="child::*">
                <xsl:choose>
                    <xsl:when test="self::step4"/>
                    <xsl:otherwise>
                        <xsl:apply-templates select="." mode="checklist"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
            <xsl:call-template name="ncw-checklist-relocation"/>
        </div>
            <xsl:if test="count(child::step4/para[2])>0">
                <xsl:for-each select="child::step4">
                    <xsl:apply-templates select="." mode="checklist"/>                    
                </xsl:for-each>
            </xsl:if>
    </xsl:template>
    
    <xsl:template match="step4" mode="checklist">
        <div class="step4">
            <xsl:if test="@id"><a id="{@id}"/></xsl:if>
            <xsl:apply-templates select="." mode="checklist"/>
            <xsl:call-template name="ncw-checklist-relocation"/>
        </div>
    </xsl:template>
    
    
    <xsl:template name="checklist-expanding-row">
        <xsl:variable name="pstep" select="parent::step1 | parent::step2 | parent::step3 | parent::step4 | parent::step5"/>
        <xsl:variable name="asteps" select="ancestor::step1 | ancestor::step2 | ancestor::step3 | ancestor::step4 | ancestor::step5"/>
        <table width="100%">
            <tr>
                <td align="left" valign="bottom">
                    <xsl:call-template name="isChangeBar">
                        <xsl:with-param name="check-others" select="$asteps"/>
                    </xsl:call-template>
                    <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                    <div class="cl-{local-name($pstep)}">
                        <span style="position: relative;">
                            <span class="cl-label">
                                <xsl:apply-templates select="$pstep" mode="numbering"/>
                            </span>
                        </span>
                        <span class="cl-left">
                            <xsl:if test="ancestor-or-self::*/@caveat='cv62'">
                                <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                            </xsl:if>
                            <xsl:call-template name="isChangeText">
                                <xsl:with-param name="check-others" select="$asteps"/>
                                <xsl:with-param name="checklist" select="true()"/>
                            </xsl:call-template>
                        </span>
                        <span class="cl-start">&#160;</span>
                    </div>
                </td>
                <xsl:if test="following-sibling::para">
                    <td width="10px"><span class="cl-leader">&#160;</span></td>
                    <td align="right" valign="bottom">
                        <span class="cl-leading" style="display: none;"/>
                        <span class="cl-right">
                            <xsl:if test="following-sibling::para[1]/ancestor-or-self::*/@caveat='cv62'">
                                <xsl:attribute name="style">padding-bottom: 0.25in;</xsl:attribute>
                            </xsl:if>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:for-each select="following-sibling::para[1]">
                                <xsl:call-template name="isChangeBar">
                                    <xsl:with-param name="check-others" select="$asteps"/>
                                </xsl:call-template>
                                <xsl:if test="@id"><a id="{@id}"/></xsl:if>
                                <xsl:call-template name="isChangeText">
                                    <xsl:with-param name="check-others" select="$asteps"/>
                                    <xsl:with-param name="checklist" select="true()"/>
                                </xsl:call-template>
                            </xsl:for-each>
                        </span>
                    </td>
                    <td align="left" valign="bottom" width="3px">
                        <span class="cl-box"/>
                        <input type="checkbox" style="width:1.8em;height:1.8em;">
                            <!--<xsl:if test="ancestor::dmodule/idstatus/dmaddres/dmc/avee[modelic = 'GAASIB0' and sdc = '06']">
                                <xsl:attribute name="onclick">ToggleSteps()</xsl:attribute>
                            </xsl:if>-->
                        </input>
                    </td>
                </xsl:if>
            </tr>
        </table>
    </xsl:template>
    
    
    
    
    
    <xsl:template match="step1 | step2 | step3 | step4" mode="xref">
        <xsl:param name="checklist" select="false()"/>
        <xsl:variable name="num">
            <xsl:apply-templates select="." mode="numbering-xref">
                <xsl:with-param name="checklist" select="$checklist"/>
            </xsl:apply-templates>
        </xsl:variable>
        <a href="#{@id}">Step <xsl:value-of select="translate($num, ',', '')"/></a>
    </xsl:template>
    
    <!-- The filter logic here exactly matches that found in <xsl:template match="para" mode="checklist"> -->
    <!-- If the filters do not match, the numbering of checklist steps will get out of sync with the steps -->
    <xsl:template match="step1" mode="numbering"><xsl:number format="1. " count="step1[not($no-change-markings and @change = 'delete')][para[not(@caveat='cv02') and (normalize-space(.) != '') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)]]" level="multiple"/></xsl:template>
    <xsl:template match="step2" mode="numbering"><xsl:number format="a. " count="step2[not($no-change-markings and @change = 'delete')][para[not(@caveat='cv02') and (normalize-space(.) != '') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)]]" level="multiple"/></xsl:template>
    <xsl:template match="step3" mode="numbering"><xsl:number format="(1) " count="step3[not($no-change-markings and @change = 'delete')][para[not(@caveat='cv02') and (normalize-space(.) != '') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)]]" level="multiple"/></xsl:template> 
    <xsl:template match="step4" mode="numbering"><xsl:number format="(a) " count="step4[not($no-change-markings and @change = 'delete')][para[not(@caveat='cv02') and (normalize-space(.) != '') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)]]" level="multiple"/></xsl:template>

		<!-- The comma in the format attribute is needed for "1" and "a" to be parsed -
		   - as separate tokens.  It is stripped out in the "xref" template, above.   -->
    <xsl:template match="step1" mode="numbering-xref">
        <xsl:param name="checklist" select="false()"/>
        <xsl:number format="1" count="step1[para[normalize-space(.) != '' and ((not($checklist) and not(@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para) and (@caveat='cv02' or not(preceding-sibling::para))) or ($checklist and not(@caveat='cv02') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)))]]" level="multiple"/>
    </xsl:template>     
    <xsl:template match="step2" mode="numbering-xref">
        <xsl:param name="checklist" select="false()"/>
        <xsl:number format="1,a" count="*[self::step1 | self::step2][para[normalize-space(.) != '' and ((not($checklist) and not(@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para) and (@caveat='cv02' or not(preceding-sibling::para))) or ($checklist and not(@caveat='cv02') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)))]]" level="multiple"/>
    </xsl:template> 
    <xsl:template match="step3" mode="numbering-xref">
        <xsl:param name="checklist" select="false()"/>
        <xsl:number format="1,a(1)" count="*[self::step1 | self::step2 | self::step3][para[normalize-space(.) != '' and ((not($checklist) and not(@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para) and (@caveat='cv02' or not(preceding-sibling::para))) or ($checklist and not(@caveat='cv02') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)))]]" level="multiple"/>
    </xsl:template> 
    <xsl:template match="step4" mode="numbering-xref">
        <xsl:param name="checklist" select="false()"/>
        <xsl:number format="1,a(1)(a)" count="*[self::step1 | self::step2 | self::step3 | self::step4][para[normalize-space(.) != '' and ((not($checklist) and not(@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para) and (@caveat='cv02' or not(preceding-sibling::para))) or ($checklist and not(@caveat='cv02') and (@caveat='cv03' or @caveat='cv07' or @caveat='ck' or preceding-sibling::para)))]]" level="multiple"/>
    </xsl:template> 
    



	<!-- ********************************************************************
		 $Id: table.xsl,v 1.30 2003/08/27 23:58:14 nwalsh Exp $
		 ********************************************************************

		 This file is part of the XSL DocBook Stylesheet distribution.
		 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
		 and other information.

		 ******************************************************************** -->

	<xsl:variable name="table.cell.border.color" select="''"/>
	<xsl:variable name="table.cell.border.style" select="'solid'"/>
	<xsl:variable name="table.cell.border.thickness" select="'0.5pt'"/>
	<xsl:variable name="entry.propagates.style" select="1"/>

	<xsl:variable name="cellspacing">0</xsl:variable>
	<xsl:variable name="cellpadding">5</xsl:variable>
	<xsl:variable name="table.borders.with.css" select="1"/>
	<xsl:variable name="default.table.width">80%</xsl:variable>


	<!---->
	<!---->
	<!---->
	<!---->
	<!---->

	<xsl:template name="copy-string">
		<!-- returns 'count' copies of 'string' -->
		<xsl:param name="string"/>
		<xsl:param name="count" select="0"/>
		<xsl:param name="result"/>

		<xsl:choose>
			<xsl:when test="$count&gt;0">
				<xsl:call-template name="copy-string">
					<xsl:with-param name="string" select="$string"/>
					<xsl:with-param name="count" select="$count - 1"/>
					<xsl:with-param name="result" select="concat($result, $string)"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="$result"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="count-columns">
		<xsl:param name="table" select="."/>
		<xsl:param name="rows" select="$table//row | $table//caprow"/>
		<xsl:param name="cols" select="0"/>
		<xsl:variable name="entries" select="count($rows[1]/entry | $rows[1]/capentry)"/>

		<xsl:choose>
			<xsl:when test="not($rows)"><xsl:value-of select="$cols"/></xsl:when>
			<xsl:when test="$entries &gt; $cols">
				<xsl:call-template name="count-columns">
					<xsl:with-param name="rows" select="$rows[position()&gt;1]"/>
					<xsl:with-param name="cols" select="$entries"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="count-columns">
					<xsl:with-param name="rows" select="$rows[position()&gt;1]"/>
					<xsl:with-param name="cols" select="$cols"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="blank.spans">
		<xsl:param name="cols" select="1"/>
		<xsl:param name="columns">
			<xsl:choose>
				<xsl:when test="not($cols) or $cols &lt; 1">
					<xsl:call-template name="count-columns">
						<xsl:with-param name="table" select=".."/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$cols"/></xsl:otherwise>
			</xsl:choose>
		</xsl:param>
		<xsl:if test="$columns &gt; 0">
			<xsl:text>0:</xsl:text>
			<xsl:call-template name="blank.spans">
				<xsl:with-param name="columns" select="$columns - 1"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<xsl:template name="calculate.following.spans">
		<xsl:param name="colspan" select="1"/>
		<xsl:param name="spans" select="''"/>

		<xsl:choose>
			<xsl:when test="$colspan &gt; 0">
				<xsl:call-template name="calculate.following.spans">
					<xsl:with-param name="colspan" select="$colspan - 1"/>
					<xsl:with-param name="spans" select="substring-after($spans,':')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$spans"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="finaltd">
		<xsl:param name="spans"/>
		<xsl:param name="col" select="0"/>
		<xsl:param name="colspec" select="/.."/>

		<xsl:if test="$spans != ''">
			<xsl:if test="starts-with($spans,'0:')">
				<xsl:call-template name="empty.table.cell">
					<xsl:with-param name="colnum" select="$col"/>
					<xsl:with-param name="colspec" select="$colspec"/>
				</xsl:call-template>
			</xsl:if>

			<xsl:call-template name="finaltd">
				<xsl:with-param name="spans" select="substring-after($spans,':')"/>
				<xsl:with-param name="col" select="$col+1"/>
				<xsl:with-param name="colspec" select="$colspec"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<xsl:template name="sfinaltd">
		<xsl:param name="spans"/>

		<xsl:if test="$spans != ''">
			<xsl:choose>
				<xsl:when test="starts-with($spans,'0:')">0:</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="substring-before($spans,':')-1"/>
					<xsl:text>:</xsl:text>
				</xsl:otherwise>
			</xsl:choose>

			<xsl:call-template name="sfinaltd">
				<xsl:with-param name="spans" select="substring-after($spans,':')"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<xsl:template name="entry.colnum">
		<xsl:param name="entry" select="."/>

		<xsl:choose>
			<xsl:when test="$entry/@spanname">
				<xsl:variable name="spanname" select="$entry/@spanname"/>
				<xsl:variable name="spanspec"
											select="($entry/ancestor::tgroup/spanspec[@spanname=$spanname] |
															 $entry/ancestor::capgrp/spanspec[@spanname=$spanname])[last()]"/>
				<xsl:variable name="colspec"
											select="($entry/ancestor::tgroup/colspec[@colname=$spanspec/@namest] |
															 $entry/ancestor::capgrp/colspec[@colname=$spanspec/@namest])[last()]"/>
				<xsl:call-template name="colspec.colnum">
					<xsl:with-param name="colspec" select="$colspec"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$entry/@colname">
				<xsl:variable name="colname" select="$entry/@colname"/>
				<xsl:variable name="colspec"
											select="($entry/ancestor::tgroup/colspec[@colname=$colname] |
															 $entry/ancestor::capgrp/colspec[@colname=$colname])[last()]"/>
				<xsl:call-template name="colspec.colnum">
					<xsl:with-param name="colspec" select="$colspec"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$entry/@namest">
				<xsl:variable name="namest" select="$entry/@namest"/>
				<xsl:variable name="colspec"
											select="($entry/ancestor::tgroup/colspec[@colname=$namest] |
															 $entry/ancestor::capgrp/colspec[@colname=$namest])[last()]"/>
				<xsl:call-template name="colspec.colnum">
					<xsl:with-param name="colspec" select="$colspec"/>
				</xsl:call-template>
			</xsl:when>
			<!-- no idea, return 0 -->
			<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="colspec.colnum">
		<xsl:param name="colspec" select="."/>
		<xsl:param name="coladd" select="0"/>
		<xsl:choose>
			<xsl:when test="$colspec/@colnum">
				<xsl:value-of select="$colspec/@colnum + $coladd"/>
			</xsl:when>
			<xsl:when test="$colspec/preceding-sibling::colspec">
				<xsl:call-template name="colspec.colnum">
					<xsl:with-param name="colspec" select="$colspec/preceding-sibling::colspec[1]"/>
					<xsl:with-param name="coladd" select="$coladd + 1"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="1 + $coladd"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="calculate.colspan">
		<xsl:param name="entry" select="."/>
		<xsl:variable name="spanname" select="$entry/@spanname"/>
		<xsl:variable name="spanspec"
									select="($entry/ancestor::tgroup/spanspec[@spanname=$spanname] |
													 $entry/ancestor::capgrp/spanspec[@spanname=$spanname])[last()]"/>

		<xsl:variable name="namest">
			<xsl:choose>
				<xsl:when test="@spanname"><xsl:value-of select="$spanspec/@namest"/></xsl:when>
				<xsl:otherwise><xsl:value-of select="$entry/@namest"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="nameend">
			<xsl:choose>
				<xsl:when test="@spanname"><xsl:value-of select="$spanspec/@nameend"/></xsl:when>
				<xsl:otherwise><xsl:value-of select="$entry/@nameend"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="scol">
			<xsl:call-template name="colspec.colnum">
				<xsl:with-param name="colspec"
												select="($entry/ancestor::tgroup/colspec[@colname=$namest] |
																 $entry/ancestor::capgrp/colspec[@colname=$namest])[last()]"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="ecol">
			<xsl:call-template name="colspec.colnum">
				<xsl:with-param name="colspec"
												select="($entry/ancestor::tgroup/colspec[@colname=$nameend] |
																 $entry/ancestor::capgrp/colspec[@colname=$nameend])[last()]"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$namest != '' and $nameend != ''">
				<xsl:choose>
					<xsl:when test="number($ecol) &gt;= number($scol)">
						<xsl:value-of select="number($ecol) - number($scol) + 1"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="number($scol) - number($ecol) + 1"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>1</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="inherited.table.attribute">
		<xsl:param name="entry" select="."/>
		<xsl:param name="row" select="($entry/ancestor-or-self::row |
																	 $entry/ancestor-or-self::caprow)[last()]"/>
		<xsl:param name="colnum" select="1"/>
		<xsl:param name="colspec" select="/.."/>
		<xsl:param name="attribute" select="'colsep'"/>

		<xsl:variable name="tgroup" select="($row/ancestor::tgroup|$row/ancestor::capgrp)[last()]"/>
		<xsl:variable name="tbody" select="$row/parent::*[1]"/>

		<xsl:variable name="table" select="($tgroup/ancestor::table |
																				$entry/ancestor::capgrp)[last()]"/>

		<xsl:variable name="specs" select="$tgroup/colspec[not($colspec)]"/>
		<xsl:variable name="c1" select="$specs[@colnum=$colnum]"/>
		<xsl:variable name="c2" select="$specs[not($c1) and
																					 preceding-sibling::colspec[@colnum][1]/@colnum +
																					 count(preceding-sibling::colspec[@colnum][1]/
																								 following-sibling::colspec) -
																					 count(following-sibling::colspec) = $colnum][1]"/>
		<xsl:variable name="col" select="$colspec | $c1 | $c2 | $specs[not($c2)][number($colnum)]"/>

		<xsl:variable name="entry.value">
			<xsl:value-of select="$entry/@*[local-name(.) = $attribute]"/>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$entry.value != ''">
				<xsl:value-of select="$entry.value"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="row.value">
					<xsl:value-of select="$row/@*[local-name(.) = $attribute]"/>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$row.value != ''">
						<xsl:value-of select="$row.value"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:variable name="span.value">
							<xsl:if test="$entry/@spanname">
								<xsl:variable name="spanname" select="$entry/@spanname"/>
								<xsl:variable name="spanspec" select="$tgroup/spanspec[@spanname=$spanname]"/>
								<xsl:variable name="spanspec.value">
									<xsl:value-of select="$spanspec/@*[local-name(.) = $attribute]"/>
								</xsl:variable>
								<xsl:choose>
									<xsl:when test="$spanspec.value != ''">
										<xsl:value-of select="$spanspec.value"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:variable name="span.colspec"
																	select="$tgroup/colspec[@colname=$spanspec/@namest]"/>
										<xsl:value-of select="$span.colspec/@*[local-name(.) = $attribute]"/>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:if>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$span.value != ''">
								<xsl:value-of select="$span.value"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:variable name="namest.value">
									<xsl:if test="$entry/@namest">
										<xsl:variable name="namest" select="$entry/@namest"/>
										<xsl:variable name="name.colspec" select="$tgroup/colspec[@colname=$namest]"/>
										<xsl:value-of select="$name.colspec/@*[local-name(.) = $attribute]"/>
									</xsl:if>
								</xsl:variable>
								<xsl:choose>
									<xsl:when test="$namest.value != ''">
										<xsl:value-of select="$namest.value"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:variable name="col.value">
											<xsl:value-of select="$col/@*[local-name(.) = $attribute]"/>
										</xsl:variable>
										<xsl:choose>
											<xsl:when test="$col.value != ''">
												<xsl:value-of select="$col.value"/>
											</xsl:when>
											<xsl:otherwise>
												<xsl:variable name="tbody.value">
													<xsl:value-of select="$tbody/@*[local-name(.) = $attribute]"/>
												</xsl:variable>
												<xsl:choose>
													<xsl:when test="$tbody.value != ''">
														<xsl:value-of select="$tbody.value"/>
													</xsl:when>
													<xsl:otherwise>
														<xsl:variable name="tgroup.value">
															<xsl:value-of select="$tgroup/@*[local-name(.) = $attribute]"/>
														</xsl:variable>
														<xsl:choose>
															<xsl:when test="$tgroup.value != ''">
																<xsl:value-of select="$tgroup.value"/>
															</xsl:when>
															<xsl:otherwise>
																<xsl:variable name="table.value">
																	<xsl:value-of select="$table/@*[local-name(.) = $attribute]"/>
																</xsl:variable>
																<xsl:choose>
																	<xsl:when test="$table.value != ''">
																		<xsl:value-of select="$table.value"/>
																	</xsl:when>
																	<xsl:otherwise>
																		<!-- This section used to say that rowsep and colsep   -->
																		<!-- have defaults based on the frame setting. Further -->
																		<!-- reflection and closer examination of the CALS     -->
																		<!-- spec reveals I was mistaken. The default is "1"   -->
																		<!-- for rowsep and colsep. For everything else, the   -->
																		<!-- default is the tgroup value.                      -->
																		<xsl:choose>
																			<xsl:when test="$tgroup.value != ''">
																				<xsl:value-of select="$tgroup.value"/>
																			</xsl:when>
																			<xsl:when test="$attribute = 'rowsep'">1</xsl:when>
																			<xsl:when test="$attribute = 'colsep'">1</xsl:when>
																			<xsl:otherwise><!-- empty --></xsl:otherwise>
																		</xsl:choose>
																	</xsl:otherwise>
																</xsl:choose>
															</xsl:otherwise>
														</xsl:choose>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="table-frame">
		<xsl:param name="frame" select="../@frame"/>
		<xsl:param name="doTop" select="$frame='all' or $frame='topbot' or $frame='top'"/>
		<xsl:param name="doBottom" select="$frame='all' or $frame='topbot' or $frame='bottom'"/>
		<xsl:param name="doSides" select="$frame='all' or $frame='sides'"/>
		<xsl:call-template name="border">
			<xsl:with-param name="side" select="'top'"/>
			<xsl:with-param name="show" select="$doTop"/>
		</xsl:call-template>
		<xsl:call-template name="border">
			<xsl:with-param name="side" select="'bottom'"/>
			<xsl:with-param name="show" select="$doBottom"/>
		</xsl:call-template>
		<xsl:call-template name="border">
			<xsl:with-param name="side" select="'left'"/>
			<xsl:with-param name="show" select="$doSides"/>
		</xsl:call-template>
		<xsl:call-template name="border">
			<xsl:with-param name="side" select="'right'"/>
			<xsl:with-param name="show" select="$doSides"/>
		</xsl:call-template>
	</xsl:template>

	<!-- Return the ordinal position of the colspec for the given column (0 = not found) -->
	<xsl:template name="col.colspecnum">
		<xsl:param name="col" select="0"/>
		<xsl:param name="colspec.ancestor" select="(ancestor::tgroup|ancestor::capgrp)[last()]"/>
		<xsl:param name="colspecs" select="$colspec.ancestor/colspec"/>
		<xsl:param name="colspec" select="1"/>
		<xsl:param name="colnum" select="1"/>

		<xsl:choose>
			<xsl:when test="$colspec &gt; count($colspecs)">0</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="spec" select="$colspecs[$colspec]"/>
				<xsl:variable name="specnum">
					<xsl:choose>
						<xsl:when test="$spec/@colnum"><xsl:value-of select="$spec/@colnum"/></xsl:when>
						<xsl:otherwise><xsl:value-of select="$colnum"/></xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$specnum = $col"><xsl:value-of select="$colspec"/></xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="col.colspecnum">
							<xsl:with-param name="col" select="$col"/>
							<xsl:with-param name="colspec.ancestor" select="$colspec.ancestor"/>
							<xsl:with-param name="colspecs" select="$colspecs"/>
							<xsl:with-param name="colspec" select="$colspec + 1"/>
							<xsl:with-param name="colnum" select="$specnum + 1"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="table-column-width">
		<xsl:param name="colwidth" select="'1*'"/>

		<!-- Colwidth: ([0-9]+(.[0-9]+)?)?\*([-+][0-9]+(\.[0-9]+)?[a-z]*)? -->
		<!--           ^ proportional width ^ fixed width         ^ unit   -->
		<!--			 or: [-+]?[0-9]+(\.[0-9]+)?[a-z]*                        -->
		<!--           ^ fixed width         ^ unit (default = pt)         -->
		<!-- proportional width of "*" is the same as "1*"                 -->
		<!-- examples: 1*  *  2.2in  3.4*+5.6in  7.8*-9  *+1               -->

		<!-- Translate proportional width to XSL-FO notation -->
		<xsl:if test="contains($colwidth, '*')">
			<xsl:text>proportional-column-width(</xsl:text>
			<xsl:choose>
				<xsl:when test="substring-before($colwidth, '*')">
					<xsl:value-of select="substring-before($colwidth, '*')"/>
				</xsl:when>
				<xsl:otherwise>1</xsl:otherwise>
			</xsl:choose>
			<xsl:text>)</xsl:text>
		</xsl:if>

		<!-- Parse and translate the fixed width, if present -->
		<xsl:variable name="fixed">
			<xsl:choose>
				<xsl:when test="contains($colwidth, '*')">
					<xsl:value-of select="normalize-space(substring-after($colwidth, '*'))"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="normalize-space($colwidth)"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="width" select="normalize-space(translate($fixed, $lower, ''))"/>
		<xsl:variable name="units" select="normalize-space(translate($fixed, '+-0123456789.', ''))"/>
		<xsl:value-of select="$width"/>
		<xsl:choose>
			<xsl:when test="$units = 'pi'">pc</xsl:when>
			<xsl:when test="$units = '' and $width != ''">pt</xsl:when>
			<xsl:otherwise><xsl:value-of select="$units"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="table-columns">
		<xsl:param name="cols" select="@cols"/>
		<xsl:param name="columns">
			<xsl:choose>
				<xsl:when test="not($cols) or $cols &lt; 1">
					<xsl:call-template name="count-columns"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$cols"/></xsl:otherwise>
			</xsl:choose>
		</xsl:param>
		<xsl:param name="col" select="1"/>
		<xsl:param name="colspecs" select="colspec"/>
		<xsl:param name="fixed" select="$colspecs[not(string(@colwidth)) or contains(@colwidth, '*')]"/>

		<xsl:if test="$col &lt;= $columns">
			<xsl:variable name="colspecnum">
				<xsl:call-template name="col.colspecnum">
					<xsl:with-param name="col" select="$col"/>
					<xsl:with-param name="colspec.ancestor" select="/.."/>
					<xsl:with-param name="colspecs" select="$colspecs"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:variable name="colspec" select="number($colspecnum)"/>
			<xsl:call-template name="output-table-column">
				<xsl:with-param name="num" select="$col"/>
				<xsl:with-param name="width">
					<xsl:call-template name="table-column-width">
						<xsl:with-param name="colwidth">
							<xsl:choose>
								<xsl:when test="$colspec &gt; 0 and string($colspecs[$colspec]/@colwidth)">
									<xsl:value-of select="$colspecs[$colspec]/@colwidth"/>
								</xsl:when>
								<xsl:otherwise>1*</xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
					</xsl:call-template>
				</xsl:with-param>
				<xsl:with-param name="fixed" select="$fixed"/>
				<xsl:with-param name="align">
					<xsl:variable name="grp" select="($colspecs/ancestor::tgroup|$colspecs/ancestor::capgroup)[last()]"/>
					<xsl:choose>
						<xsl:when test="$colspecs[$colspec]/@align">
							<xsl:value-of select="$colspecs[$colspec]/@align"/>
						</xsl:when>
						<xsl:when test="$grp/@align"><xsl:value-of select="$grp/@align"/></xsl:when>
					</xsl:choose>
				</xsl:with-param>
				<xsl:with-param name="char" select="$colspecs[$colspec]/@char"/>
				<xsl:with-param name="charoff" select="$colspecs[$colspec]/@charoff"/>
			</xsl:call-template>
			<xsl:call-template name="table-columns">
				<xsl:with-param name="columns" select="$columns"/>
				<xsl:with-param name="col" select="$col + 1"/>
				<xsl:with-param name="colspecs" select="$colspecs"/>
				<xsl:with-param name="fixed" select="$fixed"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<!---->
	<!---->
	<!---->
	<!---->
	<!---->

	<xsl:template name="output-table-column">
		<xsl:param name="num" select="0"/>
		<xsl:param name="width" select="''"/>
		<xsl:param name="fixed" select="false()"/>
		<xsl:param name="align" select="''"/>
		<xsl:param name="char" select="''"/>
		<xsl:param name="charoff" select="''"/>
		<col>
			<xsl:choose>
				<xsl:when test="starts-with($width, 'proportional-column-width(')">
					<xsl:variable name="before-width" select="substring-before($width, ')')"/>
					<xsl:variable name="prop-width" select="substring-after($before-width, '(')"/>
					<xsl:variable name="after-width" select="substring-after($width, ')')"/>
					<xsl:attribute name="width">
						<xsl:value-of select="concat(round(1000 * $prop-width), '*', $after-width)"/>
					</xsl:attribute>
				</xsl:when>
				<xsl:when test="$width != ''">
					<xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
				</xsl:when>
			</xsl:choose>
			<xsl:if test="$align != ''">
				<xsl:attribute name="align"><xsl:value-of select="$align"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="$char != ''">
				<xsl:attribute name="char"><xsl:value-of select="$char"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="$charoff != ''">
				<xsl:attribute name="charoff"><xsl:value-of select="$charoff"/></xsl:attribute>
			</xsl:if>
		</col>
	</xsl:template>

	<xsl:template name="border">
		<xsl:param name="side" select="''"/>
		<xsl:param name="show" select="true()"/>
		<xsl:variable name="style" select="concat('border-', $side, '-style')"/>
		<xsl:variable name="width" select="concat('border-', $side, '-width')"/>
		<xsl:variable name="color" select="concat('border-', $side, '-color')"/>

		<!-- Note: Some browsers (mozilla) require at least a width and style. -->

		<xsl:choose>
			<xsl:when test="not($show)"/>
			<xsl:when test="$table.cell.border.thickness != ''">
				<!-- Logically equivalent to previous:
											($table.cell.border.thickness != '' and
											 $table.cell.border.style != '' and $table.cell.border.color != '') or
											($table.cell.border.thickness != '' and $table.cell.border.style != '') or
											($table.cell.border.thickness != '') -->
				<!-- use the compound property if we can: -->
				<!-- it saves space and probably works more reliably -->
				<xsl:value-of select="concat('border-', $side, ': ')"/>
				<xsl:value-of select="concat($table.cell.border.thickness, ' ')"/>
				<xsl:value-of select="concat($table.cell.border.style, ' ')"/>
				<xsl:value-of select="concat($table.cell.border.color, '; ')"/>
			</xsl:when>
			<xsl:otherwise>
				<!-- we need to specify the styles individually -->
				<xsl:if test="$table.cell.border.thickness != ''">
					<xsl:value-of select="concat($width, ': ', $table.cell.border.thickness, '; ')"/>
				</xsl:if>
				<xsl:if test="$table.cell.border.style != ''">
					<xsl:value-of select="concat($style, ': ', $table.cell.border.style, '; ')"/>
				</xsl:if>
				<xsl:if test="$table.cell.border.color != ''">
					<xsl:value-of select="concat($color, ': ', $table.cell.border.color, '; ')"/>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- ==================================================================== -->

	<!-- ==================================================================== -->

	<xsl:template name="tablecaveats">
		<xsl:variable name="caveat" select="translate( string(@caveat), $upper, $lower)"/>
		<xsl:choose>
			<!-- by caveat -->
			<xsl:when test="@caveat='cv02'">
				<span title="FullProcedure">
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="@caveat='cv03'">
				<span title="Checklist">
					<xsl:apply-templates/>
				</span>
			</xsl:when>

			<!-- included for backwards compatablity  -->
			<xsl:when test="@caveat='cv07'">
				<span title="Checklist">
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="@caveat='ck'">
				<span title="Checklist">
					<xsl:apply-templates/>
				</span>
			</xsl:when>

			<!-- All Others... -->
			<xsl:otherwise>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- ==================================================================== -->

	<!--
		ISSUES
		...............
		1. No titles on hazmat tables. 
		2. We don't want hazmat tables to be included in the "Table 1. " count
		3. We are determining a table as being a "hazmat" table if:
		a. a hazmat symbol appears in the first entry in the first row of the table
		b. hazmat symbols are:
		- chemical
		- esds
		- explosive
		- fire
		- goggles 
		- poison
		- vapor

		DECISIONS:
		...............
		1. Table titles are only printed if it's not a hazmat table
		2. Table number in table title subtracts the # of hazmat tables
	-->

	<xsl:template match="table" mode="hazardcount">
		<xsl:param name="count"/>
		<xsl:variable name="symbol1" select="descendant::entry[1]/symbol[1]"/>
		<xsl:variable name="boardno" select="string($symbol1/@boardno)"/>
		<xsl:variable name="fileref" select="string($symbol1/@fileref)"/>
		<xsl:choose>
			<xsl:when test="count(following::table)>0">
				<xsl:choose>
					<xsl:when test="contains($boardno,'chemical')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($boardno,'esds')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($boardno,'explosive')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($boardno,'fire')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($boardno,'goggles')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($boardno,'poison')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($boardno,'vapor')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>

					<xsl:when test="contains($fileref,'chemical')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($fileref,'esds')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($fileref,'explosive')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($fileref,'fire')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($fileref,'goggles')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($fileref,'poison')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="contains($fileref,'vapor')">
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="1+$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select="following::table[1]" mode="hazardcount">
							<xsl:with-param name="count">
								<xsl:value-of select="$count"/>
							</xsl:with-param>
						</xsl:apply-templates>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$count"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="table/title"/>

	<!-- see hazmat note above -->
	<xsl:template name="tabletitle">
			<center>
				<h4 class="ital">
					<xsl:text>Table&#160;</xsl:text><xsl:number count="table[not(@tabstyle='haz' or @caveat='cv52')]" from="dmodule" level="any"/>
					<xsl:text>.</xsl:text>
					<xsl:if test="../title">&#160;<xsl:value-of select="../title/text()"/></xsl:if>
				</h4>
			</center>
	</xsl:template>

	<!-- ==================================================================== -->




	<xsl:template match="tgroup" name="tgroup">
		<xsl:variable name="chapnum" select="number(//dmodule/idstatus/dmaddres/dmc/avee/chapnum)"/>
		<xsl:variable name="secnum" select="number(//dmodule/idstatus/dmaddres/dmc/avee/section)"/>
		<xsl:variable name="symbol1" select="descendant::entry[1]/symbol[1]"/>
		<xsl:variable name="boardno" select="string($symbol1/@boardno)"/>
		<xsl:variable name="fileref" select="string($symbol1/@fileref)"/>

		<xsl:choose>
			<!-- see hazmat note above -->
			<xsl:when test="contains($boardno,'chemical')"/>
			<xsl:when test="contains($boardno,'esds')"/>
			<xsl:when test="contains($boardno,'explosive')"/>
			<xsl:when test="contains($boardno,'fire')"/>
			<xsl:when test="contains($boardno,'goggles')"/>
			<xsl:when test="contains($boardno,'poison')"/>
			<xsl:when test="contains($boardno,'vapor')"/>

			<!-- boardno gets ripped out and replaced by fileref: AND its the full value -->
			<xsl:when test="contains($fileref,'chemical')"/>
			<xsl:when test="contains($fileref,'esds')"/>
			<xsl:when test="contains($fileref,'explosive')"/>
			<xsl:when test="contains($fileref,'fire')"/>
			<xsl:when test="contains($fileref,'goggles')"/>
			<xsl:when test="contains($fileref,'poison')"/>
			<xsl:when test="contains($fileref,'vapor')"/>

			<xsl:when test="ancestor-or-self::table[@caveat='cv52']"/>

			<xsl:when test="ancestor-or-self::table[not(title)]/ancestor::frc"/>
			
			<!-- when chapnum and secnum are 0, no table titles -->
			<xsl:when test="$chapnum &lt; 1">
				<xsl:choose>
					<!-- when chapnum and secnum are 0, no table titles -->
					<xsl:when test="$secnum &lt; 1"/>

					<!-- see hazmat note above -->
					<xsl:when test="contains($boardno,'chemical')"/>
					<xsl:when test="contains($boardno,'esds')"/>
					<xsl:when test="contains($boardno,'explosive')"/>
					<xsl:when test="contains($boardno,'fire')"/>
					<xsl:when test="contains($boardno,'goggles')"/>
					<xsl:when test="contains($boardno,'poison')"/>
					<xsl:when test="contains($boardno,'vapor')"/>

					<!-- boardno gets ripped out and replaced by fileref: AND its the full value -->
					<xsl:when test="contains($fileref,'chemical')"/>
					<xsl:when test="contains($fileref,'esds')"/>
					<xsl:when test="contains($fileref,'explosive')"/>
					<xsl:when test="contains($fileref,'fire')"/>
					<xsl:when test="contains($fileref,'goggles')"/>
					<xsl:when test="contains($fileref,'poison')"/>
					<xsl:when test="contains($fileref,'vapor')"/>
					
					<xsl:otherwise>
						<xsl:call-template name="tabletitle"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="tabletitle"/>
			</xsl:otherwise>
		</xsl:choose>


		<table>
			<xsl:if test="string(../@id)">
				<xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
			</xsl:if>
		    
			<xsl:if test="../@tabstyle = 'haz'">
				<xsl:attribute name="class">hazmat</xsl:attribute>
			</xsl:if>
			<xsl:if test="not(../@tabstyle = 'haz')">
				<xsl:attribute name="class">float-header</xsl:attribute>
			</xsl:if>
		    
			<xsl:if test="$cellspacing != ''">
				<xsl:attribute name="cellspacing">
					<xsl:value-of select="$cellspacing"/>
				</xsl:attribute>
			</xsl:if>

			<xsl:if test="$cellpadding != ''">
				<xsl:attribute name="cellpadding">
					<xsl:value-of select="$cellpadding"/>
				</xsl:attribute>
			</xsl:if>

			<xsl:if test="../@pgwide=1">
				<xsl:attribute name="width">100%</xsl:attribute>
			</xsl:if>

			<xsl:variable name="css.borders" select="$table.borders.with.css != 0"/>
			<xsl:attribute name="border">
				<xsl:value-of select="number(not($css.borders or ../@frame = 'none' or self::entrytbl))"/>
			</xsl:attribute>
			<xsl:if test="$css.borders">
				<xsl:attribute name="style">
					<xsl:text>border-collapse: collapse;</xsl:text>
					<xsl:call-template name="table-frame"/>
				</xsl:attribute>
			</xsl:if>

			<xsl:variable name="colgroup">
				<xsl:call-template name="table-columns"/>
				<!--
				<colgroup>
				</colgroup>
				-->
			</xsl:variable>

			<xsl:variable name="table.width"><xsl:text>80%</xsl:text></xsl:variable>

			<xsl:if test="$default.table.width != ''">
				<xsl:attribute name="width">
					<xsl:choose>
						<xsl:when test="contains($table.width, '%')">
							<xsl:value-of select="$table.width"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="$table.width"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
			</xsl:if>

			<xsl:copy-of select="$colgroup"/>

			<xsl:apply-templates select="thead"/>
			<xsl:apply-templates select="tfoot"/>
			<xsl:apply-templates select="tbody"/>

			<xsl:if test=".//footnote">
				<tbody class="footnotes">
					<tr>
						<td colspan="{@cols}">[z]
							<xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
						</td>
					</tr>
				</tbody>
			</xsl:if>
		</table>

		<xsl:if test=".//ftnote[not(@caveat='cv55')]">
			<table width="{80 + 20 * boolean(../@pgwide = 1)}%" border="0">
				<col width="36pt"/><col/>
				<tbody>
					<xsl:for-each select=".//ftnote[not(@caveat='cv55')]">
						<tr>
							<xsl:if test="@id">
								<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
							</xsl:if>
							<td valign="top"><sup><xsl:apply-templates select="." mode="number"/></sup></td>
							<td valign="top"><xsl:apply-templates/></td>
						</tr>
					</xsl:for-each>
				</tbody>
			</table>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="table//ftnote/para[1]">
		<p style="padding-top: 0px; margin-top: 0px;"><xsl:apply-templates/></p>
	</xsl:template>

	<xsl:template match="tgroup/processing-instruction('dbhtml')"/>

	<xsl:template match="colspec"/>

	<xsl:template match="spanspec"/>

	<xsl:template match="thead|tfoot">
		<xsl:element name="{name(.)}">
			<xsl:if test="@align">
				<xsl:attribute name="align">
					<xsl:value-of select="@align"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@char">
				<xsl:attribute name="char">
					<xsl:value-of select="@char"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@charoff">
				<xsl:attribute name="charoff">
					<xsl:value-of select="@charoff"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@valign">
				<xsl:attribute name="valign">
					<xsl:value-of select="@valign"/>
				</xsl:attribute>
			</xsl:if>

			<xsl:apply-templates select="row[1]">
				<xsl:with-param name="spans">
					<xsl:call-template name="blank.spans">
						<xsl:with-param name="cols" select="../@cols"/>
					</xsl:call-template>
				</xsl:with-param>
			</xsl:apply-templates>

		</xsl:element>
	</xsl:template>

	<xsl:template match="tbody">
		<tbody>
			<xsl:if test="@align">
				<xsl:attribute name="align">
					<xsl:value-of select="@align"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@char">
				<xsl:attribute name="char">
					<xsl:value-of select="@char"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@charoff">
				<xsl:attribute name="charoff">
					<xsl:value-of select="@charoff"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@valign">
				<xsl:attribute name="valign">
					<xsl:value-of select="@valign"/>
				</xsl:attribute>
			</xsl:if>

			<xsl:apply-templates select="row[1]">
				<xsl:with-param name="spans">
					<xsl:call-template name="blank.spans">
						<xsl:with-param name="cols" select="../@cols"/>
					</xsl:call-template>
				</xsl:with-param>
			</xsl:apply-templates>

		</tbody>
	</xsl:template>

	<xsl:template match="row">
		<xsl:param name="spans"/>

		<xsl:variable name="row-height"/>

		<tr>
			   		<xsl:choose>
				<xsl:when test="@change='add' and not($no-change-markings)">
					<xsl:attribute name="class">add</xsl:attribute>
				</xsl:when>
				<xsl:when test="@change='modify' and not($no-change-markings)">
					<xsl:attribute name="class">modify</xsl:attribute>
				</xsl:when>
				<xsl:when test="@change='delete' and not($no-change-markings)">
					<xsl:attribute name="class">delete</xsl:attribute>
				</xsl:when>
			</xsl:choose>
			<xsl:if test="@rfc">
				<xsl:attribute name="title"><xsl:value-of select="@rfc"/></xsl:attribute>   
			</xsl:if>

			<xsl:call-template name="tr.attributes">
				<xsl:with-param name="rownum">
					<xsl:number from="tgroup" count="row"/>
				</xsl:with-param>
			</xsl:call-template>

			<xsl:if test="$row-height != ''">
				<xsl:attribute name="height">
					<xsl:value-of select="$row-height"/>
				</xsl:attribute>
			</xsl:if>

			<xsl:if test="@rowsep = 1 and following-sibling::row">
				<xsl:attribute name="style">
					<xsl:call-template name="border">
						<xsl:with-param name="side" select="'bottom'"/>
					</xsl:call-template>
				</xsl:attribute>
			</xsl:if>

			<xsl:if test="@align">
				<xsl:attribute name="align">
					<xsl:value-of select="@align"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@char">
				<xsl:attribute name="char">
					<xsl:value-of select="@char"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@charoff">
				<xsl:attribute name="charoff">
					<xsl:value-of select="@charoff"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@valign">
				<xsl:attribute name="valign">
					<xsl:value-of select="@valign"/>
				</xsl:attribute>
			</xsl:if>

			<xsl:apply-templates select="(entry|entrytbl)[1]">
				<xsl:with-param name="spans" select="$spans"/>
			</xsl:apply-templates>
		</tr>

		<xsl:if test="following-sibling::row">
			<xsl:variable name="nextspans">
				<xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">
					<xsl:with-param name="spans" select="$spans"/>
				</xsl:apply-templates>
			</xsl:variable>

			<xsl:apply-templates select="following-sibling::row[1]">
				<xsl:with-param name="spans" select="$nextspans"/>
			</xsl:apply-templates>
		</xsl:if>
	</xsl:template>

	<xsl:template match="entry|entrytbl" name="entry">
		<xsl:param name="col" select="1"/>
		<xsl:param name="spans"/>

		<xsl:variable name="cellgi">
			<xsl:choose>
				<xsl:when test="ancestor::thead">th</xsl:when>
				<xsl:when test="ancestor::tfoot">th</xsl:when>
				<xsl:otherwise>td</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="empty.cell" select="count(node()) = 0"/>

		<xsl:variable name="named.colnum">
			<xsl:call-template name="entry.colnum"/>
		</xsl:variable>

		<xsl:variable name="entry.colnum">
			<xsl:choose>
				<xsl:when test="$named.colnum &gt; 0">
					<xsl:value-of select="$named.colnum"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$col"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="entry.colspan">
			<xsl:choose>
				<xsl:when test="@spanname or @namest">
					<xsl:call-template name="calculate.colspan"/>
				</xsl:when>
				<xsl:otherwise>1</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="following.spans">
			<xsl:call-template name="calculate.following.spans">
				<xsl:with-param name="colspan" select="$entry.colspan"/>
				<xsl:with-param name="spans" select="$spans"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="rowsep">
			<xsl:choose>
				<!-- If this is the last row, rowsep never applies. -->
				<xsl:when
					test="ancestor::entrytbl
											and not (ancestor-or-self::row[1]/following-sibling::row)">
					<xsl:value-of select="0"/>
				</xsl:when>
				<xsl:when
					test="not(ancestor-or-self::row[1]/following-sibling::row
													or ancestor-or-self::thead/following-sibling::tbody
													or ancestor-or-self::tbody/preceding-sibling::tfoot)">
					<xsl:value-of select="0"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="inherited.table.attribute">
						<xsl:with-param name="entry" select="."/>
						<xsl:with-param name="colnum" select="$entry.colnum"/>
						<xsl:with-param name="attribute" select="'rowsep'"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="colsep">
			<xsl:choose>
				<!-- If this is the last column, colsep never applies. -->
				<xsl:when test="$following.spans = ''">0</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="inherited.table.attribute">
						<xsl:with-param name="entry" select="."/>
						<xsl:with-param name="colnum" select="$entry.colnum"/>
						<xsl:with-param name="attribute" select="'colsep'"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="valign">
			<xsl:call-template name="inherited.table.attribute">
				<xsl:with-param name="entry" select="."/>
				<xsl:with-param name="colnum" select="$entry.colnum"/>
				<xsl:with-param name="attribute" select="'valign'"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="align">
			<xsl:call-template name="inherited.table.attribute">
				<xsl:with-param name="entry" select="."/>
				<xsl:with-param name="colnum" select="$entry.colnum"/>
				<xsl:with-param name="attribute" select="'align'"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="char">
			<xsl:call-template name="inherited.table.attribute">
				<xsl:with-param name="entry" select="."/>
				<xsl:with-param name="colnum" select="$entry.colnum"/>
				<xsl:with-param name="attribute" select="'char'"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="charoff">
			<xsl:call-template name="inherited.table.attribute">
				<xsl:with-param name="entry" select="."/>
				<xsl:with-param name="colnum" select="$entry.colnum"/>
				<xsl:with-param name="attribute" select="'charoff'"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
				<xsl:call-template name="entry">
					<xsl:with-param name="col" select="$col+1"/>
					<xsl:with-param name="spans" select="substring-after($spans,':')"/>
				</xsl:call-template>
			</xsl:when>

			<xsl:when test="$entry.colnum &gt; $col">
				<xsl:call-template name="empty.table.cell"/>
				<xsl:call-template name="entry">
					<xsl:with-param name="col" select="$col+1"/>
					<xsl:with-param name="spans" select="substring-after($spans,':')"/>
				</xsl:call-template>
			</xsl:when>

			<xsl:otherwise>
				<xsl:variable name="bgcolor"/>

				<xsl:element name="{$cellgi}">
					<xsl:if test="$bgcolor != ''">
						<xsl:attribute name="bgcolor">
							<xsl:value-of select="$bgcolor"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:if test="$entry.propagates.style != 0 and @role">
						<xsl:attribute name="class">
							<xsl:value-of select="@role"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:attribute name="style">
						<xsl:if test="$colsep &gt; 0">
							<xsl:call-template name="border">
								<xsl:with-param name="side" select="'right'"/>
							</xsl:call-template>
						</xsl:if>
						<xsl:if test="$rowsep &gt; 0">
							<xsl:call-template name="border">
								<xsl:with-param name="side" select="'bottom'"/>
							</xsl:call-template>
						</xsl:if>
					</xsl:attribute>

					<xsl:if test="@morerows &gt; 0">
						<xsl:attribute name="rowspan">
							<xsl:value-of select="1+@morerows"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:if test="$entry.colspan &gt; 1">
						<xsl:attribute name="colspan">
							<xsl:value-of select="$entry.colspan"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:if test="$align != ''">
						<xsl:attribute name="align">
							<xsl:value-of select="$align"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:if test="$valign != ''">
						<xsl:attribute name="valign">
							<xsl:value-of select="$valign"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:if test="$char != ''">
						<xsl:attribute name="char">
							<xsl:value-of select="$char"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:if test="$charoff != ''">
						<xsl:attribute name="charoff">
							<xsl:value-of select="$charoff"/>
						</xsl:attribute>
					</xsl:if>

					<xsl:choose>
						<xsl:when test="$empty.cell">
							<xsl:text>&#160;</xsl:text>
						</xsl:when>
						<xsl:when test="self::entrytbl">
							<xsl:call-template name="tgroup"/>
						</xsl:when>
							<xsl:otherwise>
							<xsl:apply-templates/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:element>

				<xsl:choose>
					<xsl:when test="following-sibling::entry|following-sibling::entrytbl">
						<xsl:apply-templates
							select="(following-sibling::entry | following-sibling::entrytbl)[1]">
							<xsl:with-param name="col" select="$col+$entry.colspan"/>
							<xsl:with-param name="spans" select="$following.spans"/>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="finaltd">
							<xsl:with-param name="spans" select="$following.spans"/>
							<xsl:with-param name="col" select="$col+$entry.colspan"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="entry|entrytbl" name="sentry" mode="span">
		<xsl:param name="col" select="1"/>
		<xsl:param name="spans"/>

		<xsl:variable name="entry.colnum">
			<xsl:call-template name="entry.colnum"/>
		</xsl:variable>

		<xsl:variable name="entry.colspan">
			<xsl:choose>
				<xsl:when test="@spanname or @namest">
					<xsl:call-template name="calculate.colspan"/>
				</xsl:when>
				<xsl:otherwise>1</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="following.spans">
			<xsl:call-template name="calculate.following.spans">
				<xsl:with-param name="colspan" select="$entry.colspan"/>
				<xsl:with-param name="spans" select="$spans"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
				<xsl:value-of select="substring-before($spans,':')-1"/>
				<xsl:text>:</xsl:text>
				<xsl:call-template name="sentry">
					<xsl:with-param name="col" select="$col+1"/>
					<xsl:with-param name="spans" select="substring-after($spans,':')"/>
				</xsl:call-template>
			</xsl:when>

			<xsl:when test="$entry.colnum &gt; $col">
				<xsl:text>0:</xsl:text>
				<xsl:call-template name="sentry">
					<xsl:with-param name="col" select="$col+$entry.colspan"/>
					<xsl:with-param name="spans" select="$following.spans"/>
				</xsl:call-template>
			</xsl:when>

			<xsl:otherwise>
				<xsl:call-template name="copy-string">
					<xsl:with-param name="count" select="$entry.colspan"/>
					<xsl:with-param name="string">
						<xsl:choose>
							<xsl:when test="@morerows">
								<xsl:value-of select="@morerows"/>
							</xsl:when>
							<xsl:otherwise>0</xsl:otherwise>
						</xsl:choose>
						<xsl:text>:</xsl:text>
					</xsl:with-param>
				</xsl:call-template>
				<xsl:choose>
					<xsl:when test="following-sibling::entry|following-sibling::entrytbl">
						<xsl:apply-templates select="(following-sibling::entry |
																					following-sibling::entrytbl)[1]" mode="span">
							<xsl:with-param name="col" select="$col+$entry.colspan"/>
							<xsl:with-param name="spans" select="$following.spans"/>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="sfinaltd">
							<xsl:with-param name="spans" select="$following.spans"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="empty.table.cell">
		<xsl:param name="colnum" select="0"/>

		<xsl:variable name="rowsep">
			<xsl:choose>
				<!-- If this is the last row, rowsep never applies. -->
				<xsl:when
					test="not(ancestor-or-self::row[1]/following-sibling::row
													or ancestor-or-self::thead/following-sibling::tbody
													or ancestor-or-self::tbody/preceding-sibling::tfoot)">
					<xsl:value-of select="0"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="inherited.table.attribute">
						<xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
						<xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
						<xsl:with-param name="colnum" select="$colnum"/>
						<xsl:with-param name="attribute" select="'rowsep'"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="colsep">
			<xsl:choose>
				<!-- If this is the last column, colsep never applies. -->
				<xsl:when test="$colnum &gt;= ancestor::tgroup/@cols">0</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="inherited.table.attribute">
						<xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
						<xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
						<xsl:with-param name="colnum" select="$colnum"/>
						<xsl:with-param name="attribute" select="'colsep'"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<td>
			<xsl:attribute name="style">
				<xsl:if test="$colsep &gt; 0">
					<xsl:call-template name="border">
						<xsl:with-param name="side" select="'right'"/>
					</xsl:call-template>
				</xsl:if>
				<xsl:if test="$rowsep &gt; 0">
					<xsl:call-template name="border">
						<xsl:with-param name="side" select="'bottom'"/>
					</xsl:call-template>
				</xsl:if>
			</xsl:attribute>
			<xsl:text>&#160;</xsl:text>
		</td>
	</xsl:template>

	<!-- ====================================================================== -->

	<xsl:template name="tr.attributes">
		<xsl:param name="row" select="."/>
		<xsl:param name="rownum" select="0"/>
	</xsl:template>



	    <!-- ................................................... STYLES ................................................... -->
	    
	    
	    <!--
	        PURPOSE: Include common styles
	        REQUIREMENTS: pathParam
	        PROMISE: To include styles as defined below
	        
	        Mapping between previous CSS stylenames and new element+styles:
	        1. Identical styles all mapped to new element+style
	        2. Style variants applied to element+newstyle
	        3. Other unique styles retained.
	        
	        
	        NEW STYLE            OLD STYLES
	        .....................................
	        
	Headings
	        H1                 DMTITLE
	                           SubSectionHeader
	                           DescriptiveParaHeading
	                           
	        H1.Blue            sectionHeadingkk
	                           r4iH1
	                           r4iH2
	                           
	        H1.indent24        SubParaHeading
	        
	        H2                 SectionHeading
	        
	        H3                 SubSectionTitle
	        
	        H4                 ProceduralParaHeading
	        
	        H4.blue            heading
	        
	        H4.greenhighlight  r4sectionlabel
	        
	Text/Paras        
	        p.ncw              WarningText
	                           CautionText
	                           NoteText
	    -->
	    <xsl:template name="CSS_Styles">
	        <xsl:param name="paramPath"/>
	        <xsl:variable name="isEmergency" select="starts-with(normalize-space(//discode[1]), 'C0E')"/>
	        <style type="text/css">
	/* 
	IE - either way is fine; neither is good for FF or S: 
	   h1.ital
	   .ital
	*/
	           
	           /* The following background-* rules will produce a repeating watermark that will appear in the */
	           /* browser window and will not scroll with the document (i.e., will remain fixed);             */
	           /* the watermark will also print on each page of the screen printout, but ONLY when            */
	           /* the printing of background images is turned ON in the browser!                              */            
	           body{
	               margin: 0;
	               padding: 0;
	               width:700px;
	           <xsl:choose>
	             <xsl:when test="$isEmergency">
	               background-image: url("<xsl:value-of select="translate($paramPath, '/', '\')"/>Images\emergency.png");
	               background-attachment: scroll;
	               background-color: transparent;
	               background-position: 0% 0%;
	               background-repeat: repeat-x;
	               padding-top: 24;</xsl:when>
	             <xsl:otherwise>
	               background-image: url("<xsl:value-of select="translate($paramPath, '/', '\')"/>Images\watermark.gif");
	               background-attachment: fixed;
	               background-color: transparent;
	               background-position: 50% 10%;
	               background-repeat: repeat-y;</xsl:otherwise>
	           </xsl:choose>
	               
	               font-family: Arial, Helvetica, sans-serif; 
	               font-size: 10pt; 
	               font-style: normal; 
	               font-weight: normal;
	               color: black;
	            }
	
	
				.content {
	               width:700px;
	text-align:left;
	padding:15px;

}


               
             .add   {background:#99FF00}
             .modify  {background:#33FFFF}
             .delete {background:#FF0000}
             


	            div.disclaimer     {position: absolute; top: expression((tempTop=document.body.scrollTop - 2)+'px'); left: expression((tempLeft=document.body.scrollLeft - 2)+'px'); width: 100%; padding-top: 2px; padding-left: 5px; font-size: 12pt; font-weight: bold; color: black; background-color: white;}
	            div.dis-spacer     {font-size: 12pt; font-weight: bold; color: white; padding-left: 3px;}
	            @media print {     div.dis-spacer      {display:none;}
	                               div.disclaimer      {display:none;}
	                               div.floating-header {display:none;} }
	            
	            div.cl-step1       {margin-left: 2em;}
	            div.cl-step2       {margin-left: 4em;}
	            div.cl-step3       {margin-left: 6em;}
	            div.cl-step4       {margin-left: 8em;}
	            div.cl-step5       {margin-left: 10em;}
	            span.cl-label      {display: block; position: absolute; left: -2em;}
	            span.cl-leader     {position: absolute; border-bottom: 1px dotted black;}
	            
	            h1                 {font-size: 12pt; font-weight: bold;}
	            h1.blue            {color: blue;}
	            h1.blueital        {color: blue; font-style: italic;}
	            
	            h1.Warning         {color: red;   padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; margin-top: 0px;}
	            h1.Caution         {color: black; padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; margin-top: 0px;}
	            h1.Note            {color: blue;  padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; margin-top: 0px;}
	            
	            h2                 {font-size: 12pt; font-weight: bold; font-style: italic; padding-top: 0px; margin-top: 0px;}
	            h2.blue            {color: blue;}
	            
	            h3                 {font-size: 11pt; padding-top: 0px; margin-top: 0px;}
	            h3.blue            {color: blue;}
	            h3.blueital        {color: blue; font-style: italic;}
	
	            h4                 {font-size: 10pt; padding-top: 0px; margin-top: 0px;}
	            h4.blue            {color: blue;}
	            h4.blueital        {color: blue; font-style: italic;}
	            h4.ital            {font-style: italic;}
	            
	            p                  {font-size: 10pt; padding-top: 6px; margin-top: 3px;}
	            p.ncw              {padding-top: 3px; padding-bottom: 3px;}
	            li p.ncw           {padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;}
	            p.red              {color: red;}
	            p.prompt           {font-size: 10pt; padding-top: 8px; margin-top: 8px;}
	            p.promptindent     {font-size: 8pt; font-weight: bold;}
	            li.promptindent    {font-size: 8pt; font-weight: bold;}
	            
	
	            A.f8sBl:hover      {background-color:black; color:white;}
	            
	            td                 {padding-top: 5px;}
	            td.indent50        {padding-left: 50px;}
	            td.head1           {font-size: 12pt; font-weight: bold;}
	            td.head2           {font-size: 12pt; font-weight: bold; font-style: italic;}
	            td.head3           {font-size: 11pt;}
	            td.head4           {font-size: 10pt;}
	            td.tablestart      {}
	            td.tableend        {border-bottom: solid black 2px;}
	            td.leader          {border-bottom: dotted black 2px;}
	            td.ncw             {padding-bottom:30px; text-align:left;}
	            
	            tr.ipb             {border: solid black 1px;}
	            td.ipb50           {border: solid black 1px;}
	            td.ipbhead         {border: solid black 1px; text-align: center;}
	            td.ipbhead2        {border: solid black 1px; text-align: left;}
	            td.ipb             {border: solid black 1px;}
	            
	            table              {}
	            table.ipb          {font-size: 8pt; border: solid black 1px; }
	            table.wc           {border-collapse: collapse; border: solid black 2px;}
	            td.wc              {border: solid black 2px;}
	            td.wcstep          {border: solid black 2px; border-top: none; border-bottom: none;}
	            table.Warning      {BORDER:dashed red 4px; PADDING-RIGHT: 2px; PADDING-LEFT: 2px;}
	            table.Caution      {background: yellow; BORDER:dashed black 4px; PADDING-RIGHT: 2px; PADDING-LEFT: 2px;}
	            table.Note         {BORDER:solid blue 4px;PADDING-RIGHT: 2px; PADDING-LEFT: 2px;}                
	            
	            thead              {font-size: 10pt; font-weight: bold;}
	            tbody              {font-size: 10pt;}
	            tfoot              {font-size: 10pt;}
	
	            dl                 {font-size: 10pt;}
	            ul         		   {font-size: 10pt;}
	            .greenhighlight    {background-color:lightgreen;}
	            
	            ol     { list-style-type: decimal; }         /* 1 2 3 4 5 etc. */
	            .l2  { list-style-type: lower-alpha; }       /* a b c d e etc. */
	            .l3  { list-style-type: lower-roman; }       /* i ii iii iv v etc. */
	            .l4  { list-style-type: upper-alpha; }       /* A B C D E etc. */
	            .l5  { list-style-type: lower-alpha; }       /* a b c d e etc. */
	
	            .ChangeBar {position: absolute; left: 3pt; text-decoration: none; width: 3pt; background-color: black;}
	            .ChangeBarInvalid {position: absolute; left: 3pt; text-decoration: none; font-family: Arial, Helvetica, sans-serif; font-size: 16pt; font-style: normal; font-weight: bold; color: red;}
	            
	            .BoxHeading {font-weight: bold; BORDER:solid black 2px; PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; TEXT-ALIGN: center;}
	            .BORDER {dashed black 2px; PADDING-RIGHT: 2px; PADDING-LEFT: 3px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center;}
	            
	            .ERROR  {font-size: 16pt; font-weight: bold; color: red}
	
	            .FaultButtonChoice {BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; MARGIN: 1px; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid; TEXT-ALIGN: left; WIDTH: 100%; CURSOR: hand}
	            .FaultButtonJG     {background-color: white; BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; MARGIN: 1px; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid; TEXT-ALIGN: center; CURSOR: hand}
	
	            input.unclickedChoice {
	                background-color: white;
	                color: black;
	                BORDER-RIGHT: black 1px solid; 
	                BORDER-TOP: black 1px solid; 
	                MARGIN: 1px; 
	                BORDER-LEFT: black 1px solid; 
	                BORDER-BOTTOM: black 1px solid; 
	                TEXT-ALIGN: center; 
	                WIDTH: 100%;
	                CURSOR: hand
	            }
	            
	            input.clickedChoice {
	                background-color: black;
	                color: white;
	                BORDER-RIGHT: black 1px solid; 
	                BORDER-TOP: black 1px solid; 
	                MARGIN: 1px; 
	                BORDER-LEFT: black 1px solid; 
	                BORDER-BOTTOM: black 1px solid; 
	                TEXT-ALIGN: center; 
	                WIDTH: 100%;
	                CURSOR: hand
	            }
	            
	
	            input.unclicked {
	                background-color: white;
	                color: black;
	                BORDER-RIGHT: black 1px solid; 
	                BORDER-TOP: black 1px solid; 
	                MARGIN: 1px; 
	                BORDER-LEFT: black 1px solid; 
	                BORDER-BOTTOM: black 1px solid; 
	                TEXT-ALIGN: center; 
	                WIDTH: 50px; 
	                CURSOR: hand
	            }
	            
	            input.clicked {
	                background-color: black;
	                color: white;
	                BORDER-RIGHT: black 1px solid; 
	                BORDER-TOP: black 1px solid; 
	                MARGIN: 1px; 
	                BORDER-LEFT: black 1px solid; 
	                BORDER-BOTTOM: black 1px solid; 
	                TEXT-ALIGN: center; 
	                WIDTH: 50px; 
	                CURSOR: hand
	            }
	            
	        </style>        
	       <!--  <xsl:call-template name="common-script"/> -->
	    </xsl:template>

<xsl:template name="common-script">
        <script language="javascript">
            var dmInit = false;
            var checklist = false;
            var stepRE = /^step[1-5]$/;
            var retryTimer = -1, retries = 0;
            var dmTechname = "<xsl:value-of select="normalize-space(idstatus/dmaddres/dmtitle/techname)"/>";
            var dmInfoname = "<xsl:value-of select="normalize-space(idstatus/dmaddres/dmtitle/infoname)"/>";
            var floatTables, discDiv;

function CustomFunction1() {
	alert("Custom button 1 clicked";
}

function CustomFunction2() {
	alert("Custom button 2 clicked";
}

funtion PrintButton() {
	alert("Print Button clicked");
 }


            function DModule_Init(fromTimer)
            {
                var spans = document.getElementsByTagName("span"), deferred = 0;
                var clLeft = null, clStart = null, clLeader = null;
                var clLeading = null, clRight = null;

				

                for (var i = 0; i &lt; spans.length; i++)
                {
                    var span = spans[i];
                    if (span.className == "cl-left")         { clLeft    = span; }
                    else if (span.className == "cl-start")   { clStart   = span; }
                    else if (span.className == "cl-leader")  { clLeader  = span; }
                    else if (span.className == "cl-leading") { clLeading = span; }
                    else if (span.className == "cl-right")   { clRight   = span; }
                    else if (span.className == "cl-box" &amp;&amp; !isHidden(span))
                    {
                        var t = clStart.offsetTop - clLeft.offsetTop;
                        var l = realLeft(clStart) + clStart.offsetWidth;
                        var d = clRight.offsetHeight - clStart.offsetHeight;
                        cellVA(clLeft,  t > 0 || d > 8 ? "top" : "middle");
                        cellVA(clRight, t > 0 || d > 8 ? "bottom" : "middle");
                        cellVA(span,    t > 0 || d > 8 ? "bottom" : "middle");
                        clLeading.style.display = (t > 0 ? "block" : "none");
                        clLeading.style.height = (t > 0 ? t : 0);
                        clLeader.style.top = realTop(clStart) - 4;
                        clLeader.style.left = l;
                        clLeader.style.width = realLeft(clRight) - l;
                        clLeft = null; clStart = null; clLeader = null;
                        clLeading = null; clRight = null;
                    }
                    else if ((span.className == "ChangeBarInvalid" ||
                              span.className == "ChangeBar") &amp;&amp; !isHidden(span))
                    {
                        var p = realParent(span);
                        span.style.top = realTop(realStart(p));
                        if (span.className == "ChangeBar") { span.style.height = p.offsetHeight; }
                        var sn = span.getAttribute("name"), pn = p.nodeName.toLowerCase();
                        var split = p.outerHTML.length - p.innerHTML.length;
                        split = (p.outerHTML.indexOf(p.innerHTML) == split);
                        var isStep = (sn.match(stepRE) != null);
                        if (isStep || split || (sn == "seqlist" &amp;&amp; pn == "h4"))
                        {
                            var ns = p.nextSibling, depth = 1;
                            while (ns != null)
                            {
                                if (ns.nodeType == 1)
                                {
                                    var nsName = ns.nodeName.toLowerCase();
                                    var hazmatTable = false;
                                    /* Find out if it's a hazmat table.
                                       Don't mess with hazmat tables that are after the step. */
                                    if (ns.className.indexOf("hazmat") == -1)
                                    {
                                        hazmatTable = false;
                                    }
                                    else
                                    {
                                        hazmatTable = true;
                                    }
                                    var end, tag, len;
                                    if (split)
                                    {
                                        end = ns.outerHTML.replace(/^\s*$/, "");
                                        tag = "&lt;" + p.nodeName + ">&lt;/" + p.nodeName + ">";
                                        len = end.length - tag.length;
                                    }
                                    if (nsName == "li" || hazmatTable ||
                                        (isStep &amp;&amp; nsName == "center") ||
                                        (split &amp;&amp; end.substr(len) == tag)) { break; }
                                    var top = realTop(ns) - realTop(span);
                                    if (top >= 0 &amp;&amp; top - span.offsetHeight &lt; 40)
                                    {
                                        span.style.height = top + ns.offsetHeight;
                                    }
                                    else { deferred++; }
                                    if (sn == "seqlist") { break; }
                                }
                                if (ns.nextSibling == null &amp;&amp; depth > 0)
                                {
                                    ns = ns.parentNode; depth--;
                                }
                                ns = ns.nextSibling;
                            }
                            /* Get top of changebar before checking for hazmat tables
                               above this step in the HTML. */
                            var s_top = Number(span.style.top.replace(/px/, ""));
                            var s_height = Number(span.style.height.replace(/px/, ""));
                            var ttop = 0;
                            var old_top = 0;
                            old_top = s_top + s_height;
                            var pn = p.parentNode;
                            if (pn.previousSibling != null)
                            {
                                if (pn.previousSibling.nodeName.toLowerCase() == "li")
                                {
                                    var ps = pn.previousSibling;
                                    /* Get any tables inside the li. This only reflects the IE DOM,
                                       not what's actually in the HTML. */
                                    var tables = ps.getElementsByTagName("table");
                                    /* hazmat tables are above the step, not below it.
                                       Move the changebar up to them if necessary. */
                                    for (var j = 0; j &lt; tables.length; j++)
                                    {
                                        var table = tables[j];
                                        if (table.className == "hazmat")
                                        {
                                            var this_top = realTop(table);
                                            if (ttop == 0 || this_top &lt; ttop)
                                            {
                                                ttop = this_top;
                                            }
                                        /* Set changebar to proper length and location. */
                                        span.style.top = ttop;
                                        span.style.height = old_top - ttop;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (deferred > 0)
                {
                    if (retries &lt; 3 &amp;&amp; (retryTimer &lt; 0 || fromTimer > 0))
                    {
                        retries++;
                        retryTimer = window.setTimeout("DModule_Init(1)", 500);
                    }
                    else if (fromTimer > 0) { retryTimer = -1; retries = 0; }
                }
                else if (retryTimer >= 0)
                {
                    if (fromTimer == 0) { window.clearTimeout(retryTimer); }
                    retryTimer = -1; retries = 0;
                }
                document_Scroll();
            }

            function isHidden(node)
            {
                if (node == null) { return false; }
                if (node.style != null &amp;&amp; node.style.display != null &amp;&amp; node.style.display == "none") { return true; }
                return isHidden(node.parentNode);
            }

            function cellVA(node, valign)
            {
                var td = node;
                while (td != null &amp;&amp; td.nodeName.toLowerCase() != "td")
                {
                    td = td.parentNode;
                }
                if (td != null) { td.style.verticalAlign = valign; }
            }

            function realParent(node)
            {
                var p = node.parentNode;
                return (p.nodeName == null || p.nodeName == "" ? realParent(p) : p);
            }

            function realStart(node)
            {
                if (node.nodeName.toLowerCase() != "div") { return node; }
                for (var c = node.firstChild; c != null; c = c.nextSibling)
                {
                    if (c.offsetParent == node.offsetParent) { return c; }
                }
                return node;
            }

            function realTop(node)
            {
                return (node == null ? 0 : node.offsetTop + realTop(node.offsetParent));
            }

            function realLeft(node)
            {
                return (node == null ? 0 : node.offsetLeft + realLeft(node.offsetParent));
            }

            function ShowDoc(doc)
            {
                window.external.ShowDocument(doc, checklist ? "checklist-view" : "");
            }

            function DMName(info)
            {
                var re = /^[ \t]*(.*?)[ \t]*$/, iname = dmInfoname.replace(re, "$1");
                if (info &amp;&amp; iname != "") { return dmInfoname; }
                else if (dmTechname.replace(re, "$1") != "") { return dmTechname; }
                else if (iname != "") { return dmInfoname; }
                return "";
            }

            function document_Scroll()
            {
                var scrollAdj = (discDiv ? discDiv.offsetHeight : 0);
                var scroll = (("pageYOffset" in window) ? window.pageYOffset :
                              window.document.body.scrollTop) + scrollAdj;
                for (var i = 0; floatTables &amp;&amp; i &lt; floatTables.length; i++)
                {
                    var wrapper = floatTables[i], tabHt = wrapper.offsetHeight;
                    var div = wrapper.firstChild, tab = div.firstChild;
                    var lastHdr = (tab.tHead &amp;&amp; tab.tHead.lastChild) || tab.rows[0];
                    var tabTop = wrapper.getBoundingClientRect().top +
                                 scroll - scrollAdj - window.document.body.clientTop;
                    var pos = scroll - tabTop, inTable = (div.currentStyle.display != "none");
                    inTable = inTable &amp;&amp; (pos > 0) &amp;&amp; (scroll &lt; tabTop + tabHt);
                    div.style.visibility = (inTable ? "visible" : "hidden");
                    if (inTable) { div.style.height = lastHdr.offsetTop + lastHdr.offsetHeight; }
                    div.style.top = (!inTable ? 0 : Math.min(pos, tabHt - div.style.pixelHeight));
                }
            }

            function TableHeaders_Init()
            {
                floatTables = new Array();
                for (var n = document.body.firstChild; n; n = n.nextSibling)
                {
                    if (n.className == "dis-spacer") { discDiv = n; break; }
                }
                var tabs = document.getElementsByTagName("table");
                for (var i = 0; i &lt; tabs.length; i++)
                {
                    if (tabs[i].className != "float-header") { continue; }
                    var tab = tabs[i], div, newDiv, tCount = tabs.length;
                    div = document.createElement("div");
                    div.style.position = "relative";
                    tab.parentNode.insertBefore(div, tab);
                    div.appendChild(tab);
                    newDiv = document.createElement("div");
                    newDiv.className = "floating-header";
                    newDiv.style.position = "absolute";
                    newDiv.style.top = "0px";
                    newDiv.style.left = "0px";
                    newDiv.style.overflow = "hidden";
                    newDiv.style.visibility = "hidden";
                    var newTab = tab.cloneNode(true);
                    newTab.className = "";
                    newTab.style.backgroundColor = "white";
                    newDiv.appendChild(newTab);
                    div.insertBefore(newDiv, tab);
                    floatTables.push(div);
                    i += tabs.length - tCount;
                }
            }

            function TabSelected(winTitle) { TabSetup(winTitle, false); }

            function TabSetup(winTitle, init)
            {
                var wb = window.external.WebBrowser, win, tabmap, timer, retry = 2;
                var tab = window.external.Parent, tc, tabs, doTitle = false;
                if (wb) { win = wb.TopLevelControl; }
                if (tab) { tc = tab.TabControl; if (tc) { tabs = tc.TabPages; } }
                if (win)
                {
                    tabmap = win.Tag;
                    if (!tabmap) { tabmap = new Array(); tabmap["tabmap"] = 1; win.Tag = tabmap; }
                    try
                    {
                        if (tabmap["tabmap"] == 1)
                        {
                            tabmap[tab.Tag] = wb;
                            if (tabs &amp;&amp; (!init || tabs.Count &lt; 2)) { doTitle = true; }
                            if (doTitle) { win.Text = DMName(0) + " - " + winTitle; }
                        }
                    }
                    catch(e) { }
                }
                function TabCheck()
                {
                    var sel = tc.SelectedTabPage;
                    if (!sel) { win.Text = winTitle; return; }
                    if (sel.Tag != tab.Tag)
                    {
                        for (var i = 0; tabs &amp;&amp; i &lt; tabs.Count; i++)
                        {
                            if (tabs.Item(i) &amp;&amp; tabs.Item(i).Tag == sel.Tag)
                            {
                                var tmap = win.Tag, nwb, ax, doc;
                                try
                                {
                                    if (tmap["tabmap"] == 1) { nwb = tmap[tabs.Item(i).Tag]; }
                                }
                                catch(e) { }
                                if (nwb) { ax = nwb.ActiveXInstance; }
                                if (ax) { doc = ax.Document; }
                                if (doc)
                                {
                                    //var args = new Array(); args[0] = winTitle;
                                    var script = doc.Script;
                                    if (script)
                                    {
                                        script.TabSelected(winTitle);
                                        clearInterval(timer); return;
                                    }
                                }
                            }
                        }
                        if (retry-- &lt;= 0)
                        {
                            win.Text = winTitle;
                            clearInterval(timer);
                        }
                    }
                    else { retry = 2; }
                }
                if (doTitle) { timer = window.setInterval(TabCheck, 2000); }
            }

            function TabWinSetup()
            {
                dmInit = true;
                var we = window.external, tab = we.Parent, wb = we.WebBrowser, win;
                if (tab)
                {
                    var name = DMName(1), limit = 20;
                    if (tab.Tooltip == "" &amp;&amp; name.length > limit)
                    {
												tab.Text = name.substr(0, limit - 2) + "...";
												tab.Tooltip = name;
                    }
                    else { tab.Text = name; }
                }
                if (wb) { win = wb.TopLevelControl; }
                if (win) { TabSetup(win.Text, true); }
            }

            function StartUp_DM()
            {
            	window.external.CustomButton("CBTN1", "Print", "PrintButton", "True");
            	window.external.CustomButton("CBTN2", "This is a custom button", "CustomFunction1", "False");
            	window.external.CustomButton("CBTN3", "This is another custom button", "CustomFunction2", "False");
                TabWinSetup();
                TableHeaders_Init();
                DModule_Init();
            }
        </script>
</xsl:template>


</xsl:stylesheet>
<!-- Stylus Studio meta-information - (c) 2004-2009. Progress Software Corporation. All rights reserved.

<metaInformation>
	<scenarios>
		<scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="DMC-S1000DBIKE-AAA-D00-00-00-00AA-041A-A_005-00.xml" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth=""
		          profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal"
		          customvalidator="">
			<advancedProp name="sInitialMode" value=""/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bSchemaAware" value="true"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="iValidation" value="0"/>
			<advancedProp name="bExtensions" value="true"/>
			<advancedProp name="iWhitespace" value="0"/>
			<advancedProp name="sInitialTemplate" value=""/>
			<advancedProp name="bTinyTree" value="true"/>
			<advancedProp name="xsltVersion" value="2.0"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="bUseDTD" value="false"/>
			<advancedProp name="iErrorHandling" value="fatal"/>
		</scenario>
	</scenarios>
	<MapperMetaTag>
		<MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
		<MapperBlockPosition></MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
-->