window.addEvent('domready', function() {
  var kwicks = $$('#kwick .kwick');
  var fx = new Fx.Elements(kwicks, {wait: false, duration: 200, transition: Fx.Transitions.quadOut});
  kwicks.each(function(kwick, i){
    kwick.addEvent('mouseenter', function(e){
	  AddClassName(kwick, "active");
      var obj = {};
      obj[i] = {
        'width': [kwick.getStyle('width').toInt(), 314]
      };
      kwicks.each(function(other, j){
        if (other != kwick){
          var w = other.getStyle('width').toInt();
          if (w != 202) obj[j] = {'width': [w, 202]};
		  RemoveClassName(other, "active");
        }
      });
      fx.start(obj);
    });
  });
  
  $('kwick').addEvent('mouseleave', function(e){
    var obj = {};
    kwicks.each(function(other, j){
		RemoveClassName(other, "active");
		if(other.className.indexOf("last") != -1){
      		obj[j] = {'width': [other.getStyle('width').toInt(), 237]};
		}else{
			obj[j] = {'width': [other.getStyle('width').toInt(), 228]};
		}
    });
    fx.start(obj);
  });
});

