8 var indexSectionsWithContent =
10 0:
"_abcdefghijklmnopqrstuvw",
13 3:
"_abcdefgijklmnopqrstuvw",
17 var indexSectionNames =
26 function convertToId(search)
29 for (i=0;i<search.length;i++)
31 var c = search.charAt(i);
32 var cn = c.charCodeAt(0);
33 if (c.match(/[a-z0-9\u0080-\uFFFF]/))
39 result+=
"_0"+cn.toString(16);
43 result+=
"_"+cn.toString(16);
49 function getXPos(item)
54 while (item && item!=document.body)
57 item = item.offsetParent;
63 function getYPos(item)
68 while (item && item!=document.body)
71 item = item.offsetParent;
84 function SearchBox(name, resultsPath, inFrame, label)
86 if (!name || !resultsPath) { alert(
"Missing parameters to SearchBox."); }
90 this.resultsPath = resultsPath;
92 this.keyTimeoutLength = 500;
93 this.closeSelectionTimeout = 300;
94 this.lastSearchValue =
"";
95 this.lastResultsPage =
"";
98 this.searchActive =
false;
99 this.insideFrame = inFrame;
100 this.searchLabel = label;
104 this.DOMSearchField =
function()
105 {
return document.getElementById(
"MSearchField"); }
107 this.DOMSearchSelect =
function()
108 {
return document.getElementById(
"MSearchSelect"); }
110 this.DOMSearchSelectWindow =
function()
111 {
return document.getElementById(
"MSearchSelectWindow"); }
113 this.DOMPopupSearchResults =
function()
114 {
return document.getElementById(
"MSearchResults"); }
116 this.DOMPopupSearchResultsWindow =
function()
117 {
return document.getElementById(
"MSearchResultsWindow"); }
119 this.DOMSearchClose =
function()
120 {
return document.getElementById(
"MSearchClose"); }
122 this.DOMSearchBox =
function()
123 {
return document.getElementById(
"MSearchBox"); }
128 this.OnSearchFieldFocus =
function(isActive)
130 this.Activate(isActive);
133 this.OnSearchSelectShow =
function()
135 var searchSelectWindow = this.DOMSearchSelectWindow();
136 var searchField = this.DOMSearchSelect();
138 if (this.insideFrame)
140 var left = getXPos(searchField);
141 var top = getYPos(searchField);
142 left += searchField.offsetWidth + 6;
143 top += searchField.offsetHeight;
146 searchSelectWindow.style.display=
'block';
147 left -= searchSelectWindow.offsetWidth;
148 searchSelectWindow.style.left = left +
'px';
149 searchSelectWindow.style.top = top +
'px';
153 var left = getXPos(searchField);
154 var top = getYPos(searchField);
155 top += searchField.offsetHeight;
158 searchSelectWindow.style.display=
'block';
159 searchSelectWindow.style.left = left +
'px';
160 searchSelectWindow.style.top = top +
'px';
164 if (this.hideTimeout)
166 clearTimeout(this.hideTimeout);
172 this.OnSearchSelectHide =
function()
174 this.hideTimeout = setTimeout(this.name +
".CloseSelectionWindow()",
175 this.closeSelectionTimeout);
179 this.OnSearchFieldChange =
function(evt)
183 clearTimeout(this.keyTimeout);
187 var e = (evt) ? evt : window.event;
188 if (e.keyCode==40 || e.keyCode==13)
192 this.OnSearchSelectShow();
193 var win=this.DOMSearchSelectWindow();
194 for (i=0;i<win.childNodes.length;i++)
196 var child = win.childNodes[i];
197 if (child.className==
'SelectItem')
205 else if (window.frames.MSearchResults.searchResults)
207 var elem = window.frames.MSearchResults.searchResults.NavNext(0);
208 if (elem) elem.focus();
211 else if (e.keyCode==27)
213 this.DOMSearchField().blur();
214 this.DOMPopupSearchResultsWindow().style.display =
'none';
215 this.DOMSearchClose().style.display =
'none';
216 this.lastSearchValue =
'';
217 this.Activate(
false);
222 var searchValue = this.DOMSearchField().value.replace(/ +/g,
"");
224 if (searchValue != this.lastSearchValue)
226 if (searchValue !=
"")
229 this.keyTimeout = setTimeout(this.name +
'.Search()',
230 this.keyTimeoutLength);
234 this.DOMPopupSearchResultsWindow().style.display =
'none';
235 this.DOMSearchClose().style.display =
'none';
236 this.lastSearchValue =
'';
241 this.SelectItemCount =
function(id)
244 var win=this.DOMSearchSelectWindow();
245 for (i=0;i<win.childNodes.length;i++)
247 var child = win.childNodes[i];
248 if (child.className==
'SelectItem')
256 this.SelectItemSet =
function(id)
259 var win=this.DOMSearchSelectWindow();
260 for (i=0;i<win.childNodes.length;i++)
262 var child = win.childNodes[i];
263 if (child.className==
'SelectItem')
265 var node = child.firstChild;
268 node.innerHTML=
'•';
272 node.innerHTML=
' ';
281 this.OnSelectItem =
function(id)
283 this.searchIndex = id;
284 this.SelectItemSet(
id);
285 var searchValue = this.DOMSearchField().value.replace(/ +/g,
"");
286 if (searchValue!=
"" && this.searchActive)
292 this.OnSearchSelectKey =
function(evt)
294 var e = (evt) ? evt : window.event;
295 if (e.keyCode==40 &&
this.searchIndex<
this.SelectItemCount())
298 this.OnSelectItem(this.searchIndex);
300 else if (e.keyCode==38 &&
this.searchIndex>0)
303 this.OnSelectItem(this.searchIndex);
305 else if (e.keyCode==13 || e.keyCode==27)
307 this.OnSelectItem(this.searchIndex);
308 this.CloseSelectionWindow();
309 this.DOMSearchField().focus();
317 this.CloseResultsWindow =
function()
319 this.DOMPopupSearchResultsWindow().style.display =
'none';
320 this.DOMSearchClose().style.display =
'none';
321 this.Activate(
false);
324 this.CloseSelectionWindow =
function()
326 this.DOMSearchSelectWindow().style.display =
'none';
330 this.Search =
function()
335 var searchValue = this.DOMSearchField().value.replace(/^ +/,
"");
337 var code = searchValue.toLowerCase().charCodeAt(0);
338 var idxChar = searchValue.substr(0, 1).toLowerCase();
339 if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1)
341 idxChar = searchValue.substr(0, 2);
345 var resultsPageWithSearch;
348 var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
351 var hexCode=idx.toString(16);
352 resultsPage = this.resultsPath +
'/' + indexSectionNames[this.searchIndex] +
'_' + hexCode +
'.html';
353 resultsPageWithSearch = resultsPage+
'?'+escape(searchValue);
354 hasResultsPage =
true;
358 resultsPage = this.resultsPath +
'/nomatches.html';
359 resultsPageWithSearch = resultsPage;
360 hasResultsPage =
false;
363 window.frames.MSearchResults.location = resultsPageWithSearch;
364 var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
366 if (domPopupSearchResultsWindow.style.display!=
'block')
368 var domSearchBox = this.DOMSearchBox();
369 this.DOMSearchClose().style.display =
'inline';
370 if (this.insideFrame)
372 var domPopupSearchResults = this.DOMPopupSearchResults();
373 domPopupSearchResultsWindow.style.position =
'relative';
374 domPopupSearchResultsWindow.style.display =
'block';
375 var width = document.body.clientWidth - 8;
376 domPopupSearchResultsWindow.style.width = width +
'px';
377 domPopupSearchResults.style.width = width +
'px';
381 var domPopupSearchResults = this.DOMPopupSearchResults();
382 var left = getXPos(domSearchBox) + 150;
383 var top = getYPos(domSearchBox) + 20;
384 domPopupSearchResultsWindow.style.display =
'block';
385 left -= domPopupSearchResults.offsetWidth;
386 domPopupSearchResultsWindow.style.top = top +
'px';
387 domPopupSearchResultsWindow.style.left = left +
'px';
391 this.lastSearchValue = searchValue;
392 this.lastResultsPage = resultsPage;
399 this.Activate =
function(isActive)
402 this.DOMPopupSearchResultsWindow().style.display ==
'block'
405 this.DOMSearchBox().className =
'MSearchBoxActive';
407 var searchField = this.DOMSearchField();
409 if (searchField.value ==
this.searchLabel)
411 searchField.value =
'';
412 this.searchActive =
true;
417 this.DOMSearchBox().className =
'MSearchBoxInactive';
418 this.DOMSearchField().value = this.searchLabel;
419 this.searchActive =
false;
420 this.lastSearchValue =
''
421 this.lastResultsPage =
'';
429 function SearchResults(name)
432 this.lastMatchCount = 0;
434 this.repeatOn =
false;
437 this.FindChildElement =
function(id)
439 var parentElement = document.getElementById(
id);
440 var element = parentElement.firstChild;
442 while (element && element!=parentElement)
444 if (element.nodeName ==
'DIV' && element.className ==
'SRChildren')
449 if (element.nodeName ==
'DIV' && element.hasChildNodes())
451 element = element.firstChild;
453 else if (element.nextSibling)
455 element = element.nextSibling;
461 element = element.parentNode;
463 while (element && element!=parentElement && !element.nextSibling);
465 if (element && element!=parentElement)
467 element = element.nextSibling;
473 this.Toggle =
function(id)
475 var element = this.FindChildElement(
id);
478 if (element.style.display ==
'block')
480 element.style.display =
'none';
484 element.style.display =
'block';
494 this.Search =
function(search)
498 search = window.location.search;
499 search = search.substring(1);
500 search = unescape(search);
503 search = search.replace(/^ +/,
"");
504 search = search.replace(/ +$/,
"");
505 search = search.toLowerCase();
506 search = convertToId(search);
508 var resultRows = document.getElementsByTagName(
"div");
512 while (i < resultRows.length)
514 var row = resultRows.item(i);
515 if (row.className ==
"SRResult")
517 var rowMatchName = row.id.toLowerCase();
518 rowMatchName = rowMatchName.replace(/^sr\d*_/,
'');
520 if (search.length<=rowMatchName.length &&
521 rowMatchName.substr(0, search.length)==search)
523 row.style.display =
'block';
528 row.style.display =
'none';
533 document.getElementById(
"Searching").style.display=
'none';
536 document.getElementById(
"NoMatches").style.display=
'block';
540 document.getElementById(
"NoMatches").style.display=
'none';
542 this.lastMatchCount = matches;
547 this.NavNext =
function(index)
552 var focusName =
'Item'+index;
553 focusItem = document.getElementById(focusName);
554 if (focusItem && focusItem.parentNode.parentNode.style.display==
'block')
568 this.NavPrev =
function(index)
573 var focusName =
'Item'+index;
574 focusItem = document.getElementById(focusName);
575 if (focusItem && focusItem.parentNode.parentNode.style.display==
'block')
589 this.ProcessKeys =
function(e)
591 if (e.type ==
"keydown")
593 this.repeatOn =
false;
594 this.lastKey = e.keyCode;
596 else if (e.type ==
"keypress")
600 if (this.lastKey) this.repeatOn =
true;
604 else if (e.type ==
"keyup")
607 this.repeatOn =
false;
609 return this.lastKey!=0;
612 this.Nav =
function(evt,itemIndex)
614 var e = (evt) ? evt : window.event;
615 if (e.keyCode==13)
return true;
616 if (!this.ProcessKeys(e))
return false;
618 if (this.lastKey==38)
620 var newIndex = itemIndex-1;
621 var focusItem = this.NavPrev(newIndex);
624 var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
625 if (child && child.style.display ==
'block')
631 tmpElem = document.getElementById(
'Item'+newIndex+
'_c'+n);
650 parent.document.getElementById(
"MSearchField").focus();
653 else if (this.lastKey==40)
655 var newIndex = itemIndex+1;
657 var item = document.getElementById(
'Item'+itemIndex);
658 var elem = this.FindChildElement(item.parentNode.parentNode.id);
659 if (elem && elem.style.display ==
'block')
661 focusItem = document.getElementById(
'Item'+itemIndex+
'_c0');
663 if (!focusItem) focusItem = this.NavNext(newIndex);
664 if (focusItem) focusItem.focus();
666 else if (this.lastKey==39)
668 var item = document.getElementById(
'Item'+itemIndex);
669 var elem = this.FindChildElement(item.parentNode.parentNode.id);
670 if (elem) elem.style.display =
'block';
672 else if (this.lastKey==37)
674 var item = document.getElementById(
'Item'+itemIndex);
675 var elem = this.FindChildElement(item.parentNode.parentNode.id);
676 if (elem) elem.style.display =
'none';
678 else if (this.lastKey==27)
680 parent.searchBox.CloseResultsWindow();
681 parent.document.getElementById(
"MSearchField").focus();
683 else if (this.lastKey==13)
690 this.NavChild =
function(evt,itemIndex,childIndex)
692 var e = (evt) ? evt : window.event;
693 if (e.keyCode==13)
return true;
694 if (!this.ProcessKeys(e))
return false;
696 if (this.lastKey==38)
700 var newIndex = childIndex-1;
701 document.getElementById(
'Item'+itemIndex+
'_c'+newIndex).focus();
705 document.getElementById(
'Item'+itemIndex).focus();
708 else if (this.lastKey==40)
710 var newIndex = childIndex+1;
711 var elem = document.getElementById(
'Item'+itemIndex+
'_c'+newIndex);
714 elem = this.NavNext(itemIndex+1);
721 else if (this.lastKey==27)
723 parent.searchBox.CloseResultsWindow();
724 parent.document.getElementById(
"MSearchField").focus();
726 else if (this.lastKey==13)
734 function setKeyActions(elem,action)
736 elem.setAttribute(
'onkeydown',action);
737 elem.setAttribute(
'onkeypress',action);
738 elem.setAttribute(
'onkeyup',action);
741 function setClassAttr(elem,attr)
743 elem.setAttribute(
'class',attr);
744 elem.setAttribute(
'className',attr);
747 function createResults()
749 var results = document.getElementById(
"SRResults");
750 for (var e=0; e<searchData.length; e++)
752 var
id = searchData[e][0];
753 var srResult = document.createElement(
'div');
754 srResult.setAttribute(
'id',
'SR_'+
id);
755 setClassAttr(srResult,
'SRResult');
756 var srEntry = document.createElement(
'div');
757 setClassAttr(srEntry,
'SREntry');
758 var srLink = document.createElement(
'a');
759 srLink.setAttribute(
'id',
'Item'+e);
760 setKeyActions(srLink,
'return searchResults.Nav(event,'+e+
')');
761 setClassAttr(srLink,
'SRSymbol');
762 srLink.innerHTML = searchData[e][1][0];
763 srEntry.appendChild(srLink);
764 if (searchData[e][1].length==2)
766 srLink.setAttribute(
'href',searchData[e][1][1][0]);
767 if (searchData[e][1][1][1])
769 srLink.setAttribute(
'target',
'_parent');
771 var srScope = document.createElement(
'span');
772 setClassAttr(srScope,
'SRScope');
773 srScope.innerHTML = searchData[e][1][1][2];
774 srEntry.appendChild(srScope);
778 srLink.setAttribute(
'href',
'javascript:searchResults.Toggle("SR_'+
id+
'")');
779 var srChildren = document.createElement(
'div');
780 setClassAttr(srChildren,
'SRChildren');
781 for (var c=0; c<searchData[e][1].length-1; c++)
783 var srChild = document.createElement(
'a');
784 srChild.setAttribute(
'id',
'Item'+e+
'_c'+c);
785 setKeyActions(srChild,
'return searchResults.NavChild(event,'+e+
','+c+
')');
786 setClassAttr(srChild,
'SRScope');
787 srChild.setAttribute(
'href',searchData[e][1][c+1][0]);
788 if (searchData[e][1][c+1][1])
790 srChild.setAttribute(
'target',
'_parent');
792 srChild.innerHTML = searchData[e][1][c+1][2];
793 srChildren.appendChild(srChild);
795 srEntry.appendChild(srChildren);
797 srResult.appendChild(srEntry);
798 results.appendChild(srResult);