// popup simple
function popup(url,pWidth,pHeight,top,left){
	window.open(url,'fen1','fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+pWidth+',height='+pHeight+',top='+top+',left='+left+',true');
}

// popup simple sans barre outils
function popup_noTools(url,pWidth,pHeight){
	var large=screen.width;
	large=(large/2)-(pWidth/2);
	var haut=screen.height;
	haut=(haut/2)-(pHeight/2);
	window.open(url,'fen1','fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+pWidth+',height='+pHeight+',top='+haut+',left='+large+',true');
}

// tous parametres acceptes
function open_window(url, new_params) {
	new_params = '';
	var parametre_fenetre;
	var arg_nb = open_window.arguments.length
	var arg_values = open_window.arguments
	var window_name = (arg_nb > 2) ? arg_values[2] : 'ITCF'
	if (new_params=='')  parametre_fenetre = 'scrollbars=yes,width=420,height=400,menubar=yes,resizable=no,status=no,location=no'; 
	else parametre_fenetre = new_params;
	le_fenetre = window.open(url,window_name,parametre_fenetre);
}

// popup centre
function popup2(url,pWidth,pHeight){
	var large=screen.width;
	large=(large/2)-(pWidth/2);
	var haut=screen.height;
	haut=(haut/2)-(pHeight/2);
	window.open(url,'fen1','fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+pWidth+',height='+pHeight+',top='+haut+',left='+large+',true');
}

// popup centre
function popup_center(pName,url,pWidth,pHeight){
	var large=screen.width;
	large=(large/2)-(pWidth/2);
	var haut=screen.height;
	haut=(haut/2)-(pHeight/2);
	window.open(url,pName,'fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+pWidth+',height='+pHeight+',top='+haut+',left='+large+',true');
}

// on ferme la fenetre en cours, avec un focus sur la fenêtre ouvrante
function fQuit(){
	if(window.opener)
	{
		window.opener.focus();
		window.close();
	}
	else
	{
		window.close();
	}
}

// on ferme la fenetre en cours, avec un focus sur la fenetre ouvrante
// ou bien on affiche la racine du site si pas de fenetre ouvrante
function fReturnSite(){
	if(window.opener)
	{
		window.opener.focus();
		window.close();
	}
	else
	{
		window.location.href="/"
	}
}

function fQuit_submit(){
	window.opener.focus();
	window.opener.aform.submit();
	window.close();
}

// pour imprimer la fenetre
function fPrint(){
	bV = parseInt(navigator.appVersion);
	if (bV >= 4 && navigator.userAgent.indexOf('MSIE 4')==-1){
		window.print();
		window.close();
	}
	else
		alert('Votre navigateur est d\'une version trop ancienne pour lancer l\'impression à partir de ce bouton de commande : nous vous conseillons de passer par la barre de menu de votre navigateur, onglet \'Fichier\', cliquez sur \'Imprimer\'')
}

// on centre la fenêtre dans l'ecan
// ATTENTION ! toujours appeler cette fonction DANS LE BODY de la page !
function center_popup()
{
	// récupération de la taille de l'écran
	screenWidth = screen.availWidth;
	screenHeight = screen.availHeight;
	// récupération de la taille de la fenêtre à centrer
	if (parseInt(navigator.appVersion) > 3) 
	{
		if (navigator.appName == "Netscape") 
		{
			windowWidth = window.innerWidth;
			windowHeight = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft") != -1) 
		{
			windowWidth = document.body.offsetWidth;
			windowHeight = document.body.offsetHeight;
		}
	}
	// calcul des nouvelles coordonnées pour le centrage
	newX = (screenWidth - windowWidth) / 2;
	newY = (screenHeight - windowHeight) / 2;
	// centrage
	self.moveTo(newX, newY);
}