$(document).ready(function() {
$("#gFullsizeLink").click(function() {
var width = $(document).width();
var height = $(document).height();
$("body").append('
');
var image_size = _auto_fit(fullsize_detail.width, fullsize_detail.height);
$("body").append("
");
$("#gFullsizeClose").click(function() {
$("#gFullsizeOverlay*").remove();
$("#gFullsize").remove();
});
});
});
/*
* Calculate the size of the image panel based on the size of the image and the size of the
* window. Scale the image so the entire panel fits in the view port.
*/
function _auto_fit(imageWidth, imageHeight) {
// ui-dialog gives a padding of 2 pixels
var windowWidth = $(window).width() - 10;
var windowHeight = $(window).height() - 10;
/* If the width is greater then scale the image width first */
if (imageWidth > windowWidth) {
var ratio = windowWidth / imageWidth;
imageWidth *= ratio;
imageHeight *= ratio;
}
/* after scaling the width, check that the height fits */
if (imageHeight > windowHeight) {
var ratio = windowHeight / imageHeight;
imageWidth *= ratio;
imageHeight *= ratio;
}
return {top: (windowHeight - imageHeight) / 2, left: (windowWidth - imageWidth) / 2,
width: imageWidth, height: imageHeight};
}