function theResizorrr(which, source_x, source_y) {
	if (document.getElementById(which)) {
		var max_x = 279;
		var max_y = 320;
		var the_image = document.getElementById(which);
		var the_image_x = (source_x != null) ? source_x : the_image.width;
		var the_image_y = (source_y != null) ? source_y : the_image.height;
		var new_x = the_image_x;
		var new_y = the_image_y;
		var x_difference = (the_image_x > max_x) ? (the_image_x - max_x) : 0;
		var y_difference =  (the_image_y > max_y) ? (the_image_y - max_y) : 0;
		if ((x_difference > 0) || (y_difference > 0)) {
			var constrain_which_dimension = (x_difference >= y_difference) ? "x" : "y";
			switch (constrain_which_dimension) {
				case "x":
				new_x = max_x;
				the_image.width = new_x;
				break;
				case "y":
				new_y = max_y;
				the_image.height = new_y;
				break;
			}
		}
		else {
			the_image.width = new_x;
		}
	}
}

function swapImage(which, source_x, source_y) {
	var new_detail = which.getAttribute("src").replace("small", "medium");
	document.getElementById("detailimg").setAttribute("src", new_detail);
	theResizorrr("detailimg", source_x, source_y);
	return false;
}
