﻿
// Open popup in the centre of the screen
// It returns false if successful (to supress any further <a> processing)
function popUp(url)
{
  var popupWidth = 600;
  var popupHeight = 600;

  var day = new Date();
  var id = day.getTime();

  return commonPopUp(url, id, popupWidth, popupWidth);
}

// Open popup for Help screens
// It returns false if successful (to supress any further <a> processing)
function helpPopup(url) {
    return helpPopup(url, 'HelpPopup');
}

// Open popup for Help screens
// It returns false if successful (to supress any further <a> processing)
function helpPopup(url, target) {
    if (!target || target.length == 0) target = 'HelpPopup';
  
    var popupWidth = 720;
    var popupHeight = 600;

    return commonPopUp(url, target, popupWidth, popupWidth);
}

// Function that actually creates the popup used by popUp() and helpPopUp()
// It returns false if successful (to supress any further <a> processing)
function commonPopUp(url, popupName, popupWidth, popupHeight)
{
  var winl = (screen.availWidth - popupWidth) / 2;
  var wint = (screen.availHeight - popupHeight) / 2;

  windowDisplayOptions = 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=yes,height=' + popupHeight + ',width=' + popupWidth + ',top=' + wint + ',left=' + winl;
  newWindow = window.open(url, popupName, windowDisplayOptions);
  newWindow.focus();
  
  return (newWindow == null);
}
