function popwin(theURL,rw,rh) { //v2.0
  
  var ol = 50; // screen offset limit
  var sc = 16; // scroll bar size
  
  if( rw > screen.width-ol ) {
    var w = (screen.width - ol);
    var l = ol/2;
  } else {
    var w = rw;
    var l = (screen.width/2) - (rw/2);
  }
  
  if( rh > screen.height-ol ) {
    var h = (screen.height - ol);
    var t = ol/2;
  } else {
    var h = rh;
    var t = (screen.height/2) - (rh/2);
  }
  
  if( rh > screen.height-ol ) 
    w += sc;
  
  if( rw > screen.width-ol ) 
    h += sc;
  
  var scr = (rw > screen.width-ol || rh > screen.height-ol) ? ',scrollbars=yes' : ''; // if the either dimension is too large, add scroll bars
  var win = 'width=' + w + ',height=' + h + ',resizable=yes,left=' + l + ',top=' + t + scr; // the window features string
  window.open(theURL , '' , win); // the action!
  
}