// JavaScript popup

// <a href="javascript:PopUp('envoyer_ami.cfm','Envoyer',550,370,100,20,0,0,0,0,0,0,0)">Cliquez ici</a>
// <a href="javascript:PopUp('envoyer_ami.cfm','Envoyer',width,height,posx,posy,scrollbar,resize,toolbar,statusbar,menubar,location,0)">Cliquez ici</a>

var PopUpWindow;
function PopUp(src,name,width, height, screenx, screeny, scrollbar, resize, toolbar, status, menubar, location, directories) {
	//alert('screen:'+screenx+","+screeny+" ; dim:"+width+","+height);

	// placé avant le reste car les tests juste après se basent sur width/height
	if (width == -1)	width = screen.width;	// si -1, on utilise la taille de l'écran
	if (height == -1)	height = screen.height;
	
	
	if (screenx == -1) {	// si -1, on centre la popup dans l'écran
		screenx = (screen.width-width)/2;
		if (screenx < 0) { screenx = 0; }
	}
	if (screeny == -1) {
		screeny = (screen.height-height)/2;
		if (screeny < 0) { screeny = 0; }
	}
	var size, pos;
	size = '';
	pos = '';
	if (width > 0)		size = ',width='+width;
	if (height > 0)		size = size + ',height='+height;
	if (screenx >= 0)	pos = ',screenX='+screenx+',left='+screenx;
	if (screeny >= 0)	pos = pos + ',screenY='+screeny+',top='+screeny;
	scrollbar = (scrollbar == 1)?'yes':'no';
	resize = (resize == 1)?'yes':'no';
	toolbar = (toolbar == 1)?'yes':'no';
	status = (status == 1)?'yes':'no';
	menubar = (menubar == 1)?'yes':'no';
	location = (location == 1)?'yes':'no';	// la barre d'adresse
	directories = (directories == 1)?'yes':'no';
	//Ouverture de la pop-up
	PopUpWindow = window.open(src, name,'scrollbars='+scrollbar+',resizable='+resize+',toolbar='+toolbar+',status='+status+',menubar='+menubar+',location='+location+',directories='+directories+size+pos);
	PopUpWindow.focus();
}
