var Kwix = {

	start: function(){
		Kwix.parsepanels();
	},

	parsepanels: function(){

		var squeeze_to = 160;
		var max_width = 414;

		//get original widths
		var start_widths = new Array();
		var panels = $$('#panel .panel');
		var abss = $$('#panel .abs');
		var fx2 = new Fx.Elements(abss, {wait: false, duration: 400, transition:Fx.Transitions.Cubic.easeOut});
		var fx = new Fx.Elements(panels, {wait: false, duration: 250, transition:Fx.Transitions.Cubic.easeOut});
		panels.each(function(panel, i){

			start_widths[i] = panel.getStyle('width').toInt();

			//mouse is in, squeeze and expand
			panel.addEvent('mouseenter', function(e){

				var obj = {};
				obj[i] = {
					'width': [panel.getStyle('width').toInt(), max_width]
				};
				
				var absobj = {};
				absobj[i] = {
					'bottom' : [abss[i].getStyle('bottom'), 20]	
				};

				var counter = 0;

				panels.each(function(other, j){
					if (other != panel){
						var w = other.getStyle('width').toInt();
						absobj[j] = {'bottom': [abss[j].getStyle('bottom'), -40] };
						if (w != squeeze_to) obj[j] = {'width': [w,squeeze_to] };
						
					}
				});
				fx.start(obj);
				fx2.start(absobj);
			}
			);
		});

		//mouse is out, squeeze back
		$('panel').addEvent('mouseleave', function(e){
			var obj = {};
			var absobj = {};
				
			panels.each(function(other, j){
				obj[j] = {'width': [other.getStyle('width').toInt(), start_widths[j]]};
				absobj[j] = {'bottom' : [abss[j].getStyle('bottom'), -40]};
			});
			fx.start(obj);
			fx2.start(absobj);
		});
	}
};
window.addEvent('domready',Kwix.start);
