﻿var timeoutID;
$("img.zoomimg").mouseover(function(){

    var posX = this.offsetLeft;
    var posY = this.offsetTop;
    var aBox = this;
    do {
        aBox = aBox.offsetParent;
        posX += aBox.offsetLeft;
        posY += aBox.offsetTop;
    } while( aBox.tagName != "BODY" );
    
    timeoutID = window.setTimeout("beginZoom('"+ this.src +"','" + $(this).width() + "','" + $(this).height() + "','" + posX + "','" + posY + "')", 1000);
});
$("img.zoomimg").mouseout(function(){
    window.clearTimeout(timeoutID);
});
$(".zoomdiv").mouseout(function(){
    clearZoom();
});
function beginZoom(src,width,height,left,top){
//    src = src.replace("&width="+width,"&width="+(width*2));
//    src = src.replace("&height="+height,"&height="+(height*2));
    
    $(".zoomdiv img").attr("src",src);
    $(".zoomdiv img").height(height*2).width(width*2);
    $(".zoomdiv").css("left",left - (width*2-width)/2 + "px");
    $(".zoomdiv").css("top",top - (height*2-height)/2 + "px");
    $(".zoomdiv").show();
}
function clearZoom(){
    $(".zoomdiv img").attr("src","");
    $(".zoomdiv").hide();
}