ActionBar: neue Option »only_once«, um Buttons nur einmal anklicken zu können
[kivitendo-erp.git] / js / dhtmlsuite / menu-for-applications.js
1 /************************************************************************************************************\r
2         @fileoverview\r
3         DHTML Suite for Applications.\r
4         Copyright (C) 2006  Alf Magne Kalleland(post@dhtmlgoodies.com)<br>\r
5         <br>\r
6         This library is free software; you can redistribute it and/or<br>\r
7         modify it under the terms of the GNU Lesser General Public<br>\r
8         License as published by the Free Software Foundation; either<br>\r
9         version 2.1 of the License, or (at your option) any later version.<br>\r
10         <br>\r
11         This library is distributed in the hope that it will be useful,<br>\r
12         but WITHOUT ANY WARRANTY; without even the implied warranty of<br>\r
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>\r
14         Lesser General Public License for more details.<br>\r
15         <br>\r
16         You should have received a copy of the GNU Lesser General Public<br>\r
17         License along with this library; if not, write to the Free Software<br>\r
18         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA<br>\r
19         <br>\r
20         <br>\r
21         www.dhtmlgoodies.com<br>\r
22         Alf Magne Kalleland<br>\r
23 \r
24 ************************************************************************************************************/\r
25 \r
26 \r
27 /**\r
28  * \r
29  * @package DHTMLSuite for applications\r
30  * @copyright Copyright &copy; 2006, www.dhtmlgoodies.com\r
31  * @author Alf Magne Kalleland <post@dhtmlgoodies.com>\r
32  */\r
33 \r
34 \r
35 /************************************************************************************************************\r
36 *\r
37 * Global variables\r
38 *\r
39 ************************************************************************************************************/\r
40 \r
41 \r
42 // {{{ DHTMLSuite.createStandardObjects()\r
43 /**\r
44  * Create objects used by all scripts\r
45  *\r
46  * @public\r
47  */\r
48 \r
49 \r
50 var DHTMLSuite = new Object();\r
51 \r
52 var standardObjectsCreated = false;     // The classes below will check this variable, if it is false, default help objects will be created\r
53 DHTMLSuite.eventElements = new Array(); // Array of elements that has been assigned to an event handler.\r
54 \r
55 DHTMLSuite.createStandardObjects = function()\r
56 {\r
57         DHTMLSuite.clientInfoObj = new DHTMLSuite.clientInfo(); // Create browser info object\r
58         DHTMLSuite.clientInfoObj.init();        \r
59         if(!DHTMLSuite.configObj){      // If this object isn't allready created, create it.\r
60                 DHTMLSuite.configObj = new DHTMLSuite.config(); // Create configuration object.\r
61                 DHTMLSuite.configObj.init();\r
62         }\r
63         DHTMLSuite.commonObj = new DHTMLSuite.common(); // Create configuration object.\r
64         DHTMLSuite.variableStorage = new DHTMLSuite.globalVariableStorage();;   // Create configuration object.\r
65         DHTMLSuite.commonObj.init();\r
66         window.onunload = function() { DHTMLSuite.commonObj.__clearGarbage(); }\r
67         \r
68         standardObjectsCreated = true;\r
69 \r
70         \r
71 }\r
72 \r
73     \r
74 \r
75 \r
76 /************************************************************************************************************\r
77 *       Configuration class used by most of the scripts\r
78 *\r
79 *       Created:                        August, 19th, 2006\r
80 *       Update log:\r
81 *\r
82 ************************************************************************************************************/\r
83 \r
84 \r
85 /**\r
86 * @constructor\r
87 * @class Store global variables/configurations used by the classes below. Example: If you want to  \r
88 *                change the path to the images used by the scripts, change it here. An object of this   \r
89 *                class will always be available to the other classes. The name of this object is \r
90 *               "DHTMLSuite.configObj". <br><br>\r
91 *                       \r
92 *               If you want to create an object of this class manually, remember to name it "DHTMLSuite.configObj"\r
93 *               This object should then be created before any other objects. This is nescessary if you want\r
94 *               the other objects to use the values you have put into the object. <br>\r
95 * @version                              1.0\r
96 * @version 1.0\r
97 * @author       Alf Magne Kalleland(www.dhtmlgoodies.com)\r
98 **/\r
99 DHTMLSuite.config = function()\r
100 {\r
101         var imagePath;  // Path to images used by the classes. \r
102         var cssPath;    // Path to CSS files used by the DHTML suite.           \r
103 }\r
104 \r
105 \r
106 DHTMLSuite.config.prototype = {\r
107         // {{{ init()\r
108         /**\r
109          *\r
110          * @public\r
111          */\r
112         init : function()\r
113         {\r
114                 this.imagePath = '../images_dhtmlsuite/';       // Path to images               \r
115                 this.cssPath = '../css_dhtmlsuite/';    // Path to images               \r
116         }       \r
117         // }}}\r
118         ,\r
119         // {{{ setCssPath()\r
120     /**\r
121      * This method will save a new CSS path, i.e. where the css files of the dhtml suite are located.\r
122      *\r
123      * @param string newCssPath = New path to css files\r
124      * @public\r
125      */\r
126         \r
127         setCssPath : function(newCssPath)\r
128         {\r
129                 this.cssPath = newCssPath;\r
130         }\r
131         // }}}\r
132         ,\r
133         // {{{ setImagePath()\r
134     /**\r
135      * This method will save a new image file path, i.e. where the image files used by the dhtml suite ar located\r
136      *\r
137      * @param string newImagePath = New path to image files\r
138      * @public\r
139      */\r
140         setImagePath : function(newImagePath)\r
141         {\r
142                 this.imagePath = newImagePath;\r
143         }\r
144         // }}}\r
145 }\r
146 \r
147 \r
148 \r
149 DHTMLSuite.globalVariableStorage = function()\r
150 {\r
151         var menuBar_highlightedItems;   // Array of highlighted menu bar items\r
152         this.menuBar_highlightedItems = new Array();\r
153         \r
154         var arrayOfDhtmlSuiteObjects;   // Array of objects of class menuItem.\r
155         this.arrayOfDhtmlSuiteObjects = new Array();\r
156 }\r
157 \r
158 DHTMLSuite.globalVariableStorage.prototype = {\r
159         \r
160 }\r
161 \r
162 \r
163 /************************************************************************************************************\r
164 *       A class with general methods used by most of the scripts\r
165 *\r
166 *       Created:                        August, 19th, 2006\r
167 *       Purpose of class:       A class containing common method used by one or more of the gui classes below, \r
168 *                                               example: loadCSS. \r
169 *                                               An object("DHTMLSuite.commonObj") of this  class will always be available to the other classes. \r
170 *       Update log:\r
171 *\r
172 ************************************************************************************************************/\r
173 \r
174 \r
175 /**\r
176 * @constructor\r
177 * @class A class containing common method used by one or more of the gui classes below, example: loadCSS. An object("DHTMLSuite.commonObj") of this  class will always be available to the other classes. \r
178 * @version 1.0\r
179 * @author       Alf Magne Kalleland(www.dhtmlgoodies.com)\r
180 **/\r
181 \r
182 DHTMLSuite.common = function()\r
183 {\r
184         var loadedCSSFiles;     // Array of loaded CSS files. Prevent same CSS file from being loaded twice.\r
185         var cssCacheStatus;     // Css cache status\r
186         var eventElements;\r
187         \r
188         this.cssCacheStatus = true;     // Caching of css files = on(Default)\r
189         this.eventElements = new Array();       \r
190 }\r
191 \r
192 DHTMLSuite.common.prototype = {\r
193         \r
194         // {{{ init()\r
195     /**\r
196      * This method initializes the DHTMLSuite_common object.\r
197      *\r
198      * @public\r
199      */\r
200         \r
201         init : function()\r
202         {\r
203                 this.loadedCSSFiles = new Array();\r
204         }       \r
205         // }}}\r
206         ,\r
207         // {{{ loadCSS()\r
208     /**\r
209      * This method loads a CSS file(Cascading Style Sheet) dynamically - i.e. an alternative to <link> tag in the document.\r
210      *\r
211      * @param string cssFileName = New path to image files\r
212      * @public\r
213      */\r
214         \r
215         loadCSS : function(cssFileName)\r
216         {\r
217                 \r
218                 if(!this.loadedCSSFiles[cssFileName]){\r
219                         this.loadedCSSFiles[cssFileName] = true;\r
220                         var linkTag = document.createElement('LINK');\r
221                         if(!this.cssCacheStatus){\r
222                                 if(cssFileName.indexOf('?')>=0)cssFileName = cssFileName + '&'; else cssFileName = cssFileName + '?';\r
223                                 cssFileName = cssFileName + 'rand='+ Math.random();     // To prevent caching\r
224                         }\r
225                         linkTag.href = DHTMLSuite.configObj.cssPath + cssFileName;\r
226                         linkTag.rel = 'stylesheet';\r
227                         linkTag.media = 'screen';\r
228                         linkTag.type = 'text/css';\r
229                         document.getElementsByTagName('HEAD')[0].appendChild(linkTag);  \r
230                         \r
231                 }\r
232         }       \r
233         // }}}\r
234         ,\r
235         // {{{ getTopPos()\r
236     /**\r
237      * This method will return the top coordinate(pixel) of an object\r
238      *\r
239      * @param Object inputObj = Reference to HTML element\r
240      * @public\r
241      */ \r
242         getTopPos : function(inputObj)\r
243         {               \r
244           var returnValue = inputObj.offsetTop;\r
245       if (returnValue > 700) returnValue = 0;\r
246           while((inputObj = inputObj.offsetParent) != null){\r
247                 if(inputObj.tagName!='HTML'){\r
248                         returnValue += (inputObj.offsetTop - inputObj.scrollTop);\r
249                         if(document.all)returnValue+=inputObj.clientTop;\r
250                 }\r
251           } \r
252           return returnValue;\r
253         }\r
254         // }}}  \r
255         ,       \r
256         // {{{ setCssCacheStatus()\r
257     /**\r
258      * Specify if css files should be cached or not. \r
259      *\r
260      *  @param Boolean cssCacheStatus = true = cache on, false = cache off\r
261      *\r
262      * @public\r
263      */ \r
264         setCssCacheStatus : function(cssCacheStatus)\r
265         {               \r
266           this.cssCacheStatus = cssCacheStatus;\r
267         }\r
268         // }}}  \r
269         ,\r
270         // {{{ getLeftPos()\r
271     /**\r
272      * This method will return the left coordinate(pixel) of an object\r
273      *\r
274      * @param Object inputObj = Reference to HTML element\r
275      * @public\r
276      */ \r
277         getLeftPos : function(inputObj)\r
278         {         \r
279           var returnValue = inputObj.offsetLeft;\r
280           while((inputObj = inputObj.offsetParent) != null){\r
281                 if(inputObj.tagName!='HTML'){\r
282                         returnValue += inputObj.offsetLeft;\r
283                         if(document.all)returnValue+=inputObj.clientLeft;\r
284                 }\r
285           }\r
286           return returnValue;\r
287         }\r
288         // }}}\r
289         ,\r
290         // {{{ cancelEvent()\r
291     /**\r
292      *\r
293      *  This function only returns false. It is used to cancel selections and drag\r
294      *\r
295      * \r
296      * @public\r
297      */ \r
298         \r
299         cancelEvent : function()\r
300         {\r
301                 return false;\r
302         }\r
303         // }}}  \r
304         ,\r
305         // {{{ addEvent()\r
306     /**\r
307      *\r
308      *  This function adds an event listener to an element on the page.\r
309      *\r
310      *  @param Object whichObject = Reference to HTML element(Which object to assigne the event)\r
311      *  @param String eventType = Which type of event, example "mousemove" or "mouseup"\r
312      *  @param functionName = Name of function to execute. \r
313      * \r
314      * @public\r
315      */ \r
316         addEvent : function(whichObject,eventType,functionName)\r
317         { \r
318           if(whichObject.attachEvent){ \r
319             whichObject['e'+eventType+functionName] = functionName; \r
320             whichObject[eventType+functionName] = function(){whichObject['e'+eventType+functionName]( window.event );} \r
321             whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName] ); \r
322           } else \r
323             whichObject.addEventListener(eventType,functionName,false);             \r
324           this.__addEventElement(whichObject);\r
325           delete(whichObject);\r
326           // whichObject = null;\r
327         } \r
328         // }}}  \r
329         ,       \r
330         // {{{ removeEvent()\r
331     /**\r
332      *\r
333      *  This function removes an event listener from an element on the page.\r
334      *\r
335      *  @param Object whichObject = Reference to HTML element(Which object to assigne the event)\r
336      *  @param String eventType = Which type of event, example "mousemove" or "mouseup"\r
337      *  @param functionName = Name of function to execute. \r
338      * \r
339      * @public\r
340      */         \r
341         removeEvent : function(whichObject,eventType,functionName)\r
342         { \r
343           if(whichObject.detachEvent){ \r
344             whichObject.detachEvent('on'+eventType, whichObject[eventType+functionName]); \r
345             whichObject[eventType+functionName] = null; \r
346           } else \r
347             whichObject.removeEventListener(eventType,functionName,false); \r
348         } \r
349         ,\r
350         // {{{ __clearGarbage()\r
351     /**\r
352      *\r
353      *  This function is used for Internet Explorer in order to clear memory when the page unloads.\r
354      *\r
355      * \r
356      * @private\r
357      */ \r
358     __clearGarbage : function()\r
359     {\r
360                 /* Example of event which causes memory leakage in IE \r
361                 \r
362                 DHTMLSuite.commonObj.addEvent(expandRef,"click",function(){ window.refToMyMenuBar[index].__changeMenuBarState(this); })\r
363                 \r
364                 We got a circular reference.\r
365                 \r
366                 */\r
367                 \r
368         if(!DHTMLSuite.clientInfoObj.isMSIE)return;\r
369         \r
370         for(var no in DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects){\r
371                 DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[no] = false;                        \r
372         }\r
373         \r
374         for(var no=0;no<DHTMLSuite.eventElements.length;no++){\r
375                 DHTMLSuite.eventElements[no].onclick = null;\r
376                 DHTMLSuite.eventElements[no].onmousedown = null;\r
377                 DHTMLSuite.eventElements[no].onmousemove = null;\r
378                 DHTMLSuite.eventElements[no].onmouseout = null;\r
379                 DHTMLSuite.eventElements[no].onmouseover = null;\r
380                 DHTMLSuite.eventElements[no].onmouseup = null;\r
381                 DHTMLSuite.eventElements[no].onfocus = null;\r
382                 DHTMLSuite.eventElements[no].onblur = null;\r
383                 DHTMLSuite.eventElements[no].onkeydown = null;\r
384                 DHTMLSuite.eventElements[no].onkeypress = null;\r
385                 DHTMLSuite.eventElements[no].onkeyup = null;\r
386                 DHTMLSuite.eventElements[no].onselectstart = null;\r
387                 DHTMLSuite.eventElements[no].ondragstart = null;\r
388                 DHTMLSuite.eventElements[no].oncontextmenu = null;\r
389                 DHTMLSuite.eventElements[no].onscroll = null;\r
390                 \r
391         }\r
392         window.onunload = null;\r
393         DHTMLSuite = null;\r
394 \r
395     }           \r
396     \r
397     ,\r
398         // {{{ __addEventElement()\r
399     /**\r
400      *\r
401      *  Add element to garbage collection array. The script will loop through this array and remove event handlers onload in ie.\r
402      *\r
403      * \r
404      * @private\r
405      */     \r
406     __addEventElement : function(el)\r
407     {\r
408         DHTMLSuite.eventElements[DHTMLSuite.eventElements.length] = el;    \r
409     }\r
410     \r
411     ,\r
412         // {{{ getSrcElement()\r
413     /**\r
414      *\r
415      *  Returns a reference to the element which triggered an event.\r
416      *  @param Event e = Event object\r
417      *\r
418      * \r
419      * @private\r
420      */        \r
421     getSrcElement : function(e)\r
422     {\r
423         var el;\r
424                 // Dropped on which element\r
425                 if (e.target) el = e.target;\r
426                         else if (e.srcElement) el = e.srcElement;\r
427                         if (el.nodeType == 3) // defeat Safari bug\r
428                                 el = el.parentNode;\r
429                 return el;      \r
430     }               \r
431         \r
432 }\r
433 \r
434 \r
435 /************************************************************************************************************\r
436 *       Client info class\r
437 *\r
438 *       Created:                        August, 18th, 2006\r
439 *       Update log:\r
440 *\r
441 ************************************************************************************************************/\r
442 \r
443 /**\r
444 * @constructor\r
445 * @class Purpose of class: Provide browser information to the classes below. Instead of checking for\r
446 *                browser versions and browser types in the classes below, they should check this\r
447 *                easily by referncing properties in the class below. An object("DHTMLSuite.clientInfoObj") of this \r
448 *                class will always be accessible to the other classes. * @version 1.0\r
449 * @author       Alf Magne Kalleland(www.dhtmlgoodies.com)\r
450 **/\r
451 \r
452 \r
453 DHTMLSuite.clientInfo = function()\r
454 {\r
455         var browser;                    // Complete user agent information\r
456         \r
457         var isOpera;                    // Is the browser "Opera"\r
458         var isMSIE;                             // Is the browser "Internet Explorer"   \r
459         var isFirefox;                  // Is the browser "Firefox"\r
460         var navigatorVersion;   // Browser version\r
461 }\r
462         \r
463 DHTMLSuite.clientInfo.prototype = {\r
464         \r
465         /**\r
466         *       Constructor\r
467         *       Params:                 none:\r
468         *       return value:   none;\r
469         **/\r
470         // {{{ init()\r
471     /**\r
472      *\r
473          *\r
474      *  This method initializes the script\r
475      *\r
476      * \r
477      * @public\r
478      */ \r
479         \r
480         init : function()\r
481         {\r
482                 this.browser = navigator.userAgent;     \r
483                 this.isOpera = (this.browser.toLowerCase().indexOf('opera')>=0)?true:false;\r
484                 this.isFirefox = (this.browser.toLowerCase().indexOf('firefox')>=0)?true:false;\r
485                 this.isMSIE = (this.browser.toLowerCase().indexOf('msie')>=0)?true:false;\r
486                 this.isSafari = (this.browser.toLowerCase().indexOf('safari')>=0)?true:false;\r
487                 this.navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;\r
488         }       \r
489         // }}}          \r
490 }\r
491 \r
492 /************************************************************************************************************\r
493 *       DHTML menu model item class\r
494 *\r
495 *       Created:                                                October, 30th, 2006\r
496 *       @class Purpose of class:                Save data about a menu item.\r
497 *                       \r
498 *\r
499 *\r
500 *       Update log:\r
501 *\r
502 ************************************************************************************************************/\r
503 \r
504 DHTMLSuite.menuModelItem = function()\r
505 {\r
506         var id;                                 // id of this menu item.\r
507         var itemText;                   // Text for this menu item\r
508         var itemIcon;                   // Icon for this menu item.\r
509         var url;                                // url when click on this menu item\r
510         var parentId;                   // id of parent element\r
511         var separator;                  // is this menu item a separator\r
512         var jsFunction;                 // Js function to call onclick\r
513         var depth;                              // Depth of this menu item.\r
514         var hasSubs;                    // Does this menu item have sub items.\r
515         var type;                               // Menu item type - possible values: "top" or "sub". \r
516         var helpText;                   // Help text for this item - appear when you move your mouse over the item.\r
517         var state;\r
518         var submenuWidth;               // Width of sub menu items.\r
519         var visible;                    // Visibility of menu item.\r
520         var frameTarget;\r
521         \r
522         this.state = 'regular';\r
523 }\r
524 \r
525 DHTMLSuite.menuModelItem.prototype = {\r
526 \r
527         setMenuVars : function(id,itemText,itemIcon,url,parentId,helpText,jsFunction,type,submenuWidth,frameTarget)     \r
528         {\r
529                 this.id = id;\r
530                 this.itemText = itemText;\r
531                 this.itemIcon = itemIcon;\r
532                 this.url = url;\r
533                 this.parentId = parentId;\r
534                 this.jsFunction = jsFunction;\r
535                 this.separator = false;\r
536                 this.depth = false;\r
537                 this.hasSubs = false;\r
538                 this.helpText = helpText;\r
539                 this.submenuWidth = submenuWidth;\r
540                 this.visible = true;\r
541                 this.frameTarget = frameTarget;\r
542                 if(!type){\r
543                         if(this.parentId)this.type = 'top'; else this.type='sub';\r
544                 }else this.type = type;\r
545                 \r
546 \r
547         }\r
548         // }}}  \r
549         ,\r
550         // {{{ setState()\r
551     /**\r
552      *  Update the state attribute of a menu item.\r
553      *\r
554      *  @param String newState New state of this item\r
555      * @public  \r
556      */         \r
557         setAsSeparator : function(id,parentId)\r
558         {\r
559                 this.id = id;\r
560                 this.parentId = parentId;\r
561                 this.separator = true;  \r
562                 this.visible = true;\r
563                 if(this.parentId)this.type = 'top'; else this.type='sub';               \r
564         }\r
565         // }}}  \r
566         ,\r
567         // {{{ setState()\r
568     /**\r
569      *  Update the visible attribute of a menu item.\r
570      *\r
571      *  @param Boolean visible true = visible, false = hidden.\r
572      * @public  \r
573      */         \r
574         setVisibility : function(visible)\r
575         {\r
576                 this.visible = visible;\r
577         }\r
578         // }}}  \r
579         ,\r
580         // {{{ getState()\r
581     /**\r
582      *  Return the state attribute of a menu item.\r
583      *\r
584      * @public  \r
585      */         \r
586         getState : function()\r
587         {\r
588                 return this.state;\r
589         }\r
590         // }}}  \r
591         ,\r
592         // {{{ setState()\r
593     /**\r
594      *  Update the state attribute of a menu item.\r
595      *\r
596      *  @param String newState New state of this item\r
597      * @public  \r
598      */         \r
599         setState : function(newState)\r
600         {\r
601                 this.state = newState;\r
602         }\r
603         // }}}  \r
604         ,\r
605         // {{{ setSubMenuWidth()\r
606     /**\r
607      *  Specify width of direct subs of this item.\r
608      *\r
609      *  @param int newWidth Width of sub menu group(direct sub of this item)\r
610      * @public  \r
611      */         \r
612         setSubMenuWidth : function(newWidth)\r
613         {\r
614                 this.submenuWidth = newWidth;\r
615         }\r
616         // }}}  \r
617         ,\r
618         // {{{ setIcon()\r
619     /**\r
620      *  Specify new menu icon\r
621      *\r
622      *  @param String iconPath Path to new menu icon\r
623      * @public  \r
624      */         \r
625         setIcon : function(iconPath)\r
626         {\r
627                 this.itemIcon = iconPath;\r
628         }\r
629         // }}}  \r
630         ,\r
631         // {{{ setText()\r
632     /**\r
633      *  Specify new text for the menu item.\r
634      *\r
635      *  @param String newText New text for the menu item.\r
636      * @public  \r
637      */         \r
638         setText : function(newText)\r
639         {\r
640                 this.itemText = newText;\r
641         }\r
642 }\r
643 \r
644 /************************************************************************************************************\r
645 *       DHTML menu model class\r
646 *\r
647 *       Created:                                                October, 30th, 2006\r
648 *       @class Purpose of class:                Saves menu item data\r
649 *                       \r
650 *\r
651 *       Demos of this class:                    demo-menu-strip.html\r
652 *\r
653 *       Update log:\r
654 *\r
655 ************************************************************************************************************/\r
656 \r
657 \r
658 /**\r
659 * @constructor\r
660 * @class Purpose of class:      Organize menu items for different menu widgets. demos of menus: (<a href="../../demos/demo-menu-strip.html" target="_blank">Demo</a>)\r
661 * @version 1.0\r
662 * @author       Alf Magne Kalleland(www.dhtmlgoodies.com)\r
663 */\r
664 \r
665 \r
666 DHTMLSuite.menuModel = function()\r
667 {\r
668         var menuItems;                                  // Array of menuModelItem objects\r
669         var menuItemsOrder;                     // This array is needed in order to preserve the correct order of the array above. the array above is associative\r
670                                                                         // And some browsers will loop through that array in different orders than Firefox and IE.\r
671         var submenuType;                                // Direction of menu items(one item for each depth)\r
672         var mainMenuGroupWidth;                 // Width of menu group - useful if the first group of items are listed below each other\r
673         this.menuItems = new Array();\r
674         this.menuItemsOrder = new Array();\r
675         this.submenuType = new Array();\r
676         this.submenuType[1] = 'top';\r
677         for(var no=2;no<20;no++){\r
678                 this.submenuType[no] = 'sub';\r
679         }               \r
680         if(!standardObjectsCreated)DHTMLSuite.createStandardObjects();  \r
681 }\r
682 \r
683 DHTMLSuite.menuModel.prototype = {\r
684         // {{{ addItem()\r
685     /**\r
686      *  Add separator (special type of menu item)\r
687      *\r
688          *\r
689      *\r
690      *  @param int id of menu item\r
691      *  @param string itemText = text of menu item\r
692      *  @param string itemIcon = file name of menu icon(in front of menu text. Path will be imagePath for the DHTMLSuite + file name)\r
693      *  @param string url = Url of menu item\r
694      *  @param int parent id of menu item     \r
695      *  @param String jsFunction Name of javascript function to execute. It will replace the url param. The function with this name will be called and the element triggering the action will be \r
696      *                                  sent as argument. Name of the element which triggered the menu action may also be sent as a second argument. That depends on the widget. The context menu is an example where\r
697      *                                  the element triggering the context menu is sent as second argument to this function.    \r
698      *\r
699      * @public  \r
700      */                 \r
701         addItem : function(id,itemText,itemIcon,url,parentId,helpText,jsFunction,type,submenuWidth)\r
702         {\r
703                 if(!id)id = this.__getUniqueId();       // id not present - create it dynamically.\r
704                 this.menuItems[id] = new DHTMLSuite.menuModelItem();\r
705                 this.menuItems[id].setMenuVars(id,itemText,itemIcon,url,parentId,helpText,jsFunction,type,submenuWidth);\r
706                 this.menuItemsOrder[this.menuItemsOrder.length] = id;\r
707                 return this.menuItems[id];\r
708         }\r
709         ,\r
710         // {{{ addItemsFromMarkup()\r
711     /**\r
712      *  This method creates all the menuModelItem objects by reading it from existing markup on your page.\r
713      *  Example of HTML markup:\r
714      *<br>\r
715                 &nbsp;&nbsp;&nbsp;&nbsp;&lt;ul id="menuModel">\r
716                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="50000" itemIcon="../images/disk.gif">&lt;a href="#" title="Open the file menu">File&lt;/a>\r
717                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul width="150">\r
718                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="500001" jsFunction="saveWork()" itemIcon="../images/disk.gif">&lt;a href="#" title="Save your work">Save&lt;/a>&lt;/li>\r
719                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="500002">&lt;a href="#">Save As&lt;/a>&lt;/li>\r
720                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="500004" itemType="separator">&lt;/li>\r
721                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="500003">&lt;a href="#">Open&lt;/a>&lt;/li>\r
722                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul>\r
723                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li>\r
724                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="50001">&lt;a href="#">View&lt;/a>\r
725                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul width="130">\r
726                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="500011">&lt;a href="#">Source&lt;/a>&lt;/li>\r
727                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="500012">&lt;a href="#">Debug info&lt;/a>&lt;/li>\r
728                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="500013">&lt;a href="#">Layout&lt;/a>\r
729                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul width="150">\r
730                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="5000131">&lt;a href="#">CSS&lt;/a>&nbsp;&nbsp;\r
731                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="5000132">&lt;a href="#">HTML&lt;/a>&nbsp;&nbsp;\r
732                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="5000133">&lt;a href="#">Javascript&lt;/a>&nbsp;&nbsp;\r
733                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul>\r
734                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li>\r
735                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
736                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul>\r
737                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li>\r
738                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="50003" itemType="separator">&lt;/li>\r
739                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li id="50002">&lt;a href="#">Tools&lt;/a>&lt;/li>\r
740                 <br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul>&nbsp;&nbsp;     \r
741      *\r
742      *  @param String ulId = ID of <UL> tag on your page.\r
743      *\r
744      * @public  \r
745      */         \r
746         addItemsFromMarkup : function(ulId)\r
747         {\r
748                 if(!document.getElementById(ulId)){\r
749                         alert('<UL> tag with id ' + ulId + ' does not exist');\r
750                         return;\r
751                 }\r
752                 var ulObj = document.getElementById(ulId);\r
753                 var liTags = ulObj.getElementsByTagName('LI');          \r
754                 for(var no=0;no<liTags.length;no++){    // Walking through all <li> tags in the <ul> tree\r
755                         \r
756                         var id = liTags[no].id.replace(/[^0-9]/gi,'');  // Get id of item.\r
757                         if(!id)id = this.__getUniqueId();\r
758                         this.menuItems[id] = new DHTMLSuite.menuModelItem();    // Creating new menuModelItem object\r
759                         this.menuItemsOrder[this.menuItemsOrder.length] = id;\r
760                         // Get the attributes for this new menu item.   \r
761                         \r
762                         var parentId = 0;       // Default parent id\r
763                         if(liTags[no].parentNode!=ulObj)parentId = liTags[no].parentNode.parentNode.id; // parent node exists, set parentId equal to id of parent <li>.\r
764                                                 \r
765                         /* Checking type */\r
766                         var type = liTags[no].getAttribute('itemType');                 \r
767                         if(!type)type = liTags[no].itemType;\r
768                         if(type=='separator'){  // Menu item of type "separator"\r
769                                 this.menuItems[id].setAsSeparator(id,parentId);\r
770                                 continue;       \r
771                         }\r
772                         if(parentId)type='sub'; else type = 'top';                                              \r
773         \r
774                         var aTag = liTags[no].getElementsByTagName('A')[0];     // Get a reference to sub <a> tag\r
775                         if(!aTag){\r
776                                 continue;\r
777                         }                       \r
778                         if(aTag)var itemText = aTag.innerHTML;  // Item text is set to the innerHTML of the <a> tag.\r
779                         var itemIcon = liTags[no].getAttribute('itemIcon');     // Item icon is set from the itemIcon attribute of the <li> tag.\r
780                         var url = aTag.href;    // url is set to the href attribute of the <a> tag\r
781                         if(url=='#' || url.substr(url.length-1,1)=='#')url='';  // # = empty url.\r
782       var frameTarget = aTag.target;\r
783                         \r
784                         var jsFunction = liTags[no].getAttribute('jsFunction'); // jsFunction is set from the jsFunction attribute of the <li> tag.\r
785 \r
786                         var submenuWidth = false;       // Not set from the <li> tag. \r
787                         var helpText = aTag.getAttribute('title');      \r
788                         if(!helpText)helpText = aTag.title;\r
789                         \r
790                         this.menuItems[id].setMenuVars(id,itemText,itemIcon,url,parentId,helpText,jsFunction,type,submenuWidth,frameTarget);                    \r
791                 }               \r
792                 var subUls = ulObj.getElementsByTagName('UL');\r
793                 for(var no=0;no<subUls.length;no++){\r
794                         var width = subUls[no].getAttribute('width');\r
795                         if(!width)width = subUls[no].width;     \r
796                         if(width){\r
797                                 var id = subUls[no].parentNode.id.replace(/[^0-9]/gi,'');\r
798                                 this.setSubMenuWidth(id,width);\r
799                         }\r
800                 }               \r
801                 ulObj.style.display='none';\r
802                 \r
803         }       \r
804         // }}}  \r
805         ,\r
806         // {{{ setSubMenuWidth()\r
807     /**\r
808      *  This method specifies the width of a sub menu group. This is a useful method in order to get a correct width in IE6 and prior.\r
809      *\r
810      *  @param int id = ID of parent menu item\r
811      *  @param String newWidth = Width of sub menu items.\r
812      * @public  \r
813      */         \r
814         setSubMenuWidth : function(id,newWidth)\r
815         {\r
816                 this.menuItems[id].setSubMenuWidth(newWidth);\r
817         }       \r
818         ,\r
819         // {{{ setMainMenuGroupWidth()\r
820     /**\r
821      *  Add separator (special type of menu item)\r
822      *\r
823      *  @param String newWidth = Size of a menu group\r
824      *  @param int parent id of menu item\r
825      * @public  \r
826      */                 \r
827         setMainMenuGroupWidth : function(newWidth)\r
828         {\r
829                 this.mainMenuGroupWidth = newWidth;\r
830         }\r
831         ,\r
832         // {{{ addSeparator()\r
833     /**\r
834      *  Add separator (special type of menu item)\r
835      *\r
836      *  @param int parent id of menu item\r
837      * @public  \r
838      */         \r
839         addSeparator : function(parentId)\r
840         {\r
841                 id = this.__getUniqueId();      // Get unique id\r
842                 if(!parentId)parentId = 0;\r
843                 this.menuItems[id] = new DHTMLSuite.menuModelItem();\r
844                 this.menuItems[id].setAsSeparator(id,parentId);\r
845                 this.menuItemsOrder[this.menuItemsOrder.length] = id;\r
846                 return this.menuItems[id];\r
847         }       \r
848         ,\r
849         // {{{ init()\r
850     /**\r
851      *  Initilizes the menu model. This method should be called when all items has been added to the model.\r
852      *\r
853      *\r
854      * @public  \r
855      */         \r
856         init : function()\r
857         {\r
858                 this.__getDepths();     \r
859                 this.__setHasSubs();    \r
860                 \r
861         }\r
862         // }}}  \r
863         ,\r
864         // {{{ setMenuItemVisibility()\r
865     /**\r
866      *  Save visibility of a menu item.\r
867      *  \r
868      *  @param int id = Id of menu item..\r
869      *  @param Boolean visible = Visibility of menu item.\r
870      *\r
871      * @public  \r
872      */         \r
873         setMenuItemVisibility : function(id,visible)\r
874         {\r
875                 this.menuItems[id].setVisibility(visible);              \r
876         }\r
877         // }}}\r
878         ,\r
879         // {{{ setSubMenuType()\r
880     /**\r
881      *  Set menu type for a specific menu depth.\r
882      *  \r
883      *  @param int depth = 1 = Top menu, 2 = Sub level 1...\r
884      *  @param String newType = New menu type(possible values: "top" or "sub")\r
885      *\r
886      * @private \r
887      */         \r
888         setSubMenuType : function(depth,newType)\r
889         {\r
890                 this.submenuType[depth] = newType;      \r
891                 \r
892         }\r
893         // }}}          \r
894         ,\r
895         // {{{ __getDepths()\r
896     /**\r
897      *  Create variable for the depth of each menu item.\r
898      *  \r
899      *\r
900      * @private \r
901      */         \r
902         getItems : function(parentId,returnArray)\r
903         {\r
904                 if(!parentId)return this.menuItems;\r
905                 if(!returnArray)returnArray = new Array();\r
906                 for(var no=0;no<this.menuItemsOrder.length;no++){\r
907                         var id = this.menuItemsOrder[no];\r
908                         if(!id)continue;\r
909                         if(this.menuItems[id].parentId==parentId){\r
910                                 returnArray[returnArray.length] = this.menuItems[id];\r
911                                 if(this.menuItems[id].hasSubs)return this.getItems(this.menuItems[id].id,returnArray);\r
912                         }\r
913                 }\r
914                 return returnArray;\r
915                 \r
916         }\r
917         // }}}\r
918         ,\r
919         // {{{ __getUniqueId()\r
920     /**\r
921      *  Returns a unique id for a menu item. This method is used by the addSeparator function in case an id isn't sent to the method.\r
922      *  \r
923      *\r
924      * @private \r
925      */         \r
926         __getUniqueId : function()\r
927         {\r
928                 var num = Math.random() + '';\r
929                 num = num.replace('.','');      \r
930                 num = '99' + num;               \r
931                 num = num /1;           \r
932                 while(this.menuItems[num]){\r
933                         num = Math.random() + '';\r
934                         num = num.replace('.','');      \r
935                         num = num /1;                           \r
936                 }\r
937                 return num;\r
938         }\r
939         // }}}  \r
940         ,\r
941         // {{{ __getDepths()\r
942     /**\r
943      *  Create variable for the depth of each menu item.\r
944      *  \r
945      *\r
946      * @private \r
947      */ \r
948     __getDepths : function()\r
949     {           \r
950         for(var no=0;no<this.menuItemsOrder.length;no++){\r
951                 var id = this.menuItemsOrder[no];\r
952                 if(!id)continue;\r
953                 this.menuItems[id].depth = 1;\r
954                 if(this.menuItems[id].parentId){\r
955                         this.menuItems[id].depth = this.menuItems[this.menuItems[id].parentId].depth+1;    \r
956         \r
957                 }  \r
958                 this.menuItems[id].type = this.submenuType[this.menuItems[id].depth];   // Save menu direction for this menu item.              \r
959         }       \r
960     }   \r
961     // }}}\r
962     ,       \r
963     // {{{ __setHasSubs()\r
964     /**\r
965      *  Create variable for the depth of each menu item.\r
966      *  \r
967      *\r
968      * @private \r
969      */ \r
970     __setHasSubs : function()\r
971     {           \r
972         for(var no=0;no<this.menuItemsOrder.length;no++){\r
973                 var id = this.menuItemsOrder[no];\r
974                 if(!id)continue;                \r
975                 if(this.menuItems[id].parentId){\r
976                         this.menuItems[this.menuItems[id].parentId].hasSubs = 1;\r
977                         \r
978                 }               \r
979         }       \r
980     }   \r
981     // }}}\r
982     ,\r
983         // {{{ __hasSubs()\r
984     /**\r
985      *  Does a menu item have sub elements ?\r
986      *  \r
987      *\r
988      * @private \r
989      */ \r
990         // }}}  \r
991         __hasSubs : function(id)\r
992         {\r
993                 for(var no=0;no<this.menuItemsOrder.length;no++){\r
994                         var id = this.menuItemsOrder[no];\r
995                         if(!id)continue;\r
996                         if(this.menuItems[id].parentId==id)return true;         \r
997                 }\r
998                 return false;   \r
999         }\r
1000         // }}}\r
1001         ,\r
1002         // {{{ __deleteChildNodes()\r
1003     /**\r
1004      *  Deleting child nodes of a specific parent id\r
1005      *  \r
1006      *  @param int parentId\r
1007      *\r
1008      * @private \r
1009      */ \r
1010         // }}}          \r
1011         __deleteChildNodes : function(parentId,recursive)\r
1012         {\r
1013                 var itemsToDeleteFromOrderArray = new Array();\r
1014                 for(var prop=0;prop<this.menuItemsOrder.length;prop++){\r
1015                 var id = this.menuItemsOrder[prop];\r
1016                 if(!id)continue;    \r
1017                                         \r
1018                         if(this.menuItems[id].parentId==parentId && parentId){\r
1019                                 this.menuItems[id] = false;\r
1020                                 itemsToDeleteFromOrderArray[itemsToDeleteFromOrderArray.length] = id;                           \r
1021                                 this.__deleteChildNodes(id,true);       // Recursive call.\r
1022                         }       \r
1023                 }       \r
1024                 \r
1025                 if(!recursive){\r
1026                         for(var prop=0;prop<itemsToDeleteFromOrderArray;prop++){\r
1027                                 if(!itemsToDeleteFromOrderArray[prop])continue;\r
1028                                 this.__deleteItemFromItemOrderArray(itemsToDeleteFromOrderArray[prop]);\r
1029                         }\r
1030                 }\r
1031                 this.__setHasSubs();\r
1032         }\r
1033         // }}}\r
1034         ,\r
1035         // {{{ __deleteANode()\r
1036     /**\r
1037      *  Deleting a specific node from the menu model\r
1038      *  \r
1039      *  @param int id = Id of node to delete.\r
1040      *\r
1041      * @private \r
1042      */ \r
1043         // }}}          \r
1044         __deleteANode : function(id)\r
1045         {\r
1046                 this.menuItems[id] = false;     \r
1047                 this.__deleteItemFromItemOrderArray(id);        \r
1048         }\r
1049         ,\r
1050         // {{{ __deleteItemFromItemOrderArray()\r
1051     /**\r
1052      *  Deleting a specific node from the menuItemsOrder array(The array controlling the order of the menu items).\r
1053      *  \r
1054      *  @param int id = Id of node to delete.\r
1055      *\r
1056      * @private \r
1057      */ \r
1058         // }}}          \r
1059         __deleteItemFromItemOrderArray : function(id)\r
1060         {\r
1061                 for(var no=0;no<this.menuItemsOrder.length;no++){\r
1062                         var tmpId = this.menuItemsOrder[no];\r
1063                         if(!tmpId)continue;\r
1064                         if(this.menuItemsOrder[no]==id){\r
1065                                 this.menuItemsOrder.splice(no,1);\r
1066                                 return;\r
1067                         }\r
1068                 }\r
1069                 \r
1070         }\r
1071         // }}}\r
1072         ,       \r
1073         // {{{ __appendMenuModel()\r
1074     /**\r
1075      *  Replace the sub items of a menu item with items from a new menuModel.\r
1076      *  \r
1077      *  @param menuModel newModel = An object of class menuModel - the items of this menu model will be appended to the existing menu items.\r
1078      *  @param Int parentId = Id of parent element of the appended items.\r
1079      *\r
1080      * @private \r
1081      */ \r
1082         // }}}          \r
1083         __appendMenuModel : function(newModel,parentId)\r
1084         {\r
1085                 if(!newModel)return;\r
1086                 var items = newModel.getItems();\r
1087                 for(var no=0;no<newModel.menuItemsOrder.length;no++){\r
1088                         var id = newModel.menuItemsOrder[no];\r
1089                         if(!id)continue;\r
1090                         if(!items[id].parentId)items[id].parentId = parentId;\r
1091                         this.menuItems[id] = items[id]; \r
1092                         for(var no2=0;no2<this.menuItemsOrder.length;no2++){    // Check to see if this item allready exists in the menuItemsOrder array, if it does, remove it. \r
1093                                 if(!this.menuItemsOrder[no2])continue;\r
1094                                 if(this.menuItemsOrder[no2]==items[id].id){\r
1095                                         this.menuItemsOrder.splice(no2,1);\r
1096                                 }\r
1097                         }\r
1098                         this.menuItemsOrder[this.menuItemsOrder.length] = items[id].id;         \r
1099                 }\r
1100                 this.__getDepths();             \r
1101                 this.__setHasSubs();            \r
1102         }\r
1103         // }}}\r
1104 }\r
1105 \r
1106 /* Class for menu items - a view */\r
1107 \r
1108 /************************************************************************************************************\r
1109 *       DHTML menu item class\r
1110 *\r
1111 *       Created:                                                October, 21st, 2006\r
1112 *       @class Purpose of class:                Creates the HTML for a single menu item.\r
1113 *                       \r
1114 *       Css files used by this script:  menu-item.css\r
1115 *\r
1116 *       Demos of this class:                    demo-menu-strip.html\r
1117 *\r
1118 *       Update log:\r
1119 *\r
1120 ************************************************************************************************************/\r
1121 \r
1122 /**\r
1123 * @constructor\r
1124 * @class Purpose of class:      Creates the div(s) for a menu item. This class is used by the menuBar class. You can \r
1125 *       also create a menu item and add it where you want on your page. the createItem() method will return the div\r
1126 *       for the item. You can use the appendChild() method to add it to your page. \r
1127 *\r
1128 * @version 1.0\r
1129 * @author       Alf Magne Kalleland(www.dhtmlgoodies.com)\r
1130 */\r
1131 \r
1132 \r
1133 DHTMLSuite.menuItem = function()\r
1134 {\r
1135         var layoutCSS;  \r
1136         var divElement;                                                 // the <div> element created for this menu item\r
1137         var expandElement;                                              // Reference to the arrow div (expand sub items)\r
1138         var cssPrefix;                                                  // Css prefix for the menu items.\r
1139         var modelItemRef;                                               // Reference to menuModelItem\r
1140 \r
1141 //      this.layoutCSS = 'menu-item.css';\r
1142         this.cssPrefix = 'DHTMLSuite_';\r
1143         \r
1144         if(!standardObjectsCreated)DHTMLSuite.createStandardObjects();  \r
1145                 \r
1146         \r
1147         var objectIndex;\r
1148         this.objectIndex = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects.length;\r
1149 \r
1150         \r
1151 }\r
1152 \r
1153 DHTMLSuite.menuItem.prototype = \r
1154 {\r
1155         \r
1156         /*\r
1157         *       Create a menu item.\r
1158         *\r
1159         *       @param menuModelItem menuModelItemObj = An object of class menuModelItem\r
1160         */\r
1161         createItem : function(menuModelItemObj)\r
1162         {\r
1163 //              DHTMLSuite.commonObj.loadCSS(this.layoutCSS);   // Load css\r
1164                 \r
1165                 DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[this.objectIndex] = this;\r
1166                         \r
1167                 this.modelItemRef = menuModelItemObj;\r
1168                 this.divElement = document.createElement('DIV');        // Create main div\r
1169                 this.divElement.id = 'DHTMLSuite_menuItem' + menuModelItemObj.id;       // Giving this menu item it's unque id\r
1170                 this.divElement.className = this.cssPrefix + 'menuItem_' + menuModelItemObj.type + '_regular'; \r
1171                 this.divElement.onselectstart = function() { return DHTMLSuite.commonObj.cancelEvent(false,this) };\r
1172                 if(menuModelItemObj.helpText){  // Add "title" attribute to the div tag if helpText is defined\r
1173                         this.divElement.title = menuModelItemObj.helpText;\r
1174                 }\r
1175                 \r
1176                 // Menu item of type "top"\r
1177                 if(menuModelItemObj.type=='top'){                       \r
1178                         this.__createMenuElementsOfTypeTop(this.divElement);\r
1179                 }\r
1180 \r
1181                 if(menuModelItemObj.type=='sub'){\r
1182                         this.__createMenuElementsOfTypeSub(this.divElement);\r
1183                 }\r
1184                 \r
1185                 if(menuModelItemObj.separator){\r
1186                         this.divElement.className = this.cssPrefix + 'menuItem_separator_' + menuModelItemObj.type;\r
1187                         this.divElement.innerHTML = '<span></span>';\r
1188                 }else{          \r
1189                         /* Add events */\r
1190                         var tmpVar = this.objectIndex/1;\r
1191                         //this.divElement.onclick = function(e) { DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[tmpVar].__navigate(e); }\r
1192                         this.divElement.onmousedown = this.__clickMenuItem;                     // on mouse down effect\r
1193                         this.divElement.onmouseup = this.__rolloverMenuItem;            // on mouse up effect\r
1194                         this.divElement.onmouseover = this.__rolloverMenuItem;          // mouse over effect\r
1195                         this.divElement.onmouseout = this.__rolloutMenuItem;            // mouse out effect.\r
1196                         DHTMLSuite.commonObj.__addEventElement(this.divElement);\r
1197                 }\r
1198                 return this.divElement;\r
1199         }\r
1200         // }}}\r
1201         ,\r
1202         // {{{ setLayoutCss()\r
1203     /**\r
1204      *  Creates the different parts of a menu item of type "top".\r
1205      *\r
1206      *  @param String newLayoutCss = Name of css file used for the menu items.\r
1207      *\r
1208      * @public  \r
1209      */         \r
1210         setLayoutCss : function(newLayoutCss)\r
1211         {\r
1212                 this.layoutCSS = newLayoutCss;\r
1213                 \r
1214         }\r
1215         // }}}\r
1216         ,\r
1217         // {{{ __createMenuElementsOfTypeTop()\r
1218     /**\r
1219      *  Creates the different parts of a menu item of type "top".\r
1220      *\r
1221      *  @param menuModelItem menuModelItemObj = Object of type menuModelItemObj\r
1222      *  @param Object parentEl = Reference to parent element\r
1223      *\r
1224      * @private \r
1225      */         \r
1226         __createMenuElementsOfTypeTop : function(parentEl){\r
1227                 if(this.modelItemRef.itemIcon){\r
1228                         var iconDiv = document.createElement('DIV');\r
1229                         iconDiv.innerHTML = '<img src="' + this.modelItemRef.itemIcon + '">';\r
1230                         iconDiv.id = 'menuItemIcon' + this.modelItemRef.id\r
1231                         parentEl.appendChild(iconDiv);          \r
1232                 }\r
1233                 if(this.modelItemRef.itemText){\r
1234                         var div = document.createElement('DIV');\r
1235                         div.innerHTML = this.modelItemRef.itemText;     \r
1236                         div.className = this.cssPrefix + 'menuItem_textContent';\r
1237                         div.id = 'menuItemText' + this.modelItemRef.id; \r
1238                         parentEl.appendChild(div);\r
1239                 }\r
1240                 /* Create div for the arrow -> Show sub items */\r
1241                 var div = document.createElement('DIV');\r
1242                 div.className = this.cssPrefix + 'menuItem_top_arrowShowSub';\r
1243                 div.id = 'DHTMLSuite_menuBar_arrow' + this.modelItemRef.id;\r
1244                 parentEl.appendChild(div);\r
1245                 this.expandElement = div;\r
1246                 if(!this.modelItemRef.hasSubs)div.style.display='none';\r
1247                                 \r
1248         }\r
1249         // }}}\r
1250         ,       \r
1251         \r
1252         // {{{ __createMenuElementsOfTypeSub()\r
1253     /**\r
1254      *  Creates the different parts of a menu item of type "sub".\r
1255      *\r
1256      *  @param menuModelItem menuModelItemObj = Object of type menuModelItemObj\r
1257      *  @param Object parentEl = Reference to parent element\r
1258      *\r
1259      * @private \r
1260      */         \r
1261         __createMenuElementsOfTypeSub : function(parentEl){             \r
1262                 if(this.modelItemRef.itemIcon){\r
1263                         parentEl.style.backgroundImage = 'url(\'' + this.modelItemRef.itemIcon + '\')'; \r
1264                         parentEl.style.backgroundRepeat = 'no-repeat';\r
1265                         parentEl.style.backgroundPosition = 'left center';      \r
1266                 }\r
1267                 if(this.modelItemRef.itemText){\r
1268                   var div;\r
1269                   if( this.modelItemRef.url )\r
1270                   {\r
1271                           div = document.createElement('a');\r
1272                           div.href = this.modelItemRef.url;\r
1273                           div.target = this.modelItemRef.frameTarget;\r
1274                           div.style.display = 'block';\r
1275                         }\r
1276                         else\r
1277                           div = document.createElement('div');\r
1278                           \r
1279                         div.className = 'DHTMLSuite_textContent';\r
1280                         div.innerHTML = this.modelItemRef.itemText;     \r
1281                         div.className = this.cssPrefix + 'menuItem_textContent';\r
1282                         div.id = 'menuItemText' + this.modelItemRef.id;\r
1283                         parentEl.appendChild(div);\r
1284                 }\r
1285                 \r
1286                 /* Create div for the arrow -> Show sub items */\r
1287                 var div = document.createElement('DIV');\r
1288                 div.className = this.cssPrefix + 'menuItem_sub_arrowShowSub';\r
1289                 parentEl.appendChild(div);              \r
1290                 div.id = 'DHTMLSuite_menuBar_arrow' + this.modelItemRef.id;\r
1291                 this.expandElement = div;\r
1292                 \r
1293                 if(!this.modelItemRef.hasSubs){\r
1294                         div.style.display='none';       \r
1295                 }else{\r
1296                         div.previousSibling.style.paddingRight = '15px';\r
1297                 }       \r
1298         }\r
1299         // }}}\r
1300         ,\r
1301         // {{{ setCssPrefix()\r
1302     /**\r
1303      *  Set css prefix for the menu item. default is 'DHTMLSuite_'. This is useful in case you want to have different menus on a page with different layout.\r
1304      *\r
1305      *  @param String cssPrefix = New css prefix. \r
1306      *\r
1307      * @public  \r
1308      */         \r
1309         setCssPrefix : function(cssPrefix)\r
1310         {\r
1311                 this.cssPrefix = cssPrefix;\r
1312         }\r
1313         // }}}\r
1314         ,\r
1315         // {{{ setMenuIcon()\r
1316     /**\r
1317      *  Replace menu icon.\r
1318      *\r
1319      *  @param String newPath - Path to new icon (false if no icon);\r
1320      *\r
1321      * @public  \r
1322      */         \r
1323         setIcon : function(newPath)\r
1324         {\r
1325                 this.modelItemRef.setIcon(newPath);\r
1326                 if(this.modelItemRef.type=='top'){      // Menu item is of type "top"\r
1327                         var div = document.getElementById('menuItemIcon' + this.modelItemRef.id);       // Get a reference to the div where the icon is located.\r
1328                         var img = div.getElementsByTagName('IMG')[0];   // Find the image\r
1329                         if(!img){       // Image doesn't exists ?\r
1330                                 img = document.createElement('IMG');    // Create new image\r
1331                                 div.appendChild(img);\r
1332                         }\r
1333                         img.src = newPath;      // Set image path\r
1334                         if(!newPath)img.parentNode.removeChild(img);    // No newPath defined, remove the image.                        \r
1335                 }\r
1336                 if(this.modelItemRef.type=='sub'){      // Menu item is of type "sub"\r
1337                         this.divElement.style.backgroundImage = 'url(\'' + newPath + '\')';             // Set backgroundImage for the main div(i.e. menu item div)     \r
1338                 }               \r
1339         }\r
1340         // }}}\r
1341         ,\r
1342         // {{{ setText()\r
1343     /**\r
1344      *  Replace the text of a menu item\r
1345      *\r
1346      *  @param String newText - New text for the menu item.\r
1347      *\r
1348      * @public  \r
1349      */         \r
1350         setText : function(newText)\r
1351         {\r
1352                 this.modelItemRef.setText(newText);\r
1353                 document.getElementById('menuItemText' + this.modelItemRef.id).innerHTML = newText;\r
1354                 \r
1355                 \r
1356         }\r
1357         \r
1358         // }}}\r
1359         ,\r
1360         // {{{ __clickMenuItem()\r
1361     /**\r
1362      *  Effect - click on menu item\r
1363      *\r
1364      *\r
1365      * @private \r
1366      */         \r
1367         __clickMenuItem : function()\r
1368         {\r
1369                 this.className = this.className.replace('_regular','_click');\r
1370                 this.className = this.className.replace('_over','_click');\r
1371         }\r
1372         // }}}  \r
1373         ,       \r
1374         // {{{ __rolloverMenuItem()\r
1375     /**\r
1376      *  Roll over effect\r
1377      *\r
1378      *\r
1379      * @private \r
1380      */         \r
1381         __rolloverMenuItem : function()\r
1382         {\r
1383                 this.className = this.className.replace('_regular','_over');\r
1384                 this.className = this.className.replace('_click','_over');\r
1385         }       \r
1386         // }}}\r
1387         ,       \r
1388         // {{{ __rolloutMenuItem()\r
1389     /**\r
1390      *  Roll out effect\r
1391      *\r
1392      *\r
1393      * @private \r
1394      */         \r
1395         __rolloutMenuItem : function()\r
1396         {\r
1397                 this.className = this.className.replace('_over','_regular');\r
1398                 \r
1399         }\r
1400         // }}}\r
1401         ,       \r
1402         // {{{ setState()\r
1403     /**\r
1404      *  Set state of a menu item.\r
1405      *\r
1406      *  @param String newState = New state for the menu item\r
1407      *\r
1408      * @public  \r
1409      */         \r
1410         setState : function(newState)\r
1411         {\r
1412                 this.divElement.className = this.cssPrefix + 'menuItem_' + this.modelItemRef.type + '_' + newState;             \r
1413                 this.modelItemRef.setState(newState);\r
1414         }\r
1415         // }}}\r
1416         ,\r
1417         // {{{ getState()\r
1418     /**\r
1419      *  Return state of a menu item. \r
1420      *\r
1421      *\r
1422      * @public  \r
1423      */         \r
1424         getState : function()\r
1425         {\r
1426                 var state = this.modelItemRef.getState();\r
1427                 if(!state){\r
1428                         if(this.divElement.className.indexOf('_over')>=0)state = 'over';        \r
1429                         if(this.divElement.className.indexOf('_click')>=0)state = 'click';      \r
1430                         this.modelItemRef.setState(state);              \r
1431                 }\r
1432                 return state;\r
1433         }       \r
1434         // }}}\r
1435         ,\r
1436         // {{{ __setHasSub()\r
1437     /**\r
1438      *  Update the item, i.e. show/hide the arrow if the element has subs or not. \r
1439      *\r
1440      *\r
1441      * @private \r
1442      */ \r
1443     __setHasSub : function(hasSubs)\r
1444     {\r
1445         this.modelItemRef.hasSubs = hasSubs;\r
1446         if(!hasSubs){\r
1447                 document.getElementById(this.cssPrefix +'menuBar_arrow' + this.modelItemRef.id).style.display='none';                   \r
1448         }else{\r
1449                 document.getElementById(this.cssPrefix +'menuBar_arrow' + this.modelItemRef.id).style.display='block';\r
1450         }       \r
1451     }\r
1452     // }}}      \r
1453     ,\r
1454         // {{{ hide()\r
1455     /**\r
1456      *  Hide the menu item.\r
1457      *\r
1458      *\r
1459      * @public  \r
1460      */     \r
1461     hide : function()\r
1462     {\r
1463         this.modelItemRef.setVisibility(false);\r
1464         this.divElement.style.display='none';           \r
1465     }    \r
1466     ,\r
1467         // {{{ show()\r
1468     /**\r
1469      *  Show the menu item.\r
1470      *\r
1471      *\r
1472      * @public  \r
1473      */      \r
1474     show : function()\r
1475     {\r
1476         this.modelItemRef.setVisibility(true);\r
1477         this.divElement.style.display='block';          \r
1478     }    \r
1479         // }}}\r
1480         ,\r
1481         // {{{ __hideGroup()\r
1482     /**\r
1483      *  Hide the group the menu item is a part of. Example: if we're dealing with menu item 2.1, hide the group for all sub items of 2\r
1484      *\r
1485      *\r
1486      * @private \r
1487      */                 \r
1488         __hideGroup : function()\r
1489         {               \r
1490                 if(this.modelItemRef.parentId){\r
1491                         this.divElement.parentNode.style.visibility='hidden';   \r
1492                         if(DHTMLSuite.clientInfoObj.isMSIE){\r
1493                                 try{\r
1494                                         var tmpId = this.divElement.parentNode.id.replace(/[^0-9]/gi,'');\r
1495                                         document.getElementById('DHTMLSuite_menuBarIframe_' + tmpId).style.visibility = 'hidden';\r
1496                                 }catch(e){\r
1497                                         // IFRAME hasn't been created.\r
1498                                 }       \r
1499                         }\r
1500                 }       \r
1501 \r
1502         }\r
1503         // }}}  \r
1504         ,\r
1505         // {{{ __navigate()\r
1506     /**\r
1507      *  Navigate after click on a menu item.\r
1508      *\r
1509      *\r
1510      * @private \r
1511      */         \r
1512         __navigate : function(e)\r
1513         {\r
1514                 /* Check to see if the expand sub arrow is clicked. if it is, we shouldn't navigate from this click */\r
1515                 if(document.all)e = event;\r
1516                 if(e){\r
1517                         var srcEl = DHTMLSuite.commonObj.getSrcElement(e);\r
1518                         if(srcEl.id.indexOf('arrow')>=0)return;\r
1519                 }\r
1520                 if(this.modelItemRef.state=='disabled')return;\r
1521                 if(this.modelItemRef.url){\r
1522       if (this.modelItemRef.frameTarget == 'main_window')\r
1523         window.main_window.location = this.modelItemRef.url;\r
1524       else if (this.modelItemRef.frameTarget == '_top')\r
1525         window.location = this.modelItemRef.url;\r
1526       else if (this.modelItemRef.frameTarget)\r
1527         window.open(this.modelItemRef.url);\r
1528       else\r
1529         location.href = this.modelItemRef.url;\r
1530                 }\r
1531                 if(this.modelItemRef.jsFunction){\r
1532                         try{\r
1533                                 eval(this.modelItemRef.jsFunction);\r
1534                         }catch(e){\r
1535                                 alert('Defined Javascript code for the menu item( ' + this.modelItemRef.jsFunction + ' ) cannot be executed');\r
1536                         }\r
1537                 }\r
1538         }\r
1539 }\r
1540 \r
1541 \r
1542 /************************************************************************************************************\r
1543 *       DHTML menu bar class\r
1544 *\r
1545 *       Created:                                                October, 21st, 2006\r
1546 *       @class Purpose of class:                Creates a top bar menu\r
1547 *                       \r
1548 *       Css files used by this script:  menu-bar.css\r
1549 *\r
1550 *       Demos of this class:                    demo-menu-bar.html\r
1551 *\r
1552 *       Update log:\r
1553 *\r
1554 ************************************************************************************************************/\r
1555 \r
1556 \r
1557 /**\r
1558 * @constructor\r
1559 * @class Purpose of class:      Creates a top bar menu strip. Demos: <br>\r
1560 *       <ul>\r
1561 *       <li>(<a href="../../demos/demo-menu-bar-2.html" target="_blank">A menu with a detailed description on how it is created</a>)</li>\r
1562 *       <li>(<a href="../../demos/demo-menu-bar.html" target="_blank">Demo with lots of menus on the same page</a>)</li>\r
1563 *       <li>(<a href="../../demos/demo-menu-bar-custom-css.html" target="_blank">Two menus with different layout</a>)</li>\r
1564 *       <li>(<a href="../../demos/demo-menu-bar-custom-css-file.html" target="_blank">One menu with custom layout/css.</a>)</li>\r
1565 *       </ul>\r
1566 *\r
1567 *       <a href="../images/menu-bar-1.gif" target="_blank">Image describing the classes</a> <br><br>\r
1568 *\r
1569 * @version 1.0\r
1570 * @author       Alf Magne Kalleland(www.dhtmlgoodies.com)\r
1571 */\r
1572 \r
1573 DHTMLSuite.menuBar = function()\r
1574 {\r
1575         var menuItemObj;\r
1576         var layoutCSS;                                  // Name of css file\r
1577         var menuBarBackgroundImage;             // Name of background image\r
1578         var menuItem_objects;                   // Array of menu items - html elements.\r
1579         var menuBarObj;                                 // Reference to the main dib\r
1580         var menuBarHeight;\r
1581         var menuItems;                                  // Reference to objects of class menuModelItem\r
1582         var highlightedItems;                   // Array of currently highlighted menu items.\r
1583         var menuBarState;                               // Menu bar state - true or false - 1 = expand items on mouse over\r
1584         var activeSubItemsOnMouseOver;  // Activate sub items on mouse over     (instead of onclick)\r
1585         \r
1586 \r
1587         var submenuGroups;                              // Array of div elements for the sub menus\r
1588         var submenuIframes;                             // Array of sub menu iframes used to cover select boxes in old IE browsers.\r
1589         var createIframesForOldIeBrowsers;      // true if we want the script to create iframes in order to cover select boxes in older ie browsers.\r
1590         var targetId;                                   // Id of element where the menu will be inserted.\r
1591         var menuItemCssPrefix;                  // Css prefix of menu items.\r
1592         var cssPrefix;                                  // Css prefix for the menu bar\r
1593         var menuItemLayoutCss;                  // Css path for the menu items of this menu bar\r
1594         var globalObjectIndex;                  // Global index of this object - used to refer to the object of this class outside\r
1595         this.cssPrefix = 'DHTMLSuite_';\r
1596         this.menuItemLayoutCss = false; // false = use default for the menuItem class.\r
1597 //      this.layoutCSS = 'menu-bar.css';\r
1598         this.menuBarBackgroundImage = 'menu_strip_bg.jpg';\r
1599         this.menuItem_objects = new Array();\r
1600         DHTMLSuite.variableStorage.menuBar_highlightedItems = new Array();\r
1601         \r
1602         this.menuBarState = false;\r
1603         \r
1604         this.menuBarObj = false;\r
1605         this.menuBarHeight = 26;\r
1606         this.submenuGroups = new Array();\r
1607         this.submenuIframes = new Array();\r
1608         this.targetId = false;\r
1609         this.activeSubItemsOnMouseOver = false;\r
1610         this.menuItemCssPrefix = false;\r
1611         this.createIframesForOldIeBrowsers = false;\r
1612         if(!standardObjectsCreated)DHTMLSuite.createStandardObjects();  \r
1613         \r
1614         \r
1615 }\r
1616 \r
1617 \r
1618 \r
1619 \r
1620 \r
1621 DHTMLSuite.menuBar.prototype = {        \r
1622         \r
1623         // {{{ init()\r
1624     /**\r
1625      *  Initilizes the script\r
1626      *\r
1627      *\r
1628      * @public  \r
1629      */                                 \r
1630         init : function()\r
1631         {\r
1632                 \r
1633 //              DHTMLSuite.commonObj.loadCSS(this.layoutCSS);   \r
1634                 this.__createDivs();    // Create general divs\r
1635                 this.__createMenuItems();       // Create menu items\r
1636                 this.__setBasicEvents();        // Set basic events.\r
1637                 window.refToThismenuBar = this;\r
1638         }\r
1639         // }}}\r
1640         ,\r
1641         // {{{ setTarget()\r
1642     /**\r
1643      *  Specify where this menu bar will be inserted. the element with this id will be parent of the menu bar.\r
1644      *\r
1645      *  @param String targetId = Id of element where the menu will be inserted. \r
1646      *\r
1647      * @public  \r
1648      */         \r
1649         setTarget : function(targetId)\r
1650         {\r
1651                 this.targetId = targetId;               \r
1652                 \r
1653         }       \r
1654         // }}}  \r
1655         ,\r
1656         // {{{ setLayoutCss()\r
1657     /**\r
1658      *  Specify the css file for this menu bar\r
1659      *\r
1660      *  @param String layoutCSS = Name of new css file. \r
1661      *\r
1662      * @public  \r
1663      */         \r
1664         setLayoutCss : function(layoutCSS)\r
1665         {\r
1666                 this.layoutCSS = layoutCSS;             \r
1667                 \r
1668         }       \r
1669         // }}}\r
1670         ,       \r
1671         // {{{ setMenuItemLayoutCss()\r
1672     /**\r
1673      *  Specify the css file for the menu items\r
1674      *\r
1675      *  @param String layoutCSS = Name of new css file. \r
1676      *\r
1677      * @public  \r
1678      */         \r
1679         setMenuItemLayoutCss : function(layoutCSS)\r
1680         {\r
1681                 this.menuItemLayoutCss = layoutCSS;             \r
1682                 \r
1683         }       \r
1684         // }}}\r
1685         ,       \r
1686         // {{{ setCreateIframesForOldIeBrowsers()\r
1687     /**\r
1688      *  This method specifies if you want to the script to create iframes behind sub menu groups in order to cover eventual select boxes. This\r
1689      *  can be needed if you have users with older IE browsers(prior to version 7) and when there's a chance that a sub menu could appear on top\r
1690      *  of a select box.\r
1691      *\r
1692      *  @param Boolean createIframesForOldIeBrowsers = true if you want the script to create iframes to cover select boxes in older ie browsers.\r
1693      *\r
1694      * @public  \r
1695      */         \r
1696         setCreateIframesForOldIeBrowsers : function(createIframesForOldIeBrowsers)\r
1697         {\r
1698                 this.createIframesForOldIeBrowsers = createIframesForOldIeBrowsers;             \r
1699                 \r
1700         }       \r
1701         // }}}\r
1702         ,\r
1703         // {{{ addMenuItems()\r
1704     /**\r
1705      *  Add menu items\r
1706      *\r
1707      *  @param DHTMLSuite.menuModel menuModel Object of class DHTMLSuite.menuModel which holds menu data        \r
1708      *\r
1709      * @public  \r
1710      */                 \r
1711         addMenuItems : function(menuItemObj)\r
1712         {\r
1713                 this.menuItemObj = menuItemObj; \r
1714                 this.menuItems = menuItemObj.getItems();\r
1715         }\r
1716         // }}}\r
1717         ,\r
1718         // {{{ setActiveSubItemsOnMouseOver()\r
1719     /**\r
1720      *   Specify if sub menus should be activated on mouse over(i.e. no matter what the menuState property is).         \r
1721      *\r
1722      *  @param Boolean activateSubOnMouseOver - Specify if sub menus should be activated on mouse over(i.e. no matter what the menuState property is).\r
1723      *\r
1724      * @public  \r
1725      */         \r
1726         setActiveSubItemsOnMouseOver : function(activateSubOnMouseOver)\r
1727         {\r
1728                 this.activeSubItemsOnMouseOver = activateSubOnMouseOver;        \r
1729         }\r
1730         // }}}\r
1731         ,\r
1732         // {{{ setMenuItemState()\r
1733     /**\r
1734      *  This method changes the state of the menu bar(expanded or collapsed). This method is called when someone clicks on the arrow at the right of menu items.\r
1735      *  \r
1736      *  @param Number menuItemId - ID of the menu item we want to switch state for\r
1737      *  @param String state - New state(example: "disabled")\r
1738      *\r
1739      * @public  \r
1740      */                 \r
1741         setMenuItemState : function(menuItemId,state)\r
1742         {\r
1743                 this.menuItem_objects[menuItemId].setState(state);\r
1744         }\r
1745         // }}}  \r
1746         ,\r
1747         // {{{ setMenuItemCssPrefix()\r
1748     /**\r
1749      *  Specify prefix of css classes used for the menu items. Default css prefix is "DHTMLSuite_". If you wish have some custom styling for some of your menus, \r
1750      *  create a separate css file and replace DHTMLSuite_ for the class names with your new prefix.  This is useful if you want to have two menus on the same page\r
1751      *  with different stylings.\r
1752      *  \r
1753      *  @param String newCssPrefix - New css prefix for menu items.\r
1754      *\r
1755      * @public  \r
1756      */         \r
1757         setMenuItemCssPrefix : function(newCssPrefix)\r
1758         {\r
1759                 this.menuItemCssPrefix = newCssPrefix;\r
1760         }\r
1761         // }}}\r
1762         ,       \r
1763         // {{{ setCssPrefix()\r
1764     /**\r
1765      *  Specify prefix of css classes used for the menu bar. Default css prefix is "DHTMLSuite_" and that's the prefix of all css classes inside menu-bar.css(the default css file). \r
1766      *  If you want some custom menu bars, create and include your own css files, replace DHTMLSuite_ in the class names with your own prefix and set the new prefix by calling\r
1767      *  this method. This is useful if you want to have two menus on the same page with different stylings.\r
1768      *  \r
1769      *  @param String newCssPrefix - New css prefix for the menu bar classes.\r
1770      *\r
1771      * @public  \r
1772      */         \r
1773         setCssPrefix : function(newCssPrefix)\r
1774         {\r
1775                 this.cssPrefix = newCssPrefix;\r
1776         }\r
1777         // }}}\r
1778         ,\r
1779         // {{{ replaceSubMenus()\r
1780     /**\r
1781      *  This method replaces existing sub menu items with a new subset (To replace all menu items, pass 0 as parentId)\r
1782      *\r
1783      *  \r
1784      *  @param Number parentId - ID of parent element ( 0 if top node) - if set, all sub elements will be deleted and replaced with the new menu model.\r
1785      *  @param menuModel newMenuModel - Reference to object of class menuModel\r
1786      *\r
1787      * @private \r
1788      */         \r
1789         replaceMenuItems : function(parentId,newMenuModel)\r
1790         {               \r
1791                 this.hideSubMenus();    // Hide all sub menus\r
1792                 this.__deleteMenuItems(parentId);       // Delete old menu items.\r
1793                 this.menuItemObj.__appendMenuModel(newMenuModel,parentId);      // Appending new menu items to the menu model.\r
1794                 this.__clearAllMenuItems();\r
1795                 this.__createMenuItems();\r
1796         }       \r
1797 \r
1798         // }}}  \r
1799         ,\r
1800         // {{{ deleteMenuItems()\r
1801     /**\r
1802      *  This method deletes menu items from the menu dynamically\r
1803      *  \r
1804      *  @param Number parentId - Parent id - where to append the new items.\r
1805      *  @param Boolean includeParent - Should parent element also be deleted, or only sub elements?\r
1806      *\r
1807      * @public  \r
1808      */         \r
1809         deleteMenuItems : function(parentId,includeParent)\r
1810         {\r
1811                 this.hideSubMenus();    // Hide all sub menus\r
1812                 this.__deleteMenuItems(parentId,includeParent);\r
1813                 this.__clearAllMenuItems();\r
1814                 this.__createMenuItems();               \r
1815         }\r
1816         // }}}  \r
1817         ,\r
1818         // {{{ appendMenuItems()\r
1819     /**\r
1820      *  This method appends menu items to the menu dynamically\r
1821      *  \r
1822      *  @param Number parentId - Parent id - where to append the new items.\r
1823      *  @param menuModel newMenuModel - Object of type menuModel. This menuModel will be appended as sub elements of defined parentId\r
1824      *\r
1825      * @public  \r
1826      */         \r
1827         appendMenuItems : function(parentId,newMenuModel)\r
1828         {\r
1829                 this.hideSubMenus();    // Hide all sub menus\r
1830                 this.menuItemObj.__appendMenuModel(newMenuModel,parentId);      // Appending new menu items to the menu model.\r
1831                 this.__clearAllMenuItems();\r
1832                 this.__createMenuItems();               \r
1833         }       \r
1834         // }}}  \r
1835         ,\r
1836         // {{{ hideMenuItem()\r
1837     /**\r
1838      *  This method doesn't delete menu items. it hides them only.\r
1839      *  \r
1840      *  @param Number id - Id of the item you want to hide.\r
1841      *\r
1842      * @public  \r
1843      */         \r
1844         hideMenuItem : function(id)\r
1845         {\r
1846                 this.menuItem_objects[id].hide();\r
1847 \r
1848         }       \r
1849         // }}}  \r
1850         ,\r
1851         // {{{ showMenuItem()\r
1852     /**\r
1853      *  This method shows a menu item. If the item isn't hidden, nothing is done.\r
1854      *  \r
1855      *  @param Number id - Id of the item you want to show\r
1856      *\r
1857      * @public  \r
1858      */         \r
1859         showMenuItem : function(id)\r
1860         {\r
1861                 this.menuItem_objects[id].show();\r
1862         }       \r
1863         // }}}\r
1864         ,\r
1865         // {{{ setText()\r
1866     /**\r
1867      *  Replace the text for a menu item\r
1868      *  \r
1869      *  @param Integer id - Id of menu item.\r
1870      *  @param String newText - New text for the menu item.\r
1871      *\r
1872      * @public  \r
1873      */         \r
1874         setText : function(id,newText)\r
1875         {\r
1876                 this.menuItem_objects[id].setText(newText);\r
1877         }               \r
1878         // }}}\r
1879         ,\r
1880         // {{{ setIcon()\r
1881     /**\r
1882      *  Replace menu icon for a menu item. \r
1883      *  \r
1884      *  @param Integer id - Id of menu item.\r
1885      *  @param String newPath - Path to new menu icon. Pass blank or false if you want to clear the menu item.\r
1886      *\r
1887      * @public  \r
1888      */         \r
1889         setIcon : function(id,newPath)\r
1890         {\r
1891                 this.menuItem_objects[id].setIcon(newPath);\r
1892         }       \r
1893         // }}}\r
1894         ,\r
1895         // {{{ __clearAllMenuItems()\r
1896     /**\r
1897      *  Delete HTML elements for all menu items.\r
1898      *\r
1899      * @private \r
1900      */                 \r
1901         __clearAllMenuItems : function()\r
1902         {\r
1903                 for(var prop=0;prop<this.menuItemObj.menuItemsOrder.length;prop++){\r
1904                         var id = this.menuItemObj.menuItemsOrder[prop];\r
1905                         if(this.submenuGroups[id]){\r
1906                                 this.submenuGroups[id].parentNode.removeChild(this.submenuGroups[id]);\r
1907                                 this.submenuGroups[id] = false; \r
1908                         }\r
1909                         if(this.submenuIframes[id]){\r
1910                                 this.submenuIframes[id].parentNode.removeChild(this.submenuIframes[id]);\r
1911                                 this.submenuIframes[id] = false;\r
1912                         }       \r
1913                 }\r
1914                 this.menuBarObj.innerHTML = '';         \r
1915         }\r
1916         // }}}\r
1917         ,\r
1918         // {{{ __deleteMenuItems()\r
1919     /**\r
1920      *  This method deletes menu items from the menu, i.e. menu model and the div elements for these items.\r
1921      *  \r
1922      *  @param Number parentId - Parent id - where to start the delete process.\r
1923      *\r
1924      * @private \r
1925      */         \r
1926         __deleteMenuItems : function(parentId,includeParent)\r
1927         {\r
1928                 if(includeParent)this.menuItemObj.__deleteANode(parentId);\r
1929                 if(!this.submenuGroups[parentId])return;        // No sub items exists.         \r
1930                 this.menuItem_objects[parentId].__setHasSub(false);     // Delete existing sub menu divs.\r
1931                 this.menuItemObj.__deleteChildNodes(parentId);  // Delete existing child nodes from menu model\r
1932                 var groupBox = this.submenuGroups[parentId];\r
1933                 groupBox.parentNode.removeChild(groupBox);      // Delete sub menu group box. \r
1934                 if(this.submenuIframes[parentId]){\r
1935                         this.submenuIframes[parentId].parentNode.removeChild(this.submenuIframes[parentId]);\r
1936                 }\r
1937                 this.submenuGroups.splice(parentId,1);\r
1938                 this.submenuIframes.splice(parentId,1);\r
1939         }\r
1940         // }}}  \r
1941         ,\r
1942         // {{{ __changeMenuBarState()\r
1943     /**\r
1944      *  This method changes the state of the menu bar(expanded or collapsed). This method is called when someone clicks on the arrow at the right of menu items.\r
1945      *  \r
1946      *  @param Object obj - Reference to element triggering the action\r
1947      *\r
1948      * @private \r
1949      */         \r
1950         __changeMenuBarState : function(){\r
1951                 var objectIndex = this.getAttribute('objectRef');\r
1952                 var obj = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[objectIndex];\r
1953                 var parentId = this.id.replace(/[^0-9]/gi,'');          \r
1954                 var state = obj.menuItem_objects[parentId].getState();\r
1955                 if(state=='disabled')return;\r
1956                 obj.menuBarState = !obj.menuBarState;\r
1957                 if(!obj.menuBarState)obj.hideSubMenus();else{\r
1958                         obj.hideSubMenus();\r
1959                         obj.__expandGroup(parentId);\r
1960                 }\r
1961                 \r
1962         }\r
1963         // }}}          \r
1964         ,\r
1965         // {{{ __createDivs()\r
1966     /**\r
1967      *  Create the main HTML elements for this menu dynamically\r
1968      *  \r
1969      *\r
1970      * @private \r
1971      */         \r
1972         __createDivs : function()\r
1973         {\r
1974                 window.refTomenuBar = this;     // Reference to menu strip object\r
1975                 \r
1976                 this.menuBarObj = document.createElement('DIV');        \r
1977                 this.menuBarObj.className = this.cssPrefix + 'menuBar_' + this.menuItemObj.submenuType[1];\r
1978                 \r
1979                 if(!document.getElementById(this.targetId)){\r
1980                         alert('No target defined for the menu object');\r
1981                         return;\r
1982                 }\r
1983                 // Appending menu bar object as a sub of defined target element.\r
1984                 var target = document.getElementById(this.targetId);\r
1985                 target.appendChild(this.menuBarObj);                            \r
1986         }\r
1987         ,\r
1988         // {{{ hideSubMenus()\r
1989     /**\r
1990      *  Deactivate all sub menus ( collapse and set state back to regular )\r
1991      *  In case you have a menu inside a scrollable container, call this method in an onscroll event for that element\r
1992      *  example document.getElementById('textContent').onscroll = menuBar.__hideSubMenus;\r
1993      *  \r
1994      *  @param Event e - this variable is present if this method is called from an event. \r
1995      *\r
1996      * @public  \r
1997      */         \r
1998         hideSubMenus : function(e)\r
1999         {\r
2000                 if(this && this.tagName){       /* Method called from event */\r
2001                         if(document.all)e = event;\r
2002                         var srcEl = DHTMLSuite.commonObj.getSrcElement(e);\r
2003                         if(srcEl.tagName.toLowerCase()=='img')srcEl = srcEl.parentNode;\r
2004                         if(srcEl.className && srcEl.className.indexOf('arrow')>=0){\r
2005                                 return;\r
2006                         }\r
2007                 }\r
2008                 for(var no=0;no<DHTMLSuite.variableStorage.menuBar_highlightedItems.length;no++){\r
2009                         DHTMLSuite.variableStorage.menuBar_highlightedItems[no].setState('regular');    // Set state back to regular\r
2010                         DHTMLSuite.variableStorage.menuBar_highlightedItems[no].__hideGroup();  // Hide eventual sub menus\r
2011                 }       \r
2012                 DHTMLSuite.variableStorage.menuBar_highlightedItems = new Array();                      \r
2013         }\r
2014         \r
2015         ,\r
2016         // {{{ __expandGroup()\r
2017     /**\r
2018      *  Expand a group of sub items.\r
2019      *  @param parentId - Id of parent element\r
2020      *\r
2021      * @private \r
2022      */                 \r
2023         __expandGroup : function(parentId)\r
2024         {\r
2025         \r
2026                 var groupRef = this.submenuGroups[parentId];\r
2027                 var subDiv = groupRef.getElementsByTagName('DIV')[0];\r
2028                 \r
2029                 var numericId = subDiv.id.replace(/[^0-9]/g,'');\r
2030                 \r
2031                 groupRef.style.visibility='visible';    // Show menu group.\r
2032                 if(this.submenuIframes[parentId])this.submenuIframes[parentId].style.visibility = 'visible';    // Show iframe if it exists.\r
2033                 DHTMLSuite.variableStorage.menuBar_highlightedItems[DHTMLSuite.variableStorage.menuBar_highlightedItems.length] = this.menuItem_objects[numericId];\r
2034                 this.__positionSubMenu(parentId);\r
2035                 \r
2036                 if(DHTMLSuite.clientInfoObj.isOpera){   /* Opera fix in order to get correct height of sub menu group */\r
2037                         var subDiv = groupRef.getElementsByTagName('DIV')[0];   /* Find first menu item */\r
2038                         subDiv.className = subDiv.className.replace('_over','_over');   /* By "touching" the class of the menu item, we are able to fix a layout problem in Opera */\r
2039                 }\r
2040         }\r
2041         \r
2042         ,\r
2043         // {{{ __activateMenuElements()\r
2044     /**\r
2045      *  Traverse up the menu items and highlight them.\r
2046      *  \r
2047      *\r
2048      * @private \r
2049      */                 \r
2050         __activateMenuElements : function(inputObj,objectRef,firstIteration)\r
2051         {\r
2052                 if(!this.menuBarState && !this.activeSubItemsOnMouseOver)return;        // Menu is not activated and it shouldn't be activated on mouse over.\r
2053                 var numericId = inputObj.id.replace(/[^0-9]/g,'');      // Get a numeric reference to current menu item.\r
2054                 \r
2055                 var state = this.menuItem_objects[numericId].getState();        // Get state of this menu item.\r
2056                 if(state=='disabled')return;    // This menu item is disabled - return from function without doing anything.            \r
2057                 \r
2058                 if(firstIteration && DHTMLSuite.variableStorage.menuBar_highlightedItems.length>0){\r
2059                         this.hideSubMenus();    // First iteration of this function=> Hide other sub menus. \r
2060                 }       \r
2061                 // What should be the state of this menu item -> If it's the one the mouse is over, state should be "over". If it's a parent element, state should be "active".\r
2062                 var newState = 'over';\r
2063                 if(!firstIteration)newState = 'active'; // State should be set to 'over' for the menu item the mouse is currently over.\r
2064                         \r
2065                 this.menuItem_objects[numericId].setState(newState);    // Switch state of menu item.\r
2066                 if(this.submenuGroups[numericId]){      // Sub menu group exists. call the __expandGroup method. \r
2067                         this.__expandGroup(numericId);  // Expand sub menu group\r
2068                 }\r
2069                 DHTMLSuite.variableStorage.menuBar_highlightedItems[DHTMLSuite.variableStorage.menuBar_highlightedItems.length] = this.menuItem_objects[numericId];     // Save this menu item in the array of highlighted elements.\r
2070                 if(objectRef.menuItems[numericId].parentId){    // A parent element exists. Call this method over again with parent element as input argument.\r
2071                         this.__activateMenuElements(objectRef.menuItem_objects[objectRef.menuItems[numericId].parentId].divElement,objectRef,false);\r
2072                 }\r
2073         }\r
2074         // }}}  \r
2075         ,\r
2076         // {{{ __createMenuItems()\r
2077     /**\r
2078      *  Creates the HTML elements for the menu items.\r
2079      *  \r
2080      *\r
2081      * @private \r
2082      */         \r
2083         __createMenuItems : function()\r
2084         {\r
2085                 if(!this.globalObjectIndex)this.globalObjectIndex = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects.length;;\r
2086                 var index = this.globalObjectIndex;\r
2087                 DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[index] = this;\r
2088         \r
2089                 // Find first child of the body element. trying to insert the element before first child instead of appending it to the <body> tag, ref: problems in ie\r
2090                 var firstChild = false;\r
2091                 var firstChilds = document.getElementsByTagName('DIV');\r
2092                 if(firstChilds.length>0)firstChild = firstChilds[0]\r
2093                 \r
2094                 for(var no=0;no<this.menuItemObj.menuItemsOrder.length;no++){   // Looping through menu items           \r
2095                         var indexThis = this.menuItemObj.menuItemsOrder[no];                            \r
2096                         if(!this.menuItems[indexThis].id)continue;              \r
2097                         this.menuItem_objects[this.menuItems[indexThis].id] = new DHTMLSuite.menuItem(); \r
2098                         if(this.menuItemCssPrefix)this.menuItem_objects[this.menuItems[indexThis].id].setCssPrefix(this.menuItemCssPrefix);     // Custom css prefix set\r
2099                         if(this.menuItemLayoutCss)this.menuItem_objects[this.menuItems[indexThis].id].setLayoutCss(this.menuItemLayoutCss);     // Custom css file name\r
2100                         \r
2101                         var ref = this.menuItem_objects[this.menuItems[indexThis].id].createItem(this.menuItems[indexThis]); // Create div for this menu item.\r
2102                 \r
2103                         // Actiave sub elements when someone moves the mouse over the menu item - exception: not on separators.\r
2104                         if(!this.menuItems[indexThis].separator)DHTMLSuite.commonObj.addEvent(ref,"mouseover",function(){ DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[index].__activateMenuElements(this,DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[index],true); });  \r
2105                         \r
2106                         if(this.menuItem_objects[this.menuItems[indexThis].id].expandElement){  /* Small arrow at the right of the menu item exists - expand subs */\r
2107                                 var expandRef = this.menuItem_objects[this.menuItems[indexThis].id].expandElement;      /* Creating reference to expand div/arrow div */\r
2108                                 var parentId = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[index].menuItems[indexThis].parentId + '';   // Get parent id.\r
2109                                 var tmpId = expandRef.id.replace(/[^0-9]/gi,'');\r
2110                                 expandRef.setAttribute('objectRef',index);      /* saving the index of this object in the DHTMLSuite.variableStorage array as a property of the tag - We need to do this in order to avoid circular references and thus memory leakage in IE */\r
2111                                 expandRef.objectRef = index;\r
2112                                 expandRef.onclick = this.__changeMenuBarState;\r
2113                         }\r
2114                         var target = this.menuBarObj;   // Temporary variable - target of newly created menu item. target can be the main menu object or a sub menu group(see below where target is updated).\r
2115 \r
2116                         if(this.menuItems[indexThis].depth==1 && this.menuItemObj.submenuType[this.menuItems[indexThis].depth]!='top' && this.menuItemObj.mainMenuGroupWidth){  /* Main menu item group width set */\r
2117                                 var tmpWidth = this.menuItemObj.mainMenuGroupWidth + '';\r
2118                                 if(tmpWidth.indexOf('%')==-1)tmpWidth = tmpWidth + 'px';\r
2119                                 target.style.width = tmpWidth;  \r
2120                         }\r
2121                 \r
2122                         if(this.menuItems[indexThis].depth=='1'){       /* Top level item */\r
2123                                 if(this.menuItemObj.submenuType[this.menuItems[indexThis].depth]=='top'){       /* Type = "top" - menu items side by side */\r
2124                                         ref.style.styleFloat = 'left';                          \r
2125                                         ref.style.cssText = 'float:left';                                               \r
2126                                 }                       \r
2127                         }else{\r
2128                                 if(!this.menuItems[indexThis].depth){\r
2129                                         alert('Error in menu model(depth not defined for a menu item). Remember to call the init() method for the menuModel object.');\r
2130                                         return;\r
2131                                 }\r
2132                                 if(!this.submenuGroups[this.menuItems[indexThis].parentId]){    // Sub menu div doesn't exist - > Create it.\r
2133                                         this.submenuGroups[this.menuItems[indexThis].parentId] = document.createElement('DIV'); \r
2134                                         this.submenuGroups[this.menuItems[indexThis].parentId].style.zIndex = 10000;\r
2135                                         this.submenuGroups[this.menuItems[indexThis].parentId].id = 'DHTMLSuite_menuBarSubGroup' + this.menuItems[indexThis].parentId;\r
2136                                         this.submenuGroups[this.menuItems[indexThis].parentId].style.visibility = 'hidden';     // Initially hidden.\r
2137                                         if(this.menuItemObj.submenuType[this.menuItems[indexThis].depth]=='sub')this.submenuGroups[this.menuItems[indexThis].parentId].className = this.cssPrefix + 'menuBar_sub';\r
2138                                         if(firstChild){\r
2139                                                 firstChild.parentNode.insertBefore(this.submenuGroups[this.menuItems[indexThis].parentId],firstChild);\r
2140                                         }else{\r
2141                                                 document.body.appendChild(this.submenuGroups[this.menuItems[indexThis].parentId]);\r
2142                                         }\r
2143                                         \r
2144                                         if(DHTMLSuite.clientInfoObj.isMSIE && this.createIframesForOldIeBrowsers){      // Create iframe object in order to conver select boxes in older IE browsers(windows).\r
2145                                                 this.submenuIframes[this.menuItems[indexThis].parentId] = document.createElement('<IFRAME src="about:blank" frameborder=0>');\r
2146                                                 this.submenuIframes[this.menuItems[indexThis].parentId].id = 'DHTMLSuite_menuBarIframe_' + this.menuItems[indexThis].parentId;\r
2147                                                 this.submenuIframes[this.menuItems[indexThis].parentId].style.position = 'absolute';\r
2148                                                 this.submenuIframes[this.menuItems[indexThis].parentId].style.zIndex = 9000;\r
2149                                                 this.submenuIframes[this.menuItems[indexThis].parentId].style.visibility = 'hidden';\r
2150                                                 if(firstChild){\r
2151                                                         firstChild.parentNode.insertBefore(this.submenuIframes[this.menuItems[indexThis].parentId],firstChild);\r
2152                                                 }else{\r
2153                                                         document.body.appendChild(this.submenuIframes[this.menuItems[indexThis].parentId]);\r
2154                                                 }                                               \r
2155                                         }\r
2156                                 }       \r
2157                                 target = this.submenuGroups[this.menuItems[indexThis].parentId];        // Change target of newly created menu item. It should be appended to the sub menu div("A group box").                          \r
2158                         }                       \r
2159                         target.appendChild(ref); // Append menu item to the document.           \r
2160                         \r
2161                         if(this.menuItems[indexThis].visible == false)this.hideMenuItem(this.menuItems[indexThis].id);  // Menu item hidden, call the hideMenuItem method.\r
2162                         if(this.menuItems[indexThis].state != 'regular')this.menuItem_objects[this.menuItems[indexThis].id].setState(this.menuItems[indexThis].state);  // Menu item hidden, call the hideMenuItem method.\r
2163 \r
2164                 }       \r
2165                 \r
2166 \r
2167                 this.__setSizeOfAllSubMenus();  // Set size of all sub menu groups\r
2168                 this.__positionAllSubMenus();   // Position all sub menu groups.\r
2169                 if(DHTMLSuite.clientInfoObj.isOpera)this.__fixLayoutOpera();    // Call a function which fixes some layout issues in Opera.             \r
2170         }\r
2171         // }}}\r
2172         ,\r
2173         // {{{ __fixLayoutOpera()\r
2174     /**\r
2175      *  A method used to fix the menu layout in Opera. \r
2176      *\r
2177      *\r
2178      * @private \r
2179      */         \r
2180         __fixLayoutOpera : function()\r
2181         {\r
2182                 for(var no=0;no<this.menuItemObj.menuItemsOrder.length;no++){\r
2183                         var id = this.menuItemObj.menuItemsOrder[no];\r
2184                         if(!id)continue;\r
2185                         this.menuItem_objects[id].divElement.className = this.menuItem_objects[id].divElement.className.replace('_regular','_regular'); // Nothing is done but by "touching" the class of the menu items in Opera, we make them appear correctly\r
2186                 }               \r
2187         }\r
2188         \r
2189         // }}}  \r
2190         ,\r
2191         // {{{ __setSizeOfAllSubMenus()\r
2192     /**\r
2193      *  *       Walk through all sub menu groups and call the positioning method for each one of them.\r
2194      *\r
2195      *\r
2196      * @private \r
2197      */         \r
2198         __setSizeOfAllSubMenus : function()\r
2199         {               \r
2200                 for(var prop in this.submenuGroups){\r
2201                         this.__setSizeOfSubMenus(prop);\r
2202                 }                       \r
2203         }       \r
2204         // }}}  \r
2205         ,       \r
2206         // {{{ __positionAllSubMenus()\r
2207     /**\r
2208      *  Walk through all sub menu groups and call the positioning method for each one of them.\r
2209      *\r
2210      *\r
2211      * @private \r
2212      */         \r
2213         __positionAllSubMenus : function()\r
2214         {\r
2215                 for(var prop in this.submenuGroups){\r
2216                         this.__positionSubMenu(prop);\r
2217                 }       \r
2218                 \r
2219         }\r
2220         // }}}  \r
2221         ,\r
2222         // {{{ __positionSubMenu(parentId)\r
2223     /**\r
2224      *  Position a sub menu group\r
2225      *\r
2226      *  @param parentId         \r
2227      *\r
2228      * @private \r
2229      */         \r
2230         __positionSubMenu : function(parentId)\r
2231         {\r
2232                 try{\r
2233                         var shortRef = this.submenuGroups[parentId];    \r
2234                         \r
2235                         if( shortRef.style.visible == 'hidden' )\r
2236                   {\r
2237                           shortRef.style.display = 'none';\r
2238                           return;\r
2239                   }\r
2240                         else\r
2241                           shortRef.style.display = 'block';\r
2242                         \r
2243                         var depth = this.menuItems[parentId].depth;\r
2244                         var dir = this.menuItemObj.submenuType[depth];\r
2245                         if(dir=='top'){                 \r
2246                                 shortRef.style.left = DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement) + 'px';\r
2247                                 shortRef.style.top = (DHTMLSuite.commonObj.getTopPos(this.menuItem_objects[parentId].divElement) + this.menuItem_objects[parentId].divElement.offsetHeight) + 'px';\r
2248                         }else{\r
2249               var too_large = DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement)\r
2250                             + this.menuItem_objects[parentId].divElement.offsetWidth\r
2251                             + shortRef.offsetWidth\r
2252                             > $('#main_menu_div').width();\r
2253               if (too_large)\r
2254                 shortRef.style.left = (DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement) - shortRef.offsetWidth) + 'px';\r
2255               else\r
2256                                 shortRef.style.left = (DHTMLSuite.commonObj.getLeftPos(this.menuItem_objects[parentId].divElement) + this.menuItem_objects[parentId].divElement.offsetWidth) + 'px';\r
2257                                 shortRef.style.top = (DHTMLSuite.commonObj.getTopPos(this.menuItem_objects[parentId].divElement)) + 'px';               \r
2258                         }       \r
2259                         \r
2260                         if(DHTMLSuite.clientInfoObj.isMSIE){\r
2261                                 var iframeRef = this.submenuIframes[parentId]\r
2262                                 iframeRef.style.left = shortRef.style.left;\r
2263                                 iframeRef.style.top = shortRef.style.top;\r
2264                                 iframeRef.style.width = shortRef.clientWidth + 'px';\r
2265                                 iframeRef.style.height = shortRef.clientHeight + 'px';\r
2266                         }\r
2267                                                                         \r
2268                 }catch(e){\r
2269                         \r
2270                 }               \r
2271         }\r
2272         // }}}  \r
2273         ,\r
2274         // {{{ __setSizeOfSubMenus(parentId)\r
2275     /**\r
2276      *  Set size of a sub menu group\r
2277      *\r
2278      *  @param parentId         \r
2279      *\r
2280      * @private \r
2281      */         \r
2282         __setSizeOfSubMenus : function(parentId)\r
2283         {\r
2284                 try{\r
2285                         var shortRef = this.submenuGroups[parentId];                    \r
2286                         var subWidth = Math.max(shortRef.offsetWidth,this.menuItem_objects[parentId].divElement.offsetWidth);\r
2287                         if(this.menuItems[parentId].submenuWidth)subWidth = this.menuItems[parentId].submenuWidth;\r
2288                         subWidth = subWidth + '';\r
2289                         if(subWidth.indexOf('%')==-1)subWidth = subWidth + 'px';\r
2290                         shortRef.style.width = subWidth;        \r
2291                         \r
2292                         if(DHTMLSuite.clientInfoObj.isMSIE){\r
2293                                 this.submenuIframes[parentId].style.width = shortRef.style.width;\r
2294                                 this.submenuIFrames[parentId].style.height = shortRef.style.height;\r
2295                         }\r
2296                 }catch(e){\r
2297                         \r
2298                 }\r
2299                 \r
2300         }\r
2301         // }}}  \r
2302         ,\r
2303         // {{{ __repositionMenu()\r
2304     /**\r
2305      *  Position menu items.\r
2306      *  \r
2307      *\r
2308      * @private \r
2309      */         \r
2310         __repositionMenu : function(inputObj)\r
2311         {\r
2312                 // self.status = this;\r
2313                 inputObj.menuBarObj.style.top = document.documentElement.scrollTop + 'px';\r
2314                 \r
2315         }\r
2316         \r
2317         // }}}  \r
2318         ,\r
2319         // {{{ __menuItemRollOver()\r
2320     /**\r
2321      *  Position menu items.\r
2322      *  \r
2323      *\r
2324      * @private \r
2325      */ \r
2326         __menuItemRollOver : function(inputObj)\r
2327         {\r
2328                 var numericId = inputObj.id.replace(/[^0-9]/g,'');\r
2329                 inputObj.className = 'DHTMLSuite_menuBar_menuItem_over_' + this.menuItems[numericId]['depth'];          \r
2330         }\r
2331         // }}}  \r
2332         ,       \r
2333         // {{{ __menuItemRollOut()\r
2334     /**\r
2335      *  Position menu items.\r
2336      *  \r
2337      *\r
2338      * @private \r
2339      */ \r
2340         __menuItemRollOut : function(inputObj)\r
2341         {               \r
2342                 var numericId = inputObj.id.replace(/[^0-9]/g,'');\r
2343                 inputObj.className = 'DHTMLSuite_menuBar_menuItem_' + this.menuItems[numericId]['depth'];               \r
2344         }\r
2345         // }}}  \r
2346         ,\r
2347         // {{{ __menuNavigate()\r
2348     /**\r
2349      *  Navigate by click on a menu item\r
2350      *  \r
2351      *\r
2352      * @private \r
2353      */ \r
2354         __menuNavigate : function(inputObj)\r
2355         {\r
2356                 var numericIndex = inputObj.id.replace(/[^0-9]/g,'');\r
2357                 var url = this.menuItems[numericIndex]['url'];\r
2358                 if(!url)return;\r
2359                 alert(this.menuItems[numericIndex]['url']);\r
2360                 \r
2361         }\r
2362         // }}}  \r
2363         ,\r
2364     unsetMenuBarState : function() { this.menuBarState = false },\r
2365     changeMenuBarState: function (target) {\r
2366            var parentId = target.id.replace(/[^0-9]/gi,'');\r
2367            this.menuBarState = !this.menuBarState;\r
2368        this.hideSubMenus();\r
2369            if(this.menuBarState) {\r
2370                 this.__expandGroup(parentId);\r
2371        }\r
2372     },\r
2373         // {{{ __setBasicEvents()\r
2374     /**\r
2375      *  Set basic events for the menu widget.\r
2376      *  \r
2377      *\r
2378      * @private \r
2379      */ \r
2380         __setBasicEvents : function()\r
2381         {\r
2382         var menu = this;\r
2383         $('div.DHTMLSuite_menuBar_sub').click(function() { menu.hideSubMenus(); menu.unsetMenuBarState() });\r
2384         $('div.DHTMLSuite_menuBar_top > div > div[objectref!="0"]').click(function() { menu.changeMenuBarState(this) });\r
2385         $('div.DHTMLSuite_menuBar_top').click(function(e) {\r
2386           if ($(e.target).attr('class') == 'DHTMLSuite_menuBar_top') { menu.hideSubMenus(); menu.unsetMenuBarState() }\r
2387         });\r
2388         $('#content').mousedown(function(){\r
2389             menu.hideSubMenus();\r
2390             menu.menuBarState = false;\r
2391         });\r
2392         }\r
2393 }\r
2394 \r
2395 \r