function calculate_heads() {
  $$('.card-short-place .card-row').each(function(row) {
    row.getElements('.card-short').setStyle('height', 'auto');
    
    head_height = 0;
    row.getElements('h2 a').each(function(head) {
      head_height_actual = head.getSize().y;
      if (head_height < head_height_actual) {
        head_height = head_height_actual;
      }
    });
    
    // img_height = 0;
    // row.getElements('.img').each(function(img) {
    //   img_height_actual = img.getSize().y;
    //   if (img_height < img_height_actual) {
    //     img_height = img_height_actual;
    //   }
    // });
    
    row.getElements('h2').setStyle('height', head_height);    
    // row.getElements('.img').setStyle('height', img_height);
    
    // row.getElements('.card-short').setStyle('height', row.getStyle('height'));
    row.getElements('.card-short').setStyle('height', row.getSize().y);
  });  
}

var WatchFontSize = new Class({
	initialize : function(){
		this.element = $$('#dc-footer p')[0];
		this.initSize = this.previousSize = this.element.getStyle('width').toInt();		
		this.watch.periodical(200, this);		
	},
 
	watch : function(){
		this.newSize = this.element.getStyle('width').toInt();
		if (this.newSize != this.previousSize) {
		  this.changed();
		}
	},

	changed : function(){
    // console.debug("previous: " + this.previousSize);
    // console.debug("new: " + this.newSize);
    // console.debug("initial: " + this.initSize);
    calculate_heads();
		this.previousSize = this.newSize;
	}
});

if ($$('.card-short-place')) {
  calculate_heads();
  new WatchFontSize();
}

if ($$('.tabs .head span')) {
  $$('.tabs .head span').addEvent('click', function(){
    
    if (Browser.Engine.trident) {
      (function(){
        calculate_heads();
      }).delay(20);
    }
    else {
      calculate_heads();
    }
  });
}
