function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function center_and_resize( tWin, w, h )
{
    var body = document.body;

    body_height = h;
    body_width = w;

    // window.dialogHeight = body.offsetHeight + 50 + "px";
    // window.dialogWidth = body.offsetWidth + "px";
    tWin.resizeTo(body_width, body_height);
    var ch = body.clientHeight;
    var cw = body.clientWidth;
    //tWin.resizeBy(body.offsetWidth - cw, body_height - ch);
    var W = body_width;
    var H = 2 * body_height - ch;
    var x = (screen.availWidth - W) / 2;
    var y = (screen.availHeight - H) / 2;
    tWin.moveTo(x, y);
}

function init_window()
{
    // set default window size
    w = 500;
    h = 400;
        
    image1 = MM_findObj( 'image1' );
    if ( image1 )
    {
        // adjust the dimensions here for static page elements
        w = image1.width + 35;
        h = image1.height + 160;
        
        // set minimum dimensions
        if ( w < 300 ) w = 300;
        if ( h < 200 ) h = 200;
    }

    center_and_resize( window, w, h );
}