~percona-toolkit-dev/percona-toolkit/docu-ptc-rbr-limitation

« back to all changes in this revision

Viewing changes to docs/dev/html/javascript/main.js

  • Committer: Daniel Nichter
  • Date: 2011-07-14 19:08:47 UTC
  • Revision ID: daniel@percona.com-20110714190847-lggalkuvdrh7c4jp
Add standard pkg files (COPYING, README, etc.), percona-toolkit.pod, and user docs.  Remove dev/docs/html.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// This file is part of Natural Docs, which is Copyright � 2003-2010 Greg Valure
2
 
// Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL)
3
 
// Refer to License.txt for the complete details
4
 
 
5
 
// This file may be distributed with documentation files generated by Natural Docs.
6
 
// Such documentation is not covered by Natural Docs' copyright and licensing,
7
 
// and may have its own copyright and distribution terms as decided by its author.
8
 
 
9
 
 
10
 
//
11
 
//  Browser Styles
12
 
// ____________________________________________________________________________
13
 
 
14
 
var agt=navigator.userAgent.toLowerCase();
15
 
var browserType;
16
 
var browserVer;
17
 
 
18
 
if (agt.indexOf("opera") != -1)
19
 
    {
20
 
    browserType = "Opera";
21
 
 
22
 
    if (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1)
23
 
        {  browserVer = "Opera7";  }
24
 
    else if (agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1)
25
 
        {  browserVer = "Opera8";  }
26
 
    else if (agt.indexOf("opera 9") != -1 || agt.indexOf("opera/9") != -1)
27
 
        {  browserVer = "Opera9";  }
28
 
    }
29
 
 
30
 
else if (agt.indexOf("applewebkit") != -1)
31
 
    {
32
 
    browserType = "Safari";
33
 
 
34
 
    if (agt.indexOf("version/3") != -1)
35
 
        {  browserVer = "Safari3";  }
36
 
    else if (agt.indexOf("safari/4") != -1)
37
 
        {  browserVer = "Safari2";  }
38
 
    }
39
 
 
40
 
else if (agt.indexOf("khtml") != -1)
41
 
    {
42
 
    browserType = "Konqueror";
43
 
    }
44
 
 
45
 
else if (agt.indexOf("msie") != -1)
46
 
    {
47
 
    browserType = "IE";
48
 
 
49
 
    if (agt.indexOf("msie 6") != -1)
50
 
        {  browserVer = "IE6";  }
51
 
    else if (agt.indexOf("msie 7") != -1)
52
 
        {  browserVer = "IE7";  }
53
 
    }
54
 
 
55
 
else if (agt.indexOf("gecko") != -1)
56
 
    {
57
 
    browserType = "Firefox";
58
 
 
59
 
    if (agt.indexOf("rv:1.7") != -1)
60
 
        {  browserVer = "Firefox1";  }
61
 
    else if (agt.indexOf("rv:1.8)") != -1 || agt.indexOf("rv:1.8.0") != -1)
62
 
        {  browserVer = "Firefox15";  }
63
 
    else if (agt.indexOf("rv:1.8.1") != -1)
64
 
        {  browserVer = "Firefox2";  }
65
 
    }
66
 
 
67
 
 
68
 
//
69
 
//  Support Functions
70
 
// ____________________________________________________________________________
71
 
 
72
 
 
73
 
function GetXPosition(item)
74
 
    {
75
 
    var position = 0;
76
 
 
77
 
    if (item.offsetWidth != null)
78
 
        {
79
 
        while (item != document.body && item != null)
80
 
            {
81
 
            position += item.offsetLeft;
82
 
            item = item.offsetParent;
83
 
            };
84
 
        };
85
 
 
86
 
    return position;
87
 
    };
88
 
 
89
 
 
90
 
function GetYPosition(item)
91
 
    {
92
 
    var position = 0;
93
 
 
94
 
    if (item.offsetWidth != null)
95
 
        {
96
 
        while (item != document.body && item != null)
97
 
            {
98
 
            position += item.offsetTop;
99
 
            item = item.offsetParent;
100
 
            };
101
 
        };
102
 
 
103
 
    return position;
104
 
    };
105
 
 
106
 
 
107
 
function MoveToPosition(item, x, y)
108
 
    {
109
 
    // Opera 5 chokes on the px extension, so it can use the Microsoft one instead.
110
 
 
111
 
    if (item.style.left != null)
112
 
        {
113
 
        item.style.left = x + "px";
114
 
        item.style.top = y + "px";
115
 
        }
116
 
    else if (item.style.pixelLeft != null)
117
 
        {
118
 
        item.style.pixelLeft = x;
119
 
        item.style.pixelTop = y;
120
 
        };
121
 
    };
122
 
 
123
 
 
124
 
//
125
 
//  Menu
126
 
// ____________________________________________________________________________
127
 
 
128
 
 
129
 
function ToggleMenu(id)
130
 
    {
131
 
    if (!window.document.getElementById)
132
 
        {  return;  };
133
 
 
134
 
    var display = window.document.getElementById(id).style.display;
135
 
 
136
 
    if (display == "none")
137
 
        {  display = "block";  }
138
 
    else
139
 
        {  display = "none";  }
140
 
 
141
 
    window.document.getElementById(id).style.display = display;
142
 
    }
143
 
 
144
 
function HideAllBut(ids, max)
145
 
    {
146
 
    if (document.getElementById)
147
 
        {
148
 
        ids.sort( function(a,b) { return a - b; } );
149
 
        var number = 1;
150
 
 
151
 
        while (number < max)
152
 
            {
153
 
            if (ids.length > 0 && number == ids[0])
154
 
                {  ids.shift();  }
155
 
            else
156
 
                {
157
 
                document.getElementById("MGroupContent" + number).style.display = "none";
158
 
                };
159
 
 
160
 
            number++;
161
 
            };
162
 
        };
163
 
    }
164
 
 
165
 
 
166
 
//
167
 
//  Tooltips
168
 
// ____________________________________________________________________________
169
 
 
170
 
 
171
 
var tooltipTimer = 0;
172
 
 
173
 
function ShowTip(event, tooltipID, linkID)
174
 
    {
175
 
    if (tooltipTimer)
176
 
        {  clearTimeout(tooltipTimer);  };
177
 
 
178
 
    var docX = event.clientX + window.pageXOffset;
179
 
    var docY = event.clientY + window.pageYOffset;
180
 
 
181
 
    var showCommand = "ReallyShowTip('" + tooltipID + "', '" + linkID + "', " + docX + ", " + docY + ")";
182
 
 
183
 
    tooltipTimer = setTimeout(showCommand, 1000);
184
 
    }
185
 
 
186
 
function ReallyShowTip(tooltipID, linkID, docX, docY)
187
 
    {
188
 
    tooltipTimer = 0;
189
 
 
190
 
    var tooltip;
191
 
    var link;
192
 
 
193
 
    if (document.getElementById)
194
 
        {
195
 
        tooltip = document.getElementById(tooltipID);
196
 
        link = document.getElementById(linkID);
197
 
        }
198
 
/*    else if (document.all)
199
 
        {
200
 
        tooltip = eval("document.all['" + tooltipID + "']");
201
 
        link = eval("document.all['" + linkID + "']");
202
 
        }
203
 
*/
204
 
    if (tooltip)
205
 
        {
206
 
        var left = GetXPosition(link);
207
 
        var top = GetYPosition(link);
208
 
        top += link.offsetHeight;
209
 
 
210
 
 
211
 
        // The fallback method is to use the mouse X and Y relative to the document.  We use a separate if and test if its a number
212
 
        // in case some browser snuck through the above if statement but didn't support everything.
213
 
 
214
 
        if (!isFinite(top) || top == 0)
215
 
            {
216
 
            left = docX;
217
 
            top = docY;
218
 
            }
219
 
 
220
 
        // Some spacing to get it out from under the cursor.
221
 
 
222
 
        top += 10;
223
 
 
224
 
        // Make sure the tooltip doesnt get smushed by being too close to the edge, or in some browsers, go off the edge of the
225
 
        // page.  We do it here because Konqueror does get offsetWidth right even if it doesnt get the positioning right.
226
 
 
227
 
        if (tooltip.offsetWidth != null)
228
 
            {
229
 
            var width = tooltip.offsetWidth;
230
 
            var docWidth = document.body.clientWidth;
231
 
 
232
 
            if (left + width > docWidth)
233
 
                {  left = docWidth - width - 1;  }
234
 
 
235
 
            // If there's a horizontal scroll bar we could go past zero because it's using the page width, not the window width.
236
 
            if (left < 0)
237
 
                {  left = 0;  };
238
 
            }
239
 
 
240
 
        MoveToPosition(tooltip, left, top);
241
 
        tooltip.style.visibility = "visible";
242
 
        }
243
 
    }
244
 
 
245
 
function HideTip(tooltipID)
246
 
    {
247
 
    if (tooltipTimer)
248
 
        {
249
 
        clearTimeout(tooltipTimer);
250
 
        tooltipTimer = 0;
251
 
        }
252
 
 
253
 
    var tooltip;
254
 
 
255
 
    if (document.getElementById)
256
 
        {  tooltip = document.getElementById(tooltipID); }
257
 
    else if (document.all)
258
 
        {  tooltip = eval("document.all['" + tooltipID + "']");  }
259
 
 
260
 
    if (tooltip)
261
 
        {  tooltip.style.visibility = "hidden";  }
262
 
    }
263
 
 
264
 
 
265
 
//
266
 
//  Blockquote fix for IE
267
 
// ____________________________________________________________________________
268
 
 
269
 
 
270
 
function NDOnLoad()
271
 
    {
272
 
    if (browserVer == "IE6")
273
 
        {
274
 
        var scrollboxes = document.getElementsByTagName('blockquote');
275
 
 
276
 
        if (scrollboxes.item(0))
277
 
            {
278
 
            NDDoResize();
279
 
            window.onresize=NDOnResize;
280
 
            };
281
 
        };
282
 
    };
283
 
 
284
 
 
285
 
var resizeTimer = 0;
286
 
 
287
 
function NDOnResize()
288
 
    {
289
 
    if (resizeTimer != 0)
290
 
        {  clearTimeout(resizeTimer);  };
291
 
 
292
 
    resizeTimer = setTimeout(NDDoResize, 250);
293
 
    };
294
 
 
295
 
 
296
 
function NDDoResize()
297
 
    {
298
 
    var scrollboxes = document.getElementsByTagName('blockquote');
299
 
 
300
 
    var i;
301
 
    var item;
302
 
 
303
 
    i = 0;
304
 
    while (item = scrollboxes.item(i))
305
 
        {
306
 
        item.style.width = 100;
307
 
        i++;
308
 
        };
309
 
 
310
 
    i = 0;
311
 
    while (item = scrollboxes.item(i))
312
 
        {
313
 
        item.style.width = item.parentNode.offsetWidth;
314
 
        i++;
315
 
        };
316
 
 
317
 
    clearTimeout(resizeTimer);
318
 
    resizeTimer = 0;
319
 
    }
320
 
 
321
 
 
322
 
 
323
 
/* ________________________________________________________________________________________________________
324
 
 
325
 
    Class: SearchPanel
326
 
    ________________________________________________________________________________________________________
327
 
 
328
 
    A class handling everything associated with the search panel.
329
 
 
330
 
    Parameters:
331
 
 
332
 
        name - The name of the global variable that will be storing this instance.  Is needed to be able to set timeouts.
333
 
        mode - The mode the search is going to work in.  Pass <NaturalDocs::Builder::Base->CommandLineOption()>, so the
334
 
                   value will be something like "HTML" or "FramedHTML".
335
 
 
336
 
    ________________________________________________________________________________________________________
337
 
*/
338
 
 
339
 
 
340
 
function SearchPanel(name, mode, resultsPath)
341
 
    {
342
 
    if (!name || !mode || !resultsPath)
343
 
        {  alert("Incorrect parameters to SearchPanel.");  };
344
 
 
345
 
 
346
 
    // Group: Variables
347
 
    // ________________________________________________________________________
348
 
 
349
 
    /*
350
 
        var: name
351
 
        The name of the global variable that will be storing this instance of the class.
352
 
    */
353
 
    this.name = name;
354
 
 
355
 
    /*
356
 
        var: mode
357
 
        The mode the search is going to work in, such as "HTML" or "FramedHTML".
358
 
    */
359
 
    this.mode = mode;
360
 
 
361
 
    /*
362
 
        var: resultsPath
363
 
        The relative path from the current HTML page to the results page directory.
364
 
    */
365
 
    this.resultsPath = resultsPath;
366
 
 
367
 
    /*
368
 
        var: keyTimeout
369
 
        The timeout used between a keystroke and when a search is performed.
370
 
    */
371
 
    this.keyTimeout = 0;
372
 
 
373
 
    /*
374
 
        var: keyTimeoutLength
375
 
        The length of <keyTimeout> in thousandths of a second.
376
 
    */
377
 
    this.keyTimeoutLength = 500;
378
 
 
379
 
    /*
380
 
        var: lastSearchValue
381
 
        The last search string executed, or an empty string if none.
382
 
    */
383
 
    this.lastSearchValue = "";
384
 
 
385
 
    /*
386
 
        var: lastResultsPage
387
 
        The last results page.  The value is only relevant if <lastSearchValue> is set.
388
 
    */
389
 
    this.lastResultsPage = "";
390
 
 
391
 
    /*
392
 
        var: deactivateTimeout
393
 
 
394
 
        The timeout used between when a control is deactivated and when the entire panel is deactivated.  Is necessary
395
 
        because a control may be deactivated in favor of another control in the same panel, in which case it should stay
396
 
        active.
397
 
    */
398
 
    this.deactivateTimout = 0;
399
 
 
400
 
    /*
401
 
        var: deactivateTimeoutLength
402
 
        The length of <deactivateTimeout> in thousandths of a second.
403
 
    */
404
 
    this.deactivateTimeoutLength = 200;
405
 
 
406
 
 
407
 
 
408
 
 
409
 
    // Group: DOM Elements
410
 
    // ________________________________________________________________________
411
 
 
412
 
 
413
 
    // Function: DOMSearchField
414
 
    this.DOMSearchField = function()
415
 
        {  return document.getElementById("MSearchField");  };
416
 
 
417
 
    // Function: DOMSearchType
418
 
    this.DOMSearchType = function()
419
 
        {  return document.getElementById("MSearchType");  };
420
 
 
421
 
    // Function: DOMPopupSearchResults
422
 
    this.DOMPopupSearchResults = function()
423
 
        {  return document.getElementById("MSearchResults");  };
424
 
 
425
 
    // Function: DOMPopupSearchResultsWindow
426
 
    this.DOMPopupSearchResultsWindow = function()
427
 
        {  return document.getElementById("MSearchResultsWindow");  };
428
 
 
429
 
    // Function: DOMSearchPanel
430
 
    this.DOMSearchPanel = function()
431
 
        {  return document.getElementById("MSearchPanel");  };
432
 
 
433
 
 
434
 
 
435
 
 
436
 
    // Group: Event Handlers
437
 
    // ________________________________________________________________________
438
 
 
439
 
 
440
 
    /*
441
 
        Function: OnSearchFieldFocus
442
 
        Called when focus is added or removed from the search field.
443
 
    */
444
 
    this.OnSearchFieldFocus = function(isActive)
445
 
        {
446
 
        this.Activate(isActive);
447
 
        };
448
 
 
449
 
 
450
 
    /*
451
 
        Function: OnSearchFieldChange
452
 
        Called when the content of the search field is changed.
453
 
    */
454
 
    this.OnSearchFieldChange = function()
455
 
        {
456
 
        if (this.keyTimeout)
457
 
            {
458
 
            clearTimeout(this.keyTimeout);
459
 
            this.keyTimeout = 0;
460
 
            };
461
 
 
462
 
        var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
463
 
 
464
 
        if (searchValue != this.lastSearchValue)
465
 
            {
466
 
            if (searchValue != "")
467
 
                {
468
 
                this.keyTimeout = setTimeout(this.name + ".Search()", this.keyTimeoutLength);
469
 
                }
470
 
            else
471
 
                {
472
 
                if (this.mode == "HTML")
473
 
                    {  this.DOMPopupSearchResultsWindow().style.display = "none";  };
474
 
                this.lastSearchValue = "";
475
 
                };
476
 
            };
477
 
        };
478
 
 
479
 
 
480
 
    /*
481
 
        Function: OnSearchTypeFocus
482
 
        Called when focus is added or removed from the search type.
483
 
    */
484
 
    this.OnSearchTypeFocus = function(isActive)
485
 
        {
486
 
        this.Activate(isActive);
487
 
        };
488
 
 
489
 
 
490
 
    /*
491
 
        Function: OnSearchTypeChange
492
 
        Called when the search type is changed.
493
 
    */
494
 
    this.OnSearchTypeChange = function()
495
 
        {
496
 
        var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
497
 
 
498
 
        if (searchValue != "")
499
 
            {
500
 
            this.Search();
501
 
            };
502
 
        };
503
 
 
504
 
 
505
 
 
506
 
    // Group: Action Functions
507
 
    // ________________________________________________________________________
508
 
 
509
 
 
510
 
    /*
511
 
        Function: CloseResultsWindow
512
 
        Closes the results window.
513
 
    */
514
 
    this.CloseResultsWindow = function()
515
 
        {
516
 
        this.DOMPopupSearchResultsWindow().style.display = "none";
517
 
        this.Activate(false, true);
518
 
        };
519
 
 
520
 
 
521
 
    /*
522
 
        Function: Search
523
 
        Performs a search.
524
 
    */
525
 
    this.Search = function()
526
 
        {
527
 
        this.keyTimeout = 0;
528
 
 
529
 
        var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
530
 
        var searchTopic = this.DOMSearchType().value;
531
 
 
532
 
        var pageExtension = searchValue.substr(0,1);
533
 
 
534
 
        if (pageExtension.match(/^[a-z]/i))
535
 
            {  pageExtension = pageExtension.toUpperCase();  }
536
 
        else if (pageExtension.match(/^[0-9]/))
537
 
            {  pageExtension = 'Numbers';  }
538
 
        else
539
 
            {  pageExtension = "Symbols";  };
540
 
 
541
 
        var resultsPage;
542
 
        var resultsPageWithSearch;
543
 
        var hasResultsPage;
544
 
 
545
 
        // indexSectionsWithContent is defined in searchdata.js
546
 
        if (indexSectionsWithContent[searchTopic][pageExtension] == true)
547
 
            {
548
 
            resultsPage = this.resultsPath + '/' + searchTopic + pageExtension + '.html';
549
 
            resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
550
 
            hasResultsPage = true;
551
 
            }
552
 
        else
553
 
            {
554
 
            resultsPage = this.resultsPath + '/NoResults.html';
555
 
            resultsPageWithSearch = resultsPage;
556
 
            hasResultsPage = false;
557
 
            };
558
 
 
559
 
        var resultsFrame;
560
 
        if (this.mode == "HTML")
561
 
            {  resultsFrame = window.frames.MSearchResults;  }
562
 
        else if (this.mode == "FramedHTML")
563
 
            {  resultsFrame = window.top.frames['Content'];  };
564
 
 
565
 
 
566
 
        if (resultsPage != this.lastResultsPage ||
567
 
 
568
 
            // Bug in IE.  If everything becomes hidden in a run, none of them will be able to be reshown in the next for some
569
 
            // reason.  It counts the right number of results, and you can even read the display as "block" after setting it, but it
570
 
            // just doesn't work in IE 6 or IE 7.  So if we're on the right page but the previous search had no results, reload the
571
 
            // page anyway to get around the bug.
572
 
            (browserType == "IE" && hasResultsPage &&
573
 
                (!resultsFrame.searchResults || resultsFrame.searchResults.lastMatchCount == 0)) )
574
 
 
575
 
            {
576
 
            resultsFrame.location.href = resultsPageWithSearch;
577
 
            }
578
 
 
579
 
        // So if the results page is right and there's no IE bug, reperform the search on the existing page.  We have to check if there
580
 
        // are results because NoResults.html doesn't have any JavaScript, and it would be useless to do anything on that page even
581
 
        // if it did.
582
 
        else if (hasResultsPage)
583
 
            {
584
 
            // We need to check if this exists in case the frame is present but didn't finish loading.
585
 
            if (resultsFrame.searchResults)
586
 
                {  resultsFrame.searchResults.Search(searchValue);  }
587
 
 
588
 
            // Otherwise just reload instead of waiting.
589
 
            else
590
 
                {  resultsFrame.location.href = resultsPageWithSearch;  };
591
 
            };
592
 
 
593
 
 
594
 
        var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
595
 
 
596
 
        if (this.mode == "HTML" && domPopupSearchResultsWindow.style.display != "block")
597
 
            {
598
 
            var domSearchType = this.DOMSearchType();
599
 
 
600
 
            var left = GetXPosition(domSearchType);
601
 
            var top = GetYPosition(domSearchType) + domSearchType.offsetHeight;
602
 
 
603
 
            MoveToPosition(domPopupSearchResultsWindow, left, top);
604
 
            domPopupSearchResultsWindow.style.display = 'block';
605
 
            };
606
 
 
607
 
 
608
 
        this.lastSearchValue = searchValue;
609
 
        this.lastResultsPage = resultsPage;
610
 
        };
611
 
 
612
 
 
613
 
 
614
 
    // Group: Activation Functions
615
 
    // Functions that handle whether the entire panel is active or not.
616
 
    // ________________________________________________________________________
617
 
 
618
 
 
619
 
    /*
620
 
        Function: Activate
621
 
 
622
 
        Activates or deactivates the search panel, resetting things to their default values if necessary.  You can call this on every
623
 
        control's OnBlur() and it will handle not deactivating the entire panel when focus is just switching between them transparently.
624
 
 
625
 
        Parameters:
626
 
 
627
 
            isActive - Whether you're activating or deactivating the panel.
628
 
            ignoreDeactivateDelay - Set if you're positive the action will deactivate the panel and thus want to skip the delay.
629
 
    */
630
 
    this.Activate = function(isActive, ignoreDeactivateDelay)
631
 
        {
632
 
        // We want to ignore isActive being false while the results window is open.
633
 
        if (isActive || (this.mode == "HTML" && this.DOMPopupSearchResultsWindow().style.display == "block"))
634
 
            {
635
 
            if (this.inactivateTimeout)
636
 
                {
637
 
                clearTimeout(this.inactivateTimeout);
638
 
                this.inactivateTimeout = 0;
639
 
                };
640
 
 
641
 
            this.DOMSearchPanel().className = 'MSearchPanelActive';
642
 
 
643
 
            var searchField = this.DOMSearchField();
644
 
 
645
 
            if (searchField.value == 'Search')
646
 
                 {  searchField.value = "";  }
647
 
            }
648
 
        else if (!ignoreDeactivateDelay)
649
 
            {
650
 
            this.inactivateTimeout = setTimeout(this.name + ".InactivateAfterTimeout()", this.inactivateTimeoutLength);
651
 
            }
652
 
        else
653
 
            {
654
 
            this.InactivateAfterTimeout();
655
 
            };
656
 
        };
657
 
 
658
 
 
659
 
    /*
660
 
        Function: InactivateAfterTimeout
661
 
 
662
 
        Called by <inactivateTimeout>, which is set by <Activate()>.  Inactivation occurs on a timeout because a control may
663
 
        receive OnBlur() when focus is really transferring to another control in the search panel.  In this case we don't want to
664
 
        actually deactivate the panel because not only would that cause a visible flicker but it could also reset the search value.
665
 
        So by doing it on a timeout instead, there's a short period where the second control's OnFocus() can cancel the deactivation.
666
 
    */
667
 
    this.InactivateAfterTimeout = function()
668
 
        {
669
 
        this.inactivateTimeout = 0;
670
 
 
671
 
        this.DOMSearchPanel().className = 'MSearchPanelInactive';
672
 
        this.DOMSearchField().value = "Search";
673
 
 
674
 
            this.lastSearchValue = "";
675
 
            this.lastResultsPage = "";
676
 
        };
677
 
    };
678
 
 
679
 
 
680
 
 
681
 
 
682
 
/* ________________________________________________________________________________________________________
683
 
 
684
 
   Class: SearchResults
685
 
   _________________________________________________________________________________________________________
686
 
 
687
 
   The class that handles everything on the search results page.
688
 
   _________________________________________________________________________________________________________
689
 
*/
690
 
 
691
 
 
692
 
function SearchResults(name, mode)
693
 
    {
694
 
    /*
695
 
        var: mode
696
 
        The mode the search is going to work in, such as "HTML" or "FramedHTML".
697
 
    */
698
 
    this.mode = mode;
699
 
 
700
 
    /*
701
 
        var: lastMatchCount
702
 
        The number of matches from the last run of <Search()>.
703
 
    */
704
 
    this.lastMatchCount = 0;
705
 
 
706
 
 
707
 
    /*
708
 
        Function: Toggle
709
 
        Toggles the visibility of the passed element ID.
710
 
    */
711
 
    this.Toggle = function(id)
712
 
        {
713
 
        if (this.mode == "FramedHTML")
714
 
            {  return;  };
715
 
 
716
 
        var parentElement = document.getElementById(id);
717
 
 
718
 
        var element = parentElement.firstChild;
719
 
 
720
 
        while (element && element != parentElement)
721
 
            {
722
 
            if (element.nodeName == 'DIV' && element.className == 'ISubIndex')
723
 
                {
724
 
                if (element.style.display == 'block')
725
 
                    {  element.style.display = "none";  }
726
 
                else
727
 
                    {  element.style.display = 'block';  }
728
 
                };
729
 
 
730
 
            if (element.nodeName == 'DIV' && element.hasChildNodes())
731
 
                {  element = element.firstChild;  }
732
 
            else if (element.nextSibling)
733
 
                {  element = element.nextSibling;  }
734
 
            else
735
 
                {
736
 
                do
737
 
                    {
738
 
                    element = element.parentNode;
739
 
                    }
740
 
                while (element && element != parentElement && !element.nextSibling);
741
 
 
742
 
                if (element && element != parentElement)
743
 
                    {  element = element.nextSibling;  };
744
 
                };
745
 
            };
746
 
        };
747
 
 
748
 
 
749
 
    /*
750
 
        Function: Search
751
 
 
752
 
        Searches for the passed string.  If there is no parameter, it takes it from the URL query.
753
 
 
754
 
        Always returns true, since other documents may try to call it and that may or may not be possible.
755
 
    */
756
 
    this.Search = function(search)
757
 
        {
758
 
        if (!search)
759
 
            {
760
 
            search = window.location.search;
761
 
            search = search.substring(1);  // Remove the leading ?
762
 
            search = unescape(search);
763
 
            };
764
 
 
765
 
        search = search.replace(/^ +/, "");
766
 
        search = search.replace(/ +$/, "");
767
 
        search = search.toLowerCase();
768
 
 
769
 
        if (search.match(/[^a-z0-9]/)) // Just a little speedup so it doesn't have to go through the below unnecessarily.
770
 
            {
771
 
            search = search.replace(/\_/g, "_und");
772
 
            search = search.replace(/\ +/gi, "_spc");
773
 
            search = search.replace(/\~/g, "_til");
774
 
            search = search.replace(/\!/g, "_exc");
775
 
            search = search.replace(/\@/g, "_att");
776
 
            search = search.replace(/\#/g, "_num");
777
 
            search = search.replace(/\$/g, "_dol");
778
 
            search = search.replace(/\%/g, "_pct");
779
 
            search = search.replace(/\^/g, "_car");
780
 
            search = search.replace(/\&/g, "_amp");
781
 
            search = search.replace(/\*/g, "_ast");
782
 
            search = search.replace(/\(/g, "_lpa");
783
 
            search = search.replace(/\)/g, "_rpa");
784
 
            search = search.replace(/\-/g, "_min");
785
 
            search = search.replace(/\+/g, "_plu");
786
 
            search = search.replace(/\=/g, "_equ");
787
 
            search = search.replace(/\{/g, "_lbc");
788
 
            search = search.replace(/\}/g, "_rbc");
789
 
            search = search.replace(/\[/g, "_lbk");
790
 
            search = search.replace(/\]/g, "_rbk");
791
 
            search = search.replace(/\:/g, "_col");
792
 
            search = search.replace(/\;/g, "_sco");
793
 
            search = search.replace(/\"/g, "_quo");
794
 
            search = search.replace(/\'/g, "_apo");
795
 
            search = search.replace(/\</g, "_lan");
796
 
            search = search.replace(/\>/g, "_ran");
797
 
            search = search.replace(/\,/g, "_com");
798
 
            search = search.replace(/\./g, "_per");
799
 
            search = search.replace(/\?/g, "_que");
800
 
            search = search.replace(/\//g, "_sla");
801
 
            search = search.replace(/[^a-z0-9\_]i/gi, "_zzz");
802
 
            };
803
 
 
804
 
        var resultRows = document.getElementsByTagName("div");
805
 
        var matches = 0;
806
 
 
807
 
        var i = 0;
808
 
        while (i < resultRows.length)
809
 
            {
810
 
            var row = resultRows.item(i);
811
 
 
812
 
            if (row.className == "SRResult")
813
 
                {
814
 
                var rowMatchName = row.id.toLowerCase();
815
 
                rowMatchName = rowMatchName.replace(/^sr\d*_/, '');
816
 
 
817
 
                if (search.length <= rowMatchName.length && rowMatchName.substr(0, search.length) == search)
818
 
                    {
819
 
                    row.style.display = "block";
820
 
                    matches++;
821
 
                    }
822
 
                else
823
 
                    {  row.style.display = "none";  };
824
 
                };
825
 
 
826
 
            i++;
827
 
            };
828
 
 
829
 
        document.getElementById("Searching").style.display="none";
830
 
 
831
 
        if (matches == 0)
832
 
            {  document.getElementById("NoMatches").style.display="block";  }
833
 
        else
834
 
            {  document.getElementById("NoMatches").style.display="none";  }
835
 
 
836
 
        this.lastMatchCount = matches;
837
 
 
838
 
        return true;
839
 
        };
840
 
    };
841