/**
 * Opens a destination URL (destURL) in a popUp window of the given width and height
 *
 * @param string destURL
 * @param string windowName
 * @param integer width
 * @param integer height
 */
function popupWindow(destURL, windowName, width, height, left, top, options)
{
  var window_options = '';

  // Set the window distance from the top of screen
  if( top == 0 )
  {
  	var winHeight = parseInt(height);
  	var posY = (screen.height - winHeight) / 2;

  	window_options = window_options + 'top=' + posY +  ',';
  }
  else
  {
  	window_options = window_options + 'top=' + parseInt(top) + ',';
  }

  // Set the window distance from the left of screen
  if( left == 0 )
  {
	var winWidth = parseInt(width);
	var posX = (screen.width - winWidth) / 2;

	window_options = window_options + 'left=' + posX + ',';
  }
  else
  {
  	window_options = window_options + 'left=' + parseInt(left) + ',';
  }


  if( options.length > 0 )
  {
  	window_options = options;
  }
  else
  {
  	window_options = window_options + 'resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,status=no';
  }

  window.open(destURL,windowName,'width=' + width + ',height=' + height + ',' + window_options);
}


/**
 * Closes the window it is called from
 *
 */
function closeWindow()
{
	self.close();
}