/*
 * Util javascript methods for opening browser pop-up windows
*/

// universal function for getting the top most corner for all browsers
function getTop() {
  if (window.screenY) return window.screenY;
  return window.screenTop;
}

// universal function for getting the left most corner for all browsers
function getLeft() {
  if (window.screenX) return window.screenX;
  return window.screenLeft;
}

/*
 * function for opening a new window. takes 3 arguments:
 *
 * link - the URL for the pop-up, must be passed in with single quotes
 * height - the height desired for the pop-up window
 * width - the width desired for the pop-up window
 *
*/
function openWindow(link, height, width) {
 openWindowAt(link, height, width, 25, 25);
}

/*
 * function for opening a new window in a specific spot. takes 5 arguments:
 *
 * link - the URL for the pop-up, must be passed in with single quotes
 * height - the height desired for the pop-up window
 * width - the width desired for the pop-up window
 * x - the left to right position of the pop-up in reference to the main window
 * y - the top to bottom position of the pop-up in reference to the main window
 *
*/
function openWindowAt(link, height, width, x, y) {
 var t = getTop() + x, l = getLeft() + y;
 var winname = 'uniquePopup' + (new Date()).getTime();
 var options = 'menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',top=' + t + ',left=' + l;
 w = window.open(link, winname, options);
 w.focus();
}

