/* dm_popelement.js v1.00

	a mootools based script to pop open/closed a DOM element on click
	
	part of the (dm_) dutchmoney script library
	more information/downloads available at: http://lib.dutchmoney.com
	
	distributed under the MIT license, full terms in uncompressed file at url above
	copyright (c) 2007 dutchmoney llc
*/
var dm_popelement=new Class({options:{popstyle:'center',closedheight:5,popdelay:0,closedelay:0},initialize:function(a){this.state=0;this.setOptions(a);if(this.options.target){this.targetElement=$(this.options.target);this.addEvents();this.addEffects();if(this.options.popdelay>0){this.pop.delay(this.options.popdelay,this)}if(this.options.closedelay>0){this.close.delay(this.options.closedelay,this)}}else{console.log('dm_error: you must specify a target when calling the dm_popelement class\ncancelling call...')}},addEvents:function(){this.targetElement.addEvent('click',function(e){var e=new Event(e);var a=$(e.target).getTag();if(a!='a'&&a!='img'&&a!='input'){this.changeState()}}.bind(this))},addEffects:function(){if(this.options.popstyle=='vert'){this.fxPop=new Fx.Style(this.targetElement,'height',{duration:500,transition:Fx.Transitions.Elastic.easeOut});this.fxClose=new Fx.Style(this.targetElement,'height',{duration:250,transition:Fx.Transitions.Back.easeInOut})}else{this.fxPop=new Fx.Styles(this.targetElement,{duration:500,transition:Fx.Transitions.Elastic.easeOut});this.fxClose=new Fx.Styles(this.targetElement,{duration:250,transition:Fx.Transitions.Back.easeInOut})}},pop:function(){if(this.state==0){this.state=1;this.targetElement.setStyle('display','block');var a=this.targetElement.getSize().scrollSize.y;var b=0-(a/2);if(this.options.popstyle=='vert'){this.fxPop.start(this.options.closedheight,a).chain(function(){this.targetElement.setStyle('height','auto');this.state=11}.bind(this))}else{this.fxPop.start({'height':a,'margin-top':b}).chain(function(){this.targetElement.setStyle('height','auto');this.state=11}.bind(this))}}},close:function(){if(this.state==11){this.state=1;var a=this.targetElement.getSize().scrollSize.y;this.targetElement.setStyle('height',a);if(this.options.popstyle=='vert'){this.fxClose.start(a,this.options.closedheight).chain(function(){this.state=0}.bind(this))}else{this.fxClose.start({'height':this.options.closedheight,'margin-top':(this.options.closedheight/2).round()}).chain(function(){this.state=0}.bind(this))}}},changeState:function(){if(this.state==11){this.close()}else{this.pop()}}});dm_popelement.implement(new Options,new Events);