$(window).load(function() {
    var oWidth = $('img.imagezoomimg').width();
    var oHeight = $('img.imagezoomimg').height();
    var oRatio = (oWidth / oHeight);
    $('.imagezoom').mouseenter(function(e) {
        $(this).children('div').children('.imagezoomimg').animate({width:oWidth+'px',height:oWidth/oRatio+'px'}, 0);
        $(this).children('.imageoverlay').css('display','none');
    }).mouseleave(function(e) {
        $(this).children('div').children('.imagezoomimg').animate({width:$(this).children('div').width()+'px',height:$(this).children('div').width()/oRatio+'px'}, 0);
//        $(this).children('div').animate({top:0,left:0}, 0);
        $(this).children('.imageoverlay').css('display','block');
    }).mousemove(function(e) {
        var offset = $(this).offset();
        var x = e.pageX - offset.left;
        var y = e.pageY - offset.top;
        var imgwidth = $(this).children('div').children('img.imagezoomimg').width();
        var imgheight = $(this).children('div').children('img.imagezoomimg').height();
        var vpwidth = $(this).width();
        var vpheight = $(this).height();
        var xratio = (imgwidth - vpwidth) / vpwidth;
        var yratio = (imgheight - vpheight) / vpheight;
        var xpos = Math.round(-x * xratio);
        var ypos = Math.round(-y * yratio);
        $(this).children('div').animate({left:xpos, top:ypos},0);
    });
});

