/*************************************************************************

    chm2web Help Index Library 1.0
    Copyright (c) 2002-2003 A!K Research Labs (http://www.aklabs.com)  
    http://chm2web.aklabs.com - HTML Help Conversion Utility

    Tested with: Internet Explorer 5, Opera 6, Mozilla 1.2, NN6

    ATTENTION! You can use this library only with web help system 
               generated by chm2web software.  
               
**************************************************************************/


function Startup()
{
  for (var i = 0; i < HelpIndex.length; i++)
  {
    var e = document.createElement("OPTION");
    e.text = HelpIndex[i][0];
    e.value = i;
    document.forms[0].indexlist[document.forms[0].indexlist.length] = e;
  }
}

var oldS = "";

function SelectMatch(str)
{
  top.indexquery=str;

  var s = str.toUpperCase();
  
  if ((s == "") || (s == oldS))
    return false;

  oldS = s;

  var re = new RegExp("^"+s, "i");
  var h = Math.floor(document.forms[0].indexlist.length/100);
  var start = h*100;
  var end = document.forms[0].indexlist.length - 1;

  if (h > 0)
    for (var i = 0; i <= h; i++)
      if (s < document.forms[0].indexlist[i*100].text)
      {
        start = (i - 1)*100;
        if (start < 0)
          start = 0;
        end = i*100;
        break;
      }

  for (var i = start; i <= end; i++)
    if (document.forms[0].indexlist[i].text.match(re))
    {
      document.forms[0].indexlist[i].selected = true;
      return true;
    }


  return false;
}

function ShowMatch()
{
  if (document.forms[0].indexlist.selectedIndex >= 0) {
    open(HelpIndex[document.forms[0].indexlist[document.forms[0].indexlist.selectedIndex].value][1], "content");
    return true;
  } else 
    return false;
}
