// =============
// updated 2009/05
// updated 2011/04
// =============

/* var */
var maxWidth = 100;
var maxHeight = 150;
var thumbWidth;
var thumbHeight;
var ratioWidth;
var ratioHeight;

/* discoveryArea --------------------------------- */
$(document).ready(function(){

	// 各エントリーのサムネイルに対して
	$('.discoveryArea .entryThumb').each(function(){

		if($(this).find("img").length == 0){
			$(this).remove();
		
		} else {
			thumbWidth = $(this).find("img").attr("width");
			thumbHeight = $(this).find("img").attr("height");
			ratioWidth = maxWidth / thumbWidth;
			ratioHeight = maxHeight / thumbHeight;
			if (ratioWidth<=1 || ratioHeight<=1) {
				if (ratioWidth < ratioHeight) {
					$(this).find("img").width(thumbWidth * ratioWidth + "px").height(thumbHeight * ratioWidth + "px");
				} else {
					$(this).find("img").width(thumbWidth * ratioHeight + "px").height(thumbHeight * ratioHeight + "px");
				}
			}
			$(this).css("visibility", "visible");
		}
	});
});

