home *** CD-ROM | disk | FTP | other *** search
/ Internet CD 2005 August / MICD_2005_08.iso / Multimedia / Twist / TwistEval.exe / Main / webhelp4.js < prev    next >
Encoding:
JavaScript  |  2005-06-28  |  57.9 KB  |  2,114 lines

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