/**
 * Fonctions de gestion d'une popup centrée.
 *
 * Ce fichier contient le code javascript permettant d'ouvrir une fenêtre
 * popup centrée dépourvue des barres en tout genre. Seule customisation
 * possible : le redimensionnement et les scrollbars.
 *
 * @access public
 * @author Sébastien DECAIX
 * @package javascript
 */

/** Largeur d'écran.
 *  @var int la largeur de l'écran en pixels.
 */
var screenwidth = 1024;

/** Hauteur d'écran.
 *  @var int la hauteur de l'écran en pixels.
 */
var screenheight = 768;

if (this.screen) {
	screenwidth = this.screen.availWidth;
	screenheight = this.screen.availHeight;
}


/** Ouvre une fenêtre popup avec l'url spécifiée.
 * @param string l'url du document à ouvrir dans la fenêtre popup.
 * @param string le nom de la fenêtre popup.
 * @param int largeur de la fenêtre.
 * @param int hauteur de la fenêtre.
 * @param boolean true si la fenêtre peut être redimensionnée, false sinon.
 * @param boolean true si la fenêtre accepte les barres de défilement, false sinon.
 */
function openPopup(popurl, popname, popwidth, popheight, resizable, scrollbars) {
//	var resizable = 1; // Commenter cette ligne si on accepte le redimensionnement conditionnel
//	var scrollbars = 1; // Commenter cette ligne si on accepte l'affichage conditionnel des scrollbars
	
	if (popurl == null || popurl == "") {return null;}
	if (arguments.length > 6) {poptop = arguments[6];} else {poptop = -1;}
	if (arguments.length > 7) {popleft = arguments[7];} else {popleft = -1;}
	popleft = (popleft < 0) ? (screenwidth - popwidth) / 2 : popleft;
	poptop = (poptop < 0) ? (screenheight - popheight - 32) / 2 : poptop;
	var popopt = "width="+popwidth+",height="+popheight+",top="+poptop+",left="+popleft;
	popopt += ",menubar=0,location=0,resizable="+resizable+",scrollbars="+scrollbars+",status=0";
	win = window.open(popurl, popname, popopt);
	//win.opener = win.opener.top;
	return win;
}

function openPopup2(popurl, popname, popwidth, popheight, resizable, scrollbars, xitiurl) {
//	var resizable = 1; // Commenter cette ligne si on accepte le redimensionnement conditionnel
//	var scrollbars = 1; // Commenter cette ligne si on accepte l'affichage conditionnel des scrollbars
	if (popurl == null || popurl == "") {return null;}
	if (arguments.length > 6) {poptop = arguments[6];} else {poptop = -1;}
	if (arguments.length > 7) {popleft = arguments[7];} else {popleft = -1;}
	popleft = (popleft < 0) ? (screenwidth - popwidth) / 2 : popleft;
	poptop = (poptop < 0) ? (screenheight - popheight - 32) / 2 : poptop;
	var popopt = "width="+popwidth+",height="+popheight+",top="+poptop+",left="+popleft;
	popopt += ",menubar=0,location=0,resizable="+resizable+",scrollbars="+scrollbars+",status=0";
	win = window.open(xitiurl, popname, popopt);
	win.location=xitiurl;
	win.location=popurl;
	win.opener = win.opener.top;
	return win;
}