/******************************************************************************
*
*    $RCSfile: bsihelpjs.js,v $
*   $Revision: 1.8 $
*     $Author: SteveHarned $
*       $Date: 2003/03/13 13:56:10 $
*
* Copyright (c) 2001;  Bentley Systems, Inc., 690 Pennsylvania Drive, 
*                      Exton PA, 19341-1136, USA.  All Rights Reserved.
*
*
* JavaScript functions for Bentley Systems, Inc. Documentation Group
*	written: April 20, 2001   author: Steve Harned
*
* These functions are used in the online help file to implement the search
* feature in the Tool Index. One additional required function is in the help
* file named toolindex.html, this is the function fnGetObjCount().
******************************************************************************/


function fnToggleDisplay(currElem)
{
	var docObj = 'parent.tindex.document.all'
	var styleObj = '.style'
	var re, patrn, tempstr, tstr
	var toolname, chosen, dom
	var f = document.form1
	var findstr = f.FilterField.value
	if (findstr.length > 1) {
                tstr = findstr
                findstr = tstr.replace ('*', '.')
		tempstr = ""
	} else {
		if (findstr == "*") {
			findstr = "."
			tempstr = ""
		} else {
			tempstr = "^"
		}
	}
	patrn = tempstr.concat(findstr)
	re = new RegExp(patrn, "i")
	dom = eval(docObj + '.' + currElem + styleObj)
	toolname = dom.toolname
	chosen = re.test(toolname)
	if (!chosen) {
		dom.display = "none"
	}
	else {
		dom.display = "inline"
	}
}

function fnToggleAll()
{
	var str1 = "obj"
	var i
	var count = parent.tindex.fnGetObjCount()
	for (i=0; i < count; i++) {
		nxtObj = str1.concat(i.toString())
		fnToggleDisplay(nxtObj)
	}
}

function Clear()
{
	var f = document.form1
	f.FilterField.value=""
	fnToggleAll()
}


function getLocalFile(fn) {
        var X, Y, sl, a, ra, link, baseloc, regexp;
        ra = /mk:/;                                             // It's looking for the (mk:) characters.
        baseloc = location.href;
        a = location.href.search(ra);                           // It searches the location of the current document
        if (a == 0)                                             // If it finds mk:@MSITStore:D 
        {
                X = 14;                                         // the location of the CHM begins with char 14
                sl="\\";
        }
        else                                                    // else it starts with the 7th character.
        {
                X = 8;                                          // Need to test this a bit.
                sl = "/";                                       // It then looks for the last backslash character
        }
        Y = location.href.lastIndexOf(sl)+1;                    // it includes that character as the last in the dir.
        link = 'file:///' + baseloc.substring(X, Y) + fn;       // It returns the path found, plus the passed in file name.

	regexp = new RegExp ("%20", "g");
	link = link.replace (regexp, " ");
        return link;                   
}

function showPane (idVariable)
{
        //display the section if it's not displayed; hide it if it is displayed
        if (idVariable.style.display=="none")
        {
                idVariable.style.display="";
        }
        else
        {
                idVariable.style.display="none";
        }
}

function hidePane (idVariable)
{
        //remove the section when user clicks in the opened DIV
        if (idVariable.style.display=="")
        {
                idVariable.style.display="none";
        }
}


function kiShareLink (helpString)
{
        var X, Y, link, baseloc;

        baseloc = location.href;
        X=baseloc.lastIndexOf("\\")+1;
        Y=baseloc.lastIndexOf("::");
        link = baseloc.substring(X, Y);

        kiSharedLink.innerHTML="<OBJECT ID='kiLink' TYPE='application/x-oleobject'" +
                        "CLASSID='clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11'>" +
                        "<param name='Command' value='Related Topics'>" +
                        "<param name='Window' value='$global_mainWindow'>" +
                        "<param name='Item1' value='title;ms-its:" + link + "::" + helpString + "'>" +
                        "</OBJECT>";
        kiLink.Click(); 
}

function tiShareLink (helpString)
{
        tiSharedLink.innerHTML="<OBJECT ID='tiLink' TYPE='application/x-oleobject'" +
                        "CLASSID='clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11'>" +
                        "<param name='Command' value='ALink'>" +
			"<param name='Flags' value=',,1'>" +
                        "<param name='Window' value='$global_mainWindow'>" +
			"<param name='Item1' value=''>" +
                        "<param name='Item2' value='" + helpString + "'>" +
                        "</OBJECT>";
        tiLink.Click(); 
}

function fnFindNext()
{
	var cNum, nextNum, nextPage;
	cNum = getPageNum();
	nextNum = cNum + 1;
	if ( nextNum <= PageMax )
	{
		nextPage = getProdName() + nextNum.toString() + ".html";
		window.navigate (nextPage);
	}
}

function fnFindPrev()
{
	var cNum, prevNum, prevPage;
	cNum = getPageNum();
	prevNum = cNum - 1;
	prevPage = getProdName() + prevNum.toString() + ".html";
	window.navigate (prevPage);
}
