if (typeof(AC) == "undefined") { AC = {}; }
AC.Drawer = Class.create();
Object.extend(AC.Drawer.prototype, Event.Publisher);
Object.extend(AC.Drawer.prototype, {
	bureau: null,
	contentElement: null,
	handle: null,
	indicator: null,
	isOpen: true,
	beforeOpen: null,
	afterOpen: null,
	beforeClose: null,
	afterClose: null,
	transitionDuration: 0.3,
	triggerDelay: 0,
	initialize:	function(contentElement, handleElement, bureau, options) 
				{
					this.contentElement = $(contentElement);
					this.handle = $(handleElement);
					this.bureau = bureau;
					var triggerEvent = 'click';
					if(options != null && typeof(options) != 'undefined') 
					{
						this.beforeOpen = options.beforeOpen;
						this.afterOpen = options.afterOpen;
						this.beforeClose = options.beforeClose;
						this.afterClose = options.afterClose;
						if (typeof(options.triggerEvent) != 'undefined'){triggerEvent = options.triggerEvent;}
						if(typeof(options.triggerDelay) != 'undefined'){this.triggerDelay = options.triggerDelay;}
						if(typeof(options.transitionDuration) != 'undefined'){this.transitionDuration = options.transitionDuration;}
					}
					if(AC.Detector.isiPhone()){this.transitionDuration = 0;triggerEvent = 'click';}
					Element.addClassName(this.contentElement, 'last');
					
					var fireTrigger = function(evt) 
					{
						if(AC.Detector.isiPhone() && (this.isOpen && (this.isVisible === true)) && this.handle.tagName.match(/a/i)) {return;}
						Event.stop(evt);
						if(this.triggerDelay > 0){var onFire = this.trigger.bind(this); bureau.scheduleTrigger(onFire, this.triggerDelay);} 
						else{this.trigger();}
					}
					Event.observe(this.handle, triggerEvent, fireTrigger.bind(this), false);
					Event.observe(this.handle, 'mouseout', bureau.clearTrigger.bind(bureau), false);
				},
	toggle: 	function() {},
	open: 		function() {},
	close: 		function() {}
	
});
