// ==========================================================================================
// File:        picturewindow.js
// Purpose:     Open a given image in a new browserwindow.
//              Windowsize is imagesize.
//              If image bigger then screen, image will be resized.
//              Window closes on click or blur.
// Homepage:    http://www.mambo.i-d-sign.com
// Author:      Gotti
// Date:        10.02.2004
// License:     GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
// ==========================================================================================

function picturewindow(url, picwidth, picheight) {

        factor = 0;
        scr_x = screen.width - 20;
        scr_y = screen.height - 60;
        if (scr_x <= picwidth || scr_y <= picheight) {
                factor_x = scr_x/picwidth;
                factor_y = scr_y/picheight;

                if (factor_x < factor_y) {
                        factor = factor_x;
                } else {
                        factor = factor_y;
                }
                picwidth = picwidth*factor;
                picheight = picheight*factor;
                        
        }
        win_left = (screen.width - picwidth) / 2;
        win_top = (screen.height - picheight) / 2;


        picwindow=window.open('','picwindow','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,dependent=yes,width='+picwidth+',height='+picheight+', left='+win_left+', top='+win_top+'');
        with (picwindow) {

                focus();
                document.open();
                document.write("<html><head><title>Click picture to close</title></head>" );
                document.write("<body onblur='window.close()';" );
                document.write(" leftmargin='0' topmargin='0'><a href='javascript:window.close()' onmousedown='window.close()'>" );
                document.write("<img src='"+url+"' width='"+picwidth+"' height='"+picheight+"' border='0' ></a>" );
                document.write("</body></html>" );
                document.close();
        }
}

