
var ZoomForm = new Class(
{
	items : [],
	vals : [],
	selected : null,
	
	initialize: function(el) 
	{
		this.items = el.getElements('li');
		
		this.items.each(function(item, i)
		{			
			item.fx = new Fx.Tween(item, { unit: 'em', link: 'cancel', fps: '500', duration: '200' });
					
			item.getElement('input').addEvent('focus', function() { this.OnFocus(i); }.bind(this));
			item.getElement('input').addEvent('blur', function() { this.OnBlur(i); }.bind(this));
		}.bind(this));
		
		for (var x = 0; x < 7; x++)
		{
			this.vals[x] = (Math.sin((x - 1.5) * (Math.PI / 3)) + 1) / 2;
		}
		
		this.items.setStyle('font-size', '1em');
	},
		
	OnFocus: function(i)
	{
		this.selected = this.items[i];
		this.selected.addClass('selected');
		
		this.items.each(function(item, j) 
		{
			if (this.vals[3 + (i - j)])
			{
				this.items[j].fx.start('font-size', 1 + this.vals[3 + (i - j)]);
			}
			else
			{
				this.items[j].fx.start('font-size', '1');
			}				
			
		}.bind(this));
	},
	
	OnBlur: function(i)
	{
		if (this.selected)
		{
			this.selected.removeClass('selected');
		}
		
		this.selected = null;
		
		(function() {
			if (this.selected == null)
			{
				this.items.each(function(item) { item.fx.start('font-size', '1'); });
			}
		}).delay(50, this);
	}
	
});

window.addEvent('domready', function() 
{
	new ZoomForm($('fm'));
});