function getWindowLeft() {
  return (top.screenLeft || top.screenTop ? (top.screenLeft ? top.screenLeft : 0) : top.screenX + (top.outerWidth - top.innerWidth) - 4);
}

function getWindowTop() {
  return (top.screenLeft || top.screenTop ? (top.screenTop ? top.screenTop : 0) : top.screenY + (top.outerHeight - top.innerHeight) - 26);
}

function getClientWidth() {
  var clientWidth = 0;
  if (top.document.documentElement && top.document.documentElement.clientWidth) {
    clientWidth = top.document.documentElement.clientWidth;
  } else if (top.document.body) {
    clientWidth = top.document.body.clientWidth;
  }
  return clientWidth;
}

function getClientHeight() {
  var clientHeight = 0;
  if (top.document.documentElement && top.document.documentElement.clientHeight) {
    clientHeight = top.document.documentElement.clientHeight;
  } else if (top.document.body) {
    clientHeight = top.document.body.clientHeight;
  }
  return clientHeight;
}

function getWindowTopAsCenterOnClientArea(windowHeight) {
  var onScreenY = getWindowTop();
  var clientHeight = getClientHeight();
  var addY = ((clientHeight - windowHeight) >= 0 ? (clientHeight - windowHeight) / 2 : 0);
  var posY = (onScreenY + addY);
  return (posY > 25 ? posY - 25 : posY);
}

function getWindowLeftAsCenterOnClientArea(windowWidth) {
  var onScreenX = getWindowLeft();
  var clientWidth = getClientWidth();
  var addX = ((clientWidth - windowWidth) >= 0 ? (clientWidth - windowWidth) / 2 : 0);
  return (onScreenX + addX);
}

function callPublish(resourcePath) {
  windowName = "PublishResourceDialog";
  windowPath = "/pbs/dcms/sys/pages/explorer/publish.html";
  var windowHeight = 260, windowWidth = 360;
  var windowTop = getWindowTopAsCenterOnClientArea(windowHeight);
  var windowLeft = getWindowLeftAsCenterOnClientArea(windowWidth);
  var win = null;
  win = window.open(windowPath + "?f_resource_path=" + resourcePath
    + "&f_init=1", windowName, "toolbar=no, location=no, directories=no, status=yes, menubar=0, scrollbars=no, "
    + "resizable=no, top=" + windowTop + ", left=" + windowLeft + ", width=" + windowWidth + ", height=" + windowHeight);
  if (win) {
    win.opener = self;
    win.focus();
  }
}

function callProperty(resourcePath) {
  windowName = "ResourcePropertyDialog";
  windowPath = "/pbs/dcms/sys/pages/explorer/property.html";
  var windowHeight = 690, windowWidth = 720;
  var windowTop = getWindowTopAsCenterOnClientArea(windowHeight);
  var windowLeft = getWindowLeftAsCenterOnClientArea(windowWidth);
  var win = null;
  win = window.open(windowPath + "?f_resource_path=" + resourcePath
    + "&f_init=1", windowName, "toolbar=no, location=no, directories=no, status=yes, menubar=0, scrollbars=yes, "
    + "resizable=no, top=" + windowTop + ", left=" + windowLeft + ", width=" + windowWidth + ", height=" + windowHeight);
  if (win) {
    win.opener = self;
    win.focus();
  }
}


function isWAIEnabled() {
  return true;
}
