/////////////////////////////////////////////////////////////////////////////
// RoboHELP® WebHelp 4 Dynamic HTML Effects Script
// Copyright © 1998-2001 eHelp Corporation.  All rights reserved.

// Version= 4.43

// Warning:  Do not modify this file.  It is generated by RoboHELP® and changes will be overwritten.

//{{WH3_SYMBOL_SECTION
var gstrNavFrmst = "navpane1.asp?nohead=y";
var gstrTocDhtml = "tocdhtml.asp?nohead=y";
var gstrIdxDhtml = "idxdhtml.asp?nohead=y";
var gstrFtsDhtml = "ftsdhtml.asp?nohead=y";
var gstrIniDhtml = "tocdhtml.asp?nohead=y";
var gstrBlankhtml = "_blank.asp?nohead=y";

//}}WH3_SYMBOL_SECTION

var gnPageWidth = 0;
var gnPageHeight = 0;
var gstrColl = "";
var gstrStyle = ""
var gbNav6 = false;
var gbIE4 = false;
var gbIE = false;
var gbIE5 = false;
var gbIE55 = false;
var gbTocLoaded = false;
var gbIndexLoaded = false;
var gbFtsLoaded = false;
var gAgent = navigator.userAgent.toLowerCase(); 
var gbMac = (gAgent.indexOf("mac") != -1);

var gbIndexInputEnable = false;
var gITE = new Array();
var gIndexKeywordArray = new Array();
var gIndexLetterArray = new Array();

var gbFtsInputEnable = false;
var gKE = new Array();
var gTE = new Array();
var gSTP = new Array();

var gctrlFocus = null;
var _event = new myEvent();

function myEvent()
{
	this.pageX = 0;
	this.pageY = 0;
}

gbIE = (navigator.appName.indexOf("Microsoft") != -1);
if (parseInt(navigator.appVersion) >= 4) {
	if ( (navigator.appName == "Netscape") && parseInt(navigator.appVersion) >= 5)
			gbNav6 = true;
	gbIE4 = (navigator.appName.indexOf("Microsoft") != -1);
}
if (gbNav6) {
	document.gnPageWidth = innerWidth;
	document.gnPageHeight = innerHeight;
} else if (gbIE4) {
	gstrStyle = ".style";
	gstrColl = "all.";
	if (gAgent.indexOf("msie 5") != -1) {
		gbIE5 = true;
	}
	if (gAgent.indexOf("msie 5.5") != -1) {
		gbIE55 = true;
	}
}

function HandleResize()
{
	if (innerWidth != window.document.gnPageWidth || innerHeight != window.document.gnPageHeight) {
		if (window.document.gnPageWidth == 0) {
			window.document.gnPageWidth = innerWidth;
			window.document.gnPageHeight = innerHeight;
		} else {
			window.document.gnPageWidth = innerWidth;
			window.document.gnPageHeight = innerHeight;
			window.document.location.reload();
		}
		return false;
	}
}


function FindTopLevelLayer(strID)
{
	if (gbNav6) {
		return document.getElementById(strID);
	} else if (gbIE4) {
		var obj = eval("document.all." + strID);
		return obj;
	}
	return null;
}

function FindTopLevelLayerNS(strID)
{
	for (var iLayer = 0; iLayer < window.document.layers.length; iLayer++) {
		if (window.document.layers[iLayer].id == strID) {
			return window.document.layers[iLayer];
		}
	}

	// This section is added to the search because when the scrollbar is
	// added, Netscape messes up the layer list. This is another way
	// of getting to the layers
	if (window.document.layers.length > 0) {
		var iLayer = 0;
		var objLayer = window.document.layers[0];
		while ((iLayer < 20) && (objLayer != null)) {
			if (objLayer.id == strID) {
				return objLayer;
			}
			iLayer++;
			objLayer = objLayer.above;
		}
	}
	return null;
}

function GetAttribObject(obj)
{
	var objAttrib = null;
	if (typeof obj == "string") {
		objAttrib = eval("document." + gstrColl + obj + gstrStyle);
	} else {
		objAttrib = obj;
	}
	return objAttrib;
}


function TabFrame()
{
	if (gbIE4)
		return document.frames['Tabs'];
	if (gbNav6) {
		return window.frames['Tabs'];
	}
}

function NavFrame()
{
	if (gbIE4)
		return document.frames['Navigation'];
	else
		return window.frames['Navigation'];
}

function GetIFrameByDiv(div)
{
	var cIframe;
	if ((frames.length > 0) &&
	    (div != null) &&
	    (div.id != null))
	{
		if (div.id == "TocNav")
			cIframe = frames['TocIFrame'];
		else if (div.id == "IndexNav")
			cIframe = frames['IndexIFrame'];
		else if (div.id == "FtsNav")
			cIframe = frames['FtsIFrame'];			
	}
	return cIframe;
}


function ShowDiv(strDiv, bShow)
{
	var Div = FindTopLevelLayer(strDiv);
	if (Div == null) {
		return;
	}

	if (gbIE55)
	{
		var curIframe = GetIFrameByDiv(Div);
		if (bShow)
		{
		   Div.style.zIndex = 3;
		   if (curIframe != null)  
		   {
			curIframe.frameElement.style.zIndex=3;
			curIframe.frameElement.style.visibility = "visible";
		   }
		}
		else
		{
		   Div.style.zIndex = 2;
		   if (curIframe != null)
		   {
			curIframe.frameElement.style.zIndex= 2;
			curIframe.frameElement.style.visibility = "hidden";
		   }
		}
	}
	Div.style.visibility = (bShow == true) ? 'visible' : 'hidden';
	return;
}

function LoadTocContent(TocDiv)
{	
	gbTocLoaded = true;
	return;
}

var gstrtocURL = "";

function AutoSyncToc(strtocURL)
{
	if (strtocURL == "") return;

	var TocDiv = this.FindTopLevelLayer('TocNav');
	
	if (gbIE4) {
		if (TocDiv.document.all.TocIFrame == null) return;
		if (typeof(document.frames['TocIFrame'].window.NavBar_SyncToc) == 'function')
			document.frames['TocIFrame'].window.NavBar_SyncToc(strtocURL);
	} else if (gbNav6) {
		gstrtocURL = strtocURL;
	}
	
	gbTocLoaded = true;
	return;
}


function SyncTocContent(strtocURL)
{
	var TocDiv = this.FindTopLevelLayer('TocNav');

	if (gbIE4)  {
		if (TocDiv.document.all.TocIFrame == null) return;
	}

	if (gbNav6 || gbIE4) {
		// no refresh.
		// but we need to switch div , if need.
		if (parent.TabFrame().document.images['TocTab'] != null) {
			parent.TabFrame().document.images['TocTab'].src='bssctab1.gif';
		}
		if (parent.TabFrame().document.images['IndexTab'] != null) {
			parent.TabFrame().document.images['IndexTab'].src='bssctab4.gif';
		}
		if (parent.TabFrame().document.images['FtsTab'] != null) {
			parent.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
		}			
		ShowDiv('TocNav', true);
		ShowDiv('IndexNav', false);
		ShowDiv('FtsNav', false);
		TOCFocusA();
	}

	if (gbIE4) {
		if (typeof(document.frames['TocIFrame'].window.NavBar_SyncToc) == 'function')
			document.frames['TocIFrame'].window.NavBar_SyncToc(strtocURL);
	} else if (gbNav6) {
		gstrtocURL = strtocURL;
	}
	gbTocLoaded = true;
	return;
}

function TOCFocusA()
{
	if (gbIE55) 
	{
		var TocDiv = FindTopLevelLayer('TocNav');
		if (TocDiv && TocDiv.document && TocDiv.document.frames['TocIFrame'])
		{
			TocDiv = TocDiv.document.frames['TocIFrame'];
			if (TocDiv)
				TocDiv.focus();
		}
	}
}

function LoadIndexContent(IndexDiv)
{
	if (gstrIdxDhtml.length > 0) {
		var strFile = location.href;
		var nPosFile = strFile.indexOf(gstrNavFrmst);
		strFile = strFile.substring(0, nPosFile);
		strFile += gstrIdxDhtml;
		if (gbIE4) {
			IndexDiv.document.all.IndexIFrame.src = strFile;
		} else if (gbNav6) {
			IndexDiv.getElementsByTagName("IFrame")[0].src = strFile;
		}
		gbIndexLoaded = true;
	}
	return;
}

function LoadFtsContent(FtsDiv)
{
	if (gstrFtsDhtml.length > 0) {
		var strFile = location.href;
		var nPosFile = strFile.indexOf(gstrNavFrmst);
		strFile = strFile.substring(0, nPosFile);
		strFile += gstrFtsDhtml;
		if (gbIE4) {
			FtsDiv.document.all.FtsIFrame.src = strFile;
		} else if (gbNav6) {
			FtsDiv.getElementsByTagName("IFrame")[0].src = strFile;
		}
		
		gbFtsLoaded = true;
	}
	return;
}


function TimeoutChangeToTOC()
{
	if (!gbTocLoaded) {
		var TocDiv = window.NavFrame().FindTopLevelLayer('TocNav');
		if (TocDiv != null) {
			LoadTocContent(TocDiv);
		}
	}
	if (window.TabFrame().document.images['TocTab'] != null) {
		window.TabFrame().document.images['TocTab'].src='bssctab1.gif';
	}
	if (window.TabFrame().document.images['IndexTab'] != null) {
		window.TabFrame().document.images['IndexTab'].src='bssctab4.gif';
	}
	if (window.TabFrame().document.images['FtsTab'] != null) {
		window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
	}
	window.NavFrame().ShowDiv('TocNav', true);
	window.NavFrame().ShowDiv('IndexNav', false);
	window.NavFrame().ShowDiv('FtsNav', false);
	window.NavFrame().DoAutoSync();
}


function ChangeToTOC()
{
	setTimeout("TimeoutChangeToTOC();", 50);
	return;
}

function SelectTOC()
{
	if (!gbTocLoaded) {
		var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
		if (TocDiv != null) {
			LoadTocContent(TocDiv);
		}
	}
	if (TabFrame().document.images['TocTab'] != null) {
		TabFrame().document.images['TocTab'].src='bssctab1.gif';
	}
	if (TabFrame().document.images['IndexTab'] != null) {
		TabFrame().document.images['IndexTab'].src='bssctab4.gif';
	}
	if (TabFrame().document.images['FtsTab'] != null) {
		TabFrame().document.images['FtsTab'].src='bssctab6.gif';
	}
	NavFrame().ShowDiv('TocNav', true);
	NavFrame().ShowDiv('IndexNav', false);
	NavFrame().ShowDiv('FtsNav', false);

	if (!gbIE5 || gbIE55)
		setTimeout("TOCFocus()", 200);
	else
		window.NavFrame().DoAutoSync();
}

function TimeoutChangeToIndex()
{
	if (!gbIndexLoaded) {
		var IndexDiv = window.NavFrame().FindTopLevelLayer('IndexNav');
		if (IndexDiv != null) {
			LoadIndexContent(IndexDiv);
		}
	}
	if (window.TabFrame().document.images['TocTab'] != null) {
		window.TabFrame().document.images['TocTab'].src='bssctab2.gif';
	}
	if (window.TabFrame().document.images['IndexTab'] != null) {
		window.TabFrame().document.images['IndexTab'].src='bssctab3.gif';
	}
	if (window.TabFrame().document.images['FtsTab'] != null) {
		window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
	}
	window.NavFrame().ShowDiv('TocNav', false);
	window.NavFrame().ShowDiv('IndexNav', true);
	window.NavFrame().ShowDiv('FtsNav', false);

}


function ChangeToIndex()
{
	setTimeout("TimeoutChangeToIndex();", 50);
}

function SelectIndex()
{
	if (!gbIndexLoaded) {
		var IndexDiv = window.NavFrame().FindTopLevelLayer('IndexNav');
		if (IndexDiv != null) {
			LoadIndexContent(IndexDiv);
		}
	}
	if (TabFrame().document.images['TocTab'] != null) {
		TabFrame().document.images['TocTab'].src='bssctab2.gif';
	}
	if (TabFrame().document.images['IndexTab'] != null) {
		TabFrame().document.images['IndexTab'].src='bssctab3.gif';
	}
	if (TabFrame().document.images['FtsTab'] != null) {
		TabFrame().document.images['FtsTab'].src='bssctab6.gif';
	}
	NavFrame().ShowDiv('TocNav', false);
	NavFrame().ShowDiv('IndexNav', true);
	NavFrame().ShowDiv('FtsNav', false);

	setTimeout("IndexFocus()", 200);
}


function SelectFTS()
{
	var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
	if (!gbFtsLoaded) {
		if (FtsDiv != null) {
			LoadFtsContent(FtsDiv);
		}
	}
	if (TabFrame().document.images['TocTab'] != null) {
		TabFrame().document.images['TocTab'].src='bssctab2.gif';
	}
	if (TabFrame().document.images['IndexTab'] != null) {
		TabFrame().document.images['IndexTab'].src='bssctab4.gif';
	}
	if (TabFrame().document.images['FtsTab'] != null) {
		TabFrame().document.images['FtsTab'].src='bssctab5.gif';
	}
	NavFrame().ShowDiv('TocNav', false);
	NavFrame().ShowDiv('IndexNav', false);
	NavFrame().ShowDiv('FtsNav', true);

	setTimeout("FTSFocus()", 200);
}

function TOCFocus()
{
	if (!gbIE5 || gbIE55)
	{
		var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
		if (TocDiv && TocDiv.document && TocDiv.document.frames['TocIFrame'])
		{
			TocDiv = TocDiv.document.frames['TocIFrame'];
			if (TocDiv) {
				TocDiv.focus();
				if (typeof(TocDiv.ItemFocus) != "undefined")
					TocDiv.ItemFocus();
			}
		}
		window.NavFrame().DoAutoSync();
	}
}


function FTSFocus()
{
	var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
	if (gbIE4) {
		if (FtsDiv && FtsDiv.document && FtsDiv.document.frames['FtsIFrame'] &&
			FtsDiv.document.frames['FtsIFrame'].frames['ftsform']) 
			FtsDiv = FtsDiv.document.frames['FtsIFrame'].frames['ftsform'];
	}

	if (FtsDiv && FtsDiv.FtsInputForm != null) {
		FtsDiv.FtsInputForm.ftsField.focus();
	}
}

function IndexFocus()
{

	var IndexDiv = NavFrame().FindTopLevelLayer('IndexNav');
	if (gbIE4) {
		if (IndexDiv && IndexDiv.document && IndexDiv.document.frames['IndexIFrame'] &&
			IndexDiv.document.frames['IndexIFrame'].frames['idxform']) 
			IndexDiv = IndexDiv.document.frames['IndexIFrame'].frames['idxform'];
	}
	if (IndexDiv && IndexDiv.IndexInputForm != null) {
		IndexDiv.IndexInputForm.keywordField.focus();
	}
}

function SelectInitialTab()
{
	// Create the necessary IFrames for IE
	if (gbIE4) {
		if (FindTopLevelLayer('TocNav') != null && gstrTocDhtml.length > 0) {
			var nIFrameHeight = FindTopLevelLayer('TocNav').style.pixelHeight - 10;
			var strIFrame = '<IFRAME ID="TocIFrame" SRC="' + gstrTocDhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
			if (gbMac) {
				strIFrame += nIFrameHeight + 'px;"></IFRAME>';
			} else {
				strIFrame += '100%;"></IFRAME>';
			}
			FindTopLevelLayer('TocNav').innerHTML = strIFrame;
		}
		if (FindTopLevelLayer('IndexNav') != null && gstrIdxDhtml.length > 0) {
			var nIFrameHeight = FindTopLevelLayer('IndexNav').style.pixelHeight - 10;
			var strIFrame = '<IFRAME ID="IndexIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
			if (gbMac) {
				strIFrame += nIFrameHeight + 'px;"></IFRAME>';
			} else {
				strIFrame += '100%;"></IFRAME>';
			}
			FindTopLevelLayer('IndexNav').innerHTML = strIFrame;
		}

		if (FindTopLevelLayer('FtsNav') != null && gstrFtsDhtml.length > 0) {
			var nIFrameHeight = FindTopLevelLayer('FtsNav').style.pixelHeight - 10;
			var strIFrame = '<IFRAME ID="FtsIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
			if (gbMac) {
				strIFrame += nIFrameHeight + 'px;"></IFRAME>';
			} else {
				strIFrame += '100%;"></IFRAME>';
			}
			FindTopLevelLayer('FtsNav').innerHTML = strIFrame;
		}
	} else if (gbNav6) {
		if (FindTopLevelLayer('TocNav') != null && gstrTocDhtml.length > 0) {
			var nIFrameHeight = FindTopLevelLayer('TocNav').style.pixelHeight - 10;
			var strIFrame = '<IFRAME ID="TocIFrame" SRC="' + gstrTocDhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; width:100%; border:0;height:';
			strIFrame += '100%;"></IFRAME>';
			FindTopLevelLayer('TocNav').innerHTML = strIFrame;
		}
		if (FindTopLevelLayer('IndexNav') != null && gstrIdxDhtml.length > 0) {
			var nIFrameHeight = FindTopLevelLayer('IndexNav').style.pixelHeight - 10;
			var strIFrame = '<IFRAME ID="IndexIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; width:100%; border:0;height:';
			strIFrame += '100%;"></IFRAME>';
			FindTopLevelLayer('IndexNav').innerHTML = strIFrame;
		}

		if (FindTopLevelLayer('FtsNav') != null && gstrFtsDhtml.length > 0) {
			var nIFrameHeight = FindTopLevelLayer('FtsNav').style.pixelHeight - 10;
			var strIFrame = '<IFRAME ID="FtsIFrame" SRC="' + gstrBlankhtml + '" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; width:100%; border:0;height:';
			strIFrame += '100%;"></IFRAME>';
			FindTopLevelLayer('FtsNav').innerHTML = strIFrame;
		}
	}

	// Call the real selection function
	setTimeout("SelectInitTabReal()", 50);
}

function SelectInitTabReal()
{
	parent.gbTocLoaded = false;
	parent.gbIndexLoaded = false;
	parent.gbFtsLoaded = false;

	if (gstrIniDhtml == gstrTocDhtml)	{
		parent.SelectTOC();
	} else if (gstrIniDhtml == gstrIdxDhtml) {
		parent.SelectIndex();
	} else if (gstrIniDhtml == gstrFtsDhtml) {
		parent.SelectFTS();
	}

//	if (FindTopLevelLayer('TocNav') != null) {
//		parent.SelectTOC();
//	} else if (FindTopLevelLayer('IndexNav') != null) {
//		parent.SelectIndex();
//	} else if (FindTopLevelLayer('FtsNav') != null) {
//		parent.SelectFTS();
//	}
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Index code
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////

var gbIndexLayerInit = false;
function IndexInitPage()
{
	parent.gbIndexLayerInit = false;
	if (gbIE4 || gbNav6) {
		// Mark all Index blocks as "expanded"
		var tempColl = null;
		if (gbIE4)
			tempColl = document.all.tags("DIV");
		else
			tempColl = document.getElementsByTagName("Div");
		for (var i = 0; i < tempColl.length; i++) {
			if (tempColl[i].className == "child") tempColl[i].style.display = "block";
		}

		// Make an array of parents so we can access them directly
		var iLetterIndex = 0;
		var nACharCode = "A".charCodeAt(0);
		for (var i = 0; i < tempColl.length; i++) {
			if (tempColl[i].className == "parent") {
				var strBookName = "";
				if (gbIE4)
					strBookName = tempColl[i].innerText;
				else {	
					var bElement = tempColl[i].getElementsByTagName("B");
					if (bElement != null) {
						strBookName = bElement[0].innerHTML;
					}
				}
				if (strBookName.length > 0)  {
					gIndexLetterArray[strBookName.charCodeAt(0)] = tempColl[i];
				}
				
			}
		}
	}
	setTimeout("parent.gbIndexLayerInit = true;",1000);
	return;
}

function IndexWriteClassStyle()
{
	document.write("<STYLE TYPE='text/css'>");
	if (gbNav6) {
			document.write(".IndexItem {visibility:inherit; font-size:8pt;}");
			document.write(".parent {font-size:10pt;}");
			document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
			document.write("P {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt;}");
			document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
			document.write(".child {display:block}");
			document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
			document.write("A:link {text-decoration: none; color: 000000}");
			document.write("A:visited {text-decoration: none; color: 333333}");
			document.write("A:active {text-decoration: none; background-color: #cccccc}");
			document.write("A:hover {text-decoration: underline; color: 007f00}");
	} else if (gbIE4) {
		if (gbMac) {
			if (gbIE5) {
				document.write(".IndexItem {visibility:inherit; font-size:10pt;}");
				document.write(".parent {font-size:10pt;}");
				document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
				document.write("P {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
				document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
				document.write("H6.firstsub {font-family:'Arial'; color:#cccccc; font-size:10pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
			} else {

				document.write(".IndexItem {visibility:inherit; font-size:12pt;}");
				document.write(".parent {font-size:14pt;}");
				document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
				document.write("P {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
				document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
				document.write("H6.firstsub {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:-10pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
			}
		} else {
			document.write(".IndexItem {visibility:inherit; font-size:8pt;}");
			document.write(".parent {font-size:10pt;}");
			document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
			document.write("P {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt;}");
			document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
		}
		document.write(".child {display:block}");
		document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
		document.write("A:link {text-decoration: none; color: 000000}");
		document.write("A:visited {text-decoration: none; color: 333333}");
		document.write("A:active {text-decoration: none; background-color: #cccccc}");
		document.write("A:hover {text-decoration: underline; color: 007f00}");
	}
	document.write("</STYLE>");
	return;
}

//Define variable arguments as: strTitle, strUrl
function TE() 
{
	var argLen = TE.arguments.length;
	this.strTitle = TE.arguments[0];
	this.strURL = TE.arguments[1];
}

//Define variable arguments as: strKeyword [,strTopicIndex]*
function IndexKeywordEntry() 
{
	var argLen = IndexKeywordEntry.arguments.length;
	this.strKeyword = IndexKeywordEntry.arguments[0];
	this.arrayTopics = new Array();

	// Now add all of the topic entries
	for (var i=0; i < argLen - 1; i++) {
		this.arrayTopics[i] = IndexKeywordEntry.arguments[i + 1];
	}
}


function IndexBody()
{
	// Get the appropriate item to add items to
	var layerFind = null;
	if (gbIE4) {
		layerFind = parent.document.frames['idxbody'];
	} else if (gbNav6) {
		layerFind =  parent.frames['idxbody'];
	}
	
	return layerFind;
}

function IndexForm()
{
	// Get the appropriate item to add items to
	var layerFind = null;
	if (gbIE4) {
		layerFind = parent.document.frames['idxform'];
	} else if (gbNav6) {
		layerFind = parent.frames['idxform'];
	}
	
	return layerFind;
}

function IndexExpandIt(elId, bForceOpen) 
{
	var layerChild = null;
	if (gbIE4 || gbNav6) {
		layerChild = TocExpand(elId, false, bForceOpen);

		if (!bForceOpen) {
			var nNewScroll = document.body.scrollTop;
			if (layerChild.style.display == "block") {
				var nItemTop = layerChild.offsetTop;
				var nItemBottom = nItemTop + layerChild.offsetHeight;
				// Make sure the bottom is visible if possible
				if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
					nNewScroll = nItemBottom - document.body.clientHeight;
				}
				// If expanded item is bigger than the client area, scroll the item to the top
				if (nItemBottom - nItemTop > document.body.clientHeight) {
					nNewScroll = nItemTop - 20;
				}
			}
			document.body.scrollTop = nNewScroll;
		}
	}
	return layerChild;
}


function IndexInputEnable(bEnable)
{
	gbIndexInputEnable = bEnable;
	return;
}

function IndexInputSubmit()
{
	IndexLookup(true);
	return;
}

//Initize the site
function IndexSiteInit()
{
  if (!window.Array) return;
  document.onkeyup = IndexLookupKeydown;
}

function IndexLookupKeydown() 
{
	if (gbIE4)
	{
		if (event.keyCode == 13)	//Enter key
		{
			IndexLookup(true);
		}
		else 
			IndexLookup(false);
	}
	else
		IndexLookup(false);
}

function IndexLookup(bCR) 
{
	if (!parent.gbIndexLayerInit) {
		return; 
	}

	if (!gbIndexInputEnable && !gbMac) {
		return;
	}

	var strInput = document.IndexInputForm.keywordField.value.toUpperCase();
	if (strInput != "") {
		IndexSiteDisplay(strInput, bCR);
	}

	if (gbMac) {
		document.IndexInputForm.keywordField.focus();
	}

	return;
}

function  IndexSiteDisplay(strInput, bCR)
{
	// Get the topmost Index layer
	var IndexDiv = IndexBody();

	// Get the layer for the first letter
	var cFirst = strInput.charAt(0);
	cFirst = GetFlagChar(cFirst);
	var layerFirst = null;
	if (gbNav6) {
		layerFirst = IndexDiv.gIndexLetterArray[cFirst.charCodeAt(0)];
	} else if (gbIE4) {
		layerFirst = IndexDiv.gIndexLetterArray[cFirst.charCodeAt(0)];
	}

	// If we didn't find anything then return - something went terribly wrong
	if (layerFirst == null) {
		return;
	}

	// Expand the first layer
	var strLayerID = layerFirst.id;
	var iParent = strLayerID.indexOf("Parent");
	strLayerID = strLayerID.substr(0, iParent);

	var layerChild = IndexDiv.IndexExpandIt(strLayerID, true);

	// Find the first child that "matches" the item we are searchig for
	var MatchingItem = null;
	if (gbIE4) {
		var tempColl = layerChild.all.tags("P");
		if (tempColl.length == 0) {
			MatchingItem = layerChild;
		} else {
			var iStart = 0;
			var iEnd = tempColl.length - 1;
			var iMid = 0;
			var strItemUpper = "";
			while (iStart <= iEnd) {
				iMid = iStart + iEnd;
				iMid >>= 1;
				strItemUpper = tempColl(iMid).innerText;
				strItemUpper = strItemUpper.toUpperCase();
				if (compare(strItemUpper, strInput) > 0  ) {
					iEnd = iMid - 1;
				} else if (compare(strItemUpper, strInput) < 0) {
					iStart = iMid + 1;
					if (iStart < tempColl.length)
						iMid = iStart;
				} else break;
			}

			// Search backward to find the first one that partially matches
			var iMatch = 0;
			for (var iMatch = iMid; iMatch >= 0; iMatch--) {
				strItemUpper = tempColl(iMatch).innerText;
				strItemUpper = strItemUpper.toUpperCase();
				if (compare(strItemUpper, strInput) != 0) {
					break;
				}
			}
			if (iMatch != iMid) {
				if (iMatch >= 0) {
					if (iMatch < tempColl.length - 1) {
						iMid = iMatch + 1;
					} else {
						iMid = iMatch;
					}
				} else {
					iMid = 0;
				}
			}
			MatchingItem = tempColl(iMid);
		}
	} else if (gbNav6) {
		var tempColl = layerChild.getElementsByTagName("P");
		if (tempColl.length == 0) {
			MatchingItem = layerChild;
		} else {
			var iStart = 0;
			var iEnd = tempColl.length - 1;
			var iMid = 0;
			var strItemUpper = "";
			while (iStart <= iEnd) {
				iMid = iStart + iEnd;
				iMid >>= 1;
				var finalA = tempColl[iMid].getElementsByTagName("A");
				if (finalA.length > 0)
					strItemUpper = finalA[0].innerHTML;

				strItemUpper = strItemUpper.toUpperCase();
				if (compare(strItemUpper, strInput) > 0  ) {
					iEnd = iMid - 1;
				} else if (compare(strItemUpper, strInput) < 0) {
					iStart = iMid + 1;
					if (iStart < tempColl.length)
						iMid = iStart;
				} else break;
			}

			// Search backward to find the first one that partially matches
			var iMatch = 0;
			for (var iMatch = iMid; iMatch >= 0; iMatch--) {
				var finalA = tempColl[iMatch].getElementsByTagName("A");
				if (finalA.length > 0)
					strItemUpper = finalA[0].innerHTML;

				strItemUpper = strItemUpper.toUpperCase();
				if (compare(strItemUpper, strInput) != 0) {
					break;
				}
			}
			if (iMatch != iMid) {
				if (iMatch >= 0) {
					if (iMatch < tempColl.length - 1) {
						iMid = iMatch + 1;
					} else {
						iMid = iMatch;
					}
				} else {
					iMid = 0;
				}
			}
			MatchingItem = tempColl[iMid];
		}
	}


	// Scroll to the closest matching item
	if (MatchingItem) {
		if (gbIE4) {
			IndexDiv.document.body.scrollTop = MatchingItem.offsetTop;

			// Set the focus on the selected hyperlink (if there is one)
			tempColl = MatchingItem.all.tags("A");
			if (tempColl.length > 0) {
				// If a carriage return was used then simulate a click
				if (bCR) {
					tempColl(0).click();
				} else {
					// Simply set the focus to the hyperlink
					if (!gbIE5 || gbIE55) {
					   var nbTag = MatchingItem.all.tags("NOBR");
					   if (nbTag.length > 0)
						   HighLightElement(nbTag(0));
					} else {
					   tempColl(0).focus();
					}
				}
				IndexForm().document.IndexInputForm.keywordField.focus();
			}
		} else if (gbNav6) {
			IndexDiv.document.body.scrollTop = MatchingItem.offsetTop;

			// Set the focus on the selected hyperlink (if there is one)
			tempColl = MatchingItem.getElementsByTagName("A");
			if (tempColl.length > 0) {
				// If a carriage return was used then simulate a click
				if (bCR) {
					var strCommand = tempColl[0].getAttribute("onClick");
					var nstrCommand = strCommand.indexOf(";");
					strCommand = strCommand.substring(0, nstrCommand);
					strCommand = strCommand.replace("event", "_event");
					IndexDiv._event.pageX = MatchingItem.offsetLeft ;
					IndexDiv._event.pageY = MatchingItem.offsetTop + 20;
					IndexDiv.setTimeout(strCommand, 100);
				} else {
					   var nbTag = MatchingItem.getElementsByTagName("NOBR");
					   if (nbTag.length > 0) {
						   HighLightElement(nbTag[0]);
					     	   tempColl[0].focus();
					   }
				}
				IndexForm().document.IndexInputForm.keywordField.focus();
			}
		}

	}

	return;
}

var gBsLastHighLightElement = null;
function HighLightElement(objAnchor)
{
	resetHighLight();
	objAnchor.style.backgroundColor = "lightgrey";
	gBsLastHighLightElement = objAnchor;
}

function resetHighLight()
{
	if (gBsLastHighLightElement != null)
	{
		gBsLastHighLightElement.style.backgroundColor = "white";
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TOC code
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////
var imgBookClose ="bssctoc1.gif";
var imgBookOpen  ="bssctoc2.gif";

var  elTocArray = new Array();
var  elTocArrayNum = 0;

function TocWriteClassStyle()
{
	document.write("<STYLE TYPE='text/css'>");
	if (gbNav6) {
			document.write(".parent {font-size:10pt;}");
			document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
			document.write("P {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
			document.write("PRE {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
			document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
			document.write(".child {display:none}");
			document.write("A:link {text-decoration: none; color: 000000}");
			document.write("A:visited {text-decoration: none; color: 333333}");
			document.write("A:active {text-decoration: none; background-color: #cccccc}");
			document.write("A:hover {text-decoration: underline; color: 007f00}");
	} else if (gbIE4) {
		if (gbMac) {
			if (gbIE5){
				document.write(".parent {font-size:10pt;}");
				document.write("P {font-family:'Arial'; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
				document.write("PRE {font-family:'Arial'; font-size:10pt; margin-top:0pt; margin-bottom:0pt;}");
				document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
				document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
			} else {
				document.write(".parent {font-size:14pt;}");
				document.write("P {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
				document.write("PRE {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
				document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
				document.write("DIV {margin-top:0pt; margin-bottom:0pt;}");
			}
		} else {
			document.write(".parent {font-size:10pt;}");
			document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
			document.write("P {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
			document.write("PRE {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
			document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
		}
		document.write(".child {display:none}");
		document.write("A:link {text-decoration: none; color: 000000}");
		document.write("A:visited {text-decoration: none; color: 333333}");
		document.write("A:active {text-decoration: none; background-color: #cccccc}");
		document.write("A:hover {text-decoration: underline; color: 007f00}");
	}
	document.write("</STYLE>");
	return;
}

function TocWriteFixedWidth(bBegin, nWidth)
{
	//Avoid the wrap of text after book/page, make a invisble outter table is approch (for IE4 iMac only)
	// This will make IE4 DHTML Sync Toc DO NOT WORK.
	if ((gbIE4) && (gbMac) && (!gbIE5)) {
		if (bBegin)	{
			document.write("<table width=" + nWidth +" border=0><tr><td>");
		} else	{
			document.write("</td></tr></table>");
		}
	}
}

//Assign the layer's visibility at initialize the Page
function TocInitPage()
{
	if (gbIE4) {

		// Select the first hyperlink
		var tempColl = document.all.tags("A");
		if (tempColl.length > 0) {
			tempColl(0).focus();
		}
	} else if (gbNav6) {
		var tempColl = document.getElementsByTagName("A");
		if (tempColl.length > 0) {
			tempColl[0].focus();
		}
	}
	return;
}

function TocShowLayer(whichEl, bShow)
{
	if (bShow) {
		whichEl.visibility = "show";
	} else {
		whichEl.visibility = "hide";
	}
	for (var i=0; i<whichEl.document.layers.length; i++) {
		var whichChildEl = whichEl.document.layers[i];
		ShowLayer(whichChildEl, bShow);
	}
}

function TocExpandAll()
{
	for (var i=0; i<document.layers.length; i++) {
		var whichEl = document.layers[i];
		TocShowLayer(whichEl, true);
	}

	return;
}

function TocCollapseAll()
{
	for (var i=0; i<document.layers.length; i++) {
		var whichEl = document.layers[i];
		ShowLayer(whichEl, false);
		if (whichEl.id.indexOf("Child") != -1) {
			whichEl.visibility = "hide";
		} else {
			whichEl.visibility = "show";
		}
	}
	return;
}

//Expand a layer
function TocExpandIt(elId)
{
	TocExpandIt2(elId, false);
}

//Expand a layer
function TocExpandIt2(elId, bForceOpen)
{
	if (gbIE4 || gbNav6) {
		var child = TocExpand(elId, true, bForceOpen);
		var nNewScroll = document.body.scrollTop;
		if (child.style.display == "block") {
			var nItemTop = child.offsetTop;
			var nItemBottom = nItemTop + child.offsetHeight;
			// Make sure the bottom is visible if possible
			if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
				nNewScroll = nItemBottom - document.body.clientHeight;
			}
			// If expanded item is bigger than the client area, scroll the item to the top
			if (nItemBottom - nItemTop > document.body.clientHeight) {
				nNewScroll = nItemTop - 20;
			}
		}
		document.body.scrollTop = nNewScroll;
	}
	return;
}


////////////////////////////////////////////////////////////////
//Functions for IE
function TocExpand(elId, bChangeImg, bForceOpen) 
{ 
	var whichEl = null;
	var strChildId = elId + "Child";
	if (gbIE4) 
		whichEl = eval(strChildId);
	if (gbNav6)
		whichEl = document.getElementById(strChildId);

	var whichIm = document.images[elId];

	if (whichEl == null) {
		return null;
	}

	if ((whichEl.style.display != "block") || bForceOpen) {
		whichEl.style.display = "block";
		if (bChangeImg) {
			whichIm.src = imgBookOpen;		
		}
	} else {
		whichEl.style.display = "none";
		if (bChangeImg) {
			whichIm.src = imgBookClose;
		}
		if (gbMac) {
			//YJ: ?? can not scroll into view, if div has fixed width, it will scroll horizal to the very end.
			//whichEl.scrollIntoView(false);
		}
	}
	return whichEl;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// FTS code
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////

function FtsWriteClassStyle()
{
	document.write("<STYLE TYPE='text/css'>");
	if (gbNav6) {
		document.write("P {font-family:'Arial'; font-size:9pt;}");
		document.write("dt {font-family:'Arial'; font-size:9pt;}");
		document.write("A:link {text-decoration: none; color: 000000}");
		document.write("A:visited {text-decoration: none; color: 333333}");
		document.write("A:active {text-decoration: none; background-color: #cccccc}");
		document.write("A:hover {text-decoration: underline; color: 007f00}");
	} else if (gbIE4) {
		if (gbMac) {
			if (gbIE5) {
				document.write("P {font-family:'Arial'; font-size:10pt;}");
				document.write("dt {font-family:'Arial'; font-size:10pt;}");
			} else {
				document.write("P {font-family:'Arial'; font-size:12pt;}");
				document.write("dt {font-family:'Arial'; font-size:12pt;}");
			}
		} else {
			document.write("P {font-family:'Arial'; font-size:9pt;}");
			document.write("dt {font-family:'Arial'; font-size:9pt;}");
		}
		document.write("A:link {text-decoration: none; color: 000000}");
		document.write("A:visited {text-decoration: none; color: 333333}");
		document.write("A:active {text-decoration: none; background-color: #cccccc}");
		document.write("A:hover {text-decoration: underline; color: 007f00}");
	}
	document.write("</STYLE>");
	return;
}

//Define variable arguments as: strKeyword [,strTopicIndex]*
//function KeywordEntry() 
function KE() 
{
	var argLen = KE.arguments.length;
	this.strKeyword = KE.arguments[0];
	this.arrayTopics = new Array();

	// Now add all of the topic entries
	for (var i=0; i < argLen - 1; i++) {
		this.arrayTopics[i] = KE.arguments[i + 1];
	}
}

/*
function FtsStopWord()
{
	this.strStopWord = FtsStopWord.arguments[0];
}*/

function FtsInputEnable(bEnable)
{
   gbFtsInputEnable = bEnable;
   return;
}

function FtsInputSubmit()
{
	//Hack for IE, have to use keydown to get enter event,
	//Embedding WebHelp to WinHelp2000 will fail to fire the submit the form. 
	if (!gbIE4)
	{
		FtsLookup();
	}
	return false;
}

//Initize the site
function FtsInit()
{
  if (!window.Array) return;

  document.onkeyup = FtsLookupKeydown;
}

function FtsLookupKeydown() 
{
	if (gbIE4)
	{
		if (event.keyCode == 13)	//Enter key
		{
			FtsLookup();
		}
	}
}

function FtsLookup() 
{
	if (!gbFtsInputEnable && !gbMac)
		return;

	var strInput = document.FtsInputForm.ftsField.value.toLowerCase();
	if (strInput != "") {
		FtsDisplay(strInput);
	}

	if (gbMac) {
		document.FtsInputForm.ftsField.focus();
	}
}

var gstrDisplayInput = "";

function FtsFindTable()
{
	// Get the appropriate item to add items to
	var layerFind = null;
	if (gbIE4) {
		layerFind = parent.document.frames['ftsbody'].document.all.FtsFindTable;
	} else if (gbNav6) {
		layerFind = parent.frames['ftsbody'].document.getElementById("FtsFindTable");	
	}
	
	return layerFind;
}

function FtsBody()
{
	// Get the appropriate item to add items to
	var layerFind = null;
	if (gbIE4) {
		layerFind = parent.document.frames['ftsbody'];
	} else if (gbNav6) {
		layerFind = parent.frames['ftsbody'];
	}
	
	return layerFind;
}

function FtsDisplay(strInput)
{
	var layerFind = FtsFindTable();
	if (layerFind == null) {
		return;
	}

	// Let the user know we are busy
	var strHtm = "<P><B><FONT SIZE=2>Searching...</FONT></B></P>"
	if (gbIE4) {
		layerFind.innerHTML = strHtm;
	} else if (gbNav6) {
		layerFind.innerHTML = strHtm;
	}
	window.gstrDisplayInput = strInput;
	setTimeout("FtsDisplayReal()", 50);

	return;
}

function FtsDisplayReal()
{
	var FtsDiv = FtsBody();

	var strInput = window.gstrDisplayInput;
	var nKeywordArrayLen = FtsDiv.gKE.length;
	var nTopicArrayLen = FtsDiv.gTE.length;
	var nStopArrayLen = FtsDiv.gSTP.length;

	// Get the appropriate item to add items to
	var layerFind = FtsFindTable();
	if (layerFind == null) {
		return;
	}

	// Keep track of which operation we are currently in
	// 0 = OR; 1 = AND
	var nCurrentOp = 0;
	var bNot = false;

	// Loop through the words in the input string
	var bFinished = false;
	var bFirstKeyword = true;
	var strCurrentWord = "";
	var strCurrentStem = "";
	var strKeyword = "";
	var strHtm = "";
	var nFirstMatch = -1;
	var nLastMatch  = -1;
	var i=0;
	var iSpace = 0;
	var iFound = 0;
	var SearchTopicArray = new Array();
	var iSearch = 0;
	// If you change this Word Break string make sure you also change it in FtsDataBase.CPP
	var FTS_WORD_BREAK_CHARS = "\t\r\n\"\\ .,!@#$%^&*()~'`:;<>?/{}[]|+-=\x85\x92\x93\x94\x95\x96\x97\x99\xA9\xAE\xB7";
	var nNumWordBreakChars = FTS_WORD_BREAK_CHARS.length;

	// Clear the flags for each of the topics
	var iTopic = 0;
	for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
		SearchTopicArray[iTopic] = 0;
	}

	while (!bFinished) {

		// Get the next word
		iSpace = -1;
		iChar = 0;
		iSep = -1;
		for (var iChar = 0; iChar < nNumWordBreakChars; iChar++) {
			iFound = strInput.indexOf(FTS_WORD_BREAK_CHARS.charAt(iChar));
			if ((iFound != -1) && ((iSpace == -1) || (iFound < iSpace))) {
				iSpace = iFound;
				iSep = iChar;
			}
		}
		if (iSpace == -1) {
			strCurrentWord = strInput;
			strInput = "";
		} else {
			strCurrentWord = strInput.substr(0, iSpace);
			strInput = strInput.substr(iSpace + 1);
		}

		// Check for operators or a blank word
		if ((strCurrentWord == "or") ||
			   ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "|"))) {
			nCurrentOp = 0;
			bNot = false;
		} else if ((strCurrentWord == "and") ||
			   ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "&"))) {
			nCurrentOp = 1;
			bNot = false;
		} else if ((strCurrentWord == "not") ||
			   ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "~"))) {
			bNot = true;
		} else if (strCurrentWord == "") {
			if (strInput == "") {
				break;
			} else {
				continue;
			}
		} else if (!IsStopWord(strCurrentWord, FtsDiv.gSTP, nStopArrayLen)){

			// See if this is has a NOT at the beginning
			if (strCurrentWord.substr(0, 1) == "~") {
				bNot = true;
				strCurrentWord = strCurrentWord.substr(1);
			}

			// Get the stemmed version of the word
			strCurrentStem = GetStem(strCurrentWord);

			// See if the stemmed word is found in the list
			iFound = -1;
			iFound = FtsFindKeyword(strCurrentStem, FtsDiv.gKE, nKeywordArrayLen);

			// Did we find the keyword?
			if (iFound != -1) {

				// See if we are performing an OR operation
				var nNumTopics = FtsDiv.gKE[iFound].arrayTopics.length;
				if (nCurrentOp == 0) {
					if (bNot) {
						var cFoundArrayTopics =  FtsDiv.gKE[iFound].arrayTopics;
						// Add all topics that are not in the list for this keyword
						for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
							// See if the topic is in the list for this keyword
							for (iListTopic = 0; iListTopic < nNumTopics; iListTopic++) {
								if (cFoundArrayTopics[iListTopic] == iTopic) {
									break;
								}
							}
							if (iListTopic == nNumTopics) {
								// The topic is not in the list for the current keyword, so add it
								SearchTopicArray[iTopic] = 1;
							}
						}

					} else {
						// Loop through the topics that have the keyword and add them to the list
						for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
							var nTopicNum = FtsDiv.gKE[iFound].arrayTopics[iTopic];
							// Add the topic to the list
							SearchTopicArray[nTopicNum] = 1;
						}
					}
				// See if this is an AND operation
				} else if (nCurrentOp == 1) {

					if (bNot) {
						// Loop through the topics for the current word and remove them from the list
						for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
							SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] = 0;
						}
					} else {
						// Loop through the topics already in the list and remove them if they are not
						// in the list for the current word
						for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
							if (SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] == 1) {
								SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] = -1;
							}
						}
						for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
							if (SearchTopicArray[iTopic] == -1) {
								SearchTopicArray[iTopic] = 1;
							} else {
								SearchTopicArray[iTopic] = 0;
							}
						}
					}
				}
			} else {
				// Word was not found

				// Clear the list if this is an AND operation
				if ((nCurrentOp == 1) && (!bNot)) {
					for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
						SearchTopicArray[iSearch] = 0;
					}

				// Add all items to the list if this is an OR operation with a NOT operator
				} else if ((nCurrentOp == 0) && (bNot)) {

					// Add all topics that are not in the list for this keyword

					// First set all flags to -1 if they are not already set
					for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
						if (SearchTopicArray[iTopic] == 0) {
							SearchTopicArray[iTopic] = -1;
						}
					}

					// Now clear all -1s for topics associated with this keyword
					for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
						if (SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] == -1) {
							SearchTopicArray[FtsDiv.gKE[iFound].arrayTopics[iTopic]] = 0;
						}
					}

					// Finally change all -1s to 1s
					for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
						if (SearchTopicArray[iTopic] == -1) {
							SearchTopicArray[iTopic] = 1;
						}
					}
				}
			}

			// If this was the first word change the operation to "and". We need to have it be
			// an "or" for the first keyword so we would add the items for the first search word.
			if (bFirstKeyword) {
				bFirstKeyword = false;
				nCurrentOp = 1;
			}
		}
	}

	var aSortedTopics = new Array();
	var nNumSortTopics = 0;
	for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
		if (SearchTopicArray[iSearch]) {
			aSortedTopics[nNumSortTopics++] = iSearch;
		}
	}

	// Limit the number of topics in the result set
	if (nNumSortTopics > 75) {
		nNumSortTopics = 75;
	}

	// Sort the topics by title
	SortTopics(FtsDiv, aSortedTopics, 0, nNumSortTopics - 1);

	// Add hyperlinks for all of the found topics
	var strLine = "";
	for (iSearch = 0; iSearch < nNumSortTopics; iSearch++) {
		i = aSortedTopics[iSearch];
		if (i != -1) {
			strLine = "<dt><nobr><a href='" + FtsDiv.gTE[i].strURL + "'>";
			strLine += FtsDiv.gTE[i].strTitle; 
			strLine += "</a></nobr></dt>";
			strHtm += strLine;
		}
	}

	// Give a special message if none were found
	if (strHtm == "") {
		strHtm = "<P><B>No Topics Found.</B></P>"
	} else {
		strHtm = "<dl>" + strHtm + "</dl>";
	}

	if (gbIE4) {
		layerFind.innerHTML = strHtm;
	} else if (gbNav6) {
		layerFind.innerHTML = strHtm;
	}

	return;
}


function FtsFindKeyword(strCurrentWord, aFtsKeywordArray, nKeywordArrayLen)
{
	// Search for the current word in the array (binary search)
	var nLow = 0; 
	var nHigh = nKeywordArrayLen - 1;
	var nMid = 0;
	var bFound = false;
	var strKeyword = "";
	while (nLow <= nHigh) {
		nMid = (nLow + nHigh);
		nMid >>= 1;
		strKeyword = aFtsKeywordArray[nMid].strKeyword;
		if (strCurrentWord > strKeyword) {
			nLow = (nLow == nMid) ? nMid + 1 : nMid;
		} else {
			if (strCurrentWord < strKeyword)  {
				nHigh = (nHigh == nMid) ? nMid - 1: nMid;
			} else {
				bFound = true;
				break;
			}
		}
	}

	if (bFound) {
		return nMid;
	} else {
		return -1;
	}
}


// QuickSort
var gbSortChar = new Array();
var gbNeedStem = true;

function SortTopics(FtsDiv, SearchTopicArray, nStart, nEnd)
{
	if (nEnd - nStart > 0) {
		var nLastLow = nStart;

		// Get the first value into its proper spot
		for (var i = nStart + 1; i <= nEnd; i++) {
			if ((SearchTopicArray[i] != -1) && (SearchTopicArray[nStart] != -1) &&
			    compare(FtsDiv.gTE[SearchTopicArray[i]].strTitle, FtsDiv.gTE[SearchTopicArray[nStart]].strTitle) < 0 ) {
				nLastLow++;
				temp = SearchTopicArray[i];
				SearchTopicArray[i] = SearchTopicArray[nLastLow];
				SearchTopicArray[nLastLow] = temp;
			}
		}
		temp = SearchTopicArray[nStart];
		SearchTopicArray[nStart] = SearchTopicArray[nLastLow];
		SearchTopicArray[nLastLow] = temp;

		// Sort the two halves of this array surrounding the new spot for the first value
		SortTopics(FtsDiv, SearchTopicArray, nStart, nLastLow);
		SortTopics(FtsDiv, SearchTopicArray, nLastLow + 1, nEnd);
	}
}

function compare(strTitle1, strTitle2)
{
	if (gbSortChar.length < 256) {
		var strt1 = strTitle1.toLowerCase();
		var strt2 = strTitle2.toLowerCase();
		if (strt1 < strt2) return -1;
		if (strt1 > strt2) return 1;
		return 0;
	}
	else {
		for (var i = 0 ; i < strTitle1.length && i < strTitle2.length; i ++) {
			if (gbSortChar[strTitle1.charCodeAt(i)] < gbSortChar[strTitle2.charCodeAt(i)]) return -1;
			if (gbSortChar[strTitle1.charCodeAt(i)] > gbSortChar[strTitle2.charCodeAt(i)]) return 1;
		}
		if (strTitle1.length < strTitle2.length) return -1;
		if (strTitle1.length > strTitle2.length) return  1;
		return 0;
	}
}

function GetFlagChar(strchar)
{
	if (gbSortChar.length < 256 || strchar.length > 1) {
		return strchar.toUpperCase();
	}
	else {
		for (var i = 0 ; i < 256; i ++) {
			if (gbSortChar[i] == gbSortChar[strchar.charCodeAt(0)])
				return String.fromCharCode(i);
		}
		return strchar;
	}
	
}

function IsStopWord(strCurrentWord, aFtsStopArray, nStopArrayLen)
{
	// Search for the current word in the array (binary search)
	var nLow = 0; 
	var nHigh = nStopArrayLen - 1;
	var nMid = 0;
	var bFound = false;
	var strStopWord = "";
	while (nLow <= nHigh) {
		nMid = (nLow + nHigh);
		nMid >>= 1;
//		strStopWord = aFtsStopArray[nMid].strStopWord;
		strStopWord = aFtsStopArray[nMid];
		if (strCurrentWord > strStopWord) {
			nLow = (nLow == nMid) ? nMid + 1 : nMid;
		} else {
			if (strCurrentWord < strStopWord) {
				nHigh = (nHigh == nMid) ? nMid - 1: nMid;
			} else {
				bFound = true;
				break;
			}
		}
	}

	if (bFound) {
		return true;
	} else {
		return false;
	}
}


/////////////////////////////////////////////////////////////
//
// NOTE: If you change this function, you should also change
// it in the FtsDatabase.CPP file
//
/////////////////////////////////////////////////////////////
function GetStem(szWord)
{
	if (!gbNeedStem) return szWord; 
	var aStems = new Array();
	aStems[0] = "e";
	aStems[1] = "s";
	aStems[2] = "ed";
	aStems[3] = "es";
	aStems[4] = "er";
	aStems[5] = "ly";
	aStems[6] = "ing";
	aStems[7] = "ingly";

	// Loop through all the possible stems
	var nNumStems = aStems.length;
	var nStemPos = 0;
	var csStem = "";
	var cssub = "";
	for (var iStem = 0; iStem < nNumStems; iStem++) {

		// Get the "would be" position of the stem in the word and see
		// if this word has the stem
		if (aStems[iStem].length >= szWord.length - 1)	break;
		nStemPos = szWord.lastIndexOf(aStems[iStem]);
		if (nStemPos > 0) {
			cssub = szWord.substring(nStemPos);
			if (cssub == aStems[iStem]) {
				
				// Found a stem

				// Check for double consonant
				csStem = szWord;
				if (szWord.charAt(nStemPos - 2) == szWord.charAt(nStemPos - 1)) {
					csStem = csStem.substring(0, nStemPos - 1);
				} else {
					csStem = csStem.substring(0, nStemPos);
				}
				return csStem;
			}
		}
	}

	// No stem found
	csStem = szWord;
	return csStem;
}

////////////////////////////////////////////////////////////////////////////////////////////////
//
// Navgation Bar Code
//
////////////////////////////////////////////////////////////////////////////////////////////////

function NavBar_SelectTOC()
{
	var frameLeft = null
	if (gbNav6) {
		frameLeft = parent.frames["left"];
	} else if (gbIE4) {
		frameLeft = window.parent.frames("left");
	}
	frameLeft.ChangeToTOC();
}

function NavBar_SelectIndex()
{
	var frameLeft = null
	if (gbNav6) {
		frameLeft = parent.frames["left"];
	} else if (gbIE4) {
		frameLeft = window.parent.frames("left");
	}
	frameLeft.ChangeToIndex();
}

////////////////////////////////////////////////////////////////////////////////////////////////
//
// Function support sync toc for DHTML
//
////////////////////////////////////////////////////////////////////////////////////////////////

var gb_strCurrentURL = "";
var gb_res = null;

function NavBar_SyncToc(strRelURL)
{
	var strHomeURL = location.href;
	if (location.hash.length > 0) 
		strHomeURL = location.href.substring(0, location.href.indexOf("#"));

	var strHomePath = strHomeURL.substring(0, strHomeURL.lastIndexOf("/"));
	var strAbsURL = strHomePath + "/" + strRelURL;

	var containTags = new Array();
	strAbsURL = NavBar_ReplaceSlash(strAbsURL);
	strAbsURL = NavBar_ConvertToURLFormat(strAbsURL);
	var OrgScrollLeft = document.body.scrollLeft;

	if (gb_strCurrentURL == strAbsURL) {
		if (gb_res != null) {
			gb_res.focus();
			document.body.scrollLeft = OrgScrollLeft;
		}
		return;
	}
	var res = NavBar_SearchTocEx(document.body, strAbsURL, strRelURL, containTags, 0);
	if (res >= 0) 
	{
		for (i = 0; i < res; i ++ ) {
			var elId = containTags[i].id;
			elId = elId.substring(0, elId.indexOf("Child"));
			if (elId != null && elId.length != 0)
				TocExpandIt2(elId, true);
		}
		gb_res = containTags[res];
		if (gbNav6) 
			HighLightElement(containTags[res]);
		containTags[res].focus();
		document.body.scrollLeft = OrgScrollLeft;
	}
	gb_strCurrentURL = strAbsURL;
}

//Hash code for speeding up AutoSync
function HrefHashCode(strRelHref)
{
	var lHashCode = 0;
	var lValue = 0;
	for (i = 0; i < strRelHref.length; i ++)
	{
		var nCode = strRelHref.charCodeAt(i);
		lValue = nCode;
		if ((nCode >= 97) && (nCode <= 122))	//'a'~'z'
			nCode = nCode-97+65;				//to 'A'~'Z'
		else if (nCode == 92)					//'\'
			nCode = 47;							//'/'
		lValue = nCode;
		lHashCode = (((lHashCode * 43) & (0x00ffffff)) + lValue) & (0x00ffffff);
	}
	return lHashCode;
}

//The old way of search Toc entity is too slow: JavaScript spend too many time on fetch info from tag.
//and id of the tag is the best way to quick accessing.
//if the DHTML structure changed . the following code MUST MODIFY.
function NavBar_SearchTocEx(tagsObject, strAbsURL,strRelURL, containTags, level)
{
	if (typeof HST == "undefined")
		return NavBar_SearchToc(tagsObject, strAbsURL, containTags, level);

	var cTagsA = null;
	if (gbIE4)
		cTagsA = document.all.tags("A");
	else if (gbNav6)
		cTagsA = document.getElementsByTagName("A");

	var lHashCode = HrefHashCode(strRelURL);
	var i;
	var bFindMatch = false;
	var cFindTag
	for (i = 0; i< HST.length; i++)
	{
		if (lHashCode == HST[i])
		{
			var hid = "h"+i;
			var cTag = cTagsA[hid];
			if (typeof cTag != "undefined")
			{
				var hrefURL = NavBar_ReplaceSlash(cTag.href);
				hrefURL = NavBar_ConvertToURLFormat(hrefURL);
				if (hrefURL == strAbsURL)
				{
					bFindMatch = true;
					cFindTag = cTag;
					break;
				}
			}
		}
	}
	if (bFindMatch)
	{
		//Find the the containers: from inner to outer
		var cRevContainTags = new Array;
		var level =0;
		
		if (gbIE4) {
			var cParentTag = cFindTag.parentElement;
			cRevContainTags[level++] = cFindTag;
			do
			{
				if (cParentTag.tagName == "DIV")
				{
					var id = cParentTag.id;
					if (typeof id != "undefined")
					{
						if (id.indexOf("Child") != -1)
							cRevContainTags[level++] = cParentTag;
					}
				}
				cParentTag = cParentTag.parentElement;	
			}while(!((cParentTag.tagName == "BODY") || (cParentTag.tagName == "HTML")))
			
			var j = 0;
			for (i=level-1; i >= 0 ; i--)
			{
			  containTags[i] = cRevContainTags[j++];		
			}
			return level-1;
		}
		else if (gbNav6) {
			var cParentTag = cFindTag.parentNode;
			cRevContainTags[level++] = cFindTag;
			do
			{
				if (cParentTag.nodeName == "DIV")
				{
					var id = cParentTag.id;
					if (typeof id != "undefined")
					{
						if (id.indexOf("Child") != -1)
							cRevContainTags[level++] = cParentTag;
					}
				}
				cParentTag = cParentTag.parentNode;	
			}while(!((cParentTag.nodeName == "BODY") || (cParentTag.nodeName == "HTML")))
			
			var j = 0;
			for (i=level-1; i >= 0 ; i--)
			{
			  containTags[i] = cRevContainTags[j++];		
			}
			return level-1;
		}
	}
	return -1;
}

// if the DHTML structure changed . the following code MUST MODIFY.
// Currently do not support IE4.5 on Mac. because on iMac we will capsulate all the contents in a <TABLE>.
// for IE 4.5 will wrap text which is not good for us.
// so if want to enable IE4.5. something need to take care here.
// now we are using Applet for IE 4.5 instead of DHTML for some other reasons.
function NavBar_SearchToc(tagsObject, strAbsURL, containTags, level)
{
	if (gbIE4) {
		var i = 0;
		var j = 0;
		var collBlock = tagsObject.children.tags("BLOCKQUOTE");
		if (collBlock != null) {
			for (i = 0; i < collBlock.length ; i ++ )
			{
				// here we assume each BLOCKQUOTE has one and only one DIV
				containTags[level] = collBlock[i].children.tags("DIV")[0];
				var res = NavBar_SearchToc(containTags[level], strAbsURL, containTags, level + 1);
				if (res != -1)
					return res;
			}

		}
		var collA = tagsObject.all.tags("A");
		if (collA != null) {
			for (j = 0; j < collA.length; j ++ )
			{
				var hrefURL = NavBar_ReplaceSlash(collA[j].href);
				hrefURL = NavBar_ConvertToURLFormat(hrefURL);
				if (hrefURL == strAbsURL)
				{
					containTags[level] = collA[j];
					return level;
				}
			}

		}
	}
	else if (gbNav6) {
		var i = 0;
		var j = 0;
		var collBlock = tagsObject.getElementsByTagName("BLOCKQUOTE");
		if (collBlock != null) {
			for (i = 0; i < collBlock.length ; i ++ )
			{
				// here we assume each BLOCKQUOTE has one and only one DIV
				containTags[level] = collBlock[i].getElementsByTagName("DIV")[0];
				var res = NavBar_SearchToc(containTags[level], strAbsURL, containTags, level + 1);
				if (res != -1)
					return res;
			}

		}
		var collA = tagsObject.getElementsByTagName("A");
		if (collA != null) {
			for (j = 0; j < collA.length; j ++ )
			{
				var hrefURL = NavBar_ReplaceSlash(collA[j].href);
				hrefURL = NavBar_ConvertToURLFormat(hrefURL);
				if (hrefURL == strAbsURL)
				{
					containTags[level] = collA[j];
					return level;
				}
			}

		}
	}
	return -1;
}

// replace \\ to /
function NavBar_ReplaceSlash(strURL)
{	
	var strReplacedURL = "";
	var i = 0;
	for (i = 0; i < strURL.length; i ++ )
	{
		if (strURL.charAt(i) == '\\') 
			strReplacedURL = strReplacedURL + "/"
		else
		    strReplacedURL = strReplacedURL + strURL.charAt(i);
	}
	return strReplacedURL;
}

function ItemFocus()
{
	if (gb_strCurrentURL.length > 0 ) {
		if (gb_res != null) {
			gb_res.focus();
		}	
	}
}

// mark the current clicked url.
function MarkIt()
{
	if (gbIE4) {
		var strURL = window.event.srcElement.href;
		strURL = NavBar_ConvertToURLFormat(strURL);
		gb_strCurrentURL = strURL;
		gb_res = window.event.srcElement;
		if (typeof(parent.parent.NavFrame) != "undefined" &&
			typeof(parent.parent.NavFrame()) != "undefined" &&
			typeof(parent.parent.NavFrame().gstrAutoSyncURL) != "undefined")
			parent.parent.NavFrame().gstrAutoSyncURL = "";
	}
}


// change àáã to %E0%E1%E3
function NavBar_ConvertToURLFormat(strURL)
{
	var strResURL = "";
	var i = 0;
	for (i = 0; i < strURL.length; i ++)
	{
		var nCode = strURL.charCodeAt(i);
		if (nCode > 127) {
			strResURL += "%";
			var strTemp = String.fromCharCode(HEXToCharCode(nCode/16), HEXToCharCode(nCode%16));
			strResURL += strTemp
		}
		else 
			strResURL += strURL.charAt(i);
	}
	return strResURL;
}

function HEXToCharCode(n)
{
	if (n < 10) {
		return '0'.charCodeAt(0) + n;
	}
	else if (n < 16) {
		return 'A'.charCodeAt(0) + (n - 10);
	}
	else
		return 0;
}
