var Win = null;

function resizeWin()
{
    var Img = Win.document.getElementById('img');
    Win.resizeTo(Img.clientWidth + 100, Img.clientHeight + 100);
}

function Zoom(_url, _width, _height)
{
    Win = window.open(
        _url,
        '_blank',
        'resizable=no,scrollbars=yes,location=no,status=yes,width=' + (_width + 40) + ',height=' + (_height + 40) + ',toolbar=0'
    );
    Win.document.close();
}

function ZoomImage(_url, _width, _height)
{
    var _html = '<html><head><title></title><style>body {margin:0; padding:10; background:#fff}</style></head>' +
                '<body><table width="100%" height="' + _height + '"><tr><td align="center" valign="middle">' +
                '<img src="' + _url + '" onclick="window.close()" title="Кликните на изображении чтобы закрыть окно" ' + 
                'style="cursor: hand" id="img"></td></tr></table></body></html>';

    Win = window.open(
        'about:blank',
        '_blank',
        'resizable=no,scrollbars=yes,location=no,status=yes,width=' + (_width + 40) + ',height=' + (_height + 40) + ',toolbar=0'
    );
    Win.document.write(_html);
    Win.document.close();
    Win.document.getElementById('img').onload = resizeWin;
}

function ZoomPrint(_url, _width, _height)
{
    var _html = '<html><head><title></title><style>body {margin:0; padding:10; background:#fff}</style></head>' +
                '<body><table width="100%" height="' + _height + '"><tr><td align="center" valign="middle">' +
                '<img src="' + _url + '" onclick="window.close()" title="Кликните на изображении чтобы закрыть окно" ' + 
                'style="cursor: hand" id="img"></td></tr></table></body></html>';

    Win = window.open(
        'about:blank',
        '_blank',
        'resizable=no,scrollbars=yes,location=no,status=yes,width=' + (_width + 40) + ',height=' + (_height + 40) + ',toolbar=0'
    );
    Win.document.write(_html);
    Win.document.close();
    Win.document.getElementById('img').onload = resizeWin;
	window.print()
}