// JavaScript Document

window.onload = (function()	{
						  
// position small images
						  
var selector = 'img.medium_image';
	
	$(selector).each(function()	{
							  							  
		var width = $(this).width();
		var height = $(this).height();
		
		
		if (width > height && width > 400) {
				ratio = 400/width;
				new_width = 400;
				new_height = height * ratio;
		} else if (height > width && height > 400) {
				ratio = 400/height;
				new_height = 400;
				new_width = width * ratio;
		} else if (width == height && height > 400) {
				new_width = 400; 
				new_height = 400;
		} else {
				new_width = width;
				new_height = height;
			}
				
		var position_top = Math.floor((400 - new_height)/2);
		var position_left = Math.floor((400 - new_width)/2);
		
		$(this)
			.css("width", new_width)
			.css("height", new_height)
			.css("position","relative")
			.css("top",position_top + "px")
			.css("left",position_left + "px");
			
	});

	
});
