var okno;

function position(width, height)
{
 if ( width && height && screen.width && screen.height ) {
  var left = (screen.width / 2) - (width / 2);
  var top = (screen.height / 2) - (height / 2);
  return 'top=' + top + ', left=' + left;
 }//if
}//Position



function popup(adres, obrazek, obr_width, obr_height)
{
 if ( !nazwa ) { var nazwa = 'okno'; }

 if ( adres == '?s=informacje' )
 {
  psize = ', width=700, height=600, ' + position(700, 600);
 }
  else
 {
  psize=', width=800, height=600, ' + position(800, 600);
 } 
 var r = Math.random();
 r = r * 1000;
 r = Math.round(r);
 nazwa = nazwa + r;
 if (obrazek == false) {
  window.open(adres + '&popup=1', nazwa, 'resizable=no,scrollbars=yes,menubar=no' + psize);
 }
  else
 {
  if ( !obr_width || !obr_height )
  {
   img = new Image();
   img.src = adres;
   set_width = img.width + 40;
   set_height = img.height + 35;
  }
   else
  {
   set_width = obr_width + 40;
   set_height = obr_height + 35;
  }
  psize = ', width='+set_width+', height='+set_height+', ' + position(set_width, set_height);
   window.open(adres, nazwa, psize + ', resizable=yes,scrollbars=yes,menubar=no');
 }
}//Popup



function show(element)
{
 var block = document.getElementById(element);
 if ( block )
 {
  if (block.style.display == 'none') 
  { 
   block.style.display = 'block';
   return true;
  }
    else 
  { 
   block.style.display = 'none'; 
   return false;
  }
 }
}//show

function getSelectedRadio(radioButtons)
{
 if ( radioButtons )
 {
  for ( var i=0; i < radioButtons.length; i++ )
     { if ( radioButtons[i].checked ) { return i; } }//for
 }
}
