function OpenPopUp(sURL, sPopupTitle, bIsMenuBar, bIsScrollbars, bIsToolbar, bIsResizable, bIsCentered, iWindowLeft, iWindowTop, iWindowHeight, iWindowWidth, bIsDecaled, bIsLocation)
{
	var oWindow;
	var sExt;
	var iTop;
	var iLeft;
	var iWidth;
	var iHeight;
	
	if (isEmpty(bIsLocation)) {bIsLocation = false;}
	
	if (isEmpty(bIsDecaled)) {bIsDecaled = false;}
	
	if (isEmpty(iWindowWidth)) {iWindowWidth = 600;}
	
	if (isEmpty(iWindowHeight)) {iWindowHeight = 400;}
	
	if (isEmpty(bIsCentered)) {bIsCentered = true;}
	
	if (isEmpty(bIsToolbar)) {bIsToolbar = false;}
	
	if (isEmpty(bIsScrollbars)) {bIsScrollbars = true;}
	
	if (isEmpty(bIsMenuBar)) {bIsMenuBar = false;}
	
	if (isEmpty(bIsResizable)) {bIsResizable = true;}
	
	if (bIsCentered)
	{
		iWidth = Math.round(iWindowWidth);
		iHeight = Math.round(iWindowHeight);				
		
		iLeft = Math.round((window.screen.width - iWindowWidth) / 2);
		iTop = Math.round((window.screen.height - iWindowHeight) / 2);
		if (bIsDecaled)
		{
		iLeft = iLeft + 20;
		iTop = iTop + 20;
		}
	}
	else
	{
		iWidth = iWindowWidth;
		iHeight = iWindowHeight;				
			
		iLeft = iWindowLeft;
		iTop = iWindowTop;
	}

	if (bIsToolbar) {sExt = "toolbar=yes,";}
	else {sExt = "toolbar=no,";}

	if (bIsScrollbars) {sExt = sExt + "scrollbars=yes,";}
	else {sExt = sExt + "scrollbars=no,";}

	/*if (bIsMenuBar) {sExt = sExt + "directories=yes,";}
	else {sExt = sExt + "directories=no,";}*/

	if (bIsMenuBar) {sExt = sExt + "menubar=yes,";}
	else {sExt = sExt + "menubar=no,";}
	
	if (bIsResizable) {sExt = sExt + "resizable=yes,";}
	else {sExt = sExt + "resizable=no,";}
	
	if (bIsLocation) {sExt = sExt + "location=yes,";}
	else {sExt = sExt + "location=no,";}
	
	sExt = sExt + "width=" + iWidth + ",height=" + iHeight + ",top=" + iTop + ",left=" + iLeft;

	if (sURL != "")
	{
		oWindow = window.open("", sPopupTitle, sExt); // empty url workaround for focus problem with PDF files in popup
		if(oWindow != null)
		{
			oWindow.focus();
			oWindow.location.href=sURL;
		}	
	}
}

function openPopUp(sURL, sPopupTitle, bIsMenuBar, bIsScrollbars, bIsToolbar, bIsResizable, bIsCentered, iWindowLeft, iWindowTop, iWindowHeight, iWindowWidth, bIsDecaled)
{
	OpenPopUp(sURL, sPopupTitle, bIsMenuBar, bIsScrollbars, bIsToolbar, bIsResizable, bIsCentered, iWindowLeft, iWindowTop, iWindowHeight, iWindowWidth, bIsDecaled);
}

function openPopup(sURL, sPopupTitle, bIsMenuBar, bIsScrollbars, bIsToolbar, bIsResizable, bIsCentered, iWindowLeft, iWindowTop, iWindowHeight, iWindowWidth, bIsDecaled)
{
	OpenPopUp(sURL, sPopupTitle, bIsMenuBar, bIsScrollbars, bIsToolbar, bIsResizable, bIsCentered, iWindowLeft, iWindowTop, iWindowHeight, iWindowWidth, bIsDecaled);
}

function confirmPopup(sMessage, sURL, sPopupTitle, bIsMenuBar, bIsScrollbars, bIsToolbar, bIsResizable, bIsCentered, iWindowLeft, iWindowTop, iWindowHeight, iWindowWidth)
{
	if (confirm(sMessage)) 
	{
		OpenPopUp(sURL, sPopupTitle, bIsMenuBar, bIsScrollbars, bIsToolbar, bIsResizable, bIsCentered, iWindowLeft, iWindowTop, iWindowHeight, iWindowWidth);
	}
}

function isEmpty(s)
{   return (s == null);
}

function EnlargePopupForCtrl(ctrlId, defWidth, defHeight)
{// Added by ADE 2005-08-11
	var ctrl=document.getElementById(ctrlId);
	if(ctrl.offsetWidth > window.document.body.clientWidth)
	{//Popup should be resized to display control correctly
		iNewWidth=ctrl.offsetWidth + 150;
		if(iNewWidth>window.screen.width) //ensure popup won't be larger than client screen
			iNewWidth=window.screen.width;
		window.resizeTo(iNewWidth, defHeight);
		CenterPopup(iNewWidth, defHeight);
	}
	else if (window.document.body.clientWidth > defWidth) 
	{//If popup was enlarged during a previous call, restore default width
		window.resizeTo(defWidth, defHeight);
		CenterPopup(defWidth, defHeight);
	}
}

function CenterPopup(winWidth, winHeight)
{//Added by ADE 2005-08-11
	iLeft = Math.round((window.screen.width - winWidth) / 2);
	iTop = Math.round((window.screen.height - winHeight) / 2);
	window.moveTo(iLeft,iTop);
}

function ShowHidePopupControl(sControlID, sDisplayStyle)
{
	var ctrl = document.getElementById(sControlID);
	if (ctrl)
	{
		if (window.opener)
		{
			ctrl.style.display = sDisplayStyle;
		}
		else
		{
			ctrl.style.display = (sDisplayStyle!='none')?'none':'';
		}
	}
}
function SetHomePage()
{

window.location.href    ='Sethomepage.aspx?URLTOSAVE='+ escape(window.parent.document.location.href)
}