window.addEvent( 'domready', function()
{
		
		Element.implement({
			
			addEventDelegate : function( type, fnc )
			{
				this.addEvent( type, function( e )
				{
					var a = new Event( e );
					a.target = this;
					fnc( a );
				}.bind( this ))
			},
			
			addEventDelegates : function( obj )
			{
				for( var o in obj )
				{
					this.addEventDelegate( o, obj[o] );
				}
			}
			
		})
		
		new new Class({
			
			initialize : function()
			{
				$( 'nav1' ).getElements( 'div' ).each(function( item )
				{
					var ch = item.getElements( '.nav_slide' )[0];
					item.slider = ch;
					item.fx = new Fx.Morph( ch, { duration : 300 } );
					item.addEventDelegates({
						'mouseenter' : this.showPane.bind( this ),
						'mouseleave' : this.hidePane.bind( this )						
					});
				}.bind( this ));
			},
			
			showPane : function( e )
			{
				var item = e.target;
				if( item.fx && item.slider )
				{
					item.fx.cancel();
					item.fx.start({
						'margin-top' : -( item.slider.getSize().y )
					});
				}
			},
			
			hidePane : function( e )
			{
				var item = e.target;
				if( item.fx && item.slider )
				{
					item.fx.cancel();
					item.fx.start({
						'margin-top' : 0
					});
				}
			}
			
		})		
});
