var Kwicks = new Class({
	
	options: {
		wrapper: 'kwicks',
		selector: '#kwicks .kwick',
		normalWidth: 104,
		smallWidth: 49,
		fullWidth: 269,
		duration: 400,
		transition: Fx.Transitions.Quad.easeOut
	},
	
	initialize: function(options){
		this.setOptions(options);
		 
		var kwicks = $$(this.options.selector);
		var fx = new Fx.Elements(kwicks, {wait: false, duration: this.options.duration, transition: this.options.transition});
		kwicks.each(function(kwick, i) {
			kwick.addEvent("mouseenter", function(event) {
				var o = {};
				o[i] = {width: [kwick.getStyle("width").toInt(), this.options.fullWidth]};
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("width").toInt();
						if(w != this.options.smallWidth) o[j] = {width: [w, this.options.smallWidth]};
					}
				}.bind(this));
				fx.start(o);
			}.bind(this));
		}.bind(this));
		 
		$(this.options.wrapper).addEvent("mouseleave", function(event) {
			var o = {};
			kwicks.each(function(kwick, i) {
				o[i] = {width: [kwick.getStyle("width").toInt(), this.options.normalWidth]};
			}.bind(this));
			fx.start(o);
		}.bind(this));

		
	}
});

Kwicks.implement(new Chain(), new Events(), new Options());