/*
---
description:     Kwicks

authors:
  - David Walsh (http://davidwalsh.name)

license:
  - MIT-style license

requires:
  core/1.2.1:   '*'

provides:
  - Kwicks
...
*/
var Kwicks = new Class({

	Implements: [Options],

	options: {
		squeezeHeight: 100,
		maxHeight: 285
	},

	initialize: function(list,options) {
		this.setOptions(options);
		this.list = list;
		this.parse();
	},

	parse: function() {
		var items = this.list,
			fx = new Fx.Elements(items, {wait: false, duration: 250, transition:Fx.Transitions.Cubic.easeOut}),
			startHeights = [],
			options = this.options;
		items.each(function(item,i) {
			startHeights.push(item.getStyle('height').toInt());
			item.addEvent('mouseenter',function(){
				var fxSettings = {};
				fxSettings[i] = {
					'height': [item.getStyle('height').toInt(),options.maxHeight]
				};
				items.each(function(sibling,ii) {
					if(sibling != item) {
						var w = sibling.getStyle('height').toInt();
						if (w != options.squeezeHeight) {
							fxSettings[ii] = {
								'height': [w,options.squeezeHeight] 
							};
						}
					}
				},this);
				fx.start(fxSettings);
			},this);
		},this);
		this.list.addEvent('mouseleave',function() {
			var fxSettings = {};
			items.each(function(item,i) {
				fxSettings[i] = {
					height: [item.getStyle('height').toInt(), startHeights[i]]
				};
			});
			fx.start(fxSettings);
		});
	}
});
