home *** CD-ROM | disk | FTP | other *** search
/ Thomson (Residential) / TGSTPv7203.iso / mac / Documentation / HTML / TG587n_nl / wwhelp / wwhimpl / js / scripts / search.js < prev    next >
Text File  |  2007-10-04  |  34KB  |  1,174 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHSearch_Object()
  5. {
  6.   this.mbPanelInitialized      = false;
  7.   this.mPanelAnchor            = null;
  8.   this.mPanelTabTitle          = WWHFrame.WWHJavaScript.mMessages.mTabsSearchLabel;
  9.   this.mbBookSearchInfoLoaded  = false;
  10.   this.mInitIndex              = 0;
  11.   this.mBookSearchInfoList     = new Array();
  12.   this.mSavedSearchWords       = "";
  13.   this.mSavedSearchScope       = 0;
  14.   this.mSearchWordList         = new Array();
  15.   this.mSearchWordRegExpList   = new Array();
  16.   this.mBookIndex              = 0;
  17.   this.mBookMatchesList        = new Array();
  18.   this.mCombinedResults        = new WWHSearchResults_Object();
  19.  
  20.   this.fInitHeadHTML           = WWHSearch_InitHeadHTML;
  21.   this.fInitBodyHTML           = WWHSearch_InitBodyHTML;
  22.   this.fInitLoadBookSearchInfo = WWHSearch_InitLoadBookSearchInfo;
  23.   this.fHeadHTML               = WWHSearch_HeadHTML;
  24.   this.fStartHTMLSegments      = WWHSearch_StartHTMLSegments;
  25.   this.fAdvanceHTMLSegment     = WWHSearch_AdvanceHTMLSegment;
  26.   this.fGetHTMLSegment         = WWHSearch_GetHTMLSegment;
  27.   this.fEndHTMLSegments        = WWHSearch_EndHTMLSegments;
  28.   this.fHoverTextTranslate     = WWHSearch_HoverTextTranslate;
  29.   this.fHoverTextFormat        = WWHSearch_HoverTextFormat;
  30.   this.fDisplaySearchForm      = WWHSearch_DisplaySearchForm;
  31.   this.fSubmit                 = WWHSearch_Submit;
  32.   this.fSetSearchWords         = WWHSearch_SetSearchWords;
  33.   this.fCheckForMatch          = WWHSearch_CheckForMatch;
  34.   this.fSearchComplete         = WWHSearch_SearchComplete;
  35.   this.fCombineResults         = WWHSearch_CombineResults;
  36.   this.fShowEntry              = WWHSearch_ShowEntry;
  37. }
  38.  
  39. function  WWHSearch_InitHeadHTML()
  40. {
  41.   var  InitHeadHTML = "";
  42.  
  43.  
  44.   return InitHeadHTML;
  45. }
  46.  
  47. function  WWHSearch_InitBodyHTML()
  48. {
  49.   var  HTML = new WWHStringBuffer_Object();
  50.   var  BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  51.   var  MaxIndex;
  52.   var  Index;
  53.   var  MaxBookIndex;
  54.   var  BookIndex;
  55.   var  BookDirectory;
  56.  
  57.  
  58.   if ( ! this.mbBookSearchInfoLoaded)
  59.   {
  60.     // Display initializing message
  61.     //
  62.     HTML.fAppend("<h2 class=\"enf2\">" + WWHFrame.WWHJavaScript.mMessages.mInitializingMessage + "</h2>\n");
  63.  
  64.     // Load search info
  65.     //
  66.     this.mInitIndex = 0;
  67.     for (MaxIndex = BookList.length, Index = 0 ; Index < MaxIndex ; Index++)
  68.     {
  69.       // Reference search info
  70.       //
  71.       HTML.fAppend("<script language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + WWHStringUtilities_RestoreEscapedSpaces(BookList[Index].mDirectory) + "wwhdata/js/search.js\"></script>\n");
  72.  
  73.       // Load search info for current book
  74.       //
  75.       HTML.fAppend("<script language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search1s.js\"></script>\n");
  76.     }
  77.   }
  78.   else  // Perform search
  79.   {
  80.     // Display searching message
  81.     //
  82.     HTML.fAppend("<h5 class=\"enf2\">" + WWHFrame.WWHJavaScript.mMessages.mSearchSearchingMessage + "</h5>\n");
  83.  
  84.     // Handle single book search
  85.     //
  86.     if (this.mSavedSearchScope > 0)
  87.     {
  88.       MaxBookIndex = this.mSavedSearchScope;
  89.       BookIndex    = this.mSavedSearchScope - 1;
  90.     }
  91.     else
  92.     {
  93.       MaxBookIndex = BookList.length;
  94.       BookIndex    = 0;
  95.     }
  96.  
  97.     // Generate search actions
  98.     //
  99.     this.mBookIndex = BookIndex;
  100.     for ( ; BookIndex < MaxBookIndex ; BookIndex++)
  101.     {
  102.       BookDirectory = BookList[BookIndex].mDirectory;
  103.  
  104.       for (MaxIndex = this.mBookSearchInfoList[BookIndex].mSearchFileCount, Index = 0 ; Index < MaxIndex ; Index++)
  105.       {
  106.         HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + WWHStringUtilities_RestoreEscapedSpaces(BookDirectory) + "wwhdata/js/search/search" + Index + ".js\"></script>\n");
  107.         HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search2s.js\"></script>\n");
  108.       }
  109.  
  110.       HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search3s.js\"></script>\n");
  111.     }
  112.  
  113.     HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search4s.js\"></script>\n");
  114.   }
  115.  
  116.   return HTML.fGetBuffer();
  117. }
  118.  
  119. function  WWHSearch_InitLoadBookSearchInfo(ParamSearchFileCount,
  120.                                            ParamMinimumWordLength,
  121.                                            ParamSearchSkipWordsFunc)
  122. {
  123.   // Load book search info
  124.   //
  125.   this.mBookSearchInfoList[this.mInitIndex] = new WWHBookSearchInfo_Object(ParamSearchFileCount, ParamMinimumWordLength);
  126.   ParamSearchSkipWordsFunc(this.mBookSearchInfoList[this.mInitIndex]);
  127.  
  128.   // Create match objects for each book
  129.   //
  130.   this.mBookMatchesList[this.mBookMatchesList.length] = new WWHSearchBookMatches_Object();
  131.  
  132.   // Increment init book index
  133.   //
  134.   this.mInitIndex++;
  135.  
  136.   // Mark initialized if done
  137.   //
  138.   if (this.mInitIndex == WWHFrame.WWHHelp.mBooks.mBookList.length)
  139.   {
  140.     this.mbPanelInitialized = true;
  141.     this.mbBookSearchInfoLoaded = true;
  142.   }
  143. }
  144.  
  145. function  WWHSearch_HeadHTML()
  146. {
  147.   var  HTML = new WWHStringBuffer_Object();
  148.   var  Settings = WWHFrame.WWHJavaScript.mSettings.mSearch;
  149.  
  150.  
  151.   // Generate style section
  152.   //
  153.   HTML.fAppend("<style type=\"text/css\">\n");
  154.   HTML.fAppend(" <!--\n");
  155.   HTML.fAppend("  a  {\n");
  156.   HTML.fAppend("       text-decoration: none;\n");
  157.   HTML.fAppend("       color: " + Settings.mEnabledColor + ";\n");
  158.   HTML.fAppend("     }\n");
  159.   HTML.fAppend("  p  {\n");
  160.   HTML.fAppend("       margin-top: 1pt;\n");
  161.   HTML.fAppend("       margin-bottom: 1pt;\n");
  162.   HTML.fAppend("       " + Settings.mFontStyle + ";\n");
  163.   HTML.fAppend("     }\n");
  164.   HTML.fAppend("  ol {\n");
  165.   HTML.fAppend("       margin-top: 1pt;\n");
  166.   HTML.fAppend("       margin-bottom: 1pt;\n");
  167.   if (Settings.mbShowRank)
  168.   {
  169.     HTML.fAppend("       " + Settings.mFontStyle + ";\n");
  170.   }
  171.   else
  172.   {
  173.     HTML.fAppend("       list-style: none;\n");
  174.   }
  175.   HTML.fAppend("     }\n");
  176.   HTML.fAppend("  li {\n");
  177.   HTML.fAppend("       margin-top: 2pt;\n");
  178.   HTML.fAppend("       margin-bottom: 0pt;\n");
  179.   HTML.fAppend("       " + Settings.mFontStyle + ";\n");
  180.   HTML.fAppend("     }\n");
  181.   HTML.fAppend(" -->\n");
  182.   HTML.fAppend("</style>\n");
  183.  
  184.   return HTML.fGetBuffer();
  185. }
  186.  
  187. function  WWHSearch_StartHTMLSegments()
  188. {
  189.   var  HTML = new WWHStringBuffer_Object();
  190.  
  191.  
  192.   if (this.mbPanelInitialized)
  193.   {
  194.     HTML.fAppend(this.fDisplaySearchForm());
  195.  
  196.     if (this.mSavedSearchWords.length == 0)
  197.     {
  198.       HTML.fAppend("<h3>" + WWHFrame.WWHJavaScript.mMessages.mSearchDefaultMessage + "</h3>\n");
  199.     }
  200.     else if ((typeof this.mCombinedResults.mEntries != "undefined") &&
  201.              (this.mCombinedResults.mEntries.length > 0))
  202.     {
  203.       this.mCombinedResults.fDisplayReset();
  204.     }
  205.     else
  206.     {
  207.       HTML.fAppend("<h3>" + WWHFrame.WWHJavaScript.mMessages.mSearchNothingFoundMessage + "</h3>\n");
  208.     }
  209.   }
  210.  
  211.   // Define accessor functions to reduce file size
  212.   //
  213.   HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\">\n");
  214.   HTML.fAppend(" <!--\n");
  215.   HTML.fAppend("  function  fC(ParamEntryID)\n");
  216.   HTML.fAppend("  {\n");
  217.   HTML.fAppend("    WWHFrame.WWHSearch.fShowEntry(ParamEntryID);\n");
  218.   HTML.fAppend("  }\n");
  219.   HTML.fAppend("\n");
  220.   HTML.fAppend("  function  fS(ParamEntryID,\n");
  221.   HTML.fAppend("               ParamEvent)\n");
  222.   HTML.fAppend("  {\n");
  223.   HTML.fAppend("    WWHFrame.WWHJavaScript.mPanels.mPopup.fShow(ParamEntryID, ParamEvent);\n");
  224.   HTML.fAppend("  }\n");
  225.   HTML.fAppend("\n");
  226.   HTML.fAppend("  function  fH()\n");
  227.   HTML.fAppend("  {\n");
  228.   HTML.fAppend("    WWHFrame.WWHJavaScript.mPanels.mPopup.fHide();\n");
  229.   HTML.fAppend("  }\n");
  230.   HTML.fAppend(" // -->\n");
  231.   HTML.fAppend("</script>\n");
  232.  
  233.   return HTML.fGetBuffer();
  234. }
  235.  
  236. function  WWHSearch_AdvanceHTMLSegment()
  237. {
  238.   var  bSegmentCreated = false;
  239.  
  240.  
  241.   if (this.mbPanelInitialized)
  242.   {
  243.     bSegmentCreated = this.mCombinedResults.fDisplayAdvance();
  244.   }
  245.  
  246.   return bSegmentCreated;
  247. }
  248.  
  249. function  WWHSearch_GetHTMLSegment()
  250. {
  251.   return this.mCombinedResults.mHTMLSegment.fGetBuffer();
  252. }
  253.  
  254. function  WWHSearch_EndHTMLSegments()
  255. {
  256.   return "";
  257. }
  258.  
  259. function  WWHSearch_HoverTextTranslate(ParamEntryID)
  260. {
  261.   var  HTML     = "";
  262.   var  BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  263.   var  Settings = WWHFrame.WWHJavaScript.mSettings.mSearch;
  264.   var  Messages = WWHFrame.WWHJavaScript.mMessages;
  265.   var  Entry;
  266.   var  Rank = "";
  267.   var  Title;
  268.   var  Book = "";
  269.   var  Format;
  270.  
  271.  
  272.   // Retrieve specified entry
  273.   //
  274.   Entry = this.mCombinedResults.mEntries[ParamEntryID];
  275.  
  276.   // Get Rank
  277.   //
  278.   if (Settings.mbShowRank)
  279.   {
  280.     Rank = Math.floor((Entry.mScore / this.mCombinedResults.mMaxScore) * 100) + "%";
  281.   }
  282.  
  283.   // Get Title
  284.   //
  285.   Title = Entry.mTitle;
  286.  
  287.   // Get Book
  288.   //
  289.   if (Settings.mbShowBook)
  290.   {
  291.     if ((BookList.length > 1) &&                 // More than one book exists
  292.         (this.mCombinedResults.mSortedBy == 1))  // By Score
  293.     {
  294.       Book = BookList[Entry.mBookIndex].mTitle;
  295.     }
  296.   }
  297.  
  298.   // Format for display
  299.   //
  300.   if ((Rank.length == 0) &&
  301.       (Book.length == 0))
  302.   {
  303.     // Simple format, just the title
  304.     //
  305.     HTML = Title;
  306.   }
  307.   else
  308.   {
  309.     Format = " align=\"left\" valign=\"top\"><span style=\"" + WWHFrame.WWHJavaScript.mSettings.mHoverText.mFontStyle + "\">";
  310.  
  311.     // Complex format, requires a table
  312.     //
  313.     HTML += "<table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">";
  314.     if (Rank.length > 0)
  315.     {
  316.       HTML += "<tr>";
  317.       HTML += "<th" + Format + Messages.mSearchRankLabel + "</span></th>";
  318.       HTML += "<td" + Format + Rank + "</span></td>";
  319.       HTML += "</tr>";
  320.     }
  321.     HTML += "<tr>";
  322.     HTML += "<th" + Format + Messages.mSearchTitleLabel + "</span></th>";
  323.     HTML += "<td" + Format + Title + "</span></td>";
  324.     HTML += "</tr>";
  325.     if (Book.length > 0)
  326.     {
  327.       HTML += "<tr>";
  328.       HTML += "<th" + Format + Messages.mSearchBookLabel + "</span></th>";
  329.       HTML += "<td" + Format + Book + "</span></td>";
  330.       HTML += "</tr>";
  331.     }
  332.     HTML += "</table>";
  333.   }
  334.  
  335.   return HTML;
  336. }
  337.  
  338. function  WWHSearch_HoverTextFormat(ParamWidth,
  339.                                     ParamTextID,
  340.                                     ParamText)
  341. {
  342.   var  FormattedText   = "";
  343.   var  ForegroundColor = WWHFrame.WWHJavaScript.mSettings.mHoverText.mForegroundColor;
  344.   var  BackgroundColor = WWHFrame.WWHJavaScript.mSettings.mHoverText.mBackgroundColor;  
  345.   var  BorderColor     = WWHFrame.WWHJavaScript.mSettings.mHoverText.mBorderColor;
  346.   var  ImageDir        = WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/images";
  347.   var  ReqSpacer1w2h   = "<img src=\"" + ImageDir + "/spc1w2h.gif\" width=1 height=2>";
  348.   var  ReqSpacer2w1h   = "<img src=\"" + ImageDir + "/spc2w1h.gif\" width=2 height=1>";
  349.   var  ReqSpacer1w7h   = "<img src=\"" + ImageDir + "/spc1w7h.gif\" width=1 height=7>";
  350.   var  ReqSpacer5w1h   = "<img src=\"" + ImageDir + "/spc5w1h.gif\" width=5 height=1>";
  351.   var  Spacer1w2h      = ReqSpacer1w2h;
  352.   var  Spacer2w1h      = ReqSpacer2w1h;
  353.   var  Spacer1w7h      = ReqSpacer1w7h;
  354.   var  Spacer5w1h      = ReqSpacer5w1h;
  355.  
  356.  
  357.   // Netscape 6.x (Mozilla) renders table cells with graphics
  358.   // incorrectly inside of <div> tags that are rewritten on the fly
  359.   //
  360.   if (WWHFrame.WWHBrowserInfo.mBrowser == 4)  // Shorthand for Netscape 6.x (Mozilla)
  361.   {
  362.     Spacer1w2h = "";
  363.     Spacer2w1h = "";
  364.     Spacer1w7h = "";
  365.     Spacer5w1h = "";
  366.   }
  367.  
  368.   FormattedText += "<table width=\"" + ParamWidth + "\" border=0 cellspacing=0 cellpadding=0 bgcolor=\"" + BackgroundColor + "\">";
  369.   FormattedText += " <tr>";
  370.   FormattedText += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  371.   FormattedText += " </tr>";
  372.  
  373.   FormattedText += " <tr>";
  374.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  375.   FormattedText += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  376.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  377.   FormattedText += " </tr>";
  378.  
  379.   FormattedText += " <tr>";
  380.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  381.   FormattedText += "  <td>" + ReqSpacer5w1h + "</td>";
  382.   FormattedText += "  <td width=\"100%\" id=\"" + ParamTextID + "\" style=\"color: " + ForegroundColor + " ; " + WWHFrame.WWHJavaScript.mSettings.mHoverText.mFontStyle + "\">" + ParamText + "</td>";
  383.   FormattedText += "  <td>" + ReqSpacer5w1h + "</td>";
  384.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  385.   FormattedText += " </tr>";
  386.  
  387.   FormattedText += " <tr>";
  388.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  389.   FormattedText += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  390.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  391.   FormattedText += " </tr>";
  392.  
  393.   FormattedText += " <tr>";
  394.   FormattedText += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  395.   FormattedText += " </tr>";
  396.   FormattedText += "</table>";
  397.  
  398.   return FormattedText;
  399. }
  400.  
  401. function  WWHSearch_DisplaySearchForm()
  402. {
  403.   var  HTML = "";
  404.   var  BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  405.  
  406.  
  407.   HTML += "<form name=\"WWHSearchForm\" onSubmit=\"WWHFrame.WWHSearch.fSubmit();\">\n";
  408. //  HTML += "<nobr>\n";
  409.  
  410.   HTML += '<table border=0 cellpadding=0 cellspacing=0 style="margin:20px 0px 0px 10px"><tr><td valign="middle">';
  411.  
  412.  
  413.   HTML += "<input class=\"searchField\" type=\"text\" name=\"WWHSearchWordsText\" value=\"" + this.mSavedSearchWords + "\">";
  414.  
  415.   HTML += "</td><td valign=\"middle\" style=\"padding-left:10px;\">";
  416.  
  417.   HTML += "<input type=\"image\" src=\"../images/searchbutton_"+top.langCode[top.currentLang]+".gif\" width=\"100%\">";  
  418.   
  419.   HTML += "</td></tr></table>";
  420.   
  421. //  HTML += "</nobr>\n";
  422.  
  423.   if (BookList.length > 1)
  424.   {
  425.     var  SelectedIndex = this.mSavedSearchScope - 1;
  426.     var  MaxIndex;
  427.     var  Index;
  428.  
  429.  
  430.     HTML += "<br>\n";
  431.     HTML += "<select name=\"WWHSearchScope\">\n";
  432.     HTML += "<option>" + WWHFrame.WWHJavaScript.mMessages.mSearchScopeAllLabel + "</option>\n";
  433.     for (MaxIndex = BookList.length, Index = 0 ; Index < MaxIndex ; Index++)
  434.     {
  435.       if (Index == SelectedIndex)
  436.       {
  437.         HTML += "<option selected>";
  438.       }
  439.       else
  440.       {
  441.         HTML += "<option>";
  442.       }
  443.  
  444.       HTML += BookList[Index].mTitle + "</option>\n";
  445.     }
  446.     HTML += "</select>\n";
  447.   }
  448.  
  449.   HTML += "</form>";
  450.  
  451.   return HTML;
  452. }
  453.  
  454. function  WWHSearch_Submit()
  455. {
  456.   var  SearchForm = WWHFrame.WWHNavigationFrame.WWHPanelFrame.document.forms["WWHSearchForm"];
  457.   var  NewSearchWords;
  458.   var  NewSearchScope;
  459.   var  bSearchChanged = false;
  460.  
  461.  
  462.   // Update search words
  463.   //
  464.   NewSearchWords = SearchForm.elements["WWHSearchWordsText"].value;
  465.   if (NewSearchWords != this.mSavedSearchWords)
  466.   {
  467.     this.mSavedSearchWords = NewSearchWords;
  468.  
  469.     bSearchChanged = true;
  470.   }
  471.  
  472.   // Update search scope
  473.   //
  474.   if (WWHFrame.WWHHelp.mBooks.mBookList.length > 1)
  475.   {
  476.     NewSearchScope = SearchForm.elements["WWHSearchScope"].selectedIndex;
  477.     if (NewSearchScope != this.mSavedSearchScope)
  478.     {
  479.       this.mSavedSearchScope = NewSearchScope;
  480.  
  481.       bSearchChanged = true;
  482.     }
  483.   }
  484.  
  485.   // Perform search if something changed
  486.   //
  487.   if (bSearchChanged)
  488.   {
  489.     if (this.mSavedSearchWords.length > 0)
  490.     {
  491.       var  MaxIndex;
  492.       var  Index;
  493.  
  494.  
  495.       // Clear previous results
  496.       //
  497.       for (MaxIndex = this.mBookMatchesList.length, Index = 0 ; Index < MaxIndex ; Index++)
  498.       {
  499.         this.mBookMatchesList[Index].fClear();
  500.       }
  501.       this.mCombinedResults.fClear();
  502.  
  503.       // Save/restore current position
  504.       //
  505.       WWHFrame.WWHJavaScript.mPanels.fSaveScrollPosition();
  506.  
  507.       // Perform search
  508.       //
  509.       this.fSetSearchWords(WWHStringUtilities_NormalizeSearchWords(this.mSavedSearchWords));
  510.       this.mbPanelInitialized = false;
  511.       setTimeout("WWHFrame.WWHJavaScript.mPanels.fDisplayPanel();", 50);  // Need to finish submit
  512.     }
  513.   }
  514.  
  515.   return bSearchChanged;
  516. }
  517.  
  518. function  WWHSearch_SetSearchWords(ParamSearchWordsString)
  519. {
  520.   // Workaround for stupid Netscape 4.x bug
  521.   //
  522.   var  StringWithSpace = "x x";
  523.   var  SearchWordList;
  524.   var  MaxIndex;
  525.   var  Index;
  526.   var  SearchWord;
  527.   var  SearchRegExpPattern;
  528.  
  529.  
  530.   // Clear search words
  531.   //
  532.   this.mSearchWordList.length = 0;
  533.   this.mSearchWordRegExpList.length = 0;
  534.  
  535.   // Add search words to hash
  536.   //
  537.   SearchWordList = ParamSearchWordsString.split(StringWithSpace.substring(1, 2));
  538.   for (MaxIndex = SearchWordList.length, Index = 0 ; Index < MaxIndex ; Index++)
  539.   {
  540.     // Skip 0 length words
  541.     //
  542.     if (SearchWordList[Index].length > 0)
  543.     {
  544.       // Add to search words hash
  545.       //
  546.       SearchWord = SearchWordList[Index].toLowerCase();
  547.       SearchRegExpPattern = WWHStringUtilities_WordToRegExpPattern(SearchWord);
  548.  
  549.       this.mSearchWordList[this.mSearchWordList.length] = SearchWord;
  550.       this.mSearchWordRegExpList[this.mSearchWordRegExpList.length] = new RegExp(SearchRegExpPattern, "i");
  551.     }
  552.   }
  553. }
  554.  
  555. function  WWHSearch_CheckForMatch(ParamSearchFunc)
  556. {
  557.   var  Count;
  558.   var  MaxIndex;
  559.   var  Index;
  560.   var  BookSearchInfoEntry;
  561.   var  SearchPattern;
  562.  
  563.  
  564.   Count = 0;
  565.   for (MaxIndex = this.mSearchWordList.length, Index = 0 ; Index < MaxIndex ; Index++)
  566.   {
  567.     BookSearchInfoEntry = this.mBookSearchInfoList[this.mBookIndex]
  568.  
  569.     if (this.mBookSearchInfoList[this.mBookIndex].fValidSearchWord(this.mSearchWordList[Index]))
  570.     {
  571.       BookMatchesListEntry = this.mBookMatchesList[this.mBookIndex];
  572.  
  573.       BookMatchesListEntry.fSetMatchedWordIndex(Count);
  574.  
  575.       SearchPattern = this.mSearchWordRegExpList[Index];
  576.       SearchPattern.t = SearchPattern.test;
  577.  
  578.       ParamSearchFunc(SearchPattern, BookMatchesListEntry);
  579.  
  580.       Count++;
  581.     }
  582.   }
  583. }
  584.  
  585. function  WWHSearch_SearchComplete()
  586. {
  587.   // Set flag so that results can be displayed
  588.   //
  589.   this.mbPanelInitialized = true;
  590.  
  591.   // Combine results for display
  592.   //
  593.   this.fCombineResults();
  594.  
  595.   // Sort results based on single or multi-book display
  596.   //
  597.   if ((WWHFrame.WWHHelp.mBooks.mBookList.length == 1) ||
  598.       (this.mSavedSearchScope > 0))
  599.   {
  600.     this.mCombinedResults.fSortByBookIndex();
  601.   }
  602.   else
  603.   {
  604.     this.mCombinedResults.fSortByScore();
  605.   }
  606. }
  607.  
  608. function  WWHSearch_CombineResults()
  609. {
  610.   var  MaxBookIndex;
  611.   var  BookIndex;
  612.   var  BookMatches;
  613.   var  BookListEntry;
  614.   var  FileID;
  615.   var  FileIndex;
  616.  
  617.  
  618.   this.mCombinedResults.fClear();
  619.   for (MaxBookIndex = this.mBookMatchesList.length, BookIndex = 0 ; BookIndex < MaxBookIndex ; BookIndex++)
  620.   {
  621.     BookMatches = this.mBookMatchesList[BookIndex];
  622.     BookListEntry = WWHFrame.WWHHelp.mBooks.mBookList[BookIndex];
  623.  
  624.     // Add results
  625.     //
  626.     BookMatches.fJoinFileScores();
  627.     for (FileID in BookMatches.mFileScores)
  628.     {
  629.       FileIndex = parseInt(FileID.substring(1, FileID.length));
  630.  
  631.       this.mCombinedResults.fAddEntry(BookIndex, FileIndex, BookMatches.mFileScores[FileID], BookListEntry.mFiles.fFileIndexToTitle(FileIndex));
  632.     }
  633.   }
  634. }
  635.  
  636. function  WWHSearch_ShowEntry(ParamIndex)
  637. {
  638.   this.mCombinedResults.fShowEntry(ParamIndex);
  639. }
  640.  
  641. function  WWHBookSearchInfo_Object(ParamSearchFileCount,
  642.                                    ParamMinimumWordLength)
  643. {
  644.   this.mSearchFileCount   = ParamSearchFileCount;
  645.   this.mMinimumWordLength = ParamMinimumWordLength;
  646.   this.mSkipWords         = new WWHBookSearchInfo_SkipWords_Object();
  647.  
  648.   this.fAddSkipWord     = WWHBookSearchInfo_AddSkipWord;
  649.   this.fA               = WWHBookSearchInfo_AddSkipWord;
  650.   this.fValidSearchWord = WWHBookSearchInfo_ValidSearchWord;
  651. }
  652.  
  653. function  WWHBookSearchInfo_AddSkipWord(ParamSkipWord)
  654. {
  655.   if (ParamSkipWord.length > 0)
  656.   {
  657.     this.mSkipWords[ParamSkipWord] = 1;
  658.   }
  659. }
  660.  
  661. function  WWHBookSearchInfo_ValidSearchWord(ParamSearchWord)
  662. {
  663.   var  bValid = true;
  664.  
  665.  
  666.   if ((ParamSearchWord.length < this.mMinimumWordLength) ||
  667.       (typeof this.mSkipWords[ParamSearchWord] == "number"))
  668.   {
  669.     bValid = false;
  670.   }
  671.  
  672.   return bValid;
  673. }
  674.  
  675. function  WWHBookSearchInfo_SkipWords_Object()
  676. {
  677. }
  678.  
  679. function  WWHSearchBookMatches_Object()
  680. {
  681.   this.mFirstMatchedWordIndex = -1;
  682.   this.mMatchedWordIndex      = -1;
  683.   this.mWordFileScores        = new Array();
  684.   this.mFileScores            = new WWHSearchBookMatches_FileScores_Object();
  685.  
  686.   this.fClear               = WWHSearchBookMatches_Clear;
  687.   this.fSetMatchedWordIndex = WWHSearchBookMatches_SetMatchedWordIndex;
  688.   this.fAddMatches          = WWHSearchBookMatches_AddMatches;
  689.   this.f                    = WWHSearchBookMatches_AddMatches;  // For smaller search files
  690.   this.fJoinFileScores      = WWHSearchBookMatches_JoinFileScores;
  691. }
  692.  
  693. function  WWHSearchBookMatches_Clear()
  694. {
  695.   this.mFirstMatchedWordIndex = -1;
  696.   this.mMatchedWordIndex      = -1;
  697.   this.mWordFileScores.length = 0;
  698.   this.mFileScores            = new WWHSearchBookMatches_FileScores_Object();
  699. }
  700.  
  701. function  WWHSearchBookMatches_SetMatchedWordIndex(ParamMatchedWordIndex)
  702. {
  703.   this.mMatchedWordIndex = ParamMatchedWordIndex;
  704.   if (ParamMatchedWordIndex == this.mWordFileScores.length)
  705.   {
  706.     this.mWordFileScores[this.mWordFileScores.length] = new WWHSearchBookMatches_FileScores_Object();
  707.   }
  708. }
  709.  
  710. function  WWHSearchBookMatches_AddMatches(ParamMatchString)
  711. {
  712.   var  MatchList = null;
  713.   var  WordFileScoresEntry;
  714.   var  MaxIndex;
  715.   var  Index;
  716.   var  FileID;
  717.   var  Score;
  718.  
  719.  
  720.   if (typeof ParamMatchString != "undefined")
  721.   {
  722.     MatchList = ParamMatchString.split(",");
  723.   }
  724.  
  725.   if ((MatchList != null) &&
  726.       (MatchList.length > 0))
  727.   {
  728.     WordFileScoresEntry = this.mWordFileScores[this.mMatchedWordIndex];
  729.  
  730.     // Add all entries to word file score entry
  731.     //
  732.     for (MaxIndex = MatchList.length, Index = 0 ; Index < MaxIndex ; Index += 2)
  733.     {
  734.       FileID = "i" + MatchList[Index];
  735.       Score  = MatchList[Index + 1];
  736.  
  737.       WordFileScoresEntry[FileID] = parseInt(Score);
  738.     }
  739.   }
  740. }
  741.  
  742. function  WWHSearchBookMatches_JoinFileScores()
  743. {
  744.   var  WordFileScoresEntry;
  745.  
  746.  
  747.   this.mFileScores = new WWHSearchBookMatches_FileScores_Object();
  748.   for (MaxIndex = this.mWordFileScores.length, Index = 0 ; Index < MaxIndex ; Index++)
  749.   {
  750.     WordFileScoresEntry = this.mWordFileScores[Index];
  751.  
  752.     if (Index == 0)
  753.     {
  754.       // Add all entries if first entry
  755.       //
  756.       this.mFileScores = WordFileScoresEntry;
  757.     }
  758.     else
  759.     {
  760.       // Remove all entries not found in results set
  761.       //
  762.       for (FileID in this.mFileScores)
  763.       {
  764.         if (typeof WordFileScoresEntry[FileID] == "number")
  765.         {
  766.           this.mFileScores[FileID] += WordFileScoresEntry[FileID];
  767.         }
  768.         else
  769.         {
  770.           delete this.mFileScores[FileID];
  771.         }
  772.       }
  773.     }
  774.   }
  775. }
  776.  
  777. function  WWHSearchBookMatches_FileScores_Object()
  778. {
  779. }
  780.  
  781. function  WWHSearchResults_Object()
  782. {
  783.   this.mSortedBy     = null;
  784.   this.mEntries      = new Array();
  785.   this.mMaxScore     = 0;
  786.   this.mDisplayIndex = 0;
  787.   this.mHTMLSegment  = new WWHStringBuffer_Object();
  788.   this.mEventString  = WWHPopup_EventString();
  789.  
  790.   this.fClear           = WWHSearchResults_Clear;
  791.   this.fAddEntry        = WWHSearchResults_AddEntry;
  792.   this.fSortByScore     = WWHSearchResults_SortByScore;
  793.   this.fSortByBookIndex = WWHSearchResults_SortByBookIndex;
  794.   this.fDisplayReset    = WWHSearchResults_DisplayReset;
  795.   this.fDisplayAdvance  = WWHSearchResults_DisplayAdvance;
  796.   this.fGetPopupAction  = WWHSearchResults_GetPopupAction;
  797.   this.fShowEntry       = WWHSearchResults_ShowEntry;
  798. }
  799.  
  800. function  WWHSearchResults_Clear()
  801. {
  802.   this.mSortedBy       = null;
  803.   this.mEntries.length = 0;
  804.   this.mMaxScore       = 0;
  805. }
  806.  
  807. function  WWHSearchResults_AddEntry(ParamBookIndex,
  808.                                     ParamFileIndex,
  809.                                     ParamScore,
  810.                                     ParamTitle)
  811. {
  812.   // Add a new entry
  813.   //
  814.   this.mEntries[this.mEntries.length] = new WWHSearchResultsEntry_Object(ParamBookIndex,
  815.                                                                          ParamFileIndex,
  816.                                                                          ParamScore,
  817.                                                                          ParamTitle);
  818.  
  819.   // Bump mMaxScore if necessary
  820.   //
  821.   if (ParamScore > this.mMaxScore)
  822.   {
  823.     this.mMaxScore = ParamScore;
  824.   }
  825. }
  826.  
  827. function  WWHSearchResults_SortByScore()
  828. {
  829.   this.mSortedBy = 1;  // By Score
  830.  
  831.   if (this.mEntries.length > 0)
  832.   {
  833.     this.mEntries = this.mEntries.sort(WWHSearchResultsEntry_ByScoreByBookIndexByTitleFileIndexURL);
  834.   }
  835. }
  836.  
  837. function  WWHSearchResults_SortByBookIndex()
  838. {
  839.   this.mSortedBy = 2;  // By BookIndex
  840.  
  841.   if (this.mEntries.length > 0)
  842.   {
  843.     this.mEntries = this.mEntries.sort(WWHSearchResultsEntry_ByBookIndexByScoreByTitleFileIndexURL);
  844.   }
  845. }
  846.  
  847. function  WWHSearchResults_DisplayReset()
  848. {
  849.   this.mDisplayIndex = 0;
  850. }
  851.  
  852. function  WWHSearchResults_DisplayAdvance()
  853. {
  854.   var  bSegmentCreated = false;
  855.   var  Settings = WWHFrame.WWHJavaScript.mSettings.mSearch;
  856.   var  HTML;
  857.   var  MaxHTMLSegmentSize;
  858.   var  BookList;
  859.   var  MaxIndex;
  860.   var  Index;
  861.   var  Entry;
  862.   var  ByBookDetect;
  863.  
  864.  
  865.   // Insure that there is something to display
  866.   //
  867.   if ((this.mSortedBy != null) &&
  868.       (this.mEntries.length > 0))
  869.   {
  870.     MaxHTMLSegmentSize = WWHFrame.WWHJavaScript.mMaxHTMLSegmentSize;
  871.     this.mHTMLSegment.fReset();
  872.     BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  873.     ByBookDetect = -1;
  874.  
  875.     // If this is the first entry, display the headers and open the list
  876.     //
  877.     if (this.mDisplayIndex == 0)
  878.     {
  879.       HTML = "";
  880.  
  881. // hide column headers:
  882. if (false) {
  883.       
  884.       HTML += "<p><nobr><b>";
  885.  
  886.       // Display column headers
  887.       //
  888.       if (Settings.mbShowRank)
  889.       {
  890.         HTML += WWHFrame.WWHJavaScript.mMessages.mSearchRankLabel + " ";
  891.       }
  892.       HTML += WWHFrame.WWHJavaScript.mMessages.mSearchTitleLabel;
  893.       if (Settings.mbShowBook)
  894.       {
  895.         if ((BookList.length > 1) &&  // More than one book exists
  896.             (this.mSortedBy == 1))    // By Score
  897.         {
  898.           HTML += ", " + WWHFrame.WWHJavaScript.mMessages.mSearchBookLabel;
  899.         }
  900.       }
  901.       HTML += "</b></nobr></p>";
  902.       
  903. }
  904.  
  905.       HTML += "<table border=0 cellspacing=0 width=\"100%\"><tr><td><ol>";
  906.  
  907.       this.mHTMLSegment.fAppend(HTML);
  908.     }
  909.  
  910.     // Display result entries
  911.     //
  912.     MaxIndex = this.mEntries.length;
  913.     Index = this.mDisplayIndex;
  914.     while ((this.mHTMLSegment.fSize() < MaxHTMLSegmentSize) &&
  915.            (Index < MaxIndex))
  916.     {
  917.       HTML = "";
  918.  
  919.       Entry = this.mEntries[Index];
  920.  
  921.       if ((BookList.length > 1) &&  // More than one book exists
  922.           (this.mSortedBy == 2))    // By BookIndex
  923.       {
  924.         if (ByBookDetect != Entry.mBookIndex)
  925.         {
  926. // HACK BEN
  927. // ByBook only used for single books
  928. // No book title will be emitted
  929. //
  930. //          HTML += "<p><nobr> </nobr></p>";
  931. //          HTML += "<p><nobr>" + BookList[Entry.mBookIndex].mTitle + "</nobr></p>";
  932.  
  933.           ByBookDetect = Entry.mBookIndex;
  934.         }
  935.       }
  936.  
  937.       // Display Rank
  938.       //
  939.       if (Settings.mbShowRank)
  940.       {
  941.         if (Math.floor((Entry.mScore / this.mMaxScore) * 100)==100)
  942.             newcolor="color:#EE3224;font-weight:bold";
  943.         else {
  944.         if (Math.floor((Entry.mScore / this.mMaxScore) * 100)>50)
  945.             newcolor="color:#B32317";
  946.         else
  947.             newcolor="color:black";
  948.     }
  949.         HTML += "<li value=\"" + Math.floor((Entry.mScore / this.mMaxScore) * 100) + "\" style=\"" + newcolor + "\">";
  950.       }
  951.       else
  952.       {
  953.         HTML += "<li>";
  954.       }
  955.  
  956.       // Display Title
  957.       //
  958.       HTML += "<a href=\"javascript:fC(" + Index + ");\">";
  959.       HTML += Entry.mTitle;
  960.       HTML += "</a>";
  961.  
  962.       // Display Book
  963.       //
  964.       if (Settings.mbShowBook)
  965.       {
  966.         if ((BookList.length > 1) &&  // More than one book exists
  967.             (this.mSortedBy == 1))    // By Score
  968.         {
  969.           HTML += ", " + BookList[Entry.mBookIndex].mTitle;
  970.         }
  971.       }
  972.  
  973.       HTML += "</li>\n";
  974.  
  975.       this.mHTMLSegment.fAppend(HTML);
  976.  
  977.       Index++;
  978.     }
  979.  
  980.     // Record current display index so we can pick up where we left off
  981.     //
  982.     this.mDisplayIndex = Index;
  983.     if (this.mHTMLSegment.fSize() > 0)
  984.     {
  985.       bSegmentCreated = true;
  986.     }
  987.  
  988.     // If this is the last entry, close the list
  989.     //
  990.     if (this.mDisplayIndex == this.mEntries.length)
  991.     {
  992.       this.mHTMLSegment.fAppend("</ol></td></tr></table>");
  993.     }
  994.   }
  995.  
  996.   return bSegmentCreated;
  997. }
  998.  
  999. function  WWHSearchResults_GetPopupAction(ParamEntryIndex)
  1000. {
  1001.   var  PopupAction = "";
  1002.  
  1003.  
  1004.   if (WWHFrame.WWHJavaScript.mSettings.mHoverText.mbEnabled)
  1005.   {
  1006.     PopupAction += " onMouseOver=\"fS('" + ParamEntryIndex + "', " + this.mEventString + ");\"";
  1007.     PopupAction += " onMouseOut=\"fH();\"";
  1008.   }
  1009.  
  1010.   return PopupAction;
  1011. }
  1012.  
  1013. function  WWHSearchResults_ShowEntry(ParamIndex)
  1014. {
  1015.   var  Entry;
  1016.   var  BookListEntry;
  1017.   var  URL;
  1018.  
  1019.  
  1020.   // Update highlight words
  1021.   //
  1022.   WWHFrame.WWHHighlightWords.fSetWordList(WWHStringUtilities_NormalizeSearchWords(WWHFrame.WWHSearch.mSavedSearchWords));
  1023.  
  1024.   // Display document
  1025.   //
  1026.   Entry = this.mEntries[ParamIndex];
  1027.   BookListEntry = WWHFrame.WWHHelp.mBooks.mBookList[Entry.mBookIndex];
  1028.   URL = WWHFrame.WWHHelp.mBaseURL + BookListEntry.mDirectory + BookListEntry.mFiles.fFileIndexToHREF(Entry.mFileIndex);
  1029.   WWHFrame.WWHHelp.fSetDocumentHREF(URL, false);
  1030. }
  1031.  
  1032. function  WWHSearchResultsEntry_Object(ParamBookIndex,
  1033.                                        ParamFileIndex,
  1034.                                        ParamScore,
  1035.                                        ParamTitle)
  1036. {
  1037.   this.mBookIndex = ParamBookIndex;
  1038.   this.mFileIndex = ParamFileIndex;
  1039.   this.mScore     = ParamScore;
  1040.   this.mTitle     = ParamTitle;
  1041. }
  1042.  
  1043. function  WWHSearchResultsEntry_ByScoreByBookIndexByTitleFileIndexURL(ParamAlphaEntry,
  1044.                                                                       ParamBetaEntry)
  1045. {
  1046.   var  Result;
  1047.  
  1048.  
  1049.   Result = WWHSearchResultsEntry_CompareByScore(ParamAlphaEntry, ParamBetaEntry);
  1050.   if (Result == 0)
  1051.   {
  1052.     Result = WWHSearchResultsEntry_CompareByBookIndex(ParamAlphaEntry, ParamBetaEntry);
  1053.   }
  1054.   if (Result == 0)
  1055.   {
  1056.     Result = WWHSearchResultsEntry_CompareByTitleFileIndexURL(ParamAlphaEntry, ParamBetaEntry);
  1057.   }
  1058.  
  1059.   return Result;
  1060. }
  1061.  
  1062. function  WWHSearchResultsEntry_ByBookIndexByScoreByTitleFileIndexURL(ParamAlphaEntry,
  1063.                                                                       ParamBetaEntry)
  1064. {
  1065.   var  Result;
  1066.  
  1067.  
  1068.   Result = WWHSearchResultsEntry_CompareByBookIndex(ParamAlphaEntry, ParamBetaEntry);
  1069.   if (Result == 0)
  1070.   {
  1071.     Result = WWHSearchResultsEntry_CompareByScore(ParamAlphaEntry, ParamBetaEntry);
  1072.   }
  1073.   if (Result == 0)
  1074.   {
  1075.     Result = WWHSearchResultsEntry_CompareByTitleFileIndexURL(ParamAlphaEntry, ParamBetaEntry);
  1076.   }
  1077.  
  1078.   return Result;
  1079. }
  1080.  
  1081. function  WWHSearchResultsEntry_CompareByScore(ParamAlphaEntry,
  1082.                                                ParamBetaEntry)
  1083. {
  1084.   var  Result = 0;
  1085.  
  1086.  
  1087.   // Sort by score
  1088.   //
  1089.   if (ParamAlphaEntry.mScore < ParamBetaEntry.mScore)
  1090.   {
  1091.     Result = 1;
  1092.   }
  1093.   else if (ParamAlphaEntry.mScore > ParamBetaEntry.mScore)
  1094.   {
  1095.     Result = -1;
  1096.   }
  1097.  
  1098.   return Result;
  1099. }
  1100.  
  1101. function  WWHSearchResultsEntry_CompareByBookIndex(ParamAlphaEntry,
  1102.                                                    ParamBetaEntry)
  1103. {
  1104.   var  Result = 0;
  1105.  
  1106.  
  1107.   if (ParamAlphaEntry.mBookIndex < ParamBetaEntry.mBookIndex)
  1108.   {
  1109.     Result = -1;
  1110.   }
  1111.   else if (ParamAlphaEntry.mBookIndex > ParamBetaEntry.mBookIndex)
  1112.   {
  1113.     Result = 1;
  1114.   }
  1115.  
  1116.   return Result;
  1117. }
  1118.  
  1119. function  WWHSearchResultsEntry_CompareByTitleFileIndexURL(ParamAlphaEntry,
  1120.                                                            ParamBetaEntry)
  1121. {
  1122.   var  Result = 0;
  1123.   var  BookList;
  1124.   var  AlphaBookEntry;
  1125.   var  BetaBookEntry;
  1126.   var  AlphaURL;
  1127.   var  BetaURL;
  1128.  
  1129.  
  1130.   // Sort by Title
  1131.   //
  1132.   if (ParamAlphaEntry.mTitle < ParamBetaEntry.mTitle)
  1133.   {
  1134.     Result = -1;
  1135.   }
  1136.   else if (ParamAlphaEntry.mTitle > ParamBetaEntry.mTitle)
  1137.   {
  1138.     Result = 1;
  1139.   }
  1140.   // Sort by FileIndex
  1141.   //
  1142.   else if (ParamAlphaEntry.mFileIndex < ParamBetaEntry.mFileIndex)
  1143.   {
  1144.     Result = -1;
  1145.   }
  1146.   else if (ParamAlphaEntry.mFileIndex > ParamBetaEntry.mFileIndex)
  1147.   {
  1148.     Result = 1;
  1149.   }
  1150.   // Sort by URL
  1151.   //
  1152.   else
  1153.   {
  1154.     BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  1155.  
  1156.     AlphaBookEntry = BookList[ParamAlphaEntry.mBookIndex];
  1157.     BetaBookEntry  = BookList[ParamBetaEntry.mBookIndex];
  1158.  
  1159.     AlphaURL = WWHFrame.WWHHelp.mBaseURL + AlphaBookEntry.mDirectory + AlphaBookEntry.mFiles.fFileIndexToHREF(ParamAlphaEntry.mFileIndex);
  1160.     BetaURL  = WWHFrame.WWHHelp.mBaseURL + BetaBookEntry.mDirectory + BetaBookEntry.mFiles.fFileIndexToHREF(ParamBetaEntry.mFileIndex);
  1161.  
  1162.     if (AlphaURL < BetaURL)
  1163.     {
  1164.       Result = -1;
  1165.     }
  1166.     else if (AlphaURL > BetaURL)
  1167.     {
  1168.       Result = 1;
  1169.     }
  1170.   }
  1171.  
  1172.   return Result;
  1173. }
  1174.