var IsDlgFriendly = true;
var DlgIsGray = false;
var DlgHandle = null;
var OpenerTopHandle = null;

if (!!document.body) {
  document.open();
  document.write('<div id="TheGrayFrame" style="DISPLAY: block; Z-INDEX: 10; FILTER: alpha(opacity=50); LEFT: -10px; VISIBILITY: hidden; WIDTH: 3000px; POSITION: absolute; TOP: -10px; HEIGHT: 3000px">');
  document.write('<table width="100%" height="100%">');
  document.write('<tr><td bgcolor="black">&nbsp;</td></tr>');
  document.write('</table>');
  document.write('</div>');
  document.close();
  document.body.onbeforeunload = ResetWndModal;
  SetWndModal();
}
function HandleGrayLayer(makeGray) {
  if (DlgIsGray != makeGray)
  {
    DlgIsGray = makeGray;
    if ((top.IsDlgFriendly == true) && (top != self)) {
      top.HandleGrayLayer(makeGray);
    } //endif
    if (!!document.body) {
      if (makeGray == true) {
        if (!!document.all['TheGrayFrame']) {
          document.all['TheGrayFrame'].style.visibility = 'visible';
        } //endif
      } else {
        if (!!document.all['TheGrayFrame']) {
          document.all['TheGrayFrame'].style.visibility = 'hidden';
        } //endif
      } //endif
    } //endif
  } //endif
}
function ShowDialog(theFile, theArgs, theWidth, theHeight) {
  HandleGrayLayer(true);
  var retVal = window.showModalDialog(theFile,theArgs,'scroll=no;center=yes;resizable=no;status=no;help=no;dialogWidth=' + String(theWidth) + 'px;dialogHeight=' + String(theHeight) + 'px');
  HandleGrayLayer(false);
  return retVal;
}
function ShowWindow(theFile, theArgs, theWidth, theHeight) {
  var TmpTop = String((screen.Height - theHeight) / 2);
  var TmpLeft = String((screen.Width - theWidth) / 2);
  ShowWindowEx(theFile, theArgs, theWidth, theHeight, TmpTop, TmpLeft, 'no', 'no');
}
function ShowWindowEx(theFile, theArgs, theWidth, theHeight, theTop, theLeft, scrollStr, resizeStr) {
  top.document.body.onfocus = BringWndToForeground;
  DlgHandle = window.open(theFile, theArgs, 'left=' + theLeft + ',top=' + theTop + ',resizable=' + resizeStr + ',scrollbar=' + scrollStr + ',width=' + String(theWidth) + ',height=' + String(theHeight) + ',menubar=no,locationbar=no');
  top.window.document.body.focus();
  DlgHandle.focus();
}
function BringWndToForeground() {
  if (!!DlgHandle) {
    DlgHandle.focus();
  } //endif
  return true;
}
function DoWndNot() {
  return true;
}
function TopSetFunc() {
  HandleGrayLayer(true);
}
function TopResetFunc() {
  HandleGrayLayer(false);
  top.document.body.onfocus = DoWndNot;
  top.document.body.focus();
}
function SetWndModal() {
  if (!!top.opener) {
    if (top.opener.top.IsDlgFriendly == true) {
      OpenerTopHandle = top.opener.top;
      OpenerTopHandle.TopSetFunc();
    } //endif
  } //endif
  return true;
}
function ResetWndModal() {
  if (!!OpenerTopHandle) {
    OpenerTopHandle.TopResetFunc();
    window.close();
  } //endif
}

