/********************************************************
	Module.:window.js
	Date...:08.04.03
	Auteur.:Sebastien
	Object.:Ouvre une fenetre avec ou sans frame.
	Si il y des frames declenchement d'un timer permettant
	de gerer les differents navigateurs.
********************************************************/

/********************************************************
 Variable globale
 gFormbfOpenWindow : form global a submite dans fenetre
 giIntervalID : Entier specifiant l'interval
 giCptInterval : Entier specifiant la duree maximum d'attente
 ghandle : Reference a la fenetre a ouvrir
********************************************************/

var gFormbfOpenWindow;
var giIntervalId=0;
var giCptInterval=0;
var ghandle;

/********************************************************
 Fonction.:vfSubmitForm
 Objet....:Find frame and submit form.
********************************************************/
function vfSubmitForm(iNbFrame) {
	giCptInterval++;

	/* assigned form ? */
	if(!gFormbfOpenWindow) {
		clearInterval(giIntervalId);
		ghandle.close();
		return;
	} /* if */

	/* too long */ 
	/* 100 ms * 100 = 10 s */
	if(giCptInterval>=100) {
		clearInterval(giIntervalId);
		ghandle.close();
		return;
	} /* if */

	if(iNbFrame<=1)
	{
		clearInterval(giIntervalId);
		gFormbfOpenWindow.submit();
	}
	else
	{
		if(ghandle) {
			if(ghandle.frames) {
				if(ghandle.frames.length==iNbFrame) {
					clearInterval(giIntervalId);
					gFormbfOpenWindow.submit();
				} /* if */
			} /* if */
		} /* if */
	} /* if */
}; /* vfSubmitForm */


/********************************************************
 Fonction.:bfOpenWindow
 Objet....:Open window and start timer.
	szName:Optional. String specifying the name of the window.
	This name is used for TARGET on a FORM or an A.
	iWidth=Sets the width of the window, in pixels.
	Minimum value should be 100.
	iHeight=Specifies the height of the window, in pixels.
	Minimum value should be 100.
	szParam=Parameters after url ?...=....&...=....
	iNbFrame=Number of frame.
********************************************************/
function bfOpenWindow(szName,iWidth,iHeight,szUrl,szParam,iNbFrame) {
var bRetour=false;
var iPosx=0;
var iPosy=0;
var szFeatures="";

	giCptInterval=0;

	/* Calcul de la position de la fenetre par rapport a la taille */
	/* de l'ecran screen.height & screen.width */
	/* screen : Contains information about the client's screen and rendering abilities. */
	iPosy=(screen.height-iHeight)/2;
	iPosx=(screen.width-iWidth)/2;

	szFeatures='width='+iWidth+',height='+iHeight+',top='+iPosy+',left='+iPosx;
	szFeatures+=",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1";

	/* si il y a des parametres on les ajoutes a l'url */
	if(szParam.length!="0") szUrl+=szParam;
	/* Opens a new window and loads the document given by URL, or a blank document if a URL is not provided. */
	if((ghandle=window.open(szUrl,szName,szFeatures))) {
		ghandle.focus();
		bRetour=true;
		/* Repeatedly evaluates an expression after a specified number of milliseconds has elapsed. */
		//giIntervalId=setInterval("vfSubmitForm("+iNbFrame+");",100);
	} /* open */
	
	return(bRetour);
}; /* bfOpenWindow */



/********************************************************
	Module.:window.js
********************************************************/
