home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 August / INTERNET94.ISO / pc / software / windows / mail / ft_gate_office / officewebhelp / webhelp4.js < prev   
Encoding:
JavaScript  |  2002-02-27  |  57.3 KB  |  2,105 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // RoboHELP« WebHelp 4 Dynamic HTML Effects Script
  3. // Copyright ⌐ 1998-2000 eHelp Corporation.  All rights reserved.
  4.  
  5. // Version= 4.33
  6.  
  7. // Warning:  Do not modify this file.  It is generated by RoboHELP« and changes will be overwritten.
  8.  
  9. //{{WH3_SYMBOL_SECTION
  10. var gstrNavFrmst = "navpane1.htm";
  11. var gstrTocDhtml = "tocdhtml.htm";
  12. var gstrIdxDhtml = "idxdhtml.htm";
  13. var gstrFtsDhtml = "ftsdhtml.htm";
  14. var gstrIniDhtml = "tocdhtml.htm";
  15. var gstrBlankhtml = "_blank.htm";
  16.  
  17. //}}WH3_SYMBOL_SECTION
  18.  
  19. var gnPageWidth = 0;
  20. var gnPageHeight = 0;
  21. var gstrColl = "";
  22. var gstrStyle = ""
  23. var gbNav4 = false;
  24. var gbIE4 = false;
  25. var gbIE = false;
  26. var gbIE5 = false;
  27. var gbIE55 = false;
  28. var gbTocLoaded = false;
  29. var gbIndexLoaded = false;
  30. var gbFtsLoaded = false;
  31. var gAgent = navigator.userAgent.toLowerCase(); 
  32. var gbMac = (gAgent.indexOf("mac") != -1);
  33.  
  34. var gbIndexInputEnable = false;
  35. var gITE = new Array();
  36. var gIndexKeywordArray = new Array();
  37. var gIndexLetterArray = new Array();
  38.  
  39. var gbFtsInputEnable = false;
  40. var gKE = new Array();
  41. var gTE = new Array();
  42. var gSTP = new Array();
  43.  
  44. gbIE = (navigator.appName.indexOf("Microsoft") != -1);
  45. if (parseInt(navigator.appVersion) >= 4) {
  46.     gbNav4 = (navigator.appName == "Netscape");
  47.     gbIE4 = (navigator.appName.indexOf("Microsoft") != -1);
  48. }
  49. if (gbNav4) {
  50.     document.gnPageWidth = innerWidth;
  51.     document.gnPageHeight = innerHeight;
  52. //    document.captureEvents(Event.RESIZE);
  53. //    document.onresize = HandleResize;
  54. } else if (gbIE4) {
  55.     gstrStyle = ".style";
  56.     gstrColl = "all.";
  57.     if (gAgent.indexOf("msie 5") != -1) {
  58.         gbIE5 = true;
  59.     }
  60.     if (gAgent.indexOf("msie 5.5") != -1) {
  61.         gbIE55 = true;
  62.     }
  63. }
  64.  
  65. function HandleResize()
  66. {
  67.     if (innerWidth != window.document.gnPageWidth || innerHeight != window.document.gnPageHeight) {
  68.         if (window.document.gnPageWidth == 0) {
  69.             window.document.gnPageWidth = innerWidth;
  70.             window.document.gnPageHeight = innerHeight;
  71.         } else {
  72.             window.document.gnPageWidth = innerWidth;
  73.             window.document.gnPageHeight = innerHeight;
  74.             window.document.location.reload();
  75.         }
  76.         return false;
  77.     }
  78. }
  79.  
  80.  
  81. function FindTopLevelLayer(strID)
  82. {
  83.     if (gbNav4) {
  84.         return FindTopLevelLayerNS(strID);
  85.     } else if (gbIE4) {
  86.         var obj = eval("document.all." + strID);
  87.         return obj;
  88.     }
  89.     return null;
  90. }
  91.  
  92. function FindTopLevelLayerNS(strID)
  93. {
  94.     for (var iLayer = 0; iLayer < window.document.layers.length; iLayer++) {
  95.         if (window.document.layers[iLayer].id == strID) {
  96.             return window.document.layers[iLayer];
  97.         }
  98.     }
  99.  
  100.     // This section is added to the search because when the scrollbar is
  101.     // added, Netscape messes up the layer list. This is another way
  102.     // of getting to the layers
  103.     if (window.document.layers.length > 0) {
  104.         var iLayer = 0;
  105.         var objLayer = window.document.layers[0];
  106.         while ((iLayer < 20) && (objLayer != null)) {
  107.             if (objLayer.id == strID) {
  108.                 return objLayer;
  109.             }
  110.             iLayer++;
  111.             objLayer = objLayer.above;
  112.         }
  113.     }
  114.     return null;
  115. }
  116.  
  117. function GetAttribObject(obj)
  118. {
  119.     var objAttrib = null;
  120.     if (typeof obj == "string") {
  121.         objAttrib = eval("document." + gstrColl + obj + gstrStyle);
  122.     } else {
  123.         objAttrib = obj;
  124.     }
  125.     return objAttrib;
  126. }
  127.  
  128.  
  129. function TabFrame()
  130. {
  131.     if (gbNav4) {
  132.         return Tabs;
  133.     } else {
  134.         return document.frames['Tabs'];
  135.     }
  136. }
  137.  
  138. function NavFrame()
  139. {
  140.     if (gbNav4) {
  141.         return Navigation;
  142.     } else {
  143.         return document.frames['Navigation'];
  144.     }
  145. }
  146.  
  147. function GetIFrameByDiv(div)
  148. {
  149.     var cIframe;
  150.     if ((frames.length > 0) &&
  151.         (div != null) &&
  152.         (div.id != null))
  153.     {
  154.         if (div.id == "TocNav")
  155.             cIframe = frames['TocIFrame'];
  156.         else if (div.id == "IndexNav")
  157.             cIframe = frames['IndexIFrame'];
  158.         else if (div.id == "FtsNav")
  159.             cIframe = frames['FtsIFrame'];            
  160.     }
  161.     return cIframe;
  162. }
  163.  
  164.  
  165. function ShowDiv(strDiv, bShow)
  166. {
  167.     var Div = FindTopLevelLayer(strDiv);
  168.     if (Div == null) {
  169.         return;
  170.     }
  171.  
  172.     if (gbNav4) {
  173.         if (bShow == true) {
  174.             Div.visibility = 'show';
  175. //            Div.left = 0;
  176.             Div.moveToAbsolute(0, 0);
  177.         } else {
  178.             Div.visibility = 'hide';
  179. //            Div.left = -2000;
  180.             Div.moveToAbsolute(-2000, 0);
  181.         }
  182.     } else {
  183.         if (gbIE55)
  184.         {
  185.             var curIframe = GetIFrameByDiv(Div);
  186.             if (bShow)
  187.             {
  188.                Div.style.zIndex = 3;
  189.                if (curIframe != null)  
  190.                {
  191.                 curIframe.frameElement.style.zIndex=3;
  192.                 curIframe.frameElement.style.visibility = "visible";
  193.                }
  194.             }
  195.             else
  196.             {
  197.                Div.style.zIndex = 2;
  198.                if (curIframe != null)
  199.                {
  200.                 curIframe.frameElement.style.zIndex= 2;
  201.                 curIframe.frameElement.style.visibility = "hidden";
  202.                }
  203.             }
  204.         }
  205.  
  206.         Div.style.visibility = (bShow == true) ? 'visible' : 'hidden';
  207.     }
  208.     return;
  209. }
  210.  
  211. function LoadTocContent(TocDiv)
  212. {    
  213.     gbTocLoaded = true;
  214.     return;
  215. }
  216.  
  217. function AutoSyncToc(strtocURL)
  218. {
  219.     if (strtocURL == "") return;
  220.  
  221.     var TocDiv = this.FindTopLevelLayer('TocNav');
  222.  
  223.     if (TocDiv.document.all.TocIFrame == null) return;
  224.  
  225.     var strFile = TocDiv.document.all.TocIFrame.document.location.href;
  226.     var strHash = TocDiv.document.all.TocIFrame.document.location.hash;
  227.     if (strHash.length > 0) {
  228.         strFile = strFile.substring(0, strFile.length - strHash.length);
  229.     }
  230.  
  231.     var strHash = "";
  232.     if (strtocURL.length > 0)  {
  233.         strHash = "#" + strtocURL;
  234.     } 
  235.     if (strHash.length > 0) {
  236.         strFile += strHash;
  237.     }
  238.     if (gbNav4) {
  239.         TocDiv.src = strFile;
  240.     } else if (gbIE4) {
  241.         if (document.frames['TocIFrame'] != null) // sure. we can access this iframe.
  242.             if (typeof(document.frames['TocIFrame'].window.NavBar_SyncToc) == 'function')
  243.                 document.frames['TocIFrame'].window.NavBar_SyncToc(strtocURL);
  244.     }
  245.     gbTocLoaded = true;
  246.     return;
  247. }
  248.  
  249. function SyncTocContent(strtocURL)
  250. {
  251.     var TocDiv = this.FindTopLevelLayer('TocNav');
  252.     if (TocDiv.document.all.TocIFrame == null) return;
  253.  
  254.     var strFile = TocDiv.document.all.TocIFrame.document.location.href;
  255.     var strHash = TocDiv.document.all.TocIFrame.document.location.hash;
  256.     if (strHash.length > 0) {
  257.         strFile = strFile.substring(0, strFile.length - strHash.length);
  258.     }
  259.  
  260.     var strHash = "";
  261.     if (strtocURL.length > 0)  {
  262.         strHash = "#" + strtocURL;
  263.     } 
  264.     if (strHash.length > 0) {
  265.         strFile += strHash;
  266.     }
  267.     if (gbNav4) {
  268.         TocDiv.src = strFile;
  269.     } else if (gbIE4) {
  270.         // no refresh.
  271.         // but we need to switch div , if need.
  272.         if (parent.TabFrame().document.images['TocTab'] != null) {
  273.             parent.TabFrame().document.images['TocTab'].src='bssctab1.gif';
  274.         }
  275.         if (parent.TabFrame().document.images['IndexTab'] != null) {
  276.             parent.TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  277.         }
  278.         if (parent.TabFrame().document.images['FtsTab'] != null) {
  279.             parent.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  280.         }            
  281.         ShowDiv('TocNav', true);
  282.         ShowDiv('IndexNav', false);
  283.         ShowDiv('FtsNav', false);
  284.         TOCFocusA();
  285.         if (document.frames['TocIFrame'] != null) // sure. we can access this iframe.
  286.             document.frames['TocIFrame'].window.NavBar_SyncToc(strtocURL);
  287.  
  288. //        parent.document.strtocURL = strtocURL;
  289. //        TocDiv.document.location.reload();
  290.     }
  291.     gbTocLoaded = true;
  292.     return;
  293. }
  294.  
  295. function TOCFocusA()
  296. {
  297.     if (gbIE55) 
  298.     {
  299.         var TocDiv = FindTopLevelLayer('TocNav');
  300.         if (TocDiv && TocDiv.document && TocDiv.document.frames['TocIFrame'])
  301.         {
  302.             TocDiv = TocDiv.document.frames['TocIFrame'];
  303.             if (TocDiv)
  304.                 TocDiv.focus();
  305.         }
  306.     }
  307. }
  308.  
  309. function LoadIndexContent(IndexDiv)
  310. {
  311.     if (gstrIdxDhtml.length > 0) {
  312.         var strFile = location.href;
  313.         var nPosFile = strFile.indexOf(gstrNavFrmst);
  314.         strFile = strFile.substring(0, nPosFile);
  315.         strFile += gstrIdxDhtml;
  316.         if (gbNav4) {
  317.             IndexDiv.src = strFile;
  318.         } else if (gbIE4) {
  319. //            IndexDiv.document.frames['IndexIFrame'].location.href = strFile;
  320.             IndexDiv.document.all.IndexIFrame.src = strFile;
  321.         }
  322.         gbIndexLoaded = true;
  323.     }
  324.     return;
  325. }
  326.  
  327. function LoadFtsContent(FtsDiv)
  328. {
  329.     if (gstrFtsDhtml.length > 0) {
  330.         var strFile = location.href;
  331.         var nPosFile = strFile.indexOf(gstrNavFrmst);
  332.         strFile = strFile.substring(0, nPosFile);
  333.         strFile += gstrFtsDhtml;
  334.         if (gbNav4) {
  335.             FtsDiv.src = strFile;
  336.         } else if (gbIE4) {
  337.         //    FtsDiv.document.frames['FtsIFrame'].location.href = strFile;
  338.             FtsDiv.document.all.FtsIFrame.src = strFile;
  339.         }
  340.         gbFtsLoaded = true;
  341.     }
  342.     return;
  343. }
  344.  
  345.  
  346. function TimeoutChangeToTOC()
  347. {
  348.     if (!gbTocLoaded) {
  349.         var TocDiv = window.NavFrame().FindTopLevelLayer('TocNav');
  350.         if (TocDiv != null) {
  351.             LoadTocContent(TocDiv);
  352.         }
  353.     }
  354.     if (window.TabFrame().document.images['TocTab'] != null) {
  355.         window.TabFrame().document.images['TocTab'].src='bssctab1.gif';
  356.     }
  357.     if (window.TabFrame().document.images['IndexTab'] != null) {
  358.         window.TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  359.     }
  360.     if (window.TabFrame().document.images['FtsTab'] != null) {
  361.         window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  362.     }
  363.     window.NavFrame().ShowDiv('TocNav', true);
  364.     window.NavFrame().ShowDiv('IndexNav', false);
  365.     window.NavFrame().ShowDiv('FtsNav', false);
  366.     if (gbNav4 && window.NavFrame().window.NSscrollbar) {
  367.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('TocNav'));
  368.     }
  369.     window.NavFrame().DoAutoSync();
  370. }
  371.  
  372.  
  373. function ChangeToTOC()
  374. {
  375.     setTimeout("TimeoutChangeToTOC();", 50);
  376.     return;
  377. }
  378.  
  379. function SelectTOC()
  380. {
  381.     if (!gbTocLoaded) {
  382.         var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  383.         if (TocDiv != null) {
  384.             LoadTocContent(TocDiv);
  385.         }
  386.     }
  387.     if (TabFrame().document.images['TocTab'] != null) {
  388.         TabFrame().document.images['TocTab'].src='bssctab1.gif';
  389.     }
  390.     if (TabFrame().document.images['IndexTab'] != null) {
  391.         TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  392.     }
  393.     if (TabFrame().document.images['FtsTab'] != null) {
  394.         TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  395.     }
  396.     NavFrame().ShowDiv('TocNav', true);
  397.     NavFrame().ShowDiv('IndexNav', false);
  398.     NavFrame().ShowDiv('FtsNav', false);
  399.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  400.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('TocNav'));
  401.     }
  402.  
  403.     if (!gbIE5 || gbIE55)
  404.         setTimeout("TOCFocus()", 200);
  405.     else
  406.         window.NavFrame().DoAutoSync();
  407. }
  408.  
  409. function TimeoutChangeToIndex()
  410. {
  411.     if (!gbIndexLoaded) {
  412.         var IndexDiv = window.NavFrame().FindTopLevelLayer('IndexNav');
  413.         if (IndexDiv != null) {
  414.             LoadIndexContent(IndexDiv);
  415.         }
  416.     }
  417.     if (window.TabFrame().document.images['TocTab'] != null) {
  418.         window.TabFrame().document.images['TocTab'].src='bssctab2.gif';
  419.     }
  420.     if (window.TabFrame().document.images['IndexTab'] != null) {
  421.         window.TabFrame().document.images['IndexTab'].src='bssctab3.gif';
  422.     }
  423.     if (window.TabFrame().document.images['FtsTab'] != null) {
  424.         window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  425.     }
  426.     window.NavFrame().ShowDiv('TocNav', false);
  427.     window.NavFrame().ShowDiv('IndexNav', true);
  428.     window.NavFrame().ShowDiv('FtsNav', false);
  429.     if (gbNav4 && window.NavFrame().window.NSscrollbar) {
  430.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('IndexNav'));
  431.     }
  432. }
  433.  
  434.  
  435. function ChangeToIndex()
  436. {
  437.     setTimeout("TimeoutChangeToIndex();", 50);
  438. }
  439.  
  440. function SelectIndex()
  441. {
  442.     if (!gbIndexLoaded) {
  443.         var IndexDiv = NavFrame().FindTopLevelLayer('IndexNav');
  444.         if (IndexDiv != null) {
  445.             LoadIndexContent(IndexDiv);
  446.         }
  447.     }
  448.     if (TabFrame().document.images['TocTab'] != null) {
  449.         TabFrame().document.images['TocTab'].src='bssctab2.gif';
  450.     }
  451.     if (TabFrame().document.images['IndexTab'] != null) {
  452.         TabFrame().document.images['IndexTab'].src='bssctab3.gif';
  453.     }
  454.     if (TabFrame().document.images['FtsTab'] != null) {
  455.         TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  456.     }
  457.     NavFrame().ShowDiv('TocNav', false);
  458.     NavFrame().ShowDiv('IndexNav', true);
  459.     NavFrame().ShowDiv('FtsNav', false);
  460.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  461.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('IndexNav') );
  462.     }
  463.  
  464.     setTimeout("IndexFocus()", 200);
  465. }
  466.  
  467.  
  468. function SelectFTS()
  469. {
  470.     var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
  471.     if (!gbFtsLoaded) {
  472.         if (FtsDiv != null) {
  473.             LoadFtsContent(FtsDiv);
  474.         }
  475.     }
  476.     if (TabFrame().document.images['TocTab'] != null) {
  477.         TabFrame().document.images['TocTab'].src='bssctab2.gif';
  478.     }
  479.     if (TabFrame().document.images['IndexTab'] != null) {
  480.         TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  481.     }
  482.     if (TabFrame().document.images['FtsTab'] != null) {
  483.         TabFrame().document.images['FtsTab'].src='bssctab5.gif';
  484.     }
  485.     NavFrame().ShowDiv('TocNav', false);
  486.     NavFrame().ShowDiv('IndexNav', false);
  487.     NavFrame().ShowDiv('FtsNav', true);
  488.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  489.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('FtsNav'));
  490.     }
  491.  
  492.     setTimeout("FTSFocus()", 200);
  493. }
  494.  
  495. function TOCFocus()
  496. {
  497.     if (!gbIE5 || gbIE55)
  498.     {
  499.         var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  500.         if (TocDiv && TocDiv.document && TocDiv.document.frames['TocIFrame'])
  501.         {
  502.             TocDiv = TocDiv.document.frames['TocIFrame'];
  503.             if (TocDiv) {
  504.                 TocDiv.focus();
  505.                 if (typeof(TocDiv.ItemFocus) != "undefined")
  506.                     TocDiv.ItemFocus();
  507.             }
  508.         }
  509.         window.NavFrame().DoAutoSync();
  510.     }
  511. }
  512.  
  513.  
  514. function FTSFocus()
  515. {
  516.     var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
  517.     if (gbIE4) {
  518.         if (FtsDiv && FtsDiv.document && FtsDiv.document.frames['FtsIFrame'] &&
  519.             FtsDiv.document.frames['FtsIFrame'].frames['ftsform']) 
  520.             FtsDiv = FtsDiv.document.frames['FtsIFrame'].frames['ftsform'];
  521.     }
  522.  
  523.     if (FtsDiv && FtsDiv.FtsInputForm != null) {
  524.         FtsDiv.FtsInputForm.ftsField.focus();
  525.     }
  526. }
  527.  
  528. function IndexFocus()
  529. {
  530.  
  531.     var IndexDiv = NavFrame().FindTopLevelLayer('IndexNav');
  532.     if (gbIE4) {
  533.         if (IndexDiv && IndexDiv.document && IndexDiv.document.frames['IndexIFrame'] &&
  534.             IndexDiv.document.frames['IndexIFrame'].frames['idxform']) 
  535.             IndexDiv = IndexDiv.document.frames['IndexIFrame'].frames['idxform'];
  536.     }
  537.     if (IndexDiv && IndexDiv.IndexInputForm != null) {
  538.         IndexDiv.IndexInputForm.keywordField.focus();
  539.     }
  540. }
  541.  
  542. function SelectInitialTab()
  543. {
  544.     // Create the necessary IFrames for IE
  545.     if (gbIE4) {
  546.         if (FindTopLevelLayer('TocNav') != null && gstrTocDhtml.length > 0) {
  547.             var nIFrameHeight = FindTopLevelLayer('TocNav').style.pixelHeight - 10;
  548.             var strIFrame = '<IFRAME ID="TocIFrame" SRC="' + gstrTocDhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  549.             if (gbMac) {
  550.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  551.             } else {
  552.                 strIFrame += '100%;"></IFRAME>';
  553.             }
  554.             FindTopLevelLayer('TocNav').innerHTML = strIFrame;
  555.         }
  556.         if (FindTopLevelLayer('IndexNav') != null && gstrIdxDhtml.length > 0) {
  557.             var nIFrameHeight = FindTopLevelLayer('IndexNav').style.pixelHeight - 10;
  558.             var strIFrame = '<IFRAME ID="IndexIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  559.             if (gbMac) {
  560.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  561.             } else {
  562.                 strIFrame += '100%;"></IFRAME>';
  563.             }
  564.             FindTopLevelLayer('IndexNav').innerHTML = strIFrame;
  565.         }
  566.  
  567.         if (FindTopLevelLayer('FtsNav') != null && gstrFtsDhtml.length > 0) {
  568.             var nIFrameHeight = FindTopLevelLayer('FtsNav').style.pixelHeight - 10;
  569.             var strIFrame = '<IFRAME ID="FtsIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  570.             if (gbMac) {
  571.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  572.             } else {
  573.                 strIFrame += '100%;"></IFRAME>';
  574.             }
  575.             FindTopLevelLayer('FtsNav').innerHTML = strIFrame;
  576.         }
  577.     }
  578.  
  579.     // Call the real selection function
  580.     setTimeout("SelectInitTabReal()", 50);
  581. }
  582.  
  583. function SelectInitTabReal()
  584. {
  585.     parent.gbTocLoaded = false;
  586.     parent.gbIndexLoaded = false;
  587.     parent.gbFtsLoaded = false;
  588.  
  589.     if (gstrIniDhtml == gstrTocDhtml)    {
  590.         parent.SelectTOC();
  591.     } else if (gstrIniDhtml == gstrIdxDhtml) {
  592.         parent.SelectIndex();
  593.     } else if (gstrIniDhtml == gstrFtsDhtml) {
  594.         parent.SelectFTS();
  595.     }
  596.  
  597. //    if (FindTopLevelLayer('TocNav') != null) {
  598. //        parent.SelectTOC();
  599. //    } else if (FindTopLevelLayer('IndexNav') != null) {
  600. //        parent.SelectIndex();
  601. //    } else if (FindTopLevelLayer('FtsNav') != null) {
  602. //        parent.SelectFTS();
  603. //    }
  604. }
  605.  
  606.  
  607. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  608. //
  609. // Index code
  610. //
  611. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  612.  
  613. var gbIndexLayerInit = false;
  614. function IndexInitPage()
  615. {
  616.     parent.gbIndexLayerInit = false;
  617.     if (gbNav4) {
  618.         TocBuildLayerArrayNS();
  619.         onLoad = TocArrangeAllLayerNS();
  620.     } else if (gbIE4) {
  621.  
  622.         // Mark all Index blocks as "expanded"
  623.         var tempColl = document.all.tags("DIV");
  624.         for (var i = 0; i < tempColl.length; i++) {
  625.             if (tempColl(i).className == "child") tempColl(i).style.display = "block";
  626.         }
  627.  
  628.         // Make an array of parents so we can access them directly
  629.         var tempColl = document.all.tags("DIV");
  630.         var iLetterIndex = 0;
  631.         var nACharCode = "A".charCodeAt(0);
  632.         for (var i = 0; i < tempColl.length; i++) {
  633.             if (tempColl(i).className == "parent" && tempColl(i).innerText.length > 0 ) {
  634.                 gIndexLetterArray[tempColl(i).innerText.charCodeAt(0)] = tempColl(i);
  635.             }
  636.         }
  637.     }
  638.     setTimeout("parent.gbIndexLayerInit = true;",1000);
  639.     return;
  640. }
  641.  
  642. function IndexWriteClassStyle()
  643. {
  644.     document.write("<STYLE TYPE='text/css'>");
  645.     if (gbNav4) {
  646.         document.write(".IndexItem {visibility:inherit; font-size:9pt;}");
  647.         document.write(".parent {font-size:10pt; position:absolute; visibility:hidden}");
  648.         document.write(".child {font-size:10pt; position:absolute; visibility:hidden}");
  649.         document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:-15pt;}");
  650.         document.write("DIV {margin-left:10pt; margin-top:0pt; margin-bottom:0pt}");
  651.         document.write("P {margin-top:0pt; margin-bottom:0pt}");
  652.         document.write("A:link {text-decoration: none; color: 000000}");
  653.         document.write("A:visited {text-decoration: none; color: 333333}");
  654.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  655.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  656.     } else if (gbIE4) {
  657.         if (gbMac) {
  658.             if (gbIE5) {
  659.                 document.write(".IndexItem {visibility:inherit; font-size:10pt;}");
  660.                 document.write(".parent {font-size:10pt;}");
  661.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  662.                 document.write("P {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
  663.                 document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  664.                 document.write("H6.firstsub {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  665.             } else {
  666.  
  667.                 document.write(".IndexItem {visibility:inherit; font-size:12pt;}");
  668.                 document.write(".parent {font-size:14pt;}");
  669.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  670.                 document.write("P {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  671.                 document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  672.                 document.write("H6.firstsub {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:-10pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  673.             }
  674.         } else {
  675.             document.write(".IndexItem {visibility:inherit; font-size:8pt;}");
  676.             document.write(".parent {font-size:10pt;}");
  677.             document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  678.             document.write("P {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt;}");
  679.             document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  680.         }
  681.         document.write(".child {display:block}");
  682.         document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  683.         document.write("A:link {text-decoration: none; color: 000000}");
  684.         document.write("A:visited {text-decoration: none; color: 333333}");
  685.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  686.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  687.     }
  688.     document.write("</STYLE>");
  689.     return;
  690. }
  691.  
  692. //Define variable arguments as: strTitle, strUrl
  693. function TE() 
  694. {
  695.     var argLen = TE.arguments.length;
  696.     this.strTitle = TE.arguments[0];
  697.     this.strURL = TE.arguments[1];
  698. }
  699.  
  700. //Define variable arguments as: strKeyword [,strTopicIndex]*
  701. function IndexKeywordEntry() 
  702. {
  703.     var argLen = IndexKeywordEntry.arguments.length;
  704.     this.strKeyword = IndexKeywordEntry.arguments[0];
  705.     this.arrayTopics = new Array();
  706.  
  707.     // Now add all of the topic entries
  708.     for (var i=0; i < argLen - 1; i++) {
  709.         this.arrayTopics[i] = IndexKeywordEntry.arguments[i + 1];
  710.     }
  711. }
  712.  
  713.  
  714. function IndexBody()
  715. {
  716.     // Get the appropriate item to add items to
  717.     var layerFind = null;
  718.     if (gbIE4) {
  719.         layerFind = parent.document.frames['idxbody'];
  720.     } else if (gbNav4) {
  721.         layerFind = parent.document.idxbody.document;
  722.     }
  723.     
  724.     return layerFind;
  725. }
  726.  
  727. function IndexForm()
  728. {
  729.     // Get the appropriate item to add items to
  730.     var layerFind = null;
  731.     if (gbIE4) {
  732.         layerFind = parent.document.frames['idxform'];
  733.     } else if (gbNav4) {
  734.         layerFind = parent.document.idxform.document;
  735.     }
  736.     
  737.     return layerFind;
  738. }
  739.  
  740. function IndexExpandIt(elId, bForceOpen) 
  741. {
  742.     var layerChild = null;
  743.     if (gbIE4) {
  744.         layerChild = TocExpandIE(elId, false, bForceOpen);
  745.  
  746.         if (!bForceOpen) {
  747.             var nNewScroll = document.body.scrollTop;
  748.             if (layerChild.style.display == "block") {
  749.                 var nItemTop = layerChild.offsetTop;
  750.                 var nItemBottom = nItemTop + layerChild.offsetHeight;
  751.                 // Make sure the bottom is visible if possible
  752.                 if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
  753.                     nNewScroll = nItemBottom - document.body.clientHeight;
  754.                 }
  755.                 // If expanded item is bigger than the client area, scroll the item to the top
  756.                 if (nItemBottom - nItemTop > document.body.clientHeight) {
  757.                     nNewScroll = nItemTop - 20;
  758.                 }
  759.             }
  760.             document.body.scrollTop = nNewScroll;
  761.         }
  762.     } else if (gbNav4) {
  763.         layerChild = TocExpandNS(elId, false, bForceOpen);
  764.         if (window.NSscrollbar != null) {
  765.             window.NSscrollbar.SetContentHeight(nextY);
  766.             window.NSscrollbar.SetContentWidth(nextX);
  767.         }
  768.     }
  769.     return layerChild;
  770. }
  771.  
  772.  
  773. function IndexInputEnable(bEnable)
  774. {
  775.     gbIndexInputEnable = bEnable;
  776.     return;
  777. }
  778.  
  779. function IndexInputSubmit()
  780. {
  781.     IndexLookup(true);
  782.     return;
  783. }
  784.  
  785. //Initize the site
  786. function IndexSiteInit()
  787. {
  788.   if (!window.Array) return;
  789.  
  790.   if (gbNav4) document.captureEvents(Event.KEYUP);
  791.   document.onkeyup = IndexLookupKeydown;
  792. }
  793.  
  794. function IndexLookupKeydown() 
  795. {
  796.     if (gbIE4)
  797.     {
  798.         if (event.keyCode == 13)    //Enter key
  799.         {
  800.             IndexLookup(true);
  801.         }
  802.         else 
  803.             IndexLookup(false);
  804.     }
  805.     else
  806.         IndexLookup(false);
  807. }
  808.  
  809. function IndexLookup(bCR) 
  810. {
  811.     if (!parent.gbIndexLayerInit) {
  812.         return; 
  813.     }
  814.  
  815.     if (!gbIndexInputEnable && !gbMac) {
  816.         return;
  817.     }
  818.  
  819.     var strInput = document.IndexInputForm.keywordField.value.toUpperCase();
  820.     if (strInput != "") {
  821.         IndexSiteDisplay(strInput, bCR);
  822.     }
  823.  
  824.     if (gbMac) {
  825.         document.IndexInputForm.keywordField.focus();
  826.     }
  827.  
  828.     return;
  829. }
  830.  
  831. function  IndexSiteDisplay(strInput, bCR)
  832. {
  833.     // Get the topmost Index layer
  834.     var IndexDiv = IndexBody();
  835.  
  836.     // Get the layer for the first letter
  837.     var cFirst = strInput.charAt(0);
  838.     cFirst = GetFlagChar(cFirst);
  839.     var layerFirst = null;
  840.     if (gbNav4) {
  841.         for (var iLayer = 0; iLayer < document.layers.length; iLayer++) {
  842.             if ((document.layers[iLayer].id.indexOf("Parent") != -1) &&
  843.                 (document.layers[iLayer].id.charAt(0) == cFirst)) {
  844.                 layerFirst = document.layers[iLayer];
  845.                 break;
  846.             }
  847.         }
  848.         if (layerFirst == null) {
  849.             layerFirst = document.BookR0000000Parent;
  850.         }
  851.     } else if (gbIE4) {
  852.         layerFirst = IndexDiv.gIndexLetterArray[cFirst.charCodeAt(0)];
  853.     }
  854.  
  855.     // If we didn't find anything then return - something went terribly wrong
  856.     if (layerFirst == null) {
  857.         return;
  858.     }
  859.  
  860.     // Expand the first layer
  861.     var strLayerID = layerFirst.id;
  862.     var iParent = strLayerID.indexOf("Parent");
  863.     strLayerID = strLayerID.substr(0, iParent);
  864.  
  865.     var layerChild = IndexDiv.IndexExpandIt(strLayerID, true);
  866.  
  867.     // Find the first child that "matches" the item we are searchig for
  868.     var MatchingItem = null;
  869.     if (gbNav4) {
  870.     } else if (gbIE4) {
  871.  
  872.         var tempColl = layerChild.all.tags("P");
  873.         if (tempColl.length == 0) {
  874.             MatchingItem = layerChild;
  875.         } else {
  876.             var iStart = 0;
  877.             var iEnd = tempColl.length - 1;
  878.             var iMid = 0;
  879.             var strItemUpper = "";
  880.             while (iStart <= iEnd) {
  881.                 iMid = iStart + iEnd;
  882.                 iMid >>= 1;
  883.                 strItemUpper = tempColl(iMid).innerText;
  884.                 strItemUpper = strItemUpper.toUpperCase();
  885.                 if (compare(strItemUpper, strInput) > 0  ) {
  886.                     iEnd = iMid - 1;
  887.                 } else if (compare(strItemUpper, strInput) < 0) {
  888.                     iStart = iMid + 1;
  889.                     if (iStart < tempColl.length)
  890.                         iMid = iStart;
  891.                 } else break;
  892.             }
  893.  
  894.             // Search backward to find the first one that partially matches
  895.             var iMatch = 0;
  896.             for (var iMatch = iMid; iMatch >= 0; iMatch--) {
  897.                 strItemUpper = tempColl(iMatch).innerText;
  898.                 strItemUpper = strItemUpper.toUpperCase();
  899.                 if (compare(strItemUpper, strInput) != 0) {
  900.                     break;
  901.                 }
  902.             }
  903.             if (iMatch != iMid) {
  904.                 if (iMatch >= 0) {
  905.                     if (iMatch < tempColl.length - 1) {
  906.                         iMid = iMatch + 1;
  907.                     } else {
  908.                         iMid = iMatch;
  909.                     }
  910.                 } else {
  911.                     iMid = 0;
  912.                 }
  913.             }
  914.             MatchingItem = tempColl(iMid);
  915.         }
  916.     }
  917.  
  918.     // Scroll to the closest matching item
  919.     if (MatchingItem) {
  920.         if (gbNav4) {
  921.         } else if (gbIE4) {
  922.             IndexDiv.document.body.scrollTop = MatchingItem.offsetTop;
  923.  
  924.             // Set the focus on the selected hyperlink (if there is one)
  925.             tempColl = MatchingItem.all.tags("A");
  926.             if (tempColl.length > 0) {
  927.                 // If a carriage return was used then simulate a click
  928.                 if (bCR) {
  929.                     tempColl(0).click();
  930.                 } else {
  931.                     // Simply set the focus to the hyperlink
  932.                     if (!gbIE5 || gbIE55) {
  933.                        var nbTag = MatchingItem.all.tags("NOBR");
  934.                        if (nbTag.length > 0)
  935.                            HighLightElement(nbTag(0));
  936.                     } else {
  937.                        tempColl(0).focus();
  938.                     }
  939.                 }
  940.                 IndexForm().document.IndexInputForm.keywordField.focus();
  941.             }
  942.         }
  943.     }
  944.  
  945.     return;
  946. }
  947.  
  948. var gBsLastHighLightElement = null;
  949. function HighLightElement(objAnchor)
  950. {
  951.     resetHighLight();
  952.     objAnchor.style.backgroundColor = "lightgrey";
  953.     gBsLastHighLightElement = objAnchor;
  954. }
  955.  
  956. function resetHighLight()
  957. {
  958.     if (gBsLastHighLightElement != null)
  959.     {
  960.         gBsLastHighLightElement.style.backgroundColor = "white";
  961.     }
  962. }
  963.  
  964. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  965. //
  966. // TOC code
  967. //
  968. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  969. var imgBookClose ="bssctoc1.gif";
  970. var imgBookOpen  ="bssctoc2.gif";
  971.  
  972. var  elTocArray = new Array();
  973. var  elTocArrayNum = 0;
  974.  
  975. function TocWriteClassStyle()
  976. {
  977.     document.write("<STYLE TYPE='text/css'>");
  978.     if (gbNav4) {
  979.         document.write(".parent {position:absolute; visibility:hidden}");
  980.         document.write(".child {position:absolute; visibility:hidden}");
  981.         document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:-15pt;}");
  982.         document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  983.         document.write("P {margin-top:0pt; margin-bottom:0pt}");
  984.         document.write("PRE {margin-top:0pt; margin-bottom:0pt}");
  985.     } else if (gbIE4) {
  986.         if (gbMac) {
  987.             if (gbIE5){
  988.                 document.write(".parent {font-size:10pt;}");
  989.                 document.write("P {font-family:'Arial'; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
  990.                 document.write("PRE {font-family:'Arial'; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
  991.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  992.                 document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  993.             } else {
  994.                 document.write(".parent {font-size:14pt;}");
  995.                 document.write("P {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  996.                 document.write("PRE {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  997.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  998.                 document.write("DIV {margin-top:0pt; margin-bottom:0pt;}");
  999.             }
  1000.         } else {
  1001.             document.write(".parent {font-size:10pt;}");
  1002.             document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  1003.             document.write("P {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
  1004.             document.write("PRE {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
  1005.             document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  1006.         }
  1007.         document.write(".child {display:none}");
  1008.         document.write("A:link {text-decoration: none; color: 000000}");
  1009.         document.write("A:visited {text-decoration: none; color: 333333}");
  1010.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  1011.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  1012.     }
  1013.     document.write("</STYLE>");
  1014.     return;
  1015. }
  1016.  
  1017. function TocWriteFixedWidth(bBegin, nWidth)
  1018. {
  1019.     //Avoid the wrap of text after book/page, make a invisble outter table is approch (for IE4 iMac only)
  1020.     // This will make IE4 DHTML Sync Toc DO NOT WORK.
  1021.     if ((gbIE4) && (gbMac) && (!gbIE5)) {
  1022.         if (bBegin)    {
  1023.             document.write("<table width=" + nWidth +" border=0><tr><td>");
  1024.         } else    {
  1025.             document.write("</td></tr></table>");
  1026.         }
  1027.     }
  1028. }
  1029.  
  1030. //Assign the layer's visibility at initialize the Page
  1031. function TocInitPage()
  1032. {
  1033. //    var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  1034. //    if (TocDiv != null) {
  1035. //        return;
  1036. //    }
  1037.     if (gbNav4) {
  1038. //        for (var i=0; i < document.layers.length; i++) {
  1039. //            var whichEl = document.layers[i];
  1040. //            if (whichEl.id.indexOf("Child") != -1) {
  1041. //                whichEl.visibility = "hide";
  1042. //            } else {
  1043. //                whichEl.visibility = "show";
  1044. //            }
  1045. //        }
  1046.         TocBuildLayerArrayNS();
  1047.         onLoad  = TocArrangeAllLayerNS();
  1048.     } else if (gbIE4) {
  1049.  
  1050.         // Select the first hyperlink
  1051.         var tempColl = document.all.tags("A");
  1052.         if (tempColl.length > 0) {
  1053.             tempColl(0).focus();
  1054.         }
  1055.     }
  1056.     return;
  1057. }
  1058.  
  1059. function TocShowLayer(whichEl, bShow)
  1060. {
  1061.     if (bShow) {
  1062.         whichEl.visibility = "show";
  1063.     } else {
  1064.         whichEl.visibility = "hide";
  1065.     }
  1066.     for (var i=0; i<whichEl.document.layers.length; i++) {
  1067.         var whichChildEl = whichEl.document.layers[i];
  1068.         ShowLayer(whichChildEl, bShow);
  1069.     }
  1070. }
  1071.  
  1072. function TocExpandAll()
  1073. {
  1074.     for (var i=0; i<document.layers.length; i++) {
  1075.         var whichEl = document.layers[i];
  1076.         TocShowLayer(whichEl, true);
  1077.     }
  1078.     TocBuildLayerArrayNS();
  1079.     TocArrangeAllLayerNS();
  1080.  
  1081.     return;
  1082. }
  1083.  
  1084. function TocCollapseAll()
  1085. {
  1086.     for (var i=0; i<document.layers.length; i++) {
  1087.         var whichEl = document.layers[i];
  1088.         ShowLayer(whichEl, false);
  1089.         if (whichEl.id.indexOf("Child") != -1) {
  1090.             whichEl.visibility = "hide";
  1091.         } else {
  1092.             whichEl.visibility = "show";
  1093.         }
  1094.     }
  1095.     TocBuildLayerArrayNS();
  1096.     TocArrangeAllLayerNS();
  1097.  
  1098.     return;
  1099. }
  1100.  
  1101. //Expand a layer
  1102. function TocExpandIt(elId)
  1103. {
  1104.     TocExpandIt2(elId, false);
  1105. }
  1106.  
  1107. //Expand a layer
  1108. function TocExpandIt2(elId, bForceOpen)
  1109. {
  1110.     if (gbIE4) {
  1111.         var child = TocExpandIE(elId, true, bForceOpen);
  1112.         var nNewScroll = document.body.scrollTop;
  1113.         if (child.style.display == "block") {
  1114.             var nItemTop = child.offsetTop;
  1115.             var nItemBottom = nItemTop + child.offsetHeight;
  1116.             // Make sure the bottom is visible if possible
  1117.             if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
  1118.                 nNewScroll = nItemBottom - document.body.clientHeight;
  1119.             }
  1120.             // If expanded item is bigger than the client area, scroll the item to the top
  1121.             if (nItemBottom - nItemTop > document.body.clientHeight) {
  1122.                 nNewScroll = nItemTop - 20;
  1123.             }
  1124.         }
  1125.         document.body.scrollTop = nNewScroll;
  1126.     } else if (gbNav4) {
  1127.         TocExpandNS(elId, true, false);
  1128.         if (window.NSscrollbar != null) {
  1129.             window.NSscrollbar.SetContentHeight(nextY);
  1130.             window.NSscrollbar.SetContentWidth(nextX);
  1131.         }
  1132.     }
  1133.     return;
  1134. }
  1135.  
  1136.  
  1137. ////////////////////////////////////////////////////////////////
  1138. //Functions for IE
  1139. function TocExpandIE(elId, bChangeImg, bForceOpen) 
  1140.     var whichEl = eval(elId + "Child");
  1141.     var whichIm = document.images[elId];
  1142.  
  1143.     if (whichEl == null) {
  1144.         return null;
  1145.     }
  1146.  
  1147.     if ((whichEl.style.display != "block") || bForceOpen) {
  1148.         whichEl.style.display = "block";
  1149.         if (bChangeImg) {
  1150.             whichIm.src = imgBookOpen;        
  1151.         }
  1152.     } else {
  1153.         whichEl.style.display = "none";
  1154.         if (bChangeImg) {
  1155.             whichIm.src = imgBookClose;
  1156.         }
  1157.         if (gbMac) {
  1158.             //YJ: ?? can not scroll into view, if div has fixed width, it will scroll horizal to the very end.
  1159.             //whichEl.scrollIntoView(false);
  1160.         }
  1161.     }
  1162.     return whichEl;
  1163. }
  1164.  
  1165. ////////////////////////////////////////////////////////////////
  1166. //Functions for NS
  1167. function TocExpandNS(elId, bChangeImg, bForceOpen)
  1168. {
  1169.     var whichParent = null;
  1170.     var whichChild  = null;
  1171.     var idParent = elId + "Parent";
  1172.     var idChild  = elId + "Child";
  1173.     for (var i=0; i<elTocArrayNum ;i++) {
  1174.         if  (idParent == elTocArray[i].id) {
  1175.             whichParent = elTocArray[i].el;
  1176.  
  1177.             if ((i+1 < elTocArrayNum) && (idChild == elTocArray[i+1].id))
  1178.             {
  1179.                 whichChild = elTocArray[i+1].el;
  1180.             }
  1181.             break;
  1182.         }
  1183.     }
  1184.     if (whichParent == null)    return null;
  1185.     var imgParent = whichParent.document.images[0];
  1186.     if (whichChild == null) return null;
  1187.  
  1188.     if (whichChild.visibility == "hide")
  1189.     {
  1190.         whichChild.visibility = "show";
  1191.         if (bChangeImg) {
  1192.             imgParent.src = imgBookOpen;
  1193.         }
  1194.         for (var i=0; i<whichChild.layers.length; i++)
  1195.         {
  1196.             var whichEl = whichChild.layers[i];
  1197.             if (whichEl.id.indexOf("Parent") != -1)
  1198.                 whichEl.visibility = "show";
  1199.         }
  1200.     }
  1201.     else if (bForceOpen)
  1202.     {
  1203.         return whichChild;
  1204.     }
  1205.     else
  1206.     {
  1207.         whichChild.visibility = "hide";
  1208.         if (bChangeImg) {
  1209.             imgParent.src = imgBookClose;
  1210.         }
  1211.         for (var i=0; i<whichChild.layers.length; i++)
  1212.         {
  1213.             var whichEl = whichChild.layers[i];
  1214.             whichEl.visibility = "hide";
  1215.         }
  1216.     }
  1217.     TocArrangeAllLayerNS(bChangeImg);
  1218.     return whichChild;
  1219. }
  1220.  
  1221. function elTocLayerNS(elLayer, elLayerId)
  1222. {
  1223.     this.el  = elLayer;
  1224.     this.id  = elLayerId;
  1225.     return;
  1226. }
  1227.  
  1228. function TocFindLayerNS(elLayer)
  1229. {
  1230.     for (var i = 0; i < elLayer.layers.length; i++) {
  1231.         var whichEl = elLayer.layers[i];
  1232. //        if (typeof whichEl != "undefined") {
  1233.         if ((whichEl.id.indexOf("Parent") != -1) ||
  1234.             (whichEl.id.indexOf("Child") != -1)) {
  1235.             elTocArray[elTocArrayNum] = new elTocLayerNS(whichEl,whichEl.id);
  1236.             elTocArrayNum++;
  1237.             TocFindLayerNS(whichEl);
  1238.         }
  1239.     }
  1240.     return;
  1241. }
  1242.  
  1243. function TocBuildLayerArrayNS()
  1244. {
  1245.     elTocArrayNum = 0;
  1246.     TocFindLayerNS(document);
  1247.     return;
  1248. }
  1249.  
  1250. var  nextY = 0;
  1251. var  nextX = 0; // real means : the maxium width of sub-layers' width
  1252. function TocArrangeLayerNS(elLayer, bShowLayer, iLevel, bChangeImg)
  1253. {
  1254.     var i = 0;
  1255.     while (i < elLayer.layers.length)
  1256.     {
  1257.         var whichParent = elLayer.layers[i];
  1258.         
  1259.         if (whichParent.id.indexOf("Parent") == -1) 
  1260.             i++; // Check to make sure this is a "parent" because we do have extra layers on the page
  1261.         else
  1262.         {
  1263.             var whichChild  = elLayer.layers[i+1];
  1264.             if (bShowLayer)
  1265.             {   // Check to see if we have a second (or lower level) block with pages
  1266.                 // on top of books. If so, Netscape would ordinarily add space for the
  1267.                 // BLOCKQUOTE, but we don't want one - so remove the space.
  1268.                 if( (i == 0) && (iLevel > 0) &&
  1269.                     (null != whichParent.parentLayer) &&
  1270.                     (whichParent.parentLayer.document.images.length > 0))
  1271.                     nextY -= whichParent.document.height;
  1272.  
  1273.                 whichParent.pageY = nextY;
  1274.                 whichParent.visibility = "show";
  1275.  
  1276.                 whichParent.clip.bottom = whichParent.document.height;
  1277.                 whichParent.clip.right  = whichParent.document.width + iLevel*20;// plus indent width
  1278.                 if( whichParent.clip.right > nextX )
  1279.                     nextX = whichParent.clip.right;
  1280.  
  1281.                 nextY += whichParent.document.height;
  1282.                 if (whichChild.visibility == "show")
  1283.                 {
  1284.                     if (bChangeImg)
  1285.                         whichParent.document.images[0].src = imgBookOpen;
  1286.  
  1287.                     whichChild.pageY = nextY;
  1288.                     nextY += whichChild.document.height;
  1289.  
  1290.                     whichChild.clip.right = whichChild.document.width + iLevel*20;// plus indent width
  1291.                     if( whichChild.clip.right > nextX )
  1292.                         nextX = whichChild.clip.right;
  1293.  
  1294.                     TocArrangeLayerNS(whichChild, true, iLevel + 1, bChangeImg);
  1295.                     whichChild.clip.bottom = nextY - window.NSscrollbar.GetContentVerticalPos();
  1296.                     if( nextX > whichChild.clip.right )
  1297.                         whichChild.clip.right = nextX;
  1298.                 }
  1299.                 else
  1300.                 {
  1301.                     if (bChangeImg)
  1302.                         whichParent.document.images[0].src = imgBookClose;
  1303.  
  1304.                     TocArrangeLayerNS(whichChild, false, iLevel + 1, bChangeImg);
  1305.                 }
  1306.             }
  1307.             else
  1308.             {
  1309.                 if (bChangeImg)
  1310.                     whichParent.document.images[0].src = imgBookClose;
  1311.                 whichParent.visibility = "hide";
  1312.                 whichParent.clip.bottom = 0;
  1313.                 whichParent.clip.right  = 0;
  1314.  
  1315.                 whichChild.visibility = "hide";
  1316.                 whichChild.clip.bottom = 0;
  1317.                 whichChild.clip.right  = 0;
  1318.                 TocArrangeLayerNS(whichChild, false, iLevel, bChangeImg);
  1319.             }
  1320.             i += 2;
  1321.         }
  1322.     }
  1323.     return;
  1324. }
  1325.  
  1326. function TocArrangeAllLayerNS(bChangeImg) 
  1327. {
  1328.     if (document.layers.length > 0) {
  1329.         nextX = document.layers[0].pageX;
  1330.         nextY = document.layers[0].pageY;
  1331.         TocArrangeLayerNS(document, true, 0, bChangeImg);
  1332.     }
  1333.     return;
  1334. }
  1335.  
  1336. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  1337. //
  1338. // FTS code
  1339. //
  1340. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  1341.  
  1342. function FtsWriteClassStyle()
  1343. {
  1344.     document.write("<STYLE TYPE='text/css'>");
  1345.     if (gbNav4) {
  1346.         document.write("P {font-family:'Arial'; font-size:9pt;}");
  1347.         document.write("A:link {text-decoration: none; color: 000000}");
  1348.         document.write("A:visited {text-decoration: none; color: 333333}");
  1349.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  1350.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  1351.     } else if (gbIE4) {
  1352.         if (gbMac) {
  1353.             if (gbIE5) {
  1354.                 document.write("P {font-family:'Arial'; font-size:10pt;}");
  1355.                 document.write("dt {font-family:'Arial'; font-size:10pt;}");
  1356.             } else {
  1357.                 document.write("P {font-family:'Arial'; font-size:12pt;}");
  1358.                 document.write("dt {font-family:'Arial'; font-size:12pt;}");
  1359.             }
  1360.         } else {
  1361.             document.write("P {font-family:'Arial'; font-size:9pt;}");
  1362.             document.write("dt {font-family:'Arial'; font-size:9pt;}");
  1363.         }
  1364.         document.write("A:link {text-decoration: none; color: 000000}");
  1365.         document.write("A:visited {text-decoration: none; color: 333333}");
  1366.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  1367.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  1368.     }
  1369.     document.write("</STYLE>");
  1370.     return;
  1371. }
  1372.  
  1373. //Define variable arguments as: strKeyword [,strTopicIndex]*
  1374. //function KeywordEntry() 
  1375. function KE() 
  1376. {
  1377.     var argLen = KE.arguments.length;
  1378.     this.strKeyword = KE.arguments[0];
  1379.     this.arrayTopics = new Array();
  1380.  
  1381.     // Now add all of the topic entries
  1382.     for (var i=0; i < argLen - 1; i++) {
  1383.         this.arrayTopics[i] = KE.arguments[i + 1];
  1384.     }
  1385. }
  1386.  
  1387. /*
  1388. function FtsStopWord()
  1389. {
  1390.     this.strStopWord = FtsStopWord.arguments[0];
  1391. }*/
  1392.  
  1393. function FtsInputEnable(bEnable)
  1394. {
  1395.    gbFtsInputEnable = bEnable;
  1396.    return;
  1397. }
  1398.  
  1399. function FtsInputSubmit()
  1400. {
  1401.     //Hack for IE, have to use keydown to get enter event,
  1402.     //Embedding WebHelp to WinHelp2000 will fail to fire the submit the form. 
  1403.     if (!gbIE4)
  1404.     {
  1405.         FtsLookup();
  1406.     }
  1407.     return false;
  1408. }
  1409.  
  1410. //Initize the site
  1411. function FtsInit()
  1412. {
  1413.   if (!window.Array) return;
  1414.  
  1415.   if (gbNav4) document.captureEvents(Event.KEYUP);
  1416.   document.onkeyup = FtsLookupKeydown;
  1417. }
  1418.  
  1419. function FtsLookupKeydown() 
  1420. {
  1421.     if (gbIE4)
  1422.     {
  1423.         if (event.keyCode == 13)    //Enter key
  1424.         {
  1425.             FtsLookup();
  1426.         }
  1427.     }
  1428. }
  1429.  
  1430. function FtsLookup() 
  1431. {
  1432.     if (!gbFtsInputEnable && !gbMac)
  1433.         return;
  1434.  
  1435.     var strInput = document.FtsInputForm.ftsField.value.toLowerCase();
  1436.     if (strInput != "") {
  1437.         FtsDisplay(strInput);
  1438.     }
  1439.  
  1440.     if (gbMac) {
  1441.         document.FtsInputForm.ftsField.focus();
  1442.     }
  1443. }
  1444.  
  1445. var gstrDisplayInput = "";
  1446.  
  1447. function FtsFindTable()
  1448. {
  1449.     // Get the appropriate item to add items to
  1450.     var layerFind = null;
  1451.     if (gbIE4) {
  1452.         layerFind = parent.document.frames['ftsbody'].document.all.FtsFindTable;
  1453.     } else if (gbNav4) {
  1454.         layerFind = parent.document.ftsbody.document.FtsFindTable.document;
  1455.     }
  1456.     
  1457.     return layerFind;
  1458. }
  1459.  
  1460. function FtsBody()
  1461. {
  1462.     // Get the appropriate item to add items to
  1463.     var layerFind = null;
  1464.     if (gbIE4) {
  1465.         layerFind = parent.document.frames['ftsbody'];
  1466.     } else if (gbNav4) {
  1467.         layerFind = parent.document.ftsbody.document;
  1468.     }
  1469.     
  1470.     return layerFind;
  1471. }
  1472.  
  1473. function FtsDisplay(strInput)
  1474. {
  1475.     var layerFind = FtsFindTable();
  1476.     if (layerFind == null) {
  1477.         return;
  1478.     }
  1479.  
  1480.     // Let the user know we are busy
  1481.     var strHtm = "<P><B><FONT SIZE=2>Searching...</FONT></B></P>"
  1482.     if (gbIE4) {
  1483.         layerFind.innerHTML = strHtm;
  1484.     } else if (gbNav4) {
  1485.         layerFind.write(strHtm);
  1486.         layerFind.close();
  1487.     }
  1488.     window.gstrDisplayInput = strInput;
  1489.     setTimeout("FtsDisplayReal()", 50);
  1490.  
  1491.     return;
  1492. }
  1493.  
  1494. function FtsDisplayReal()
  1495. {
  1496.     var FtsDiv = FtsBody();
  1497. //    if (gbNav4) {
  1498. //        FtsDiv = FindTopLevelLayer('FtsNav');
  1499. //    } else if (gbIE4) {
  1500. //        FtsDiv = parent.parent.FindTopLevelLayer('FtsNav');
  1501. //        FtsDiv = FtsDiv.document.frames['FtsIFrame'].document.all.ftsbody;
  1502. //    }
  1503.  
  1504.     var strInput = window.gstrDisplayInput;
  1505.     var nKeywordArrayLen = FtsDiv.gKE.length;
  1506.     var nTopicArrayLen = FtsDiv.gTE.length;
  1507.     var nStopArrayLen = FtsDiv.gSTP.length;
  1508.  
  1509.     // Get the appropriate item to add items to
  1510.     var layerFind = FtsFindTable();
  1511.     if (layerFind == null) {
  1512.         return;
  1513.     }
  1514.  
  1515.     // Keep track of which operation we are currently in
  1516.     // 0 = OR; 1 = AND
  1517.     var nCurrentOp = 0;
  1518.     var bNot = false;
  1519.  
  1520.     // Loop through the words in the input string
  1521.     var bFinished = false;
  1522.     var bFirstKeyword = true;
  1523.     var strCurrentWord = "";
  1524.     var strCurrentStem = "";
  1525.     var strKeyword = "";
  1526.     var strHtm = "";
  1527.     var nFirstMatch = -1;
  1528.     var nLastMatch  = -1;
  1529.     var i=0;
  1530.     var iSpace = 0;
  1531.     var iFound = 0;
  1532.     var SearchTopicArray = new Array();
  1533.     var iSearch = 0;
  1534.     // If you change this Word Break string make sure you also change it in FtsDataBase.CPP
  1535.     var FTS_WORD_BREAK_CHARS = "\t\r\n\"\\ .,!@#$%^&*()~'`:;<>?/{}[]|+-=\x85\x92\x93\x94\x95\x96\x97\x99\xA9\xAE\xB7";
  1536.     var nNumWordBreakChars = FTS_WORD_BREAK_CHARS.length;
  1537.  
  1538.     // Clear the flags for each of the topics
  1539.     var iTopic = 0;
  1540.     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1541.         SearchTopicArray[iTopic] = 0;
  1542.     }
  1543.  
  1544.     while (!bFinished) {
  1545.  
  1546.         // Get the next word
  1547.         iSpace = -1;
  1548.         iChar = 0;
  1549.         iSep = -1;
  1550.         for (var iChar = 0; iChar < nNumWordBreakChars; iChar++) {
  1551.             iFound = strInput.indexOf(FTS_WORD_BREAK_CHARS.charAt(iChar));
  1552.             if ((iFound != -1) && ((iSpace == -1) || (iFound < iSpace))) {
  1553.                 iSpace = iFound;
  1554.                 iSep = iChar;
  1555.             }
  1556.         }
  1557.         if (iSpace == -1) {
  1558.             strCurrentWord = strInput;
  1559.             strInput = "";
  1560.         } else {
  1561.             strCurrentWord = strInput.substr(0, iSpace);
  1562.             strInput = strInput.substr(iSpace + 1);
  1563.         }
  1564.  
  1565.         // Check for operators or a blank word
  1566.         if ((strCurrentWord == "or") ||
  1567.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "|"))) {
  1568.             nCurrentOp = 0;
  1569.             bNot = false;
  1570.         } else if ((strCurrentWord == "and") ||
  1571.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "&"))) {
  1572.             nCurrentOp = 1;
  1573.             bNot = false;
  1574.         } else if ((strCurrentWord == "not") ||
  1575.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "~"))) {
  1576.             bNot = true;
  1577.         } else if (strCurrentWord == "") {
  1578.             if (strInput == "") {
  1579.                 break;
  1580.             } else {
  1581.                 continue;
  1582.             }
  1583.         } else if (!IsStopWord(strCurrentWord, FtsDiv.gSTP, nStopArrayLen)){
  1584.  
  1585.             // See if this is has a NOT at the beginning
  1586.             if (strCurrentWord.substr(0, 1) == "~") {
  1587.                 bNot = true;
  1588.                 strCurrentWord = strCurrentWord.substr(1);
  1589.             }
  1590.  
  1591.             // Get the stemmed version of the word
  1592.             strCurrentStem = GetStem(strCurrentWord);
  1593.  
  1594.             // See if the stemmed word is found in the list
  1595.             iFound = -1;
  1596.             iFound = FtsFindKeyword(strCurrentStem, FtsDiv.gKE, nKeywordArrayLen);
  1597.  
  1598.             // Did we find the keyword?
  1599.             if (iFound != -1) {
  1600.  
  1601.                 // See if we are performing an OR operation
  1602.                 var nNumTopics = FtsDiv.gKE[iFound].arrayTopics.length;
  1603.                 if (nCurrentOp == 0) {
  1604.                     if (bNot) {
  1605.                         var cFoundArrayTopics =  FtsDiv.gKE[iFound].arrayTopics;
  1606.                         // Add all topics that are not in the list for this keyword
  1607.                         for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1608.                             // See if the topic is in the list for this keyword
  1609.                             for (iListTopic = 0; iListTopic < nNumTopics; iListTopic++) {
  1610.                                 if (cFoundArrayTopics[iListTopic] == iTopic) {
  1611.                                     break;
  1612.                                 }
  1613.                             }
  1614.                             if (iListTopic == nNumTopics) {
  1615.                                 // The topic is not in the list for the current keyword, so add it
  1616.                                 SearchTopicArray[iTopic] = 1;
  1617.                             }
  1618.                         }
  1619.  
  1620.                     } else {
  1621.                         // Loop through the topics that have the keyword and add them to the list
  1622.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1623.                             var nTopicNum = FtsDiv.gKE[iFound].arrayTopics[iTopic];
  1624.                             // Add the topic to the list
  1625.                             SearchTopicArray[nTopicNum] = 1;
  1626.                         }
  1627.                     }
  1628.                 // See if this is an AND operation
  1629.                 } else if (nCurrentOp == 1) {
  1630.  
  1631.                     if (bNot) {
  1632.                         // Loop through the topics for the current word and remove them from the list
  1633.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1634.                             SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] = 0;
  1635.                         }
  1636.                     } else {
  1637.                         // Loop through the topics already in the list and remove them if they are not
  1638.                         // in the list for the current word
  1639.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1640.                             if (SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] == 1) {
  1641.                                 SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] = -1;
  1642.                             }
  1643.                         }
  1644.                         for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1645.                             if (SearchTopicArray[iTopic] == -1) {
  1646.                                 SearchTopicArray[iTopic] = 1;
  1647.                             } else {
  1648.                                 SearchTopicArray[iTopic] = 0;
  1649.                             }
  1650.                         }
  1651.                     }
  1652.                 }
  1653.             } else {
  1654.                 // Word was not found
  1655.  
  1656.                 // Clear the list if this is an AND operation
  1657.                 if ((nCurrentOp == 1) && (!bNot)) {
  1658.                     for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
  1659.                         SearchTopicArray[iSearch] = 0;
  1660.                     }
  1661.  
  1662.                 // Add all items to the list if this is an OR operation with a NOT operator
  1663.                 } else if ((nCurrentOp == 0) && (bNot)) {
  1664.  
  1665.                     // Add all topics that are not in the list for this keyword
  1666.  
  1667.                     // First set all flags to -1 if they are not already set
  1668.                     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1669.                         if (SearchTopicArray[iTopic] == 0) {
  1670.                             SearchTopicArray[iTopic] = -1;
  1671.                         }
  1672.                     }
  1673.  
  1674.                     // Now clear all -1s for topics associated with this keyword
  1675.                     for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1676.                         if (SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] == -1) {
  1677.                             SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] = 0;
  1678.                         }
  1679.                     }
  1680.  
  1681.                     // Finally change all -1s to 1s
  1682.                     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1683.                         if (SearchTopicArray[iTopic] == -1) {
  1684.                             SearchTopicArray[iTopic] = 1;
  1685.                         }
  1686.                     }
  1687.                 }
  1688.             }
  1689.  
  1690.             // If this was the first word change the operation to "and". We need to have it be
  1691.             // an "or" for the first keyword so we would add the items for the first search word.
  1692.             if (bFirstKeyword) {
  1693.                 bFirstKeyword = false;
  1694.                 nCurrentOp = 1;
  1695.             }
  1696.         }
  1697.     }
  1698.  
  1699.     var aSortedTopics = new Array();
  1700.     var nNumSortTopics = 0;
  1701.     for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
  1702.         if (SearchTopicArray[iSearch]) {
  1703.             aSortedTopics[nNumSortTopics++] = iSearch;
  1704.         }
  1705.     }
  1706.  
  1707.     // Limit the number of topics in the result set
  1708.     if (nNumSortTopics > 75) {
  1709.         nNumSortTopics = 75;
  1710.     }
  1711.  
  1712.     // Sort the topics by title
  1713.     SortTopics(FtsDiv, aSortedTopics, 0, nNumSortTopics - 1);
  1714.  
  1715.     // Add hyperlinks for all of the found topics
  1716.     var strLine = "";
  1717.     for (iSearch = 0; iSearch < nNumSortTopics; iSearch++) {
  1718.         i = aSortedTopics[iSearch];
  1719.         if (i != -1) {
  1720.             strLine = "<dt><nobr><a href='" + FtsDiv.gTE[i].strURL + "'>";
  1721.             strLine += FtsDiv.gTE[i].strTitle; 
  1722.             strLine += "</a></nobr></dt>";
  1723.             strHtm += strLine;
  1724.         }
  1725.     }
  1726.  
  1727.     // Give a special message if none were found
  1728.     if (strHtm == "") {
  1729.         strHtm = "<P><B>No Topics Found.</B></P>"
  1730.     } else {
  1731.         strHtm = "<dl>" + strHtm + "</dl>";
  1732.     }
  1733.  
  1734.     if (gbIE4) {
  1735.         layerFind.innerHTML = strHtm;
  1736.     } else if (gbNav4) {
  1737.         layerFind.write(strHtm);
  1738.         layerFind.close();
  1739.     }
  1740.  
  1741.     return;
  1742. }
  1743.  
  1744.  
  1745. function FtsFindKeyword(strCurrentWord, aFtsKeywordArray, nKeywordArrayLen)
  1746. {
  1747.     // Search for the current word in the array (binary search)
  1748.     var nLow = 0; 
  1749.     var nHigh = nKeywordArrayLen - 1;
  1750.     var nMid = 0;
  1751.     var bFound = false;
  1752.     var strKeyword = "";
  1753.     while (nLow <= nHigh) {
  1754.         nMid = (nLow + nHigh);
  1755.         nMid >>= 1;
  1756.         strKeyword = aFtsKeywordArray[nMid].strKeyword;
  1757.         if (strCurrentWord > strKeyword) {
  1758.             nLow = (nLow == nMid) ? nMid + 1 : nMid;
  1759.         } else {
  1760.             if (strCurrentWord < strKeyword)  {
  1761.                 nHigh = (nHigh == nMid) ? nMid - 1: nMid;
  1762.             } else {
  1763.                 bFound = true;
  1764.                 break;
  1765.             }
  1766.         }
  1767.     }
  1768.  
  1769.     if (bFound) {
  1770.         return nMid;
  1771.     } else {
  1772.         return -1;
  1773.     }
  1774. }
  1775.  
  1776.  
  1777. // QuickSort
  1778. var gbSortChar = new Array();
  1779. var gbNeedStem = true;
  1780.  
  1781. function SortTopics(FtsDiv, SearchTopicArray, nStart, nEnd)
  1782. {
  1783.     if (nEnd - nStart > 0) {
  1784.         var nLastLow = nStart;
  1785.  
  1786.         // Get the first value into its proper spot
  1787.         for (var i = nStart + 1; i <= nEnd; i++) {
  1788.             if ((SearchTopicArray[i] != -1) && (SearchTopicArray[nStart] != -1) &&
  1789.                 compare(FtsDiv.gTE[SearchTopicArray[i]].strTitle, FtsDiv.gTE[SearchTopicArray[nStart]].strTitle) < 0 ) {
  1790.                 nLastLow++;
  1791.                 temp = SearchTopicArray[i];
  1792.                 SearchTopicArray[i] = SearchTopicArray[nLastLow];
  1793.                 SearchTopicArray[nLastLow] = temp;
  1794.             }
  1795.         }
  1796.         temp = SearchTopicArray[nStart];
  1797.         SearchTopicArray[nStart] = SearchTopicArray[nLastLow];
  1798.         SearchTopicArray[nLastLow] = temp;
  1799.  
  1800.         // Sort the two halves of this array surrounding the new spot for the first value
  1801.         SortTopics(FtsDiv, SearchTopicArray, nStart, nLastLow);
  1802.         SortTopics(FtsDiv, SearchTopicArray, nLastLow + 1, nEnd);
  1803.     }
  1804. }
  1805.  
  1806. function compare(strTitle1, strTitle2)
  1807. {
  1808.     if (gbSortChar.length < 256) {
  1809.         var strt1 = strTitle1.toLowerCase();
  1810.         var strt2 = strTitle2.toLowerCase();
  1811.         if (strt1 < strt2) return -1;
  1812.         if (strt1 > strt2) return 1;
  1813.         return 0;
  1814.     }
  1815.     else {
  1816.         for (var i = 0 ; i < strTitle1.length && i < strTitle2.length; i ++) {
  1817.             if (gbSortChar[strTitle1.charCodeAt(i)] < gbSortChar[strTitle2.charCodeAt(i)]) return -1;
  1818.             if (gbSortChar[strTitle1.charCodeAt(i)] > gbSortChar[strTitle2.charCodeAt(i)]) return 1;
  1819.         }
  1820.         if (strTitle1.length < strTitle2.length) return -1;
  1821.         if (strTitle1.length > strTitle2.length) return  1;
  1822.         return 0;
  1823.     }
  1824. }
  1825.  
  1826. function GetFlagChar(strchar)
  1827. {
  1828.     if (gbSortChar.length < 256 || strchar.length > 1) {
  1829.         return strchar.toUpperCase();
  1830.     }
  1831.     else {
  1832.         for (var i = 0 ; i < 256; i ++) {
  1833.             if (gbSortChar[i] == gbSortChar[strchar.charCodeAt(0)])
  1834.                 return String.fromCharCode(i);
  1835.         }
  1836.         return strchar;
  1837.     }
  1838.     
  1839. }
  1840.  
  1841. function IsStopWord(strCurrentWord, aFtsStopArray, nStopArrayLen)
  1842. {
  1843.     // Search for the current word in the array (binary search)
  1844.     var nLow = 0; 
  1845.     var nHigh = nStopArrayLen - 1;
  1846.     var nMid = 0;
  1847.     var bFound = false;
  1848.     var strStopWord = "";
  1849.     while (nLow <= nHigh) {
  1850.         nMid = (nLow + nHigh);
  1851.         nMid >>= 1;
  1852. //        strStopWord = aFtsStopArray[nMid].strStopWord;
  1853.         strStopWord = aFtsStopArray[nMid];
  1854.         if (strCurrentWord > strStopWord) {
  1855.             nLow = (nLow == nMid) ? nMid + 1 : nMid;
  1856.         } else {
  1857.             if (strCurrentWord < strStopWord) {
  1858.                 nHigh = (nHigh == nMid) ? nMid - 1: nMid;
  1859.             } else {
  1860.                 bFound = true;
  1861.                 break;
  1862.             }
  1863.         }
  1864.     }
  1865.  
  1866.     if (bFound) {
  1867.         return true;
  1868.     } else {
  1869.         return false;
  1870.     }
  1871. }
  1872.  
  1873.  
  1874. /////////////////////////////////////////////////////////////
  1875. //
  1876. // NOTE: If you change this function, you should also change
  1877. // it in the FtsDatabase.CPP file
  1878. //
  1879. /////////////////////////////////////////////////////////////
  1880. function GetStem(szWord)
  1881. {
  1882.     if (!gbNeedStem) return szWord; 
  1883.     var aStems = new Array();
  1884.     aStems[0] = "ed";
  1885.     aStems[1] = "es";
  1886.     aStems[2] = "er";
  1887.     aStems[3] = "e";
  1888.     aStems[4] = "s";
  1889.     aStems[5] = "ingly";
  1890.     aStems[6] = "ing";
  1891.     aStems[7] = "ly";
  1892.  
  1893.     // Loop through all the stems
  1894.     var nNumStems = aStems.length;
  1895.     var    nStemPos = 0;
  1896.     var csStem = "";
  1897.     var csSubString = "";
  1898.     for (var iStem = 0; iStem < nNumStems; iStem++) {
  1899.  
  1900.         // Get the "would be" position of the stem in the word and see
  1901.         // if this word has the stem
  1902.         nStemPos = szWord.lastIndexOf(aStems[iStem]);
  1903.         if (nStemPos > 0) {
  1904.             csSubString = szWord.substring(nStemPos);
  1905.             if (csSubString == aStems[iStem]) {
  1906.                 
  1907.                 // Found a stem
  1908.  
  1909.                 // Check for double consonant
  1910.                 csStem = szWord;
  1911.                 if (szWord.charAt(nStemPos - 2) == szWord.charAt(nStemPos - 1)) {
  1912.                     csStem = csStem.substring(0, nStemPos - 1);
  1913.                 } else {
  1914.                     csStem = csStem.substring(0, nStemPos);
  1915.                 }
  1916.                 return csStem;
  1917.             }
  1918.         }
  1919.     }
  1920.  
  1921.     // No stem found
  1922.     csStem = szWord;
  1923.     return csStem;
  1924. }
  1925.  
  1926. ////////////////////////////////////////////////////////////////////////////////////////////////
  1927. //
  1928. // Navgation Bar Code
  1929. //
  1930. ////////////////////////////////////////////////////////////////////////////////////////////////
  1931.  
  1932. function NavBar_SelectTOC()
  1933. {
  1934.     var frameLeft = null
  1935.     if (gbNav4) {
  1936.         frameLeft = window.parent.left;
  1937.     } else {
  1938.         frameLeft = window.parent.frames("left");
  1939.     }
  1940.     frameLeft.ChangeToTOC();
  1941. }
  1942.  
  1943. function NavBar_SelectIndex()
  1944. {
  1945.     var frameLeft = null
  1946.     if (gbNav4) {
  1947.         frameLeft = window.parent.left;
  1948.     } else {
  1949.         frameLeft = window.parent.frames("left");
  1950.     }
  1951.     frameLeft.ChangeToIndex();
  1952. }
  1953.  
  1954. ////////////////////////////////////////////////////////////////////////////////////////////////
  1955. //
  1956. // Function support sync toc for DHTML
  1957. //
  1958. ////////////////////////////////////////////////////////////////////////////////////////////////
  1959.  
  1960. var gb_strCurrentURL = "";
  1961. var gb_res = null;
  1962.  
  1963. function NavBar_SyncToc(strRelURL)
  1964. {
  1965.     var strHomeURL = location.href;
  1966.     if (location.hash.length > 0) 
  1967.         strHomeURL = location.href.substring(0, location.href.indexOf("#"));
  1968.  
  1969.     var strHomePath = strHomeURL.substring(0, strHomeURL.lastIndexOf("/"));
  1970.     var strAbsURL = strHomePath + "/" + strRelURL;
  1971.  
  1972.     var containTags = new Array();
  1973.     strAbsURL = NavBar_ReplaceSlash(strAbsURL);
  1974.     strAbsURL = NavBar_ConvertToURLFormat(strAbsURL);
  1975.     var OrgScrollLeft = document.body.scrollLeft;
  1976.  
  1977.     if (gb_strCurrentURL == strAbsURL) {
  1978.         if (gb_res != null) {
  1979.             gb_res.focus();
  1980.             document.body.scrollLeft = OrgScrollLeft;
  1981.         }
  1982.         return;
  1983.     }
  1984.     var res = NavBar_SearchToc(document.body, strAbsURL, containTags, 0);
  1985.     if (res >= 0) 
  1986.     {
  1987.         for (i = 0; i < res; i ++ ) {
  1988.             var elId = containTags[i].id;
  1989.             elId = elId.substring(0, elId.indexOf("Child"));
  1990.             TocExpandIt2(elId, true);
  1991.         }
  1992.         gb_res = containTags[res];
  1993.         containTags[res].focus();
  1994.         document.body.scrollLeft = OrgScrollLeft;
  1995.     }
  1996.     gb_strCurrentURL = strAbsURL;
  1997. }
  1998.  
  1999. // if the DHTML structure changed . the following code MUST MODIFY.
  2000. // Currently do not support IE4.5 on Mac. because on iMac we will capsulate all the contents in a <TABLE>.
  2001. // for IE 4.5 will wrap text which is not good for us.
  2002. // so if want to enable IE4.5. something need to take care here.
  2003. // now we are using Applet for IE 4.5 instead of DHTML for some other reasons.
  2004. function NavBar_SearchToc(tagsObject, strAbsURL, containTags, level)
  2005. {
  2006.     var i = 0;
  2007.     var j = 0;
  2008.     var collBlock = tagsObject.children.tags("BLOCKQUOTE");
  2009.     if (collBlock != null) {
  2010.         for (i = 0; i < collBlock.length ; i ++ )
  2011.         {
  2012.             // here we assume each BLOCKQUOTE has one and only one DIV
  2013.             containTags[level] = collBlock[i].children.tags("DIV")[0];
  2014.             var res = NavBar_SearchToc(containTags[level], strAbsURL, containTags, level + 1);
  2015.             if (res != -1)
  2016.                 return res;
  2017.         }
  2018.  
  2019.     }
  2020.     var collA = tagsObject.all.tags("A");
  2021.     if (collA != null) {
  2022.         for (j = 0; j < collA.length; j ++ )
  2023.         {
  2024.             var hrefURL = NavBar_ReplaceSlash(collA[j].href);
  2025.             hrefURL = NavBar_ConvertToURLFormat(hrefURL);
  2026.             if (hrefURL == strAbsURL)
  2027.             {
  2028.                 containTags[level] = collA[j];
  2029.                 return level;
  2030.             }
  2031.         }
  2032.  
  2033.     }
  2034.     return -1;
  2035. }
  2036.  
  2037. // replace \\ to /
  2038. function NavBar_ReplaceSlash(strURL)
  2039. {    
  2040.     var strReplacedURL = "";
  2041.     var i = 0;
  2042.     for (i = 0; i < strURL.length; i ++ )
  2043.     {
  2044.         if (strURL.charAt(i) == '\\') 
  2045.             strReplacedURL = strReplacedURL + "/"
  2046.         else
  2047.             strReplacedURL = strReplacedURL + strURL.charAt(i);
  2048.     }
  2049.     return strReplacedURL;
  2050. }
  2051.  
  2052. function ItemFocus()
  2053. {
  2054.     if (gb_strCurrentURL.length > 0 ) {
  2055.         if (gb_res != null) {
  2056.             gb_res.focus();
  2057.         }    
  2058.     }
  2059. }
  2060.  
  2061. // mark the current clicked url.
  2062. function MarkIt()
  2063. {
  2064.     var strURL = window.event.srcElement.href;
  2065.     strURL = NavBar_ConvertToURLFormat(strURL);
  2066.     gb_strCurrentURL = strURL;
  2067.     gb_res = window.event.srcElement;
  2068.     if (typeof(parent.parent.NavFrame) != "undefined" &&
  2069.         typeof(parent.parent.NavFrame().gstrAutoSyncURL) != "undefined")
  2070.         parent.parent.NavFrame().gstrAutoSyncURL = "";
  2071. }
  2072.  
  2073.  
  2074. // change αßπ to %E0%E1%E3
  2075. function NavBar_ConvertToURLFormat(strURL)
  2076. {
  2077.     var strResURL = "";
  2078.     var i = 0;
  2079.     for (i = 0; i < strURL.length; i ++)
  2080.     {
  2081.         var nCode = strURL.charCodeAt(i);
  2082.         if (nCode > 127) {
  2083.             strResURL += "%";
  2084.             var strTemp = String.fromCharCode(HEXToCharCode(nCode/16), HEXToCharCode(nCode%16));
  2085.             strResURL += strTemp
  2086.         }
  2087.         else 
  2088.             strResURL += strURL.charAt(i);
  2089.     }
  2090.     return strResURL;
  2091. }
  2092.  
  2093. function HEXToCharCode(n)
  2094. {
  2095.     if (n < 10) {
  2096.         return '0'.charCodeAt(0) + n;
  2097.     }
  2098.     else if (n < 16) {
  2099.         return 'A'.charCodeAt(0) + (n - 10);
  2100.     }
  2101.     else
  2102.         return 0;
  2103. }
  2104.