
// W osobnym oknie.
function ShowPicture(FileName, picWidth, picHeight, left, top, scrollbars) {
  var width = picWidth; 
  var height = picHeight;
  if(!left) left = 300;
  if(!top) top = 300;
  if(left == -1) left = (screen.width - width )/ 2;
  if(top == -1) top = (screen.height - height)/ 2 ;
  
  if (scrollbars=='') scrollbars='no';
  
//  left = Math.min(left, screen.width - width - 50);
//  top = Math.min(top, screen.height - height - 50);
  var w = window.open("./inc/newWindow.php?URL="+URLSafeEncode(FileName),'Zdjecie',
            'scrollbars='+scrollbars+',resizable=no,status=no,width=' + width + ',height=' + height + 
            ',dependent=yes,left=' + left + ',top=' + top);
  w.focus();
}   

// Koduje adres WWW tak, aby bez problemów przesłać jako parametr w adresie www.
// W szczególności zamienia znak "&" na coś bez "&".
// Oryginał można otrzymać funkcją URLSafeDecode.
function URLSafeEncode(str)
{
  return(str.replace(/x/g, 'xx').replace(/&/g, 'xy'));
}

// Odtwarza tekst zakodowany funkcją URLSafeEncode.
function URLSafeDecode(str)
{
  return(str.replace(/xx|xy/g, function($0){return $0 == 'xx' ? 'x' : '&';}));
}
