var Kwicker = new Class({

	Implements: [Options],
	
	options: {
		large: {width: 200},
		medium: {width: 90},
		small: {width: 70},
		kwicksSelector: '.kwick',
		activateOnCreation: true,
		duration: 'normal'
	},

	initialize: function(kwicker, options) {
		this.setOptions(options);
		this.kwicker = $(kwicker);

		this.kwicks = this.kwicker.getElements(this.options.kwicksSelector);
		
		this.showOne = new Fx.Preset(Fx.Presets.Unique, [this.options.large, this.options.small]);
		this.mediumAll = new Fx.Preset(Fx.Presets.All, this.options.medium);
		this.fx = new Fx.Elements.Preset(this.kwicks, {link:'cancel', duration: this.options.duration});
		
		!this.options.activateOnCreation || this.activate();
	},
	
	activate: function() {
		if (!this.activated) {
			this.kwicks.each(function(k,i) {
				k.addEvent('mouseenter', this.expand.bind(this,i));
			}, this);
			this.kwicker.addEvent('mouseleave', this.reset.bind(this));	
		}

		this.activated = true;	
	},
	
	expand: function(i) {
		this.isReset = false;
		this.fx.start(this.showOne, i);
	},
	
	reset: function() {
		this.isReset || this.fx.start(this.mediumAll);
		this.isReset = true;
	}
	
});