$(function() {
$("img").click(function(event) {
var nh = this.naturalHeight,
nw = this.naturalWidth,
p = nw / nh,
h = Math.min(this.scrollHeight, this.scrollWidth / p),
w = h * p,
t = (this.scrollHeight - h) / 2,
d = (this.scrollWidth - w) / 2,
x = event.offsetX,
y = event.offsetY;
if (x >= d && x <= d + w && y >= t && y <= t + h) {
x -= d;
x *= nw / w;
x = Math.round(x);
y -= t;
y *= nh / h;
y = Math.round(y);
alert([x, y])
}
})
});