
//***********************************************************//
// OPENCENTEREDPOPUP
// -----------------
// Opens a centered popup with size based on screen resolution
//
// page:        is the page called
// title:       is the popup name
// width:       is the popup width in a 800x600 screen.
// height:      is the popup height in a 800x600 screen
// options:     is the window options
// fixed:       yes - Don't modify the sizes based on resolution
//
// if width=0 the popup width will be screen.width-100
// if height=0 the popup width will be screen.width-100
// if screen resolution is other than 800x600, width & height
// will change to fit correctly
//
// The options are: 
//     alwaysRaised - If yes, the created window is raised. 
//     directories - The value of yes or no determines if the window shows directory buttons or not. 
//     location - The value of yes or no determines if the window has a location displayed on the address line (or has an address line) or not. 
//     menubar - The value of yes or no determines if the window has a menubar or not. 
//     outerWidth - Specifies the outer window width in pixels. This is set to an integer value, rather than yes or no. 
//     outerHeight - Specifies the outer window height in pixels. This is set to an integer value, rather than yes or no. 
//     resizable - The value of yes or no determines if the window can be resized by the user or not 
//     status - The value of yes or no determines if the window has a status bar or not. 
//     scrollbars - The value of yes or no determines if the window has scroll bars or not. 
//     toolbar - The value of yes or no determines if the window has a toolbar or not. 
//     z-lock - If yes, the created window is in the background.
//***********************************************************//
function OpenCenteredPopup(page,title,width,height,options,fixed)
{
	//correct size for the popup
	var popupWidth;
	var popupHeight;
	var popupTop;
	var popupLeft;
	
	if (fixed=='yes') {

		if (width==0)
			popupWidth = screen.width - 100;
		else
			popupWidth = width;
		if (height==0)
			popupHeight = screen.height - 100;
		else
			popupHeight = height;

	} else {

		if (width==0)
			popupWidth = screen.width - 100;
		else
			popupWidth = screen.width * width / 800
		if (height==0)
			popupHeight = screen.height - 100;
		else
			popupHeight = screen.height * height / 600

	}

	//center the popup
	var screenX;
	var screenY;
	
	screenY = screen.availHeight;
	screenX = screen.availWidth;
	
	popupLeft = (screenX - popupWidth) / 2;
	popupTop = (screenY - popupHeight) / 2;
	if (navigator.appName.indexOf("Microsoft")<0) {
		popupLeft = (popupLeft - pageXOffset);
		popupTop = (popupTop - pageYOffset);
	}
	if (popupTop<0) popupTop=0;
	if (popupLeft<0) popupLeft=0;
		
	//opens the popup
	if (navigator.appName.indexOf("Microsoft")>=0) 
	{
		if (options != '') options+=',';
		options+='width='+popupWidth+',height='+popupHeight+',left='+ popupLeft +',top='+popupTop+',scrollbars=yes';
	}
	else
	{
		if (options != '') options+=',';
		options+='width='+popupWidth+',height='+popupHeight+',screenX='+ popupLeft +',screenY='+popupTop+',scrollbars=1';
	}
	floater=window.open(page,title,options);
	floater.focus();
}
