function ChildWindow( name, url, props )
{
  this.name = name;
  this.url = url;
  this.props = props;

  this.top = null;
  this.left = null;
  this.width = null;
  this.height = null;

  this.scrollbars = true;
  this.resizable = true;
  this.menubar = false;
  this.status = false;
  this.titlebar = false;
  this.toolbar = false;

  this.reload = false;
  this.window = null;
  this.blockedMessage = "Please turn your pop-up blocker off to see this window.";

  this.getProperty = function( name, value )
  {
    return value == null ? "" : name + "=" + value + ",";
  };

  this.getBooleanProperty = function( name, value )
  {
    return this.getProperty( name, value ? "yes" : "no" );
  };

  this.getUrl = function()
  {
    if( this.reload )
    {
      var anchor = ""
      var anchorIndex = this.url.indexOf( "#" );
      if( anchorIndex != -1 )
      {
        anchor = this.url.substring( anchorIndex + 1 );
        this.url = this.url.substring( 0, anchorIndex );
      }

      if( this.url.indexOf( "?" ) == -1 )
        this.url += "?";
      else
        this.url += "&";

      this.url += "noCache=" + new Date().getTime();

      if( anchor.length > 0 )
        this.url += "#" + anchor;
    }
    return this.url;
  };
}

ChildWindow.prototype.getPropsString = function()
{
  return this.getProperty( "left", this.left ) +
    this.getProperty( "top", this.top ) +
    this.getProperty( "width", this.width ) +
    this.getProperty( "height", this.height ) +
    this.getBooleanProperty( "scrollbars", this.scrollbars ) +
    this.getBooleanProperty( "resizable", this.resizable ) +
    this.getBooleanProperty( "menubar", this.menubar ) +
    this.getBooleanProperty( "status", this.status ) +
    this.getBooleanProperty( "titlebar", this.titlebar ) +
    this.getBooleanProperty( "toolbar", this.toolbar );
};

ChildWindow.prototype.open = function()
{
  if( this.window != null && this.window.closed )
    this.window = null;

  if( this.window == null )
    this.window = window.open( this.getUrl(), this.name, this.getPropsString() );

  if( this.window == null )
    alert( this.blockedMessage );
  else
    this.window.focus();
};

ChildWindow.prototype.close = function()
{
  var win = this.window;
  if( win == null )
    win = window.open( "", this.name, "width=100,height=100" );
  if( win != null && ! win.closed )
    win.close();
};
