//  ProtoTypes:
// requires inclusion of
// utilsString.js


function openCenteredWindow (width, height, windowName, scroll, url, htmlText, focus)
{
  var winName = "" + windowName;
  var winprops = "";
  var scrollbars = scroll;


  var doc_width  = width;
  var doc_height = height;
  var screenHeight = screen.height;

  if (doc_height > (screen.height-100) )
  {
   screenHeight = screenHeight - 100;
   doc_height = screenHeight;
   doc_width  = doc_width + 17;
   scrollbars = 'yes';
  }
  if (doc_width > screen.width)
  {
   doc_width = screen.width - 20;

   if (IsEmpty (scrollbars) || scrollbars == 'no' || scrollbars == 'false' || scrollbars == 'FALSE' || scrollbars == '0')
   {
     doc_height = doc_height + 17;
     scrollbars = 'no';
   }
   else
   {
     scrollbars = 'yes';
   }
  }

  var winl = (screen.width - doc_width) / 2;
  var wint = ((screenHeight - doc_height) / 2) - 30;

  // alert ('scr. w: ' + screen.width + ', scr. h: ' + screenHeight + ', width: ' + width + ', height: ' + height + ', topX: ' + winl + ', topY: ' + wint );

  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;

  winprops = 'status=0,toolbar=0,menubar=0,height='+doc_height+',width='+doc_width+',top='+wint+',left='+winl+',scrollbars='+scrollbars;

  msgWindow=window.open('',winName,winprops);

  if (focus == 1)
    msgWindow.focus();
  else
    msgWindow.blur();

  msgWindow.document.location.href = url;
  
  if (!IsEmpty (htmlText))
  {
    msgWindow.document.write (htmlText);
    msgWindow.document.close ();
  }
  return msgWindow
}

