var imgWin;

function imgView(sender) {
    var img = new Image();
    img.onload = imgOnLoad;
    img.src = sender.href;
    return false;
}

function imgOnLoad() {
    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 (imgWin != null)
        imgWin.close();
    imgWin = window.open('', 'imgview', 
        'height='+ imgHeight +','+
        'left='+ imgLeft +','+
        'top='+ imgTop +','+
        'width='+ imgWidth +','+
        'dependent=0,directories=0,location=0,hotkeys=0,menubar=0,'+
        'personalbar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0');
    imgWin.document.write(
        '<HTML>' +
        '<HEAD><TITLE>AUTOŠKOLA VLADIMÍRA A JAROSLAV VÍTKOVI Klobouky u Brna</TITLE>'+
        '<meta http-equiv="content-type" content="text/html; charset=iso-8859-2"></HEAD>'+
        '<BODY STYLE="margin: 0;">' +
        '<IMG ALT="zavřít" HEIGHT="'+ imgHeight +'" ONCLICK="window.close();" SRC="'+ this.src +'" WIDTH="'+ imgWidth +'">' +
        '</BODY>' +
        '</HTML>');
    imgWin.focus();
    return true;
}


/* End of file. */

