8 var indexSectionsWithContent =
12 var indexSectionNames =
16 function convertToId(search)
19 for (i=0;i<search.length;i++)
21 var c = search.charAt(i);
22 var cn = c.charCodeAt(0);
23 if (c.match(/[a-z0-9\u0080-\uFFFF]/))
29 result+=
"_0"+cn.toString(16);
33 result+=
"_"+cn.toString(16);
39 function getXPos(item)
44 while (item && item!=document.body)
47 item = item.offsetParent;
53 function getYPos(item)
58 while (item && item!=document.body)
61 item = item.offsetParent;
74 function SearchBox(name, resultsPath, inFrame, label)
76 if (!name || !resultsPath) { alert(
"Missing parameters to SearchBox."); }
80 this.resultsPath = resultsPath;
82 this.keyTimeoutLength = 500;
83 this.closeSelectionTimeout = 300;
84 this.lastSearchValue =
"";
85 this.lastResultsPage =
"";
88 this.searchActive =
false;
89 this.insideFrame = inFrame;
90 this.searchLabel = label;
94 this.DOMSearchField =
function()
95 {
return document.getElementById(
"MSearchField"); }
97 this.DOMSearchSelect =
function()
98 {
return document.getElementById(
"MSearchSelect"); }
100 this.DOMSearchSelectWindow =
function()
101 {
return document.getElementById(
"MSearchSelectWindow"); }
103 this.DOMPopupSearchResults =
function()
104 {
return document.getElementById(
"MSearchResults"); }
106 this.DOMPopupSearchResultsWindow =
function()
107 {
return document.getElementById(
"MSearchResultsWindow"); }
109 this.DOMSearchClose =
function()
110 {
return document.getElementById(
"MSearchClose"); }
112 this.DOMSearchBox =
function()
113 {
return document.getElementById(
"MSearchBox"); }
118 this.OnSearchFieldFocus =
function(isActive)
120 this.Activate(isActive);
123 this.OnSearchSelectShow =
function()
125 var searchSelectWindow = this.DOMSearchSelectWindow();
126 var searchField = this.DOMSearchSelect();
128 if (this.insideFrame)
130 var left = getXPos(searchField);
131 var top = getYPos(searchField);
132 left += searchField.offsetWidth + 6;
133 top += searchField.offsetHeight;
136 searchSelectWindow.style.display=
'block';
137 left -= searchSelectWindow.offsetWidth;
138 searchSelectWindow.style.left = left +
'px';
139 searchSelectWindow.style.top = top +
'px';
143 var left = getXPos(searchField);
144 var top = getYPos(searchField);
145 top += searchField.offsetHeight;
148 searchSelectWindow.style.display=
'block';
149 searchSelectWindow.style.left = left +
'px';
150 searchSelectWindow.style.top = top +
'px';
154 if (this.hideTimeout)
156 clearTimeout(this.hideTimeout);
162 this.OnSearchSelectHide =
function()
164 this.hideTimeout = setTimeout(this.name +
".CloseSelectionWindow()",
165 this.closeSelectionTimeout);
169 this.OnSearchFieldChange =
function(evt)
173 clearTimeout(this.keyTimeout);
177 var e = (evt) ? evt : window.event;
178 if (e.keyCode==40 || e.keyCode==13)
182 this.OnSearchSelectShow();
183 var win=this.DOMSearchSelectWindow();
184 for (i=0;i<win.childNodes.length;i++)
186 var child = win.childNodes[i];
187 if (child.className==
'SelectItem')
195 else if (window.frames.MSearchResults.searchResults)
197 var elem = window.frames.MSearchResults.searchResults.NavNext(0);
198 if (elem) elem.focus();
201 else if (e.keyCode==27)
203 this.DOMSearchField().blur();
204 this.DOMPopupSearchResultsWindow().style.display =
'none';
205 this.DOMSearchClose().style.display =
'none';
206 this.lastSearchValue =
'';
207 this.Activate(
false);
212 var searchValue = this.DOMSearchField().value.replace(/ +/g,
"");
214 if (searchValue != this.lastSearchValue)
216 if (searchValue !=
"")
219 this.keyTimeout = setTimeout(this.name +
'.Search()',
220 this.keyTimeoutLength);
224 this.DOMPopupSearchResultsWindow().style.display =
'none';
225 this.DOMSearchClose().style.display =
'none';
226 this.lastSearchValue =
'';
231 this.SelectItemCount =
function(id)
234 var win=this.DOMSearchSelectWindow();
235 for (i=0;i<win.childNodes.length;i++)
237 var child = win.childNodes[i];
238 if (child.className==
'SelectItem')
246 this.SelectItemSet =
function(id)
249 var win=this.DOMSearchSelectWindow();
250 for (i=0;i<win.childNodes.length;i++)
252 var child = win.childNodes[i];
253 if (child.className==
'SelectItem')
255 var node = child.firstChild;
258 node.innerHTML=
'•';
262 node.innerHTML=
' ';
271 this.OnSelectItem =
function(id)
273 this.searchIndex = id;
274 this.SelectItemSet(
id);
275 var searchValue = this.DOMSearchField().value.replace(/ +/g,
"");
276 if (searchValue!=
"" && this.searchActive)
282 this.OnSearchSelectKey =
function(evt)
284 var e = (evt) ? evt : window.event;
285 if (e.keyCode==40 &&
this.searchIndex<
this.SelectItemCount())
288 this.OnSelectItem(this.searchIndex);
290 else if (e.keyCode==38 &&
this.searchIndex>0)
293 this.OnSelectItem(this.searchIndex);
295 else if (e.keyCode==13 || e.keyCode==27)
297 this.OnSelectItem(this.searchIndex);
298 this.CloseSelectionWindow();
299 this.DOMSearchField().focus();
307 this.CloseResultsWindow =
function()
309 this.DOMPopupSearchResultsWindow().style.display =
'none';
310 this.DOMSearchClose().style.display =
'none';
311 this.Activate(
false);
314 this.CloseSelectionWindow =
function()
316 this.DOMSearchSelectWindow().style.display =
'none';
320 this.Search =
function()
325 var searchValue = this.DOMSearchField().value.replace(/^ +/,
"");
327 var code = searchValue.toLowerCase().charCodeAt(0);
328 var idxChar = searchValue.substr(0, 1).toLowerCase();
329 if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1)
331 idxChar = searchValue.substr(0, 2);
335 var resultsPageWithSearch;
338 var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
341 var hexCode=idx.toString(16);
342 resultsPage = this.resultsPath +
'/' + indexSectionNames[this.searchIndex] +
'_' + hexCode +
'.html';
343 resultsPageWithSearch = resultsPage+
'?'+escape(searchValue);
344 hasResultsPage =
true;
348 resultsPage = this.resultsPath +
'/nomatches.html';
349 resultsPageWithSearch = resultsPage;
350 hasResultsPage =
false;
353 window.frames.MSearchResults.location = resultsPageWithSearch;
354 var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
356 if (domPopupSearchResultsWindow.style.display!=
'block')
358 var domSearchBox = this.DOMSearchBox();
359 this.DOMSearchClose().style.display =
'inline';
360 if (this.insideFrame)
362 var domPopupSearchResults = this.DOMPopupSearchResults();
363 domPopupSearchResultsWindow.style.position =
'relative';
364 domPopupSearchResultsWindow.style.display =
'block';
365 var width = document.body.clientWidth - 8;
366 domPopupSearchResultsWindow.style.width = width +
'px';
367 domPopupSearchResults.style.width = width +
'px';
371 var domPopupSearchResults = this.DOMPopupSearchResults();
372 var left = getXPos(domSearchBox) + 150;
373 var top = getYPos(domSearchBox) + 20;
374 domPopupSearchResultsWindow.style.display =
'block';
375 left -= domPopupSearchResults.offsetWidth;
376 domPopupSearchResultsWindow.style.top = top +
'px';
377 domPopupSearchResultsWindow.style.left = left +
'px';
381 this.lastSearchValue = searchValue;
382 this.lastResultsPage = resultsPage;
389 this.Activate =
function(isActive)
392 this.DOMPopupSearchResultsWindow().style.display ==
'block'
395 this.DOMSearchBox().className =
'MSearchBoxActive';
397 var searchField = this.DOMSearchField();
399 if (searchField.value ==
this.searchLabel)
401 searchField.value =
'';
402 this.searchActive =
true;
407 this.DOMSearchBox().className =
'MSearchBoxInactive';
408 this.DOMSearchField().value = this.searchLabel;
409 this.searchActive =
false;
410 this.lastSearchValue =
''
411 this.lastResultsPage =
'';
419 function SearchResults(name)
422 this.lastMatchCount = 0;
424 this.repeatOn =
false;
427 this.FindChildElement =
function(id)
429 var parentElement = document.getElementById(
id);
430 var element = parentElement.firstChild;
432 while (element && element!=parentElement)
434 if (element.nodeName ==
'DIV' && element.className ==
'SRChildren')
439 if (element.nodeName ==
'DIV' && element.hasChildNodes())
441 element = element.firstChild;
443 else if (element.nextSibling)
445 element = element.nextSibling;
451 element = element.parentNode;
453 while (element && element!=parentElement && !element.nextSibling);
455 if (element && element!=parentElement)
457 element = element.nextSibling;
463 this.Toggle =
function(id)
465 var element = this.FindChildElement(
id);
468 if (element.style.display ==
'block')
470 element.style.display =
'none';
474 element.style.display =
'block';
484 this.Search =
function(search)
488 search = window.location.search;
489 search = search.substring(1);
490 search = unescape(search);
493 search = search.replace(/^ +/,
"");
494 search = search.replace(/ +$/,
"");
495 search = search.toLowerCase();
496 search = convertToId(search);
498 var resultRows = document.getElementsByTagName(
"div");
502 while (i < resultRows.length)
504 var row = resultRows.item(i);
505 if (row.className ==
"SRResult")
507 var rowMatchName = row.id.toLowerCase();
508 rowMatchName = rowMatchName.replace(/^sr\d*_/,
'');
510 if (search.length<=rowMatchName.length &&
511 rowMatchName.substr(0, search.length)==search)
513 row.style.display =
'block';
518 row.style.display =
'none';
523 document.getElementById(
"Searching").style.display=
'none';
526 document.getElementById(
"NoMatches").style.display=
'block';
530 document.getElementById(
"NoMatches").style.display=
'none';
532 this.lastMatchCount = matches;
537 this.NavNext =
function(index)
542 var focusName =
'Item'+index;
543 focusItem = document.getElementById(focusName);
544 if (focusItem && focusItem.parentNode.parentNode.style.display==
'block')
558 this.NavPrev =
function(index)
563 var focusName =
'Item'+index;
564 focusItem = document.getElementById(focusName);
565 if (focusItem && focusItem.parentNode.parentNode.style.display==
'block')
579 this.ProcessKeys =
function(e)
581 if (e.type ==
"keydown")
583 this.repeatOn =
false;
584 this.lastKey = e.keyCode;
586 else if (e.type ==
"keypress")
590 if (this.lastKey) this.repeatOn =
true;
594 else if (e.type ==
"keyup")
597 this.repeatOn =
false;
599 return this.lastKey!=0;
602 this.Nav =
function(evt,itemIndex)
604 var e = (evt) ? evt : window.event;
605 if (e.keyCode==13)
return true;
606 if (!this.ProcessKeys(e))
return false;
608 if (this.lastKey==38)
610 var newIndex = itemIndex-1;
611 var focusItem = this.NavPrev(newIndex);
614 var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
615 if (child && child.style.display ==
'block')
621 tmpElem = document.getElementById(
'Item'+newIndex+
'_c'+n);
640 parent.document.getElementById(
"MSearchField").focus();
643 else if (this.lastKey==40)
645 var newIndex = itemIndex+1;
647 var item = document.getElementById(
'Item'+itemIndex);
648 var elem = this.FindChildElement(item.parentNode.parentNode.id);
649 if (elem && elem.style.display ==
'block')
651 focusItem = document.getElementById(
'Item'+itemIndex+
'_c0');
653 if (!focusItem) focusItem = this.NavNext(newIndex);
654 if (focusItem) focusItem.focus();
656 else if (this.lastKey==39)
658 var item = document.getElementById(
'Item'+itemIndex);
659 var elem = this.FindChildElement(item.parentNode.parentNode.id);
660 if (elem) elem.style.display =
'block';
662 else if (this.lastKey==37)
664 var item = document.getElementById(
'Item'+itemIndex);
665 var elem = this.FindChildElement(item.parentNode.parentNode.id);
666 if (elem) elem.style.display =
'none';
668 else if (this.lastKey==27)
670 parent.searchBox.CloseResultsWindow();
671 parent.document.getElementById(
"MSearchField").focus();
673 else if (this.lastKey==13)
680 this.NavChild =
function(evt,itemIndex,childIndex)
682 var e = (evt) ? evt : window.event;
683 if (e.keyCode==13)
return true;
684 if (!this.ProcessKeys(e))
return false;
686 if (this.lastKey==38)
690 var newIndex = childIndex-1;
691 document.getElementById(
'Item'+itemIndex+
'_c'+newIndex).focus();
695 document.getElementById(
'Item'+itemIndex).focus();
698 else if (this.lastKey==40)
700 var newIndex = childIndex+1;
701 var elem = document.getElementById(
'Item'+itemIndex+
'_c'+newIndex);
704 elem = this.NavNext(itemIndex+1);
711 else if (this.lastKey==27)
713 parent.searchBox.CloseResultsWindow();
714 parent.document.getElementById(
"MSearchField").focus();
716 else if (this.lastKey==13)
724 function setKeyActions(elem,action)
726 elem.setAttribute(
'onkeydown',action);
727 elem.setAttribute(
'onkeypress',action);
728 elem.setAttribute(
'onkeyup',action);
731 function setClassAttr(elem,attr)
733 elem.setAttribute(
'class',attr);
734 elem.setAttribute(
'className',attr);
737 function createResults()
739 var results = document.getElementById(
"SRResults");
740 for (var e=0; e<searchData.length; e++)
742 var
id = searchData[e][0];
743 var srResult = document.createElement(
'div');
744 srResult.setAttribute(
'id',
'SR_'+
id);
745 setClassAttr(srResult,
'SRResult');
746 var srEntry = document.createElement(
'div');
747 setClassAttr(srEntry,
'SREntry');
748 var srLink = document.createElement(
'a');
749 srLink.setAttribute(
'id',
'Item'+e);
750 setKeyActions(srLink,
'return searchResults.Nav(event,'+e+
')');
751 setClassAttr(srLink,
'SRSymbol');
752 srLink.innerHTML = searchData[e][1][0];
753 srEntry.appendChild(srLink);
754 if (searchData[e][1].length==2)
756 srLink.setAttribute(
'href',searchData[e][1][1][0]);
757 if (searchData[e][1][1][1])
759 srLink.setAttribute(
'target',
'_parent');
761 var srScope = document.createElement(
'span');
762 setClassAttr(srScope,
'SRScope');
763 srScope.innerHTML = searchData[e][1][1][2];
764 srEntry.appendChild(srScope);
768 srLink.setAttribute(
'href',
'javascript:searchResults.Toggle("SR_'+
id+
'")');
769 var srChildren = document.createElement(
'div');
770 setClassAttr(srChildren,
'SRChildren');
771 for (var c=0; c<searchData[e][1].length-1; c++)
773 var srChild = document.createElement(
'a');
774 srChild.setAttribute(
'id',
'Item'+e+
'_c'+c);
775 setKeyActions(srChild,
'return searchResults.NavChild(event,'+e+
','+c+
')');
776 setClassAttr(srChild,
'SRScope');
777 srChild.setAttribute(
'href',searchData[e][1][c+1][0]);
778 if (searchData[e][1][c+1][1])
780 srChild.setAttribute(
'target',
'_parent');
782 srChild.innerHTML = searchData[e][1][c+1][2];
783 srChildren.appendChild(srChild);
785 srEntry.appendChild(srChildren);
787 srResult.appendChild(srEntry);
788 results.appendChild(srResult);