/*** Asset: asset/scripts/menu.js ***/

var Menu=new Class({Implements:[Options,Events,Chain],options:{'direction':'down','effects':{'duration':250,'transition':Fx.Transitions.Cubic.easeIn},'child_options':{'direction':'right','effects':{'duration':250,'transition':Fx.Transitions.Cubic.easeIn}}},initialize:function(menu,options){if($type(menu)=='string')
this.menu=$(menu);else this.menu=menu;if(!this.menu)return;this.setOptions(options);this.wrapper=new Element('div',{'styles':{'margin':0,'padding':0,'opacity':0,'display':'block','width':0,'height':0,'overflow':'hidden','position':'absolute'}});this.menu.getChildren('li').getChildren('ul').each(function(el){if($type(el[0])!='element')return;var child=el[0];el=child.getParent();this.slide(el,child);new Menu(child,this.options.child_options);}.bind(this));},slide:function(el,child){var wrapper=this.wrapper.clone();wrapper.inject(child,'before');child.setStyle('display','block');var inherit_styles={};if(child.getStyle('position')=='absolute'){inherit_styles=child.getStyles('top','right','bottom','left');child.setStyles({'position':'relative','top':'auto','right':'auto','bottom':'auto','left':'auto'});}
var height=child.getHeight().toInt();var width=child.getWidth().toInt();wrapper.grab(child);var fx=new Fx.Morph(wrapper,this.options.effects);el.addEvent('mouseenter',function(){el.addClass('active');wrapper.setStyles({'overflow':'hidden','width':(this.options.direction=='right'?0:width),'height':(this.options.direction=='down'?0:height),'opacity':1});wrapper.setStyles(inherit_styles);fx.start({'height':height,'width':width}).chain(function(){wrapper.setStyle('overflow','visible');}.bind(this));}.bind(this));el.addEvent('mouseleave',function(){el.removeClass('active');wrapper.setStyle('opacity',0);}.bind(this));}});
