/*
  cp_functions.js
  Extract of the original cp_functions.js
  Copyright (C) 2006, Cinematica Producciones Ltda.
  Author: Andres Melguizo Velez
  Created: 20061207
  Modified: 20061207
*/

// Open a centered window
function openCenterWindow(theURL, winName, winWidth, winHeight, bResizable, bScrollbars) {
  var centerLeft = (screen.width - winWidth) / 2;
  var centerTop = (screen.height - winHeight) / 2 - 15;
  var szCenterSettings = "status=1,menubar=0,left=" + centerLeft + ",top=" + centerTop + ",width=" + winWidth + ",height=" + winHeight + ",resizable=" + (bResizable ? "1" : "0") + ",scrollbars=" + (bScrollbars ? "1" : "0");
  var w = window.open(theURL, winName, szCenterSettings);
  w.focus();
  return w;
}

// Returns true if the window is closed or not opened
function isWindowClosed(win) {
  return(!(win != null && !win.closed));
}

// Closes a window and set the handle to null
function closeWindow(win) {
  if(!isWindowClosed(win))
    win.close();
  win = null;
  return(win);
}
