var Kwix = {

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

	parseKwicks: function(){

		var squeeze_to = 150;
		var max_width = 385;
		var position_diff = 175;

		//get original widths
		var start_widths = new Array();
		// get background-position doesn't work in ie - so we set it here
		var start_position = new Array(80, 155, 160, 120);

		var kwicks = $$('#mod_teaser .teaser');
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 250, transition:Fx.Transitions.Cubic.easeOut});
		kwicks.each(function(kwick, i){

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

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

				position = start_position[i] + position_diff;
				var obj = {};
				obj[i] = {
					'width': [kwick.getStyle('width').toInt(), max_width],
					'background-position': [start_position[i] + " 50px", position + " 50px"]
				};

				var counter = 0;

				kwicks.each(function(other, j){
					if (other != kwick){
						var w = other.getStyle('width').toInt();
						if (w != squeeze_to) obj[j] = {'width': [w,squeeze_to], 'background-position': [start_position[j] + " 50px", start_position[j] + " 50px"]};
					}
				});
				fx.start(obj);
			}
			);
			
		});
	
		//mouse is out, squeeze back
		$('mod_teaser').addEvent('mouseleave', function(e){
			var obj = {};
			kwicks.each(function(other, j){
				obj[j] = {'width': [other.getStyle('width').toInt(), start_widths[j]], 'background-position': [start_position[j] + " 50px"]};
			});
			fx.start(obj);
		});
	}
};

window.addEvent('domready',Kwix.start);
