var resId=0;
var imgWnd;

function ImgWindow(imageLink, title)
{
    if (typeof(imgWnd) == 'object')
        imgWnd.close();
    imgWnd = window.open('',imageLink.target,'width=100,height=100'+',toolbar=no,menubar=no,location=no,status=no,'+'resizable=yes,scrollbars=no,left='+(screen.width/2)+',top='+(screen.height/2));
    self.focus();
    var imgTitle=(title)?title:imageLink.href;
    with (imgWnd.document)
    {
        open();
        write('<ht'+'ml><he'+'ad><ti'+'tle>'+imgTitle+'</ti'+'tle>'+'</he'+'ad><bo'+'dy leftmargin="0" topmargin="0"'+'rightmargin="0" bottommargin="0" marginwidth="0"'+'style="margin:0;padding:0;position:fixed;overflow:none;"'+'marginheight="0"><img src="'+imageLink.href+'" border="0" '+' alt="'+imgTitle+'" title="'+imgTitle+'" class="r"/></bo'+'dy></ht'+'ml>');
        close();
    }
    resId=setInterval('WndResize()',100);
    return false;
}

function WndResize()
{
    var w=imgWnd.document.images[0].width;
    if (w>screen.availWidth) w=screen.availWidth;
    var h=imgWnd.document.images[0].height;
    if (h>screen.availHeight) h=screen.availHeight;
    if (w>50 && h>50)
    {
        var ww=(imgWnd.innerWidth)?imgWnd.innerWidth:((document.body)?imgWnd.document.body.clientWidth:null);
        var wh=(imgWnd.innerHeight)?imgWnd.innerHeight:((document.body)?imgWnd.document.body.clientHeight:null);
        if (ww && wh)
        {
            imgWnd.resizeBy(w-ww,h-wh);
        }
        imgWnd.moveBy(-w/2-20,-h/2);
        imgWnd.focus();
        clearInterval(resId)
    }
}


