/* (C) 2007 YOOtheme.com, mod_yoo_toppanel.js */

/*eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('H=m.G.I({J:4(5,6){3.F({d:K,M:B,x:m.y.D},6);3.5=$E(\'.g\',5);3.8=$E(\'.g-8\',5);3.c=$E(\'.g-c\',5);3.9=\'n\';3.t=\'l\';3.b=[];3.C(3.6)},A:4(j){p f=$E(j);u(3.5&&f)f.V(\'N\',4(){3.w()}.Y(3))},U:4(){T(p i=0;i<2;i++)3.b[i]=3.Q(3.R[i],3.S[i])},e:4(){7[3.5.q(\'9-n\').k(),3.8.q(\'l\').k()]},r:4(){3.c.a(\'z-h\',P);7 3.v(3.e(),[0,3.6.d])},s:4(){3.c.a(\'z-h\',X);7 3.v(3.e(),[-3.6.d,0])},w:4(){u(3.8.O==0)7 3.r();W 7 3.s()},L:4(){3.5.a(\'9-\'+3.9,3.b[0]+3.6.o);3.8.a(3.t,3.b[1]+3.6.o)}});',61,61,'|||this|function|element|options|return|wrapper|margin|setStyle|now|container|offset|vertical|trigger|panel|index||tr|toInt|height|Fx|top|unit|var|getStyle|slideIn|slideOut|layout|if|start|toggle|transition|Transitions||addTriggerEvent|500|parent|linear||setOptions|Base|YOOtoppanel|extend|initialize|320|increase|duration|click|offsetHeight|20|compute|from|to|for|setNow|addEvent|else|15|bind'.split('|'),0,{}))*/
YOOtoppanel = Fx.Base.extend({
	initialize: function (element, options) {
		this.setOptions({
			offset: 320,
			duration: 500,
			transition: Fx.Transitions.linear
		},
		options);
		this.element = $E('.panel', element);
		this.wrapper = $E('.panel-wrapper', element);
		this.container = $E('.panel-container', element);
		this.margin = 'top';
		this.layout = 'height';
		this.now = [];
		this.parent(this.options)
	},
	addTriggerEvent: function (tr) {
		var trigger = $E(tr);
		if (this.element && trigger) trigger.addEvent('click', function () {
			this.toggle()
		}.bind(this))
	},
	setNow: function () {
		for (var i = 0; i < 2; i++) this.now[i] = this.compute(this.from[i], this.to[i])
	},
	vertical: function () {
		return [this.element.getStyle('margin-top').toInt(), this.wrapper.getStyle('height').toInt()]
	},
	slideIn: function () {
		this.container.setStyle('z-index', 60);
		return this.start(this.vertical(), [0, this.options.offset])
	},
	slideOut: function () {
		this.container.setStyle('z-index', 55);
		return this.start(this.vertical(), [ - this.options.offset, 0])
	},
	toggle: function () {
		if (this.wrapper.offsetHeight == 0) return this.slideIn();
		else return this.slideOut()
	},
	increase: function () {
		this.element.setStyle('margin-' + this.margin, this.now[0] + this.options.unit);
		this.wrapper.setStyle(this.layout, this.now[1] + this.options.unit)
	}
});

