//*********************************************************************
//*                  Module de gestion des fenêtres                   *
//*                    Ecrit par Alexandre GASTAUD                    *
//*********************************************************************
//* A inclure : PARAMS.JS, TAILLES.JS, INFOS.JS                       *
//*********************************************************************

var FEN_HSCROLL = 16;
var FEN_VSCROLL = 16;
var FEN_HMARGES = 19;
var FEN_VMARGES = 29;

var xWindowDebug = null;

function OpenFullscreen (adresse, nom, options)
	{
	return new WindowX (adresse, 0, 0, ScreenWidth (), ScreenHeight (), nom, "fullscreen=yes," + options);
	}

function OpenBusy (adresse)
	{
	return new WindowX (URLUnique (adresse), null, null, 100, 100);
	}

function Debug (chaine)
	{
	if (xWindowDebug == null) xWindowDebug = new WindowX (null, 0, 0, 200, 400, "_xDebug");
	xWindowDebug.Write (chaine + "<br>\n");
	xWindowDebug.objet.scrollBy (0, 100);
	}

function WindowX (adresse, x, y, dx, dy, nom, options)
	{
	if (adresse == null) adresse = "";
	if (options == null) options = "";
	if (x != null) options += ((isNetscape) ? ",screenX=" + x : ",left=" + x);
	if (y != null) options += ((isNetscape) ? ",screenY=" + y : ",top=" + y);
	if (dx != null) options += ((isNetscape) ? ",innerWidth=" + dx : ",width=" + (dx + ((options.indexOf ("scrollbars=no") == -1) ? FEN_VSCROLL : 0)));
	if (dy != null) options += ((isNetscape) ? ",innerHeight=" + dy : ",height=" + (dy + ((options.indexOf ("scrollbars=no") == -1) ? FEN_HSCROLL : 0)));
	if (nom == null) nom = "_blank";
	if (options.indexOf ("resizable=") == -1)
		if (dx != null || dy != null) options += ",resizable=no"; else options += ",resizable=yes";
	if (options.indexOf ("scrollbars=") == -1) options += ",scrollbars=yes";

	this.Move = MoveWindow;
	this.Size = SizeWindow;
	this.Write = WriteWindow;
	this.Delete = DeleteWindow;
	this.Focus = FocusWindow;
	this.Close = CloseWindow;

	this.objet = window.open (adresse, nom, "directories=no,location=no,menubar=no,personalbar=no,status=no,toolbar=no," + options);
	this.Focus (true);
	}

function MoveWindow (x, y)
	{
	this.objet.moveTo (x, y);
	}

function SizeWindow (dx, dy)
	{
	this.objet.resizeTo (dx, dy);
	}

function WriteWindow (source)
	{
	this.objet.document.write (source);
	}

function DeleteWindow ()
	{
	this.objet.document.close ();
	this.objet.document.open ();
	}

function FocusWindow (focus)
	{
	if (focus != false)
		this.objet.focus ();
	else
		this.objet.blur ();
	}

function CloseWindow ()
	{
	this.objet.close ();
	}

//*************************** FIN DU FICHIER **************************