

var mtImageWindow = null;


function mtImage(sender)
{
    var img = new Image();
    img.onload = mtImageLoad;
    img.src = sender.href ? sender.href : sender.src;
    img.alt = sender.title ? sender.title : '';
    img.title = sender.title ? sender.title : '';
    return false;
}

function mtImageLoad()
{
    var imgP = this.width / this.height;
    var srcP = (screen.availWidth - 10) / (screen.availHeight - 30);
    var imgHeight = this.height;
    var imgWidth = this.width;
    var imgLeft = (screen.availWidth >> 1) - (imgWidth >> 1);       // x div 2
    var imgTop = (screen.availHeight >> 1) - (imgHeight >> 1);
    // obr. je sirsi nez obrazovka -> pomerem jej zmensime
    if ((imgLeft < 0 || imgTop < 0) && (imgP > srcP)) {
        imgLeft = 0;
        imgWidth = screen.availWidth - 10;
        imgHeight = imgWidth / imgP;
        imgTop = (screen.availHeight >> 1) - (imgHeight >> 1);
    }
    // obr. je vyssi nez obrazovka -> pomerem jej zmensime
    if ((imgLeft < 0 || imgTop < 0) && (imgP < srcP)) {
        imgTop = 0;
        imgHeight = screen.availHeight - 30;
        imgWidth = imgHeight * imgP;
        imgLeft = (screen.availWidth >> 1) - (imgWidth >> 1);
    }
    if (this.title) {
        imgHeight = imgHeight + 30;
    }

    if (mtImageWindow != null)
        mtImageWindow.close();
    mtImageWindow = window.open('', 'mtimage', 
        'height='+ imgHeight +','+
        'left='+ imgLeft +','+
        'top='+ imgTop +','+
        'width='+ imgWidth +','+
        'dependent=0,directories=0,location=0,hotkeys=0,menubar=0,'+
        'personalbar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0');
    mtImageWindow.document.open('text/html', 'replace');
    mtImageWindow.document.write(
        '<html>' +
        '<head>'+
            '<meta http-equiv="content-type" content="text/html; charset=utf-8">'+
            '<title>'+ this.title +'</title>'+
        '</head>');
    mtImageWindow.document.write(
        '<body bgcolor="#ffffff" style="font-family:Arial, Helvetica, sans-serif;font-size:11px; margin:0; padding:0" oncontextmenu="return false" onselectstart="return false" onmousedown="return false" ondragstart="return false"');
    if (document.getElementById)
        mtImageWindow.document.write(
              ' onload="document.getElementById(\'iInfo\').style.display=\'none\';'+
                       'document.getElementById(\'iInfo\').style.visibility=\'hidden\';'+
                       'document.getElementById(\'iImage\').style.display=\'block\';'+
                       'document.getElementById(\'iImage\').style.visibility=\'visible\';"');
    mtImageWindow.document.write(
              ' style="background-color:#ffffff;margin:0;">');
    if (document.getElementById)
        mtImageWindow.document.write(
        '<div id="iInfo"><br><br><br><div align="center"><b>Please wait ... / Prosím čekejte ...</b></div></div>'+
        '<div id="iImage" style="display:none;visibility:hidden;"><img alt="close / zavřít" src="'+ this.src +'" title="close / zavřít" onclick="window.close();"></div>');
        //'<scriptdocument.getElementById(\'iImage\').style.display=\'none\';document.getElementById(\'iInfo\').style.display = \'\';</script>'
    else
        mtImageWindow.document.write(
        '<img alt="close / zavřít" src="'+ this.src +'" title="close / zavřít" onclick="window.close();">');
        //'<img alt="close / zavřít" height="'+ imgHeight +'" src="'+ this.src +'" title="close / zavřít" width="'+ imgWidth +'" onclick="window.close();">'
    mtImageWindow.document.write(
        '<div align="center">' + this.title + '</div>' +
        '</body>' +
        '</html>');
    mtImageWindow.document.close();
    mtImageWindow.focus();
    return true;
}


/* End of file. */
