updated acknowledgments
[openemr.git] / DocumentTreeMenu.js
blob011ebfabe64e38b7d802fdc2b08af1eaaa558baa
1 // +-----------------------------------------------------------------------+
2 // | Copyright (c) 2002-2003, Richard Heyes, Harald Radi                        |
3 // | All rights reserved.                                                  |
4 // |                                                                       |
5 // | Redistribution and use in source and binary forms, with or without    |
6 // | modification, are permitted provided that the following conditions    |
7 // | are met:                                                              |
8 // |                                                                       |
9 // | o Redistributions of source code must retain the above copyright      |
10 // |   notice, this list of conditions and the following disclaimer.       |
11 // | o Redistributions in binary form must reproduce the above copyright   |
12 // |   notice, this list of conditions and the following disclaimer in the |
13 // |   documentation and/or other materials provided with the distribution.|
14 // | o The names of the authors may not be used to endorse or promote      |
15 // |   products derived from this software without specific prior written  |
16 // |   permission.                                                         |
17 // |                                                                       |
18 // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
19 // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
20 // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
22 // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
24 // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
27 // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
29 // |                                                                       |
30 // +-----------------------------------------------------------------------+
31 // | Author: Richard Heyes <richard@phpguru.org>                           |
32 // |         Harald Radi <harald.radi@nme.at>                              |
33 // +-----------------------------------------------------------------------+
35 // $Id$
37 /**
38 * Function to create copies of objects which are
39 * normally passed around by references (Arrays for example)
41 function arrayCopy(input)
43         var output = new Array(input.length);
45         for (i in input) {
46                 if (typeof(input[i]) == 'array') {
47                         output[i] = arrayCopy(input[i]);
48                 } else {
49                         output[i] = input[i];
50                 }
51         }
53         return output;
56 /**
57 * TreeMenu class
59         function TreeMenu(iconpath, myname, linkTarget, defaultClass, usePersistence, noTopLevelImages)
60         {
61                 // Properties
62                 this.iconpath         = iconpath;
63                 this.myname           = myname;
64                 this.linkTarget       = linkTarget;
65                 this.defaultClass     = defaultClass;
66                 this.usePersistence   = usePersistence;
67                 this.noTopLevelImages = noTopLevelImages;
68                 this.n                = new Array();
69                 this.output           = '';
71                 this.nodeRefs       = new Array();
72                 this.branches       = new Array();
73                 this.branchStatus   = new Array();
74                 this.layerRelations = new Array();
75                 this.childParents   = new Array();
76                 this.cookieStatuses = new Array();
78                 this.preloadImages();
79         }
81 /**
82 * Adds a node to the tree
84         TreeMenu.prototype.addItem = function (newNode)
85         {
86                 newIndex = this.n.length;
87                 this.n[newIndex] = newNode;
88                 
89                 return this.n[newIndex];
90         }
92 /**
93 * Preload images hack for Mozilla
95         TreeMenu.prototype.preloadImages = function ()
96         {
97                 var plustop    = new Image; plustop.src    = this.iconpath + '/plustop.gif';
98                 var plusbottom = new Image; plusbottom.src = this.iconpath + '/plusbottom.gif';
99                 var plus       = new Image; plus.src       = this.iconpath + '/plus.gif';
100         
101                 var minustop    = new Image; minustop.src    = this.iconpath + '/minustop.gif';
102                 var minusbottom = new Image; minusbottom.src = this.iconpath + '/minusbottom.gif';
103                 var minus       = new Image; minus.src       = this.iconpath + '/minus.gif';
104         
105                 var branchtop    = new Image; branchtop.src    = this.iconpath + '/branchtop.gif';
106                 var branchbottom = new Image; branchbottom.src = this.iconpath + '/branchbottom.gif';
107                 var branch       = new Image; branch.src       = this.iconpath + '/branch.gif';
108         
109                 var linebottom = new Image; linebottom.src = this.iconpath + '/linebottom.gif';
110                 var line       = new Image; line.src       = this.iconpath + '/line.gif';
111         }
114 * Main function that draws the menu and assigns it
115 * to the layer (or document.write()s it)
117         TreeMenu.prototype.drawMenu = function ()// OPTIONAL ARGS: nodes = [], level = [], prepend = '', expanded = false, visbility = 'inline', parentLayerID = null
118         {
119                 /**
120             * Necessary variables
121             */
122                 var output        = '';
123                 var modifier      = '';
124                 var layerID       = '';
125                 var parentLayerID = '';
126         
127                 /**
128             * Parse any optional arguments
129             */
130                 var nodes         = arguments[0] ? arguments[0] : this.n
131                 var level         = arguments[1] ? arguments[1] : [];
132                 var prepend       = arguments[2] ? arguments[2] : '';
133                 var expanded      = arguments[3] ? arguments[3] : false;
134                 var visibility    = arguments[4] ? arguments[4] : 'inline';
135                 var parentLayerID = arguments[5] ? arguments[5] : null;
137                 var currentlevel  = level.length;
139                 for (var i=0; i<nodes.length; i++) {
140                 
141                         level[currentlevel] = i+1;
142                         layerID = this.myname + '_' + 'node_' + this.implode('_', level);
144                         /**
145             * Store this object in the nodeRefs array
146             */
147                         this.nodeRefs[layerID] = nodes[i];
149                         /**
150                 * Store the child/parent relationship
151                 */
152                         this.childParents[layerID] = parentLayerID;
153         
154                         /**
155                 * Gif modifier
156                 */
157                         if (i == 0 && parentLayerID == null) {
158                                 modifier = nodes.length > 1 ? "top" : 'single';
159                         } else if(i == (nodes.length-1)) {
160                                 modifier = "bottom";
161                         } else {
162                                 modifier = "";
163                         }
164         
165                         /**
166                 * Single root branch is always expanded
167                 */
168                         if (!this.doesMenu() || (parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages))) {
169                                 expanded = true;
170         
171                         } else if (nodes[i].expanded) {
172                                 expanded = true;
173         
174                         } else {
175                                 expanded = false;
176                         }
177         
178                         /**
179                 * Make sure visibility is correct based on parent status
180                 */
181                         visibility =  this.checkParentVisibility(layerID) ? visibility : 'none';
183                         /**
184                 * Setup branch status and build an indexed array
185                         * of branch layer ids
186                 */
187                         if (nodes[i].n.length > 0) {
188                                 this.branchStatus[layerID] = expanded;
189                                 this.branches[this.branches.length] = layerID;
190                         }
191         
192                         /**
193                 * Setup toggle relationship
194                 */
195                         if (!this.layerRelations[parentLayerID]) {
196                                 this.layerRelations[parentLayerID] = new Array();
197                         }
198                         this.layerRelations[parentLayerID][this.layerRelations[parentLayerID].length] = layerID;
199         
200                         /**
201                 * Branch images
202                 */
203                         var gifname  = nodes[i].n.length && this.doesMenu() && nodes[i].isDynamic ? (expanded ? 'minus' : 'plus') : 'branch';
204                         var iconName = expanded && nodes[i].expandedIcon ? nodes[i].expandedIcon : nodes[i].icon;
205                         var iconimg  = nodes[i].icon ? this.stringFormat('<img src="{0}/{1}" width="20" height="20" align="top" id="icon_{2}">', this.iconpath, iconName, layerID) : '';
206                         
207                         /**
208                         * Add event handlers
209                         */
210                         var eventHandlers = "";
211                         for (j in nodes[i].events) {
212                                 eventHandlers += this.stringFormat('{0}="{1}" ', j, nodes[i].events[j]);
213                         }
215                         /**
216                 * Build the html to write to the document
217                         * IMPORTANT:
218                         * document.write()ing the string: '<div style="display:...' will screw up nn4.x
219                 */
220                         var layerTag  = this.doesMenu() ? this.stringFormat('<div id="{0}" style="display: {1}" class="{2}">', layerID, visibility, (nodes[i].cssClass ? nodes[i].cssClass : this.defaultClass)) : this.stringFormat('<div class="{0}">', nodes[i].cssClass ? nodes[i].cssClass : this.defaultClass);
221                         var onMDown   = this.doesMenu() && nodes[i].n.length  && nodes[i].isDynamic ? this.stringFormat('onmousedown="{0}.toggleBranch(\'{1}\', true)" style="cursor: pointer; cursor: hand"', this.myname, layerID) : '';
222                         var imgTag    = this.stringFormat('<img src="{0}/{1}{2}.gif" width="20" height="20" align="top" border="0" name="img_{3}" {4}>', this.iconpath, gifname, modifier, layerID, onMDown);
223                         var linkTarget= nodes[i].linkTarget ? nodes[i].linkTarget : this.linkTarget;
224                         var linkStart = nodes[i].link ? this.stringFormat('<a href="{0}" target="{1}">', nodes[i].link, linkTarget) : '';
225                         var linkEnd = '</a>';
226                         
227                         this.output += this.stringFormat('{0}<nobr>{1}{2}{3}{4}<span {5}>{6}</span>{7}</nobr><br></div>',
228                                           layerTag,
229                                                           prepend,
230                                           parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages) ? '' : imgTag,
231                                                           iconimg,
232                                                           linkStart,
233                                                           eventHandlers,
234                                                           nodes[i].title,
235                                                           linkEnd);
237                         /**
238                 * Traverse sub nodes ?
239                 */
240                         if (nodes[i].n.length) {
241                                 /**
242                     * Determine what to prepend. If there is only one root
243                                 * node then the prepend to pass to children is nothing.
244                                 * Otherwise it depends on where we are in the tree.
245                     */
246                                 if (parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages)) {
247                                         var newPrepend = '';
248         
249                                 } else if (i < (nodes.length - 1)) {
250                                         var newPrepend = prepend + this.stringFormat('<img src="{0}/line.gif" width="20" height="20" align="top">', this.iconpath);
251         
252                                 } else {
253                                         var newPrepend = prepend + this.stringFormat('<img src="{0}/linebottom.gif" width="20" height="20" align="top">', this.iconpath);
254                                 }
256                                 this.drawMenu(nodes[i].n,
257                                               arrayCopy(level),
258                                               newPrepend,
259                                               nodes[i].expanded,
260                                               expanded ? 'inline' : 'none',
261                                               layerID);
262                         }
263                 }
264         }
267 * Writes the output generated by drawMenu() to the page
269         TreeMenu.prototype.writeOutput = function ()
270         {
271                 document.write(this.output);
272         }
275 * Toggles a branches visible status. Called from resetBranches()
276 * and also when a +/- graphic is clicked.
278         TreeMenu.prototype.toggleBranch = function (layerID, updateStatus) // OPTIONAL ARGS: fireEvents = true
279         {
280                 var currentDisplay = this.getLayer(layerID).style.display;
281                 var newDisplay     = (this.branchStatus[layerID] && currentDisplay == 'inline') ? 'none' : 'inline';
282                 var fireEvents     = arguments[2] != null ? arguments[2] : true;
284                 for (var i=0; i<this.layerRelations[layerID].length; i++) {
286                         if (this.branchStatus[this.layerRelations[layerID][i]]) {
287                                 this.toggleBranch(this.layerRelations[layerID][i], false);
288                         }
289         
290                         this.getLayer(this.layerRelations[layerID][i]).style.display = newDisplay;
291                 }
292         
293                 if (updateStatus) {
294                         this.branchStatus[layerID] = !this.branchStatus[layerID];
295         
296                         /**
297                 * Persistence
298                 */
299                         if (this.doesPersistence() && !arguments[2] && this.usePersistence) {
300                                 this.setExpandedStatusForCookie(layerID, this.branchStatus[layerID]);
301                         }
303                         /**
304                         * Fire custom events
305                         */
306                         if (fireEvents) {
307                                 nodeObject = this.nodeRefs[layerID];
308         
309                                 if (nodeObject.ontoggle != null) {
310                                         eval(nodeObject.ontoggle);
311                                 }
312                                 
313                                 if (newDisplay == 'none' && nodeObject.oncollapse != null) {
314                                         eval(nodeObject.oncollapse);
315                                 } else if (newDisplay == 'inline' && nodeObject.onexpand != null){
316                                         eval(nodeObject.onexpand);
317                                 }
318                         }
320                         // Swap image
321                         this.swapImage(layerID);
322                 }
324                 // Swap icon
325                 this.swapIcon(layerID);
326         }
329 * Swaps the plus/minus branch images
331         TreeMenu.prototype.swapImage = function (layerID)
332         {
333                 var imgSrc = document.images['img_' + layerID].src;
334         
335                 var re = /^(.*)(plus|minus)(bottom|top|single)?.gif$/
336                 if (matches = imgSrc.match(re)) {
337         
338                         document.images['img_' + layerID].src = this.stringFormat('{0}{1}{2}{3}',
339                                                                         matches[1],
340                                                                                                                         matches[2] == 'plus' ? 'minus' : 'plus',
341                                                                                                                         matches[3] ? matches[3] : '',
342                                                                                                                         '.gif');
343                 }
344         }
347 * Swaps the icon for the expanded icon if one
348 * has been supplied.
350         TreeMenu.prototype.swapIcon = function (layerID)
351         {
352                 if (document.images['icon_' + layerID]) {
353                         var imgSrc = document.images['icon_' + layerID].src;
354         
355                         if (this.nodeRefs[layerID].icon && this.nodeRefs[layerID].expandedIcon) {
356                                 var newSrc = (imgSrc.indexOf(this.nodeRefs[layerID].expandedIcon) == -1 ? this.nodeRefs[layerID].expandedIcon : this.nodeRefs[layerID].icon);
357         
358                                 document.images['icon_' + layerID].src = this.iconpath + '/' + newSrc;
359                         }
360                 }
361         }
364 * Can the browser handle the dynamic menu?
366         TreeMenu.prototype.doesMenu = function ()
367         {
368                 return (is_ie4up || is_nav6up || is_gecko || is_opera7);
369         }
372 * Can the browser handle save the branch status
374         TreeMenu.prototype.doesPersistence = function ()
375         {
376                 return (is_ie4up || is_gecko || is_nav6up || is_opera7);
377         }
380 * Returns the appropriate layer accessor
382         TreeMenu.prototype.getLayer = function (layerID)
383         {
384                 if (is_ie4) {
385                         return document.all(layerID);
386         
387                 } else if (document.getElementById(layerID)) {
388                         return document.getElementById(layerID);
389         
390                 } else if (document.all(layerID)) {
391                         return document.all(layerID);
392                 }
393         }
396 * Save the status of the layer
398         TreeMenu.prototype.setExpandedStatusForCookie = function (layerID, expanded)
399         {
400                 this.cookieStatuses[layerID] = expanded;
401                 this.saveCookie();
402         }
405 * Load the status of the layer
407         TreeMenu.prototype.getExpandedStatusFromCookie = function (layerID)
408         {
409                 if (this.cookieStatuses[layerID]) {
410                         return this.cookieStatuses[layerID];
411                 }
413                 return false;
414         }
417 * Saves the cookie that holds which branches are expanded.
418 * Only saves the details of the branches which are expanded.
420         TreeMenu.prototype.saveCookie = function ()
421         {
422                 var cookieString = new Array();
424                 for (var i in this.cookieStatuses) {
425                         if (this.cookieStatuses[i] == true) {
426                                 cookieString[cookieString.length] = i;
427                         }
428                 }
429                 
430                 document.cookie = 'TreeMenuBranchStatus=' + cookieString.join(':');
431         }
434 * Reads cookie parses it for status info and
435 * stores that info in the class member.
437         TreeMenu.prototype.loadCookie = function ()
438         {
439                 var cookie = document.cookie.split('; ');
441                 for (var i=0; i < cookie.length; i++) {
442                         var crumb = cookie[i].split('=');
443                         if ('TreeMenuBranchStatus' == crumb[0] && crumb[1]) {
444                                 var expandedBranches = crumb[1].split(':');
445                                 for (var j=0; j<expandedBranches.length; j++) {
446                                         this.cookieStatuses[expandedBranches[j]] = true;
447                                 }
448                         }
449                 }
450         }
453 * Reset branch status
455         TreeMenu.prototype.resetBranches = function ()
456         {
457                 if (!this.doesPersistence()) {
458                         return false;
459                 }
460                 
461                 this.loadCookie();
463                 for (var i=0; i<this.branches.length; i++) {
464                         var status = this.getExpandedStatusFromCookie(this.branches[i]);
465                         // Only update if it's supposed to be expanded and it's not already
466                         if (status == true && this.branchStatus[this.branches[i]] != true) {
467                                 if (this.checkParentVisibility(this.branches[i])) {
468                                         this.toggleBranch(this.branches[i], true, false);
469                                 } else {
470                                         this.branchStatus[this.branches[i]] = true;
471                                         this.swapImage(this.branches[i]);
472                                 }
473                         }
474                 }
475         }
478 * ViSolve - Function to expand all the branches
480         TreeMenu.prototype.expandAll = function ()
481         {
482         
483                 if (!this.doesPersistence()) {
484                         return false;
485                 }
486                 
487                 this.loadCookie();
488         
489                 for (var i=0; i<this.branches.length; i++) {
490                         var status = this.getExpandedStatusFromCookie(this.branches[i]);
491                         // Only update if it's supposed to be expanded and it is
492                         if (status == false && this.branchStatus[this.branches[i]] == false) {
493                                 if (this.checkParentVisibility(this.branches[i])) {
494                                         this.toggleBranch(this.branches[i], true, false);
495                                 } else {
496                                         this.branchStatus[this.branches[i]] = true;
497                                         this.swapImage(this.branches[i]);
498                                 }
499                         }
500                 }
501                 
502                 
503         }
506 * Collapse all branches
508         TreeMenu.prototype.collapseAll = function ()
509         {
510         
511                 if (!this.doesPersistence()) {
512                         return false;
513                 }
514                 
515                 this.loadCookie();
516         
517                 for (var i=0; i<this.branches.length; i++) {
518                         var status = this.getExpandedStatusFromCookie(this.branches[i]);
519                         // Only update if it's supposed to be expanded and it is
520                         if (status == true && this.branchStatus[this.branches[i]] == true) {
521                                 if (this.checkParentVisibility(this.branches[i])) {
522                                         this.toggleBranch(this.branches[i], true, false);
523                                 } else {
524                                         this.branchStatus[this.branches[i]] = true;
525                                         this.swapImage(this.branches[i]);
526                                 }
527                         }
528                 }
529                 
530                 
531         }
536 * Checks whether a branch should be open
537 * or not based on its parents' status
539         TreeMenu.prototype.checkParentVisibility = function (layerID)
540         {
541                 if (this.in_array(this.childParents[layerID], this.branches)
542                     && this.branchStatus[this.childParents[layerID]]
543                         && this.checkParentVisibility(this.childParents[layerID]) ) {
544                         
545                         return true;
546         
547                 } else if (this.childParents[layerID] == null) {
548                         return true;
549                 }
550                 
551                 return false;
552         }
555 * New C# style string formatter
557         TreeMenu.prototype.stringFormat = function (strInput)
558         {
559                 var idx = 0;
560         
561                 for (var i=1; i<arguments.length; i++) {
562                         while ((idx = strInput.indexOf('{' + (i - 1) + '}', idx)) != -1) {
563                                 strInput = strInput.substring(0, idx) + arguments[i] + strInput.substr(idx + 3);
564                         }
565                 }
566                 
567                 return strInput;
568         }
571 * Also much adored, the PHP implode() function
573         TreeMenu.prototype.implode = function (seperator, input)
574         {
575                 var output = '';
576         
577                 for (var i=0; i<input.length; i++) {
578                         if (i == 0) {
579                                 output += input[i];
580                         } else {
581                                 output += seperator + input[i];
582                         }
583                 }
584                 
585                 return output;
586         }
589 * Aah, all the old favourites are coming out...
591         TreeMenu.prototype.in_array = function (item, arr)
592         {
593                 for (var i=0; i<arr.length; i++) {
594                         if (arr[i] == item) {
595                                 return true;
596                         }
597                 }
598         
599                 return false;
600         }
603 * TreeNode Class
605         function TreeNode(title, icon, link, expanded, isDynamic, cssClass, linkTarget, expandedIcon)
606         {
607                 this.title        = title;
608                 this.icon         = icon;
609                 this.expandedIcon = expandedIcon;
610                 this.link         = link;
611                 this.expanded     = expanded;
612                 this.isDynamic    = isDynamic;
613                 this.cssClass     = cssClass;
614                 this.linkTarget   = linkTarget;
615                 this.n            = new Array();
616                 this.events       = new Array();
617                 this.handlers     = null;
618                 this.oncollapse   = null;
619                 this.onexpand     = null;
620                 this.ontoggle     = null;
621         }
624 * Adds a node to an already existing node
626         TreeNode.prototype.addItem = function (newNode)
627         {
628                 newIndex = this.n.length;
629                 this.n[newIndex] = newNode;
630                 
631                 return this.n[newIndex];
632         }
635 * Sets an event for this particular node
637         TreeNode.prototype.setEvent = function (eventName, eventHandler)
638         {
639                 switch (eventName.toLowerCase()) {
640                         case 'onexpand':
641                                 this.onexpand = eventHandler;
642                                 break;
644                         case 'oncollapse':
645                                 this.oncollapse = eventHandler;
646                                 break;
648                         case 'ontoggle':
649                                 this.ontoggle = eventHandler;
650                                 break;
652                         default:
653                                 this.events[eventName] = eventHandler;
654                 }
655         }
658 * That's the end of the tree classes. What follows is
659 * the browser detection code.
661         
663 //<!--
664 // Ultimate client-side JavaScript client sniff. Version 3.03
665 // (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
666 // Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
667 // Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
668 //                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV
669 // Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4,
670 //                      correct Opera 5 detection
671 //                      add support for winME and win2k
672 //                      synch with browser-type-oo.js
673 // Revised 26 Mar 01 to correct Opera detection
674 // Revised 02 Oct 01 to add IE6 detection
676 // Everything you always wanted to know about your JavaScript client
677 // but were afraid to ask. Creates "is_" variables indicating:
678 // (1) browser vendor:
679 //     is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
680 // (2) browser version number:
681 //     is_major (integer indicating major version number: 2, 3, 4 ...)
682 //     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
683 // (3) browser vendor AND major version number
684 //     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
685 //     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
686 //     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
687 // (4) JavaScript version number:
688 //     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
689 // (5) OS platform and version:
690 //     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
691 //     is_os2
692 //     is_mac, is_mac68k, is_macppc
693 //     is_unix
694 //     is_sun, is_sun4, is_sun5, is_suni86
695 //     is_irix, is_irix5, is_irix6
696 //     is_hpux, is_hpux9, is_hpux10
697 //     is_aix, is_aix1, is_aix2, is_aix3, is_aix4
698 //     is_linux, is_sco, is_unixware, is_mpras, is_reliant
699 //     is_dec, is_sinix, is_freebsd, is_bsd
700 //     is_vms
702 // See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
703 // http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
704 // for detailed lists of userAgent strings.
706 // Note: you don't want your Nav4 or IE4 code to "turn off" or
707 // stop working when new versions of browsers are released, so
708 // in conditional code forks, use is_ie5up ("IE 5.0 or greater")
709 // is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
710 // to check version in code which you want to work on future
711 // versions.
714 * Severly curtailed all this as only certain elements
715 * are required by TreeMenu, specifically:
716 *  o is_ie4up
717 *  o is_nav6up
718 *  o is_gecko
721     // convert all characters to lowercase to simplify testing
722     var agt=navigator.userAgent.toLowerCase();
724     // *** BROWSER VERSION ***
725     // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
726     var is_major = parseInt(navigator.appVersion);
727     var is_minor = parseFloat(navigator.appVersion);
729     // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
730     // If you want to allow spoofing, take out the tests for opera and webtv.
731     var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
732                 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
733                 && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
734     var is_nav6up = (is_nav && (is_major >= 5));
735     var is_gecko = (agt.indexOf('gecko') != -1);
738     var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
739     var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
740     var is_ie4up  = (is_ie && (is_major >= 4));
741         
742         var is_opera  = (agt.indexOf("opera") != -1);
743         var is_opera7 = is_opera && (agt.indexOf("opera 7") != -1);
745         // Patch from Harald Fielker
746     if (agt.indexOf('konqueror') != -1) {
747         var is_nav    = false;
748         var is_nav6up = false;
749         var is_gecko  = false;
750         var is_ie     = true;
751         var is_ie4    = true;
752         var is_ie4up  = true;
753     }
754 //--> end hide JavaScript