<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="#default"
>

<xsl:output method="html" encoding="utf-8" indent="yes"/>

<xsl:param name="style">prodLine</xsl:param>
<xsl:param name="prodline">all</xsl:param>
<xsl:param name="bookpath"></xsl:param>

<xsl:key name="prodlines" match="//prodline" use="code"/>
<xsl:key name="products" match="//product" use="name"/>
<xsl:key name="books" match="//book" use="ancestor::prodline"/>
<xsl:key name="bookcodes" match="//book/code" use="ancestor::prodline"/>

<xsl:variable name="browser">
  <xsl:choose>
    <xsl:when test="system-property('xsl:vendor')='Microsoft'">IE</xsl:when>
    <xsl:otherwise>NS</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:template match="prodlines">
<!-- Main Routine -->
<HTML>
<HEAD>
<SCRIPT type="text/javascript">
var strRelPathToRoot = "../../";
</SCRIPT>
<SCRIPT type="text/javascript" SRC="../../js/common.js">
</SCRIPT>
<SCRIPT type="text/javascript" SRC="../../eng/psbooks/js/booklist.js">
</SCRIPT>
<STYLE TYPE="text/css">
H2 {font-family:Arial, Helvetica, sans-serif; color:#333399; font-size:20pt; font-weight:bold;margin-top:36pt; margin-bottom:18pt;}
.P {font-size:10pt;}
BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt;margin-left:30px}
P {font-family:'Arial'; color: 000000; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}
PRE {font-family:'Arial'; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}
DIV {margin-top:0pt; margin-bottom:0pt;display:block}
.C {display:none}
A {color: blue;}
A:visited {color: blue;}
</STYLE>
</HEAD>
  <xsl:choose>
    <xsl:when test="$style='titleIdx'">
      <xsl:call-template name="titleIdx"/>
    </xsl:when>
    <xsl:when test="$style='prodIdx'">
      <xsl:call-template name="prodIdx"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="prodLine"/>
    </xsl:otherwise>
  </xsl:choose>
</HTML>
</xsl:template>





<xsl:template name="prodLine">
<SCRIPT type="text/javascript">
<![CDATA[
function loadFunc() {
  var text;
  var label;
  label = document.getElementById("titleH2");
  text = document.createTextNode(strProdLineIdx);
  label.appendChild(text);
  label = document.getElementById("backToLib");
  text = document.createTextNode(strGoBackHome);
  label.appendChild(text);
  label = document.getElementById("choosePL");
  text = document.createTextNode(strChooseProdLine);
  label.appendChild(text);
}
]]>
</SCRIPT>
<BODY onLoad="loadFunc()">
<H2><SPAN ID="titleH2"/></H2>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="RIGHT">
<P><A HREF="../../htm/utf-8/home_toc.htm"><SPAN ID="backToLib"/></A></P>
</TD>
</TR>
</TABLE>
<P CLASS="SUBTOPIC"><SPAN ID="choosePL"/><BR/><BR/></P>
<!-- For each distinct product line code, write the name of the last one found. (This allows us to append
     the xml file with each install and not worry about duplicate prodline codes.) -->
  <xsl:for-each select="prodline[generate-id(.) = generate-id(key('prodlines',code)[1])]">
    <xsl:sort select="name"/>
<P CLASS="TOPICLIST"><A HREF="prodidx.htm?style=prodIdx&amp;prodline={code}"><B><xsl:value-of select="key('prodlines',code)[last()]/name"/></B></A></P>
  </xsl:for-each>
</BODY>
</xsl:template>




<xsl:template name="titleIdx">
<BODY onLoad="loadFunc()">
  <xsl:for-each select="prodline[code=$prodline][last()]">
<SCRIPT type="text/javascript">
<![CDATA[
function loadFunc() {
  var text;
  var label;
  label = document.getElementById("titleH2");
  text = document.createTextNode("]]><xsl:value-of select="name"/><![CDATA[ " + top.strPBIndexTitle);
  label.appendChild(text);
  label = document.getElementById("chooseOne");
  text = document.createTextNode(top.strInstalledBooks);
  label.appendChild(text);
  label = document.getElementById("backToLib");
  text = document.createTextNode(strGoBackHome);
  label.appendChild(text);
  label = document.getElementById("byProd");
  text = document.createTextNode(strByProduct);
  label.appendChild(text);
  titles = new Array(0);
  var links = document.getElementById("LINKS").getElementsByTagName("A");
  var code;
  for(var e=0; e < links.length; e++){
    if (links[e].childNodes.length > 1) continue;
    code = links[e].getAttribute("HREF");
    code = code.substring(0, code.lastIndexOf("/"));
    code = code.substring(code.lastIndexOf("/") + 1, code.length);
    titles[titles.length] = getTitle(code,"psbooks");
  }
  titles.sort();
  for(e=0; e < titles.length; e++) {
    text = document.createTextNode(titles[e]);
    links[e].appendChild(text);
  }
}
]]>
</SCRIPT>
<DIV ID="TITLE">
<H2><SPAN ID="titleH2"/></H2>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="RIGHT">
<P>
<A HREF="prodidx.htm?style=prodIdx&amp;prodline={$prodline}"><SPAN ID="byProd"/></A>
<xsl:call-template name="addSpace"/> 
<A HREF="../../htm/utf-8/home_toc.htm"><SPAN ID="backToLib"/><SPAN ID="backToLib"/></A>
</P>
</TD>
</TR>
</TABLE>
<P CLASS="SUBTOPIC"><SPAN ID="chooseOne"/><BR/><BR/></P>
</DIV>
<DIV ID="LINKS">
    <!--xsl:for-each select=".//book">
      <xsl:sort select="name"/>
        <xsl:if test="count(preceding::book[ancestor::prodline=current()/ancestor::prodline][code=current()/code])=0">
<P><A HREF="{$bookpath}/{code}/book.htm" TARGET="_top"></A></P>
        </xsl:if>
    </xsl:for-each-->
    <xsl:variable name="bookcodes" select="product/book"/>
    <xsl:for-each select="$bookcodes">
      <xsl:if test="generate-id(.)= generate-id($bookcodes[code=current()/code])">
        <!-- finds each unique book code in set -->
        <xsl:for-each select="$bookcodes[code=current()/code][last()]">
          <!-- finds the last occurrence of this book code -->
<P CLASS="TOPICLIST"><A HREF="{$bookpath}/{code}/book.htm" TARGET="_top"></A></P>
        </xsl:for-each>
      </xsl:if>
    </xsl:for-each>
</DIV>
  </xsl:for-each>
</BODY>
</xsl:template>




<xsl:template name="prodIdx">
<xsl:for-each select="prodline[code=$prodline][last()]">
<STYLE type="text/css">
DIV {margin-top:0pt; margin-bottom:3pt;display:block}
A.FOLDER {color: #333333; text-decoration: none; font-weight: bold; }
A.FOLDER:link {text-decoration: none; color: 000000}
A.FOLDER:visited {text-decoration: none; color: 000000}
A.FOLDER:active {text-decoration: none; background-color: #cccccc}
#TITLE A {color: blue; text-decoration: underline;}
A {color: blue; text-decoration: none; }
A:link {text-decoration: none; color: 000000}
A:visited {text-decoration: none; color: 000000}
A:active {text-decoration: none; background-color: #cccccc}
A:hover {text-decoration: underline; color: blue}
#HILIGHTLYR {z-index:999; position:absolute; width:10px; height:10px; top:0; left:0;  background-color:darkblue; z-index:600; visibility:hidden;}
</STYLE>
<SCRIPT type="text/javascript">
<![CDATA[

function clickFolder(itmID) {
  var objP = document.getElementById(itmID + 'IEP');
  var objC = document.getElementById(itmID + 'IEC');
  objImg = document.images[itmID];
  if (objC.style.display != "block") {
    var links = objC.getElementsByTagName("A");
    var code = "";
    var text;
    for(var e=0; e < links.length; e++){
      if (links[e].childNodes.length > 1) continue;
      code = links[e].getAttribute("HREF");
      code = code.substring(0, code.lastIndexOf("/"));
      code = code.substring(code.lastIndexOf("/") + 1, code.length);
      text = document.createTextNode(getTitle(code,"psbooks"));
      links[e].appendChild(text);
    }
    objC.style.display="block";
    objImg.src = "../../img/collapse.gif";
  } else if (objImg.src.indexOf("collapse.gif") != -1) {
    objImg.src = "../../img/expand.gif";
    objC.style.display = "none";
  }
}

function loadFunc() {
  var text;
  var label;
  label = document.getElementById("titleH2");
  text = document.createTextNode("]]><xsl:value-of select="name"/><![CDATA[ " + strProducts);
  label.appendChild(text);
  label = document.getElementById("backToLib");
  text = document.createTextNode(strGoBackHome);
  label.appendChild(text);
  label = document.getElementById("byTitle");
  text = document.createTextNode(strByTitle);
  label.appendChild(text);
  label = document.getElementById("clickProd");
  text = document.createTextNode(strClickProduct);
  label.appendChild(text);
}

]]>
</SCRIPT>
<BODY onLoad="loadFunc()">
<DIV ID="TITLE">
<H2><SPAN ID="titleH2"/></H2>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="RIGHT">
<P>
<A HREF="prodidx.htm?style=titleIdx&amp;prodline={$prodline}"><SPAN ID="byTitle"/></A>
<xsl:call-template name="addSpace"/>
<A HREF="../../htm/utf-8/home_toc.htm"><SPAN ID="backToLib"/></A>
</P>
</TD>
</TR>
</TABLE>
<P CLASS="SUBTOPIC"><SPAN ID="clickProd"/><BR/><BR/></P>
</DIV>
<xsl:for-each select="product">
  <xsl:sort select="name"/>
  <xsl:call-template name="prodIdxLayers">
     <xsl:with-param name="layerID"><xsl:value-of select="generate-id(.)"/></xsl:with-param>
  </xsl:call-template>
 </xsl:for-each>
</BODY>
</xsl:for-each>
</xsl:template>

<xsl:template name="prodIdxLayers">
  <xsl:param name="layerID"></xsl:param>
<DIV ID="{$layerID}IEP" CLASS="P"><NOBR>
<P><A HREF="#" CLASS="FOLDER" onClick="clickFolder('{$layerID}'); return false">
<IMG NAME="{$layerID}" SRC="../../img/expand.gif" BORDER="0"/><xsl:text> </xsl:text>
  <xsl:value-of select="name"/></A></P>
</NOBR></DIV>
<BLOCKQUOTE>
<DIV ID="{$layerID}IEC" CLASS="C"><NOBR>
  <xsl:for-each select="book">
<P>
<xsl:choose>
  <xsl:when test="position()=1">
<B><A HREF="{$bookpath}/{code}/book.htm" TARGET="_top"></A></B>
  </xsl:when>
  <xsl:otherwise>
<A HREF="{$bookpath}/{code}/book.htm" TARGET="_top"></A>
  </xsl:otherwise>
</xsl:choose>
</P>
  </xsl:for-each>
</NOBR></DIV>
</BLOCKQUOTE>
</xsl:template>

<xsl:template name="addSpace">
<xsl:if test="$browser='IE'"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></xsl:if>
<xsl:if test="$browser='NS'"><xsl:text> </xsl:text></xsl:if>
</xsl:template>

</xsl:stylesheet>
