// MooTools: the javascript framework.
// Load this file's selection again by visiting: http://mootools.net/more/fe8902069d60b562fc160ed306813577 
// Or build this file again with packager using: packager build More/Fx.Slide
/*
---

script: More.js

name: More

description: MooTools More

license: MIT-style license

authors:
  - Guillermo Rauch
  - Thomas Aylott
  - Scott Kyle
  - Arian Stolwijk
  - Tim Wienk
  - Christoph Pojer
  - Aaron Newton
  - Jacob Thornton

requires:
  - Core/MooTools

provides: [MooTools.More]

...
*/

MooTools.More = {
	'version': '1.3.2.1',
	'build': 'e586bcd2496e9b22acfde32e12f84d49ce09e59d'
};


/*
---

script: Fx.Slide.js

name: Fx.Slide

description: Effect to slide an element in and out of view.

license: MIT-style license

authors:
  - Valerio Proietti

requires:
  - Core/Fx
  - Core/Element.Style
  - /MooTools.More

provides: [Fx.Slide]

...
*/

Fx.Slide = new Class({

	Extends: Fx,

	options: {
		mode: 'vertical',
		wrapper: false,
		hideOverflow: true,
		resetHeight: false
	},

	initialize: function(element, options){
		element = this.element = this.subject = document.id(element);
		this.parent(options);
		options = this.options;

		var wrapper = element.retrieve('wrapper'),
			styles = element.getStyles('margin', 'position', 'overflow');

		if (options.hideOverflow) styles = Object.append(styles, {overflow: 'hidden'});
		if (options.wrapper) wrapper = document.id(options.wrapper).setStyles(styles);

		if (!wrapper) wrapper = new Element('div', {
			styles: styles
		}).wraps(element);

		element.store('wrapper', wrapper).setStyle('margin', 0);
		if (element.getStyle('overflow') == 'visible') element.setStyle('overflow', 'hidden');

		this.now = [];
		this.open = true;
		this.wrapper = wrapper;

		this.addEvent('complete', function(){
			this.open = (wrapper['offset' + this.layout.capitalize()] != 0);
			if (this.open && this.options.resetHeight) wrapper.setStyle('height', '');
		}, true);
	},

	vertical: function(){
		this.margin = 'margin-top';
		this.layout = 'height';
		this.offset = this.element.offsetHeight;
	},

	horizontal: function(){
		this.margin = 'margin-left';
		this.layout = 'width';
		this.offset = this.element.offsetWidth;
	},

	set: function(now){
		this.element.setStyle(this.margin, now[0]);
		this.wrapper.setStyle(this.layout, now[1]);
		return this;
	},

	compute: function(from, to, delta){
		return [0, 1].map(function(i){
			return Fx.compute(from[i], to[i], delta);
		});
	},

	start: function(how, mode){
		if (!this.check(how, mode)) return this;
		this[mode || this.options.mode]();

		var margin = this.element.getStyle(this.margin).toInt(),
			layout = this.wrapper.getStyle(this.layout).toInt(),
			caseIn = [[margin, layout], [0, this.offset]],
			caseOut = [[margin, layout], [-this.offset, 0]],
			start;

		switch (how){
			case 'in': start = caseIn; break;
			case 'out': start = caseOut; break;
			case 'toggle': start = (layout == 0) ? caseIn : caseOut;
		}
		return this.parent(start[0], start[1]);
	},

	slideIn: function(mode){
		return this.start('in', mode);
	},

	slideOut: function(mode){
		return this.start('out', mode);
	},

	hide: function(mode){
		this[mode || this.options.mode]();
		this.open = false;
		return this.set([-this.offset, 0]);
	},

	show: function(mode){
		this[mode || this.options.mode]();
		this.open = true;
		return this.set([0, this.offset]);
	},

	toggle: function(mode){
		return this.start('toggle', mode);
	}

});

Element.Properties.slide = {

	set: function(options){
		this.get('slide').cancel().setOptions(options);
		return this;
	},

	get: function(){
		var slide = this.retrieve('slide');
		if (!slide){
			slide = new Fx.Slide(this, {link: 'cancel'});
			this.store('slide', slide);
		}
		return slide;
	}

};

Element.implement({

	slide: function(how, mode){
		how = how || 'toggle';
		var slide = this.get('slide'), toggle;
		switch (how){
			case 'hide': slide.hide(mode); break;
			case 'show': slide.show(mode); break;
			case 'toggle':
				var flag = this.retrieve('slide:flag', slide.open);
				slide[flag ? 'slideOut' : 'slideIn'](mode);
				this.store('slide:flag', !flag);
				toggle = true;
			break;
			default: slide.start(how, mode);
		}
		if (!toggle) this.eliminate('slide:flag');
		return this;
	}

});
/*
MooTools.More = {
	version : "1.3.0.1",
	build : "6dce99bed2792dffcbbbb4ddc15a1fb9a41994b5"
};
 * */
var Asset = {
		javascript : function(d, b) {
			b = Object.append({
				document : document
			}, b);
			if (b.onLoad) {
				b.onload = b.onLoad;
				delete b.onLoad;
			}
			var a = new Element("script", {
				src : d,
				type : "text/javascript"
			});
			var c = b.onload || function() {
			}, e = b.document;
			delete b.onload;
			delete b.document;
			return a.addEvents({
				load : c,
				readystatechange : function() {
					if ([ "loaded", "complete" ].contains(this.readyState)) {
						c.call(this);
					}
				}
			}).set(b).inject(e.head);
		},
		css : function(b, a) {
			a = a || {};
			var c = a.onload || a.onLoad;
			if (c) {
				a.events = a.events || {};
				a.events.load = c;
				delete a.onload;
				delete a.onLoad;
			}
			return new Element("link", Object.merge({
				rel : "stylesheet",
				media : "screen",
				type : "text/css",
				href : b
			}, a)).inject(document.head);
		},
		image : function(c, b) {
			b = Object.merge({
				onload : function() {
				},
				onabort : function() {
				},
				onerror : function() {
				}
			}, b);
			var d = new Image();
			var a = document.id(d) || new Element("img");
			[ "load", "abort", "error" ].each(function(e) {
				var g = "on" + e;
				var f = e.capitalize();
				if (b["on" + f]) {
					b[g] = b["on" + f];
					delete b["on" + f];
				}
				var h = b[g];
				delete b[g];
				d[g] = function() {
					if (!d) {
						return;
					}
					if (!a.parentNode) {
						a.width = d.width;
						a.height = d.height;
					}
					d = d.onload = d.onabort = d.onerror = null;
					h.delay(1, a, a);
					a.fireEvent(e, a, 1);
				};
			});
			d.src = a.src = c;
			if (d && d.complete) {
				d.onload.delay(1);
			}
			return a.set(b);
		},
		images : function(c, b) {
			b = Object.merge({
				onComplete : function() {
				},
				onProgress : function() {
				},
				onError : function() {
				},
				properties : {}
			}, b);
			c = Array.from(c);
			var a = 0;
			return new Elements(c.map(function(e, d) {
				return Asset.image(e, Object.append(b.properties, {
					onload : function() {
						a++;
						b.onProgress.call(this, a, d, e);
						if (a == c.length) {
							b.onComplete();
						}
					},
					onerror : function() {
						a++;
						b.onError.call(this, a, d, e);
						if (a == c.length) {
							b.onComplete();
						}
					}
				}));
			}));
		}
	};
