function jsopen_window(url, name, width, height) 
{
    if (width  < 50) width = 700;
    if (height < 50) height = 500;

    var leftval = (screen.width - width) / 2;
    var topval = (screen.height - height) / 2
    topval -= (screen.height - height) / 5;
    
    
    var w = window.open(url, name, 'width=' + width +',height='+ height +',resizable=1,scrollbars=1,left='+leftval+',top='+topval);
    w.focus();
    return false;
}

function jsopen_baldwindow(url, name, width, height) {
    if (width  < 50) width = 700;
    if (height < 50) height = 500;

    var leftval = (screen.width - width) / 2;
    var topval = (screen.height - height) / 2
    topval -= (screen.height - height) / 5;

    var attrs = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,dependent=yes';
    var w = window.open(url, name, 'width=' + width +',height='+ height +',left='+leftval+',top='+topval+','+attrs);
    w.focus();
    return false;
}

function jsopen_img(url, width, height) {
   return jsopen_baldwindow(url, 'wgimage', width, height);
}

function jsclose_and_refresh_parent() 
{
    if (window.opener) {
       var l = new String(window.opener.document.location);
       var i = l.indexOf('?');
       if (i > 0)
           l = l.substring(0, i);
       window.opener.document.location = l;
       //window.opener.document.location.reload();
    }
    window.close();
}

function wgClickOpenImage(o, width, height) {
	return jsopen_baldwindow('/x/imagepopup.html?'+o.href, 'wgimage', width, height);
}


