//flags for the openWindow function

var OPEN_FLAG_LOCATION        = 0x1;    //display agent location bar
var OPEN_FLAG_MENUBAR         = 0x2;    //display agent menu bar
var OPEN_FLAG_RESIZEABLE      = 0x4;    //resizeable
var OPEN_FLAG_SCROLLBARS      = 0x8;    //display agent scroll bars
var OPEN_FLAG_STATUS          = 0x10;   //display agent status bar
var OPEN_FLAG_TITLEBAR        = 0x20;   //display agent title bar
var OPEN_FLAG_TOOLBAR         = 0x40;   //display agent toolbar
// how do we get the opener width and height??
//var OPEN_FLAG_CENTER          = 0x80;   //center on opener (left/top ignored)
var OPEN_FLAG_SCREENCENTER    = 0x100;  //center of screen (left/top ignored)
var OPEN_FLAG_STANDARD_BROWSER = OPEN_FLAG_LOCATION | OPEN_FLAG_MENUBAR | OPEN_FLAG_RESIZEABLE | OPEN_FLAG_SCROLLBARS | OPEN_FLAG_STATUS | OPEN_FLAG_TITLEBAR | OPEN_FLAG_TOOLBAR


function createWindow(opener, name, left, top, width, height, url, flags)
{
  //if ((flags & OPEN_FLAG_CENTER) > 0)
  //{
  //  left = opener.screenLeft;// + ((opener.width-width)/2);
  //  top = opener.screenTop;// + ((opener.height-height)/2);
  //}
  if ((flags & OPEN_FLAG_SCREENCENTER) > 0)
  {
    left = (screen.width - width) / 2;
    top = (screen.height - height) / 2;
  }

  strFeatures='left=' + left.toString() + ',top=' + top.toString() + ',width=' + width.toString() + ',height=' + height.toString();

  if ((flags & OPEN_FLAG_LOCATION) > 0)
    strFeatures = strFeatures + ',location=yes'
  else
    strFeatures = strFeatures + ',location=no';
  if ((flags & OPEN_FLAG_MENUBAR) > 0)
    strFeatures = strFeatures + ',menubar=yes'
  else
    strFeatures = strFeatures + ',menubar=no';
  if ((flags & OPEN_FLAG_RESIZEABLE) > 0)
    strFeatures = strFeatures + ',resizable=yes'
  else
    strFeatures = strFeatures + ',resizable=no';
  if ((flags & OPEN_FLAG_SCROLLBARS) > 0)
    strFeatures = strFeatures + ',scrollbars=yes'
  else
    strFeatures = strFeatures + ',scrollbars=no';
  if ((flags & OPEN_FLAG_STATUS) > 0)
    strFeatures = strFeatures + ',status=yes'
  else
    strFeatures = strFeatures + ',status=no';
  if ((flags & OPEN_FLAG_TITLEBAR) > 0)
    strFeatures = strFeatures + ',titlebar=yes'
  else
    strFeatures = strFeatures + ',titlebar=no';
  if ((flags & OPEN_FLAG_TOOLBAR) > 0)
    strFeatures = strFeatures + ',toolbar=yes'
  else
    strFeatures = strFeatures + ',toolbar=no';
  aWindow = window.open(url, name, strFeatures, false);
  aWindow.opener = opener;
  return aWindow;
}

function openWindow(opener, name, left, top, width, height, url, flags)
{
  awin = createWindow(opener, name, left, top, width, height, url, flags);
  awin.focus();
}