/*
 Moogets - MorphList 0.5 (formerly SlideList, aka Fancy Menu)
	- MooTools version required: 1.2
	- MooTools components required: 
		Core: Fx.Tween, Fx.Morph, Selectors, Element.Event and dependencies
		More: -

	Changelog:
		- 0.1: First release
		- 0.2: MooTools 1.2 compatible
		- 0.3: Now alters morphs width/height/top properties by default
		- 0.4: Morphing code now part of the function and not of the event.
		- 0.5: setOpacity changed to fade('show') so that visibility css is altered.
*/

/* Copyright: Guillermo Rauch <http://devthought.com/> - Distributed under MIT - Keep this message! */

var MorphList=new Class({Implements:[Events,Options],options:{morph:{link:"cancel"}},initialize:function(c,a){var b=this;this.setOptions(a);this.menu=$(c);this.menuitems=this.menu.getChildren();this.menuitems.addEvents({mouseenter:function(){b.morphTo(this)},mouseleave:function(){b.morphTo(b.current)},click:function(d){b.click(d,this)}});this.bg=new Element("li",{"class":"background"}).adopt(new Element("div",{"class":"left"}));this.bg.inject(this.menu).set("morph",this.options.morph);this.setCurrent(this.menu.getElement(".current"))},click:function(b,a){this.setCurrent(a,true);this.fireEvent("onClick",[b,a])},setCurrent:function(b,a){if(b&&!this.current){this.bg.set("styles",{left:b.offsetLeft,width:b.offsetWidth,height:b.offsetHeight,top:b.offsetTop});(a)?this.bg.fade("hide").fade("in"):this.bg.fade("show")}if(this.current){this.current.removeClass("current")}if(b){this.current=b.addClass("current")}},morphTo:function(a){if(!this.current){return}this.bg.morph({left:a.offsetLeft,top:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight});this.fireEvent("onMorph",a)}});