var ToolbarDrawer = jQuery.Class.create({
	
	options:{
		openerClass: 'toolbarAction',
		openDuration: 800,
		openTransition: 'linear',
		closeDuration: 800,
		closeTransition: 'linear'
	},
	element: null,
	busy:false,	
	
    init: function(elt, options)
	{
		this.element = $('#'+elt);
		this.options = options;
		$('.'+this.options.openerClass).bind('click', this, this._openClose);
		$('.'+this.options.openerClass+' a').bind('click', this, this._noneClick);
		// this.element.bind("mouseleave", this, this._mouseLeave);
    },
	
	_noneClick: function(e) 
	{
		window.location.href = e.target.href;
		return false;
	},
	
	_openClose: function(e) 
	{
		var _this = e.data;
		if (!_this.busy) 
		{
			if (_this.element.css('display') == 'none')
			{
				_this.busy = true;
				_this.element.css({ marginTop: - (_this.element.outerHeight()) }).show()
				.animate({ marginTop: 0 }, {
					duration:_this.options.openDuration,
					easing:_this.options.openTransition,
					complete:function(){
						_this.busy = false;
					}
				});
			}
			else
			{
				_this.busy = true;
				_this.element.animate({ marginTop: - (_this.element.outerHeight()) }, {
					queue:true, 
					duration:_this.options.closeDuration,
					easing:_this.options.closeTransition,
					complete:function(){
						_this.busy = false;
						_this.element.hide();
					}
				});
			}
		}
	}	
});
