if (typeof(AC) == "undefined") { AC = {}; }
AC.SlidingDrawer = Class.create();
Object.extend(AC.SlidingDrawer.prototype, AC.Drawer.prototype);
Object.extend(AC.SlidingDrawer.prototype, {
	isOpen: true,
	isTransitioning: false,
	setNextDrawer:		function(drawer){this.nextDrawer = drawer; Element.removeClassName(this.contentElement, 'last'); Element.removeClassName(this.handle, 'last');},
	setPreviousDrawer: 	function(drawer){this.previousDrawer = drawer;},
	trigger: 			function(){this.toggle();	},
	toggle: 			function(){if(!this.isOpen){this.initiateOpen();}},
	initiateOpen: 		function(){if(this.isTransitioning || this.isOpen){return;}this.dispatchEvent('beforeOpen', this);},
	open:				function(minHeight)
						{
							this.isTransitioning = true;
							Element.addClassName(this.contentElement, 'open');
							Element.addClassName(this.handle, 'open');
							var afterFinish =function()
								{
									this.isOpen = true;
									if (minHeight) 
									{
										Element.setStyle(this.contentElement, {'min-height': minHeight});
										if (!AC.Detector.isIEStrict()) {Element.setStyle(this.contentElement, {'height': 'auto'});}
									}
									this.dispatchEvent('afterOpen', this);
									this.isTransitioning = false;
								}.bind(this);
							if(AC.Detector.isiPhone()){this.contentElement.show();afterFinish();} 
							else{new Effect.BlindDown(this.contentElement, {duration: this.transitionDuration,afterFinish: afterFinish});}
						},
	initiateClose: 		function(force)
						{
							if (this.isTransitioning || !this.isOpen){return;}
							this.dispatchEvent('beforeClose', this);
						},
	close: 				function(minHeight) 
						{
							this.isTransitioning = true;
							var afterFinish = function()
								{
									this.isOpen = false;
									Element.removeClassName(this.contentElement, 'open');
									Element.removeClassName(this.handle, 'open');
									if(minHeight)
									{
										Element.setStyle(this.contentElement, {'min-height': minHeight});
										if(!AC.Detector.isIEStrict()){Element.setStyle(this.contentElement, {'height': 'auto'});}
									}
									this.dispatchEvent('afterClose', this);
									this.isTransitioning = false;
								}.bind(this);
							if(AC.Detector.isiPhone()){this.contentElement.hide();afterFinish();} 
							else{new Effect.BlindUp(this.contentElement,{duration: this.transitionDuration, afterFinish:  afterFinish});}
						}
});
