var heights = {
	set : function(k,v) {this[k] = v;},
	get : function(k) {return this[k];}
}

var width = 149;

$(document).ready(function(){
	$("table.matrix td img").load(function() {
//		alert($(this).attr("src"));
//		alert('height = '+$(this).css("height")+', width = '+$(this).css("width"));
//		alert('height = '+$(this).height()+', width = '+$(this).width());

//		alert('this.height = '+$(this).height()+', height = '+height);
		var row = $(this).attr("row");
		var compression = width / $(this).width();
		var height = Math.round($(this).height() * compression);

		if(!heights.get(row) || height > heights.get(row)) {
//			alert('='+heights.get(row));
			heights.set(row, height);
			$.each($(this).parents("tr").children(), function(i, td){
				$(td).children().filter("div.desc").css("margin-top", (height+15)+"px");
				});
		}
		$(this).css({height:(height+'px'),width:(width+'px'),display:'block'});
	   });
});
