<!--
/*
NOTICE

How to call the popupfunction ?

These functions return the new window handler so be sure to not call them from an anchor HREF
(<A HREF="javascript:popup...) cuz in this case you 'll get a blank page with the word [object] in it.
The best method to call these function is 
In a script 
	var myhandler = popup....
In an onClick property
<A HREF="#"	onClick="popup...;return false;">link</A>
	
By returning false in the onClick event, the anchor will not open the page set in the HREF
*/

var agt=navigator.userAgent.toLowerCase();
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
/*--------------------------------------------------------------------------------
 NAME : popupWindow
 DESCRIPTION : Open a popup window and display a the page given in the Source parameter.
				The popup window is centered.
 PARAMETERS :
  source 	the source of the window 
  winName	the name of the window  
  X			the width of the window
  Y			the height of the window
--------------------------------------------------------------------------------*/
function test() {
alert('test');

}

function popupWindow(source,winName,X,Y)
{
	if (!X) {X = 320;}
	if (!Y) {Y = 200;}
	// correction because of the scrollbar
	if (is_ie) {
		X += 13;
		Y -= 4;
	}
	var newWin = window.open('',winName,'location=0,status=0,resizable=0,scrollbars=0,width=' + X + ',height=' + Y + ',top='+(screen.availHeight-Y)/2 + ',left=' + (screen.availWidth-X)/2);
	newWin.opener = self;
	// it's not crazy to define the source this way, cuz else scripts in the new window will acces to the old opener value in case the latency is very short	
	newWin.location.href = source;
	newWin.focus();
	return newWin;
}

/*--------------------------------------------------------------------------------
 NAME : popupMenuedWindow
 DESCRIPTION : Open a popup window and display the page given in the Source parameter.
				The popup window have the standard menu of the browser.
				The popup window is centered.
 PARAMETERS :
  source 	the source of the window
  winName	the name of the window   
  X			the width of the window
  Y			the height of the window
--------------------------------------------------------------------------------*/
function popupMenuedWindow(source,winName,X,Y)
{
	if (!X) {X = 320;}
	if (!Y) {Y = 200;}
	if (is_ie) {	
	// correction because of the scrollbar
		X += 13;
		Y -= 24;
	}
	var newWin = window.open('',winName,'menubar=1,resizable=1,scrollbars=1,width=' + X + ',height=' + Y + ',top='+(screen.availHeight-Y)/2 + ',left=' + (screen.availWidth-X)/2);
	newWin.opener = self;
	// it's not crazy to define the source this way, cuz else scripts in the new window will acces to the old opener value in case the latency is very short
	newWin.location.href = source;
	newWin.focus();
	return newWin;	
}

/*--------------------------------------------------------------------------------
 NAME : popupFreezedWindow
 DESCRIPTION : Open a popup window and display the page given in the Source parameter.
				The popup window can not be resized and there is no scrollbar.
				The popup window is centered.
 PARAMETERS :
  source 	the source of the window
  winName	the name of the window   
  X			the width of the window
  Y			the height of the window
--------------------------------------------------------------------------------*/
function popupFreezedWindow(source,winName,X,Y)
{
	if (!X) {X = 320;}
	if (!Y) {Y = 200;}
	// correction because of the border
	if (is_ie) {
		X -= 4;
		Y -= 4;	
	}
	var newWin = window.open('',winName,'width=' + X + ',height=' + Y + ',top='+(screen.availHeight-Y)/2 + ',left=' + (screen.availWidth-X)/2);
	newWin.opener = self;
	// it's not crazy to define the source this way, cuz else scripts in the new window will acces to the old opener value in case the latency is very short
	newWin.location.href = source;
	newWin.focus();
	return newWin;	
}

/*--------------------------------------------------------------------------------
 NAME : popupMaximizedWindow
 DESCRIPTION : Open a popup window and display the page given in the Source parameter.
				The popup window can not be resized, there is no scrollbar and the popup always stay on top.
				No frame are allowed in this window.
				The popup window is centered.
 PARAMETERS :
  source 	the source of the window
  winName	the name of the window   
  X			the width of the window
  Y			the height of the window
--------------------------------------------------------------------------------*/
function popupMaximizedWindow(source,winName)
{
	var X = screen.availWidth;
	var Y = screen.availHeight;
	// correction because of the scrollbar
	if (is_ie) {
		X -= 12;
		Y -= 38;	
	}
	else {
		X -= 8;
		Y -= 34;
	}
	var newWin = window.open('',winName,'maximized=1,resizable=1,scrollbars=1,width=' + X + ',height=' + Y + ',top=0,left=0');
	newWin.opener = self;
	// it's not crazy to define the source this way, cuz else scripts in the new window will acces to the old opener value in case the latency is very short
	newWin.location.href = source;
	newWin.focus();
	newWin.document.body.onBlur = "self.focus()";
	return newWin;
}

/*--------------------------------------------------------------------------------
 NAME : targetOpener
 DESCRIPTION : Close the current window, change the source of the opener window and give it the focus
				If there is no opener a new window is opened
 PARAMETERS :
  myLink	the new URL of the opener window.
--------------------------------------------------------------------------------*/
function targetOpener(myLink)
{
	if (!window.opener.closed) {
		window.opener.location.href=myLink;
		window.opener.focus();
		top.close();
	}
	else {
		var newWin = window.open (myLink);
		newWin.focus();
		top.close();
	}
}

/*--------------------------------------------------------------------------------
 NAME : closePopup
 DESCRIPTION : Close the current window and give the focus to the opener if it exists
--------------------------------------------------------------------------------*/
function closePopup(winName)
{
	if (winName == undefined) {
		if (!window.opener.closed) {
			window.opener.focus();
		}
		top.close();
	}
	else {
		var itshandler = getHandler(winName);
		if (!itshandler.opener.closed) {
			itshandler.opener.focus();
		}
		itshandler.close();
	}
}


/*--------------------------------------------------------------------------------
 NAME : getHandler
 DESCRIPTION : Get the hanlder of the named window.
 				If the named window is not open a new window will be open and then closed immediatly.
 PARMETERS :
 	winName		name of the window
--------------------------------------------------------------------------------*/
function getHandler(winName)
{
	var handler = window.open ('',winName,'width=1,height=1,top=0,left=3000');
	if (handler.location.href == '') { // the window is upposed to be newly created by the previous instruction
		handler.close();
		return null;
		}
	else {
		return handler;
	}
}

//-->