function popup(url,windowname,width,height) {
  width=(width)?width:screen.width/3;
  height=(height)?height:screen.height/3;
  var screenX = (screen.width/2 - width/2);
  var screenY = (screen.height/2 - height/2);
  var features= "width=" + width + ",height=" + height;
  features += ",screenX=" + screenX + ",left=" + screenX;
  features += ",screenY=" + screenY  +",top=" + screenY;
  var mywin=window.open(url, windowname, features);
  if (mywin) 
    mywin.focus();
  return mywin;
}
var myimage = new Image();
var popupwin=null;
myimage.onload=function(){popupwin=popup(this.src,"pic",this.width+20,this.height+30)}
function size(what){
if (popupwin && !popupwin.closed)popupwin.close();
myimage.src=what;
}


