// JavaScript Document
var WindowObjectReferenceOfRequestedPopup , WindowObjectReferenceOfIntermediaryPopup;
//Hdivider,Wdivider in the next line modify the height & width
//T_factor,L_factor in the next line modify the distance added to top & from Left
function OpenRequestedPopup(strUrl, strTarget,H_factor,W_factor,T_factor,L_factor)
{
var windowWidth, windowHeight, windowLeft, windowTop;

if(typeof window.screenX == "number" && typeof window.innerWidth == "number")
	{
	windowWidth = window.innerWidth * .38; // default= .68
	windowHeight = window.innerHeight * .28; // default= .68
	windowLeft = window.screenX + window.innerWidth * .16;
	windowTop = window.screenY + window.innerHeight * .16;
	}
else if(typeof window.screenTop == "number" && typeof document.documentElement.offsetHeight == "number")
	{
	windowWidth = document.documentElement.offsetWidth * .38; // default= .68
	windowHeight = document.documentElement.offsetHeight * .38; // default= .68
	windowLeft = window.screenLeft + document.documentElement.offsetWidth * .16;
	windowTop = window.screenTop - 50;
	}
else
	{
	windowWidth = 500;
	windowHeight = 250;
	windowLeft = 60;
	windowTop = 40;
	};
				windowHeight=	(windowHeight+	H_factor);	
				windowWidth=	(windowWidth+	W_factor);
				windowTop=	(windowTop+	T_factor);
						windowLeft=	(windowLeft+	L_factor);
								
/* The above code is just to define reasonable sizes and initial positions to the popup to be. */

if (WindowObjectReferenceOfRequestedPopup == null || WindowObjectReferenceOfRequestedPopup.closed)
	{
	WindowObjectReferenceOfRequestedPopup = window.open(strUrl, strTarget, "top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth + ",height=" + windowHeight + ",menubar=no,toolbar=no,resizable=no,scrollbars=no,titlebar=no,directories=no,location=no,status=no");
	}
else
	{
	WindowObjectReferenceOfRequestedPopup.focus();
	};

/*
The above 9 lines of code creates the popup; if the popup is already opened, then it is only brought on top. This feature is possible only if the user allows it via the setting Edit/Preferences.../category:Advanced/Scripts & Plugins/Allow webpages to:/Raise or lower windows
*/
}

function BringRequestedPopupOnTop()
{
if(WindowObjectReferenceOfRequestedPopup != null && !WindowObjectReferenceOfRequestedPopup.closed)
	{
	WindowObjectReferenceOfRequestedPopup.focus();
	};

/*
The above 4 lines of code verify if the popup exists and if the popup has not been closed: it that's the case, then the popup window is given focus and the popup window is brought on top of other windows.
*/
}