PageSourceSearch

https://tehranpeacemuseum.org/modules/mod_ice_verticalmenu/assets/js/icemegamenu.js

js tehranpeacemuseum.org collected 2026-10-02 11:42:43 UTC 55,745 bytes, 1,062 lines download raw bytes

1/** 
2* IceMegaMenu Extension for Joomla 1.6 By IceTheme
3
4We have changed some parts from the original javscript code found
5below to suit the needs to the MegaMenu sctructure.
6
7We dont reccomend that you upgrade this javascript file directly
8from the author as it may not work with the IceMegamenu module.
9
10**/
11
12/**
13 * menuMatic 
14 * @version 0.68.3 (beta)
15 * @author Jason J. Jaeger | greengeckodesign.com
16 * @copyright 2008 Jason John Jaeger
17 * @license MIT-style License
18 *            Permission is hereby granted, free of charge, to any person obtaining a copy
19 *            of this software and associated documentation files (the "Software"), to deal
20 *            in the Software without restriction, including without limitation the rights
21 *            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 *            copies of the Software, and to permit persons to whom the Software is
23 *            furnished to do so, subject to the following conditions:
24 *    
25 *            The above copyright notice and this permission notice shall be included in
26 *            all copies or substantial portions of the Software.
27 *    
28 *            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 *            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 *            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 *            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 *            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 *            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 *            THE SOFTWARE.
35 *    
36 *  @changeLog_________________________________________________________________________________
37 *  
38 *  Nov  15th 2008
39 *  JJJ - incremented version to 0.68.3
40 *      - Fixed bug which occured when ol was used instead of ul.. was because you cannot use selectors such 
41 *          as 'ul.icesubMenu, ol.icesubMenu' with getParent() and getNext() despite the mootool documentation saying "if Selectors 
42 *          is included, a full CSS selector can be passed."
43 *  
44 *  Nov 4th 2008
45 *  JJJ - incremented version to 0.68.2
46 *      - Removed extranious comma which threw an error in IE. (Thanks to Robert S. for catching that)
47 *      - Added check to change the opacity to 99.9 if it is over 99 due to the fact that 
48 *          setting the opaicty to 100% in safari caused misc strange behaviour (thanks to Roland Barker 
49 *          at xnau webdesign for reporting this one)
50 *  
51 *  Nov 3rd 2008
52 *  JJJ - Renamed menuWidth option to stretchMainMenu and made it work much quicker
53 *  
54 *  Nov 2nd 2008
55 *  JJJ - Finished adding several callback functions
56 *      - Added fixHasLayoutBug option
57 *  
58 *  Oct 4th 2008
59 *  JJJ - Continued to go through code to optimize and clean it up
60 *      - Added center option
61 *  
62 *  Sept 28th 2008
63 *  JJJ - Incremented version to 0.68
64 *      - Began optimizing & better commenting code
65 *  
66 *  Sept 16th 2008
67 *  JJJ - Incremented version to 0.67
68 *      - Specifically set each submenu z-index on show, incrementing each time. Set z-index back to 1 on hide.
69 *  
70 *  Sept 14th 2008
71 *  JJJ - Added bottom edge detection and redirection (if bottom of subsequent submenu is lower than the scrollheight of the body)
72 *  
73 *  Sept 10th 2008
74 *  JJJ - Did a google search for MooMenu and it looks like that name is already being used, so I must reluctently change the name.
75 *          The name I have chose to move forward with is: MenuMatic.
76 *  
77 *  Sept 8th 2008
78 *  JJJ - Incremented version to 0.66
79 *      - Fixed IE bug whiched caused some events to be incorrectly attached to parent buttons causing sub submenus to not open
80 *        correctly when transitions are enabled. This error was introduced in 0.65. 
81 *  
82 *  August 10th 2008
83 *  JJJ - Incremented verion to 0.65
84 *      - Fixed bug with edge detection and redirection
85 *      - Improved javascript and CSS to assure the submenus will always be on top
86 *      - Improved edge detection and redirection logic
87 *      - Added subMenusContainerId option so that if you have multiple MooMenu instances on a page they can be styled differently
88 *  
89 *  May 7th 2008
90 *  JJJ - Incremented version to 0.64
91 *      - Fixed bug with that occured when firing events
92 *  
93 *  April 28th 2008:
94 *  JJJ - Incremented version to 0.63
95 *      - Added killDivider option
96 *      - Removed focus on hover since it adds browser default dotted outline
97 *      - Changed menuWidth option to use actual width of nav element (so it can be set in css) instead of a width set in javascript
98 *  
99 *  Feb 17th 2008:
100 *  JJJ - Incremented version to 0.62
101 *      - Added mmbClassName and mmbFocusedClassName options to allow morphing of main menu btns
102 *  
103 *  Feb 16th 2008:
104 *  JJJ - Incremented version to 0.61
105 *      - Made changes to options syntax. 
106 *      - Improved keyboard accessability to take into account a menu's orientation, and its x and y direction when using arrow keys
107 *      - Added matchWidthMode option.
108 *  
109 *  Feb 14th 2008:
110 *  JJJ - Incremented version to 0.60
111 *      - Added menuWidth option to simulate a table based layout for the main menu when the orienation is horizontal
112 **/
113
114
115/*
116 * To Do:
117 * 
118 * 1. Make screencast tutorials
119 * 
120 * 2. Add more examples to website
121 * 
122 * 3. Clean up/optimize CSS / make easier to edit 
123 * 
124 * 4. Make online generator 
125 * 
126 * 5. Add rounded corners option
127 * 
128 * 6. Add drop shadow option
129 * 
130 * 7. Add sound integration 
131 * 
132 */
133var MenuMatic = new Class({
134    Implements: Options,
135    options: {
136        id: 'nav',//the id of the main menu (ul or ol)
137        subMenusContainerId:'subMenusContainer',//id of the container div that will be generated to hold the submenus 
138        
139        //subMenu behavior
140        effect: 'slide & fade',// 'slide', 'fade', 'slide & fade', or  null
141        duration: 600,//duration of the effect in milliseconds
142        physics: Fx.Transitions.Pow.easeOut,//how the effect behaves
143        hideDelay: 1000,//in milliseconds, how long you have after mov
143ing your mouse off of the submenus before they dissapear
144        
145        //layout
146        stretchMainMenu:false,//stretch main menu btn widths to fit within the width {set in the css} of the parent UL or OL
147        matchWidthMode:false,//initial submenus match their parent button's width
148        orientation: 'horizontal',//horizontal or vertical
149        direction:{    x: 'left',    y: 'down' },//for submenus ( relative to the parent button )left or right, up or down
150        tweakInitial:{ x:0, y:0    },//if you need to tweak the placement of the initial submenus
151        tweakSubsequent:{ x:0, y:0 },//if you need to tweak the placement of the subsequent submenus
152        center: false,// will attempt to center main nav element
153        
154        //dynamic style
155        opacity: 95,//of the submenus
156        mmbFocusedClassName:null,//main menu button classname, used for morphing to focused state
157        mmbClassName:null,//main menu button classname, used for morphing back to original state
158        killDivider:null,    
159        
160        fixHasLayoutBug:false,    
161        
162        onHideAllSubMenusNow_begin: (function(){}),
163        onHideAllSubMenusNow_complete: (function(){}),
164        
165        onInit_begin: (function(){}),
166        onInit_complete: (function(){})        
167
168    },
169    
170    hideAllMenusTimeout:null,
171    allSubMenus:[],
172    subMenuZindex:1,
173    
174    initialize: function(options){
175        //if(Browser.Engine.webkit419){return;}        
176        this.setOptions(options);
177        this.options.onInit_begin();
178        if(this.options.opacity > 99){this.options.opacity = 99.9;}
179        this.options.opacity = this.options.opacity /100;
180
181        Element.implement({
182            getId: function(){
183                //If this element does not have an id, give it a unique one
184                if(!this.id){ 
185                    var uniqueId = this.get('tag') + "-" + $time();
186                    while($(uniqueId)){
187                        //make sure it is absolutely unique
188                        uniqueId = this.get('tag') + "-" + $time();                        
189                    }
190                    this.id = uniqueId;                        
191                }
192                return this.id;
193            }
194        });
195        
196        //initialize directions
197        this.options.direction.x = this.options.direction.x.toLowerCase();
198        this.options.direction.y = this.options.direction.y.toLowerCase();
199        if(this.options.direction.x === 'right'){
200            this.options.direction.xInverse = 'left';
201        }else if(this.options.direction.x === 'left'){
202            this.options.direction.xInverse = 'right';
203        }
204        if(this.options.direction.y === 'up'){
205            this.options.direction.yInverse = 'down';
206        }else if(this.options.direction.y === 'down'){
207            this.options.direction.yInverse = 'up';
208        }
209        
210        var links = $(this.options.id).getElements('a.iceMenuTitle'); 
211        //links.append($(this.options.id).getElements('ul.icesubMenu'));  alert(links.toSource());
212                             
213        links.each(function(item,index){
214            
215            //store parent links & child menu info
216            item.store('parentLinks', item.getParent().getParents('li').getFirst('a'));                                                         
217                                  
218            if(String(item.getParent().getParent('div').get('class'))=='iceCols')
219            {
220                item.store('parentLinks',item.getParent().getParent('div').getParent().getParents('li').getFirst().erase(item.getParent().getParent('div').getParent().getParents('li').getFirst().getFirst('a')));  
221            }
222            item.store('childMenu',item.getNext('ul.icesubMenu') || item.getNext('ol.icesubMenu'));
223            
224            //determine submenu type
225            theSubMenuType = 'subsequent';         
226            
227            if( $(item.getParent('ul') || item.getParent('ol') ).id === this.options.id){theSubMenuType = 'initial';    }
228            item.store('subMenuType',theSubMenuType );
229            
230            //add classes to parents
231            if(theSubMenuType === 'initial' && $(item.getNext('ul.icesubMenu') || item.getNext('ol.icesubMenu') )){
232                item.addClass('mainMenuParentBtn');
233            }else if($(item.getNext('ul.icesubMenu') || item.getNext('ol.icesubMenu') )){
234                item.addClass('subMenuParentBtn');
235            }            
236        }.bind(this));
237        
238        //rip the submenus apart into separate divs inside of subMenusContainer
239        var subMenusContainer = new Element('div', { 'id': this.options.subMenusContainerId    }).inject( $(document.body) ,'bottom');
240        $(this.options.id).getElements('ul.icesubMenu, ol.icesubMenu').each(function(item,index){    
241            new Element('div',{'class': 'smOW'}).inject(subMenusContainer).grab(item).addEvents({
242                'mouseenter': function(e){                    
243                }.bind(this)});        
244        }.bind(this));        
245        
246        subMenusContainer.getElements('a').set('tabindex','-1'); 
247        
248        links.each(function(item,index){
249            //only apply to links with subMenus
250            if (!item.retrieve('childMenu')) {return;}
251            //update childMenu pointer to look at smOW DIVs
252            item.store('childMenu', item.retrieve('childMenu').getParent('div'));
253            
254            //add to allSubMenus array
255            this.allSubMenus.include(item.retrieve('childMenu'));            
256            
257            //store parentSubMenus
258            item.store('parentSubMenus',item.retrieve('parentLinks').retrieve('childMenu'));
259
260            //now create the MenuMaticSubMenu class instances 
261
262            var aSubMenu = new MenuMaticSubMenu(this.options,this, item);
263
264        }.bind(this));
265
266        //attach event handlers to non-parent main menu buttons
267        var nonParentBtns = $(this.options.id).getElements('a').filter(function(item, index){ return !item.retrieve('childMenu'); });
268        nonParentBtns.each(function(item, index){
269            item.addEvents({
270                'mouseenter': function(e){             
271                    //e = new Event(e).stop();
272					$(item).getParent('li').addClass('current'); 
273                    this.hideAllSubMenusNow();    
274                    if(this.options.mmbClassName && this.options.mmbFocusedClassName){
275                        $(item).retrieve('btnMorph', new Fx.Morph(item, { 'duration':(this.options.duration/2), transition:this.options.physics, link:'cancel'})).start(this.options.mmbFocusedClassName); 
276                    }     
277                    //$(item).getParent('li').removeClass('notCurrent');
278                                              
279                }.bind(this),
280                
281                'focus': function(e){
282                    //e = new Event(e).stop();
283                    this.hideAllSubMenusNow();    
284                    if(this.options.mmbClassName && this.options.mmbFocusedClassName){
285                        $(item).retrieve('btnMorph', new Fx.Morph(item, { 'duration':(this.options.duration/2), transition:this.options.physics, link:'cancel'})).start(this.options.mmbFocusedClassName); 
286                    }
287                }.bind(this),
288                
289                'mouseleave':function(e){
290                    //e = new Event(e).stop();
291                    if (this.options.mmbClassName && this.options.mmbFocusedClassName) {                        
292                        $(item).retrieve('btnMorph', new Fx.Morph(item, {    'duration': (this.options.duration * 5),transition: this.options.physics,link: 'cancel'    })).start(this.options.mmbClassName);
293                    } 
294                    $(item).getParent('li').removeClass('current');
295                    //$(item).getParent('li').addClass('notCurrent');
296                }.bind(this),
297                
298                'blur':function(e){
299                    //e = new Event(e).stop();
300                    if (this.options.mmbClassName && this.options.mmbFocusedClassName) {                        
301                        $(item).retrieve('btnMorph', new Fx.Morph(item, {    'duration': (this.options.duration * 5),transition: this.options.physics,link: 'cancel'    })).start(this.options.mmbClassName);
302                    }
303                }.bind(this),
304                
305                'keydown' : function(e){
306                    var event = new Event(e);
307                    if (e.key === 'up' || e.key === 'down' || e.key === 'left' || e.key === 'right') {    e.stop();    }
308                    
309                    if( e.key === 'left' && this.options.orientation === 'horizontal' || 
310                        e.key === 'up' && this.options.orientation === 'vertical'){
311                        
312                        if(item.getParent('li').getPrevious('li')){
313                            item.getParent('li').getPrevious('li').getFirst('a').focus();
314                        }else{
315                            item.getParent('li').getParent().getLast('li').getFirst('a').focus();
316                        }
317                    }else if(e.key === 'right' && this.options.orientation === 'horizontal' || 
318                             e.key === 'down' && this.options.orientation === 'vertical'){
319                        if(item.getParent('li').getNext('li')){
320                            item.getParent('li').getNext('li').getFirst('a').focus();
321                        }else{
322                            item.getParent('li').getParent().getFirst('li').getFirst('a').focus();
323                        }    
324                    }
325                }.bind(this)
326            });
327        }, this);
328
329        
330        this.stretch();
331        this.killDivider();
332        this.center();
333        this.fixHasLayoutBug();
334        this.options.onInit_complete();        
335    },
336    
337    fixHasLayoutBug:function(){
338        if(Browser.Engine.trident && this.options.fixHasLayoutBug){
339            $(this.options.id).getParents().setStyle('zoom',1);
340            $(this.options.id).setStyle('zoom',1);
341            $(this.options.id).getChildren().setStyle('zoom',1);
342            $(this.options.subMenusContainerId).setStyle('zoom',1);
343            $(this.options.subMenusContainerId).getChildren().setStyle('zoom',1);
344        }        
345    },
346    
347    center:function(){
348        if(!this.options.center){return;}
349        $(this.options.id).setStyles({'left':'50%','margin-left': -($(this.options.id).getSize().x/2) });
350    },
351    
352    stretch:function(){
353        //stretch main menu btn widths to fit within the width of the parent UL or OL
354        if(this.options.stretchMainMenu  && this.options.orientation === 'horizontal'){
355            var targetWidth = parseFloat($(this.options.id).getCoordinates().width) ;
356            var totalBtnWidth = 0;
357            var mainBtns = $(this.options.id).getElements('a');
358            mainBtns.setStyles({'padding-left':0,'padding-right':0});
359            mainBtns.each(function(item,index){ totalBtnWidth+= item.getSize().x; }.bind(this));
360            if(targetWidth < totalBtnWidth){return;}
361            var increment = (targetWidth - totalBtnWidth)/ mainBtns.length;
362            mainBtns.each(function(item,index){ item.setStyle('width',item.getSize().x+increment);    }.bind(this));
363            mainBtns.getLast().setStyle('width',mainBtns.getLast().getSize().x-1);
364        }
365    },
366    
367    killDivider:function(){
368        if(this.options.killDivider && this.options.killDivider.toLowerCase() === 'first'){
369            $($(this.options.id).getElements('li')[0]).setStyles({'background':'none'});
370        }else if(this.options.killDivider && this.options.killDivider.toLowerCase() === 'last'){
371            $($(this.options.id).getElements('li').getLast()).setStyles({'background':'none'});
372        }
373    },
374
375    hideAllSubMenusNow: function(){
376        this.options.onHideAllSubMenusNow_begin();
377        $clear(this.hideAllMenusTimeout);
378        $$(this.allSubMenus).fireEvent('hide');
379        this.options.onHideAllSubMenusNow_complete();    
380    } 
381    
382});
383
384var MenuMaticSubMenu = new Class({
385    Implements: Options,
386    Extends: MenuMatic,
387    options: {
388        onSubMenuInit_begin: (function(subMenuClass){}),
389        onSubMenuInit_complete: (function(subMenuClass){}),
390        
391        onMatchWidth_begin: (function(subMenuClass){}),
392        onMatchWidth_complete: (function(subMenuClass){}),
393        
394        onHideSubMenu_begin: (function(subMenuClass){}),
395        onHideSubMenu_complete: (function(subMenuClass){}),
396        
397        onHideOtherSubMenus_begin: (function(subMenuClass){}),
398        onHideOtherSubMenus_complete: (function(subMenuClass){}),        
399        
400        onHideAllSubMenus_begin: (function(subMenuClass){}),
401        onHideAllSubMenus_complete: (function(subMenuClass){}),
402        
403        onPositionSubMenu_begin: (function(subMenuClass){}),
404        onPositionSubMenu_complete: (function(subMenuClass){}),
405        
406        onShowSubMenu_begin: (function(subMenuClass){}),
407        onShowSubMenu_complete: (function(subMenuClass){})
408    },
409    root:null,
410    btn:null,
411    hidden:true,
412    myEffect:null,
413        
414    initialize: function(options,root,btn){
415        this.setOptions(options);        
416        this.root = root;
417        this.btn = btn;
418        this.childMenu = this.btn.retrieve('childMenu');
419        this.subMenuType = this.btn.retrieve('subMenuType');
420        this.childMenu = this.btn.retrieve('childMenu');
421        this.parentSubMenus =  $$(this.btn.retrieve('parentSubMenus'));
422        this.parentLinks =  $$(this.btn.retrieve('parentLinks'));
423        this.parentSubMenu = $(this.parentSubMenus[0]);
424        if(this.parentSubMenu ){this.parentSubMenu =this.parentSubMenu.retrieve('class');}
425        this.childMenu.store('class',this);
426        this.btn.store('class',this);
427        this.childMenu.store('status','closed')
428        
429        this.options.onSubMenuInit_begin(this);        
430        
431        //add hide Event
432        this.childMenu.addEvent('hide',function(){this.hideSubMenu();}.bind(this));
433        
434        //add show Event
435        this.childMenu.addEvent('show',function(){this.showSubMenu();}.bind(this));
436
437        if(this.options.effect){
438            this.myEffect = new Fx.Morph(
439                $(this.childMenu).getFirst(), {    duration: this.options.duration, transition: this.options.physics,  link: 'cancel' } 
440            );
441        }
442        if(this.options.effect === 'slide' || this.options.effect === 'slide & fade'){
443            if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' ) {
444                this.childMenu.getFirst().setStyle('margin-top','0' );
445            }else {
446                this.childMenu.getFirst().setStyle('margin-left', '0');
447            }
448            
449        }else if (this.options.effect === 'fade' || this.options.effect === 'slide & fade'){
450            this.childMenu.getFirst().setStyle('opacity',0 );
451        }
452        
453        if (this.options.effect != 'fade' && this.options.effect != 'slide & fade') {
454            this.childMenu.getFirst().setStyle('opacity',this.options.opacity);
455        }
456
457        var nonParentBtns = $(this.childMenu).getElements('a.iceMenuTitle').filter(function(item, index){ return !item.retrieve('
457childMenu'); });                          
458        var that = this;
459		$(this.options.subMenusContainerId).getElements('ul.icesubMenu').each(function(item, index){       
460			item.addEvents({                            
461					'mouseenter': function(e){
462					   item.getParent('div').fireEvent('show'); 
463						that.cancellHideAllSubMenus();    
464					}.bind(this),                    
465					'mouseleave': function(e){ 
466						that.cancellHideAllSubMenus();
467						that.hideAllSubMenus();
468					}.bind(this)
469					
470					});
471		});       
472          
473        nonParentBtns.each(function(item, index){
474            $(item).addClass('subMenuBtn');
475            
476            item.addEvents({       
477                'mouseenter': function(e){          
478                    this.childMenu.fireEvent('show');
479                    this.cancellHideAllSubMenus();                    
480                    this.hideOtherSubMenus();                
481                }.bind(this),
482                
483                'focus': function(e){
484                    this.childMenu.fireEvent('show');
485                    this.cancellHideAllSubMenus();        
486                    this.hideOtherSubMenus();
487                }.bind(this),
488                
489                'mouseleave': function(e){  
490                    this.cancellHideAllSubMenus();
491                    //this.hideAllSubMenus();                     
492                }.bind(this),
493                
494                'blur': function(e){
495                    this.cancellHideAllSubMenus();
496                    this.hideAllSubMenus();
497                }.bind(this),
498                
499                'keydown' : function(e){
500                    var event = new Event(e);
501                    
502                    if (e.key === 'up' || e.key === 'down' || e.key === 'left' || e.key === 'right' || e.key === 'tab') {    e.stop();    }
503                    
504                    if(e.key === 'up'){
505                        if(item.getParent('li').getPrevious('li')){
506                            //move focus to the next link up if possible
507                            item.getParent('li').getPrevious('li').getFirst('a').focus();
508                        }else if(this.options.direction.y ==='down'){
509                            //move focus to the parent link
510                            this.btn.focus();
511                        }else if(this.options.direction.y ==='up'){
512                            //move focus to the last link in the subMenu
513                            item.getParent('li').getParent().getLast('li').getFirst('a').focus();
514                        }
515                    }else if(e.key === 'down'){
516                        if(item.getParent('li').getNext('li')){
517                            //move focus to the next link down if possible
518                            item.getParent('li').getNext('li').getFirst('a').focus();
519                        }else if(this.options.direction.y ==='down'){
520                            //move focus to the first link in the submenu
521                            item.getParent('li').getParent().getFirst('li').getFirst('a').focus();
522                        }else if(this.options.direction.y ==='up'){
523                            //move focus to the parent link
524                            this.btn.focus();
525                        }
526                    }else if(e.key === this.options.direction.xInverse){
527                        this.btn.focus();
528                    }
529                }.bind(this) 
530            });
531            
532        }, this);  
533        
534        $(this.btn).removeClass('subMenuBtn');    
535        
536        if (this.subMenuType == 'initial') {
537            this.btn.addClass('mainParentBtn');    
538        }else{    
539            this.btn.addClass('subParentBtn');    
540        }
541       
542        //attach event handlers to parent button
543        $(this.btn).addEvents({
544            'mouseenter' : function(e){    
545                //e = new Event(e).stop();
546                this.cancellHideAllSubMenus();
547                this.hideOtherSubMenus();
548                this.showSubMenu();
549                if(this.subMenuType === 'initial' && this.options.mmbClassName && this.options.mmbFocusedClassName){
550                    $(this.btn).retrieve('btnMorph', new Fx.Morph($(this.btn), { 'duration':(this.options.duration/2), transition:this.options.physics, link:'cancel' })).start(this.options.mmbFocusedClassName);
551                }
552            }.bind(this),
553            
554            'focus' : function(e){            
555                //e = new Event(e).stop();
556                this.cancellHideAllSubMenus();
557                this.hideOtherSubMenus();
558                this.showSubMenu();
559                if(this.subMenuType === 'initial' && this.options.mmbClassName && this.options.mmbFocusedClassName){
560                    $(this.btn).retrieve('btnMorph', new Fx.Morph($(this.btn), { 'duration':(this.options.duration/2), transition:this.options.physics, link:'cancel' })).start(this.options.mmbFocusedClassName);
561                }
562            }.bind(this),
563                
564            'mouseleave': function(e){     
565                //e = new Event(e).stop();  
566				
567                if($(this.btn).getParent().get('class')=='iceMenuLiLevel_1')
568                {                       
569                    this.cancellHideAllSubMenus();
570                    this.hideAllSubMenus();
571                }  
572                else{
573                    this.hideSubMenu();
574                }  
575            }.bind(this),
576            
577            'blur': function(e){
578                //e = new Event(e).stop();
579                this.cancellHideAllSubMenus();
580                this.hideAllSubMenus();
581            }.bind(this),
582            
583            'keydown' : function(e){
584                e = new Event(e)
585                if (e.key === 'up' || e.key === 'down' || e.key === 'left' || e.key === 'right') {    e.stop();    }
586                
587                if(!this.parentSubMenu){
588                    //main menu parent buttons
589                    if(
590                        this.options.orientation === 'horizontal' && e.key === this.options.direction.y ||
591                        this.options.orientation === 'vertical' && e.key === this.options.direction.x
592                    ){
593                        if(this.options.direction.y ==='down'){
594                            //move focus to the first link in the child menu
595                            this.childMenu.getFirst().getFirst('li').getFirst('a').focus();
596                        }else if(this.options.direction.y ==='up'){
597                            //move focus to the first link in the child menu
598                            this.childMenu.getFirst().getLast('li').getFirst('a').focus();
599                        }
600                    }else if(
601                        this.options.orientation === 'horizontal' && e.key === 'left' ||
602                        this.options.orientation === 'vertical' && e.key === this.options.direction.yInverse 
603                    ){
604                        //move focus to the previous link if possible, if not, move focus to the last link in the menu
605                        if(this.btn.getParent().getPrevious()){
606                            this.btn.getParent().getPrevious().getFirst().focus();
607                        }else{
608                            this.btn.getParent().getParent().getLast().getFirst().focus();
609                        }
610                    }else if(
611                        this.options.orientation === 'horizontal' && e.key === 'right' ||
612                        this.options.orientation === 'vertical' && e.key === this.options.direction.y 
613                    ){
614                        //move focus to the next link if possible, if not, move focus to the first link in the menu
615                        if (this.btn.getParent().getNext()) {
616                            this.btn.getParent().getNext().getFirst().focus();
617                        }else{
618                            this.btn.getParent().getParent().getFirst().getFirst().focus();
619                        }
620                    }
621                }else{
622                    if(e.key === 'tab'){e.stop();}
623                    //submenu parent buttons
624                    if (e.key === 'up') {
625                        if (this.btn.getParent('li').getPrevious('li')) {
626                            //move focus to the next link up
627                            this.btn.getParent('li').getPrevious('li').getFirst('a').focus();
628                        }else if(this.options.direction.y === 'down'){
629                            //move focus to the parent link
630                            this.parentSubMenu.btn.focus();
631                        }else if(this.options.direction.y === 'up'){
632                            //move focus to the bottom link in this submenu
633                            this.btn.getParent('li').getParent().getLast('li').getFirst('a').focus();
634                        }
635                    }else if(e.key === 'down'){
636                        if(this.btn.getParent('li').getNext('li')){
637                            //move focus to the next link down
638                            this.btn.getParent('li').getNext('li').getFirst('a').focus();
639                        }else if(this.options.direction.y === 'down'){
640                            //move focus to the top link in this submenu
641                            this.btn.getParent('li').getParent().getFirst('li').getFirst('a').focus();
642                        }else if(this.options.direction.y === 'up'){
643                            //move focus to the parent link
644                            this.parentSubMenu.btn.focus();
645                        }
646                    }else if(e.key === this.options.direction.xInverse){
647                        this.parentSubMenu.btn.focus();
648                    }else if(e.key === this.options.direction.x){
649                        if(this.options.direction.y === 'down'){
650                            this.childMenu.getFirst().getFirst('li').getFirst('a').focus();
651                        }else if(this.options.direction.y === 'up'){
652                        //    this.childMenu.getFirst().getLast('li').getFirst('a').focus();
653                        }
654                    }
655                }
656            }.bind(this)    
657        });
658        
659        this.options.onSubMenuInit_complete(this);
660        
661    },
662    
663    matchWidth:function(){
664        if (this.widthMatched || !this.options.matchWidthMode || this.subMenuType === 'subsequent'){return;}
665        this.options.onMatchWidth_begin(this);
666        var parentWidth = this.btn.getCoordinates().width;
667        $(this.childMenu).getElements('a').each(function(item,index){
668            var borderWidth = parseFloat($(this.childMenu).getFirst().getStyle('border-left-width')) + parseFloat($(this.childMenu).getFirst().getStyle('border-right-width'));
669            var paddingWidth = parseFloat(item.getStyle('padding-left')) +     parseFloat(item.getStyle('padding-right'));
670            var offset = borderWidth + paddingWidth ;
671            if(parentWidth > item.getCoordinates().width){
672                item.setStyle('width',parentWidth - offset);
673                item.setStyle('margin-right',-borderWidth);
674            }
675        }.bind(this));
676        this.width = this.childMenu.getFirst().getCoordinates().width;
677        this.widthMatched = true;
678        this.options.onMatchWidth_complete(this);
679    },
680    
681    hideSubMenu: function() {    
682        if(this.childMenu.retrieve('status') === 'closed'){return;}    
683        this.options.onHideSubMenu_begin(this);
684        if (this.subMenuType == 'initial') {
685            if(this.options.mmbClassName && this.options.mmbFocusedClassName){
686                $(this.btn).retrieve('btnMorph', new Fx.Morph($(this.btn), { 'duration':(this.options.duration), transition:this.options.physics, link:'cancel' })).start(this.options.mmbClassName )
687                .chain(function(){
688                    $(this.btn).removeClass('mainMenuParentBtnFocused');
689                    $(this.btn).addClass('mainMenuParentBtn');
690                    $(this.btn).getParent('li').removeClass('current');
691                    //$(this.btn).getParent('li').addClass('notCurrent'); 
692                }.bind(this));
693            }else{
694                $(this.btn).removeClass('mainMenuParentBtnFocused');
695                $(this.btn).addClass('mainMenuParentBtn');
696                 $(this.btn).getParent('li').removeClass('current');
697                 //$(this.btn).getParent('li').addClass('notCurrent');
698            }
699        }else{
700            $(this.btn).removeClass('subMenuParentBtnFocused');
701            $(this.btn).addClass('subMenuParentBtn');
702             $(this.btn).getParent('li').removeClass('current');
703             //$(this.btn).getParent('li').addClass('notCurrent');
704        }
705        
706        this.childMenu.setStyle('z-index', 1);
707       
708        if(this.options.effect && this.options.effect.toLowerCase() === 'slide'){
709            if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'down') {
710                this.myEffect.start({ 'margin-top': -this.height }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
711            }else if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'up') {
712                this.myEffect.start({ 'margin-top': this.height }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
713            }else if(this.options.direction.x === 'right'){
714                this.myEffect.start({ 'margin-left': -this.width }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
715            }else if(this.options.direction.x === 'left'){
716                this.myEffect.start({ 'margin-left': this.width }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
717            }
718        }else if(this.options.effect == 'fade'){  
719            this.myEffect.start({ 'opacity': 0 }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
720        }else if(this.options.effect == 'slide & fade'){    
721            if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'down') {
722                this.myEffect.start({ 'margin-top': -this.height }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
723            }else if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' && this.options.direction.y === 'up') {
724                this.myEffect.start({ 'margin-top': this.height }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
725            }else if(this.options.direction.x === 'right'){
726                this.myEffect.start({ 'margin-left': -this.width }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
727            }else if(this.options.direction.x === 'left'){
728                this.myEffect.start({ 'margin-left': this.width }).chain(function(){    this.childMenu.style.display = "none";    }.bind(this));
729            }
730        }else{   
731            this.childMenu.style.display = "none";
732        }
733        this.childMenu.store('status','closed');
734        this.options.onHideSubMenu_complete(this);
735    },
736    
737    hideOtherSubMenus: function() {        
738        this.options.onHideOtherSubMenus_begin(this);
739        //set up otherSubMenus element collection
740        if(!this.btn.retrieve('otherSubMenus')){
741            this.btn.store('otherSubMenus', $$(this.root.allSubMenus.filter(function(item){ return !this.btn.retrieve('parentSubMenus').contains(item) && item != this.childMenu; }.bind(this)) ));
742        }        
743        this.parentSubMenus.fireEvent('show');
744        this.btn.retrieve('otherSubMenus').fireEvent('hide');
745        this.options.onHideOtherSubMenus_complete(this);
746    },
747    
748    hideAllSubMenus: function(){
749        this.options.onHideAllSubMenus_begin(this);
750        $clear(this.root.hideAllMenusTimeout);
751        this.root.hideAllMenusTimeout = (function(){
752            $clear(this.hideAllMenusTimeout);            
753            $$(this.root.allSubMenus).fireEvent('hide');            
754        }).bind(this).delay(this.options.hideDelay);
755        this.options.onHideAllSubMenus_complete(this);        
756    },
757
758    cancellHideAllSubMenus: function(){ 
759        $clear(this.root.hideAllMenusTimeout);    
760    },
761    
762    showSubMenu: function(now){    //alert('ass')    
763        //if(this.childMenu.retrieve('status') === 'open'){alert('ss'); return;}   
764        this.options.onShowSubMenu_begin(this);
765        if (this.subMenuType == 'initial') {
766            $(this.btn).removeClass('mainMenuParentBtn');
767            $(this.btn).addClass('mainMenuParentBtnFocused');   
768            //$(this.btn).getParent('li').removeClass('notCurrent');
769            $(this.btn).getParent('li').addClass('current'); 
770        }else{
771            $(this.btn).removeClass('subMenuParentBtn');
772            $(this.btn).addClass('subMenuParentBtnFocused');
773            //$(this.btn).getParent('li').removeClass('notCurrent');
774            $(this.btn).getParent('li').addClass('current'); 
775        }         
776        this.root.subMenuZindex++;
777        this.childMenu.setStyles({'display':'block','visibility':'hidden','z-index':1000});
778        
779        if(!this.width || !this.height ){
780            this.width = this.childMenu.getFirst().getCoordinates().width;
781            this.height = this.childMenu.getFirst().getCoordinates().height;
782            this.childMenu.setStyle('height',this.height,'border');
783            if(this.options.effect === 'slide' || this.options.effect === 'slide & fade'){
784                if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' ) {
785                    this.childMenu.getFirst().setStyle('margin-top','0' );
786                    if(this.options.direction.y === 'down'){
787                        this.myEffect.set({ 'margin-top': - this.height });
788                    }else if(this.options.direction.y === 'up'){
789                        this.myEffect.set({ 'margin-top': this.height });
790                    }
791                }else {
792                    if(this.options.direction.x === 'left'){
793                        this.myEffect.set({ 'margin-left': this.width });
794                    }else{
795                        this.myEffect.set({ 'margin-left': -this.width });
796                    }
797                }
798            }
799        }
800        this.matchWidth();
801        this.positionSubMenu();
802        
803        if(this.options.effect === 'slide' ){
804            this.childMenu.setStyles({'display':'block','visibility':'visible'});
805            if (this.subMenuType === 'initial' && this.options.orientation === 'horizontal') {
806                if(now){
807                    this.myEffect.set({ 'margin-top': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
808                }else{
809                    this.myEffect.start({ 'margin-top': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
810                }
811            }else{
812                if (now) {
813                    this.myEffect.set({ 'margin-left': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
814                }else{
815                    this.myEffect.start({ 'margin-left': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
816                }
817            }
818        }else if(this.options.effect === 'fade' ){
819            if (now) {
820                this.myEffect.set({'opacity': this.options.opacity}).chain(function(){    this.showSubMenuComplete();    }.bind(this));
821            }else{
822                this.myEffect.start({'opacity': this.options.opacity}).chain(function(){    this.showSubMenuComplete();    }.bind(this));
823            }
824        }else if(this.options.effect == 'slide & fade'){
825            this.childMenu.setStyles({'display':'block','visibility':'visible'});
826            this.childMenu.getFirst().setStyles({'left':0});
827            if (this.subMenuType === 'initial' && this.options.orientation === 'horizontal') {
828                if (now) {
829                    this.myEffect.set({ 'margin-top': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
830                }else{
831                    this.myEffect.start({ 'margin-top': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
832                }
833            }else{
834                if (now) {
835                    if (this.options.direction.x === 'right') {
836                        this.myEffect.set({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComp
836lete();    }.bind(this));
837                    }else if (this.options.direction.x === 'left') {
838                        this.myEffect.set({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
839                    }    
840                }else{
841                    if (this.options.direction.x === 'right') {                        
842                        this.myEffect.set({ 'margin-left': -this.width, 'opacity': this.options.opacity });                        
843                        this.myEffect.start({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
844                    }else if (this.options.direction.x === 'left') {
845                        this.myEffect.start({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
846                    }
847                }
848            }
849        }else{
850            this.childMenu.setStyles({'display':'block','visibility':'visible'}).chain(function(){    this.showSubMenuComplete(this);    }.bind(this));
851        }
852        this.childMenu.store('status','open');
853        
854    },
855    showSubMenu: function(now){
856        //if(this.childMenu.retrieve('status') === 'open'){alert('ss'); return;}   
857        this.options.onShowSubMenu_begin(this);
858        if (this.subMenuType == 'initial') {
859            $(this.btn).removeClass('mainMenuParentBtn');
860            $(this.btn).addClass('mainMenuParentBtnFocused');  
861            //$(this.btn).getParent('li').removeClass('notCurrent');
862            $(this.btn).getParent('li').addClass('current');   
863        }else{
864            $(this.btn).removeClass('subMenuParentBtn');
865            $(this.btn).addClass('subMenuParentBtnFocused');
866            $(this.btn).removeClass('mainMenuParentBtn');
867            $(this.btn).addClass('mainMenuParentBtnFocused');
868            $(this.btn).getParent('li').removeClass('current');
869           // $(this.btn).getParent('li').addClass('notCurrent'); 
870        }
871        this.root.subMenuZindex++;    
872        this.childMenu.setStyles({'display':'block','visibility':'hidden','z-index':1000});
873        
874        if(!this.width || !this.height ){
875            this.width = this.childMenu.getFirst().getCoordinates().width;
876            this.height = this.childMenu.getFirst().getCoordinates().height;
877            this.childMenu.setStyle('height',this.height,'border');
878            if(this.options.effect === 'slide' || this.options.effect === 'slide & fade'){
879                if (this.subMenuType == 'initial' && this.options.orientation === 'horizontal' ) {
880                    this.childMenu.getFirst().setStyle('margin-top','0' );
881                    if(this.options.direction.y === 'down'){
882                        this.myEffect.set({ 'margin-top': - this.height });
883                    }else if(this.options.direction.y === 'up'){
884                        this.myEffect.set({ 'margin-top': this.height });
885                    }
886                }else {
887                    if(this.options.direction.x === 'left'){
888                        this.myEffect.set({ 'margin-left': this.width });
889                    }else{
890                        this.myEffect.set({ 'margin-left': -this.width });
891                    }
892                }
893            }
894        }
895        this.matchWidth();
896        this.positionSubMenu();
897        
898        if(this.options.effect === 'slide' ){
899            this.childMenu.setStyles({'display':'block','visibility':'visible'});
900            if (this.subMenuType === 'initial' && this.options.orientation === 'horizontal') {
901                if(now){
902                    this.myEffect.set({ 'margin-top': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
903                }else{
904                    this.myEffect.start({ 'margin-top': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
905                }
906            }else{
907                if (now) {
908                    this.myEffect.set({ 'margin-left': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
909                }else{
910                    this.myEffect.start({ 'margin-left': 0 }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
911                }
912            }
913        }else if(this.options.effect === 'fade' ){
914            if (now) {
915                this.myEffect.set({'opacity': this.options.opacity}).chain(function(){    this.showSubMenuComplete();    }.bind(this));
916            }else{
917                this.myEffect.start({'opacity': this.options.opacity}).chain(function(){    this.showSubMenuComplete();    }.bind(this));
918            }
919        }else if(this.options.effect == 'slide & fade'){
920            this.childMenu.setStyles({'display':'block','visibility':'visible'});
921            this.childMenu.getFirst().setStyles({'left':0});
922            if (this.subMenuType === 'initial' && this.options.orientation === 'horizontal') {
923                if (now) {
924                    this.myEffect.set({ 'margin-top': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
925                }else{
926                    this.myEffect.start({ 'margin-top': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
927                }
928            }else{
929                if (now) {
930                    if (this.options.direction.x === 'right') {
931                        this.myEffect.set({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
932                    }else if (this.options.direction.x === 'left') {
933                        this.myEffect.set({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
934                    }    
935                }else{
936                    if (this.options.direction.x === 'right') {                        
937                        //this.myEffect.set({ 'margin-left': -this.width, 'opacity': this.options.opacity });                        
938                        this.myEffect.start({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
939                    }else if (this.options.direction.x === 'left') {
940                        this.myEffect.start({ 'margin-left': 0, 'opacity': this.options.opacity }).chain(function(){    this.showSubMenuComplete();    }.bind(this));
941                    }
942                }
943            }
944        }else{
945            this.childMenu.setStyles({'display':'block','visibility':'visible'}).chain(function(){    this.showSubMenuComplete(this);    }.bind(this));
946        }
947        this.childMenu.store('status','open');
948        
949    },
950    
951    showSubMenuComplete:function(){        
952        this.options.onShowSubMenu_complete(this);
953    },
954    
955    positionSubMenu: function(){
956        this.options.onPositionSubMenu_begin(this);
957        this.childMenu.setStyle('width',this.width) ;
958        this.childMenu.getFirst().setStyle('width',this.width) ;
959        
960        //if any parent has bounced off a viewport edge, inherit that new direction
961        if (this.subMenuType === 'subsequent') {
962            if(this.parentSubMenu && this.options.direction.x != this.parentSubMenu.options.direction.x){
963                if(this.parentSubMenu.options.direction.x === 'left' && this.options.effect && this.options.effect.contains('slide')){
964                    this.myEffect.set({ 'margin-left': this.width });    
965                }
966            }
967            this.options.direction.x = this.parentSubMenu.options.direction.x;
968            this.options.direction.xInverse = this.parentSubMenu.options.direction.xInverse;
969            this.options.direction.y = this.parentSubMenu.options.direction.y;
970            this.options.direction.yInverse = this.parentSubMenu.options.direction.yInverse;
971        }
972
973        var top;
974        var overlap
975        if(this.subMenuType == 'initial')
976		{
977            if(this.options.direction.y === 'up')
978			{
979                if(this.options.orientation === 'vertical')
980				{
981                    top = this.btn.getCoordinates().bottom - this.height + this.options.tweakInitial.y ;
982                }
983				else
984				{
985                    top = this.btn.getCoordinates().top - this.height + this.options.tweakInitial.y ;
986                }
987                this.childMenu.style.top = top+ 'px';
988            }
989			else if(this.options.orientation == 'horizontal')
990			{
991                this.childMenu.style.top = this.btn.getCoordinates().bottom + this.options.tweakInitial.y + 'px';
992            }
993			else if(this.options.orientation == 'vertical')
994			{
995                top = this.btn.getPosition().y + this.options.tweakInitial.y ;                
996                if((top + this.childMenu.getSize().y) >= $(document.body).getScrollSize().y){
997                    overlap = (top + this.childMenu.getSize().y) 
997- $(document.body).getScrollSize().y  ;
998                    top = top - overlap - 20;
999                }    
1000                this.childMenu.style.top = top+ 'px';
1001            }
1002            if(this.options.orientation == 'horizontal'){
1003				if($(document.body).getScrollSize().x > (this.btn.getPosition().x + this.childMenu.getCoordinates().width))				
1004                	this.childMenu.style.left = this.btn.getPosition().x + this.options.tweakInitial.x + 'px';
1005				else if(this.btn.getCoordinates().right > this.childMenu.getCoordinates().width)
1006					this.childMenu.style.left = this.btn.getCoordinates().right - this.childMenu.getCoordinates().width + 'px';
1007				else
1008					this.childMenu.style.left = ($(document.body).getScrollSize().x - this.childMenu.getCoordinates().width)/2 + 'px';
1009					
1010            }else if(this.options.direction.x == 'left'){
1011				this.childMenu.style.left = this.btn.getPosition().x - this.childMenu.getCoordinates().width + this.options.tweakInitial.x + 'px';
1012            }else if(this.options.direction.x == 'right'){				
1013                this.childMenu.style.left = this.btn.getCoordinates().right + this.options.tweakInitial.x + 'px';
1014            }
1015        }
1016		else if(this.subMenuType == 'subsequent')
1017		{
1018            if(this.options.direction.y === 'down'){
1019                if((this.btn.getCoordinates().top + this.options.tweakSubsequent.y+ this.childMenu.getSize().y) >= $(document.body).getScrollSize().y ){
1020                    overlap = (this.btn.getCoordinates().top + this.options.tweakSubsequent.y+ this.childMenu.getSize().y) -$(document.body).getScrollSize().y;
1021					this.childMenu.style.top = (this.btn.getCoordinates().top + this.options.tweakSubsequent.y) - overlap - 20+ 'px';
1022                }else{
1023                    this.childMenu.style.top = this.btn.getCoordinates().top + this.options.tweakSubsequent.y + 'px';
1024                }
1025            }else if(this.options.direction.y === 'up'){
1026                if((this.btn.getCoordinates().bottom - this.height + this.options.tweakSubsequent.y)< 1){
1027                    this.options.direction.y = 'down';
1028                    this.options.direction.yInverse = 'up';
1029                    this.childMenu.style.top = this.btn.getCoordinates().top + this.options.tweakSubsequent.y + 'px';
1030                }else{
1031                    this.childMenu.style.top = this.btn.getCoordinates().bottom - this.height + this.options.tweakSubsequent.y + 'px';
1032                }
1033            }
1034            if(this.options.direction.x == 'left'){
1035                this.childMenu.style.left = this.btn.getCoordinates().left - this.childMenu.getCoordinates().width + this.options.tweakSubsequent.x + 'px';
1036                
1037                if( this.childMenu.getPosition().x < 0){                    
1038                    this.options.direction.x = 'right';
1039                    this.options.direction.xInverse = 'left';
1040                    this.childMenu.style.left = this.btn.getPosition().x + this.btn.getCoordinates().width + this.options.tweakSubsequent.x + 'px';
1041                    
1042                    if(this.options.effect === 'slide' || this.options.effect === 'slide & fade'){
1043                        this.myEffect.set({ 'margin-left': -this.width, 'opacity': this.options.opacity });                        
1044                    }
1045                }
1046            }else if(this.options.direction.x == 'right'){
1047                this.childMenu.style.left = this.btn.getCoordinates().right + this.options.tweakSubsequent.x + 'px';
1048                var smRight = this.childMenu.getCoordinates().right;
1049                var viewportRightEdge = document.getCoordinates().width + window.getScroll().x;                
1050                if( smRight > viewportRightEdge ){
1051                    this.options.direction.x = 'left';
1052                    this.options.direction.xInverse = 'right';
1053                    this.childMenu.style.left = this.btn.getCoordinates().left - this.childMenu.getCoordinates().width + this.options.tweakSubsequent.x + 'px'
1054                    if (this.options.effect === 'slide' || this.options.effect === 'slide & fade') {
1055                        this.myEffect.set({    'margin-left': 0,    'opacity': this.options.opacity    });
1056                    }
1057                }
1058            }
1059        }
1060        this.options.onPositionSubMenu_complete(this);
1061    }    
1062});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.