// JavaScript Document

var BottomMenuControl = Class.create(
{
	element: null,
	
	dom: {},
	
	menu: null, // BottomMenu object
	
	initialize: function( element )
	{
		this.element = $( element );
		
		this.initDOM();
		this.initOther();
		this.initEvents();
	},
	
	initDOM: function()
	{
		this.dom.menu = this.element.next( "ul.bottom-menu" );
		
		if( typeof this.dom.menu === "undefined" )
			throw "BottomMenuControl::initDOM() Cannot initialize menu";
	},
	
	initOther: function()
	{
		this.menu = new BottomMenu( this.dom.menu, this );
	},
	
	initEvents: function()
	{
		this.element.observe( "click", this.handleClick.bind( this ) );
	},
	
	getElement: function()
	{
		return this.element;
	},
	
	handleClick: function( e )
	{
		Event.stop( e );
		this.element.blur();
		this.menu.toggle();
	}
});
		
document.observe( "dom:loaded", function(){ $$( '.bottom-menu-control' ).each( function( el ){ new BottomMenuControl( el ) } ) } );	