﻿// JScript File
var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialog = new Object;

ModalDialog.value = '';
ModalDialog.eventhandler = '';
 
function ModalDialogMaintainFocus()
{
	try
	{
		if (ModalDialogWindow.closed)
		{
			window.clearInterval(ModalDialogInterval);
			eval(ModalDialog.eventhandler);       
	        return;
		}
		ModalDialogWindow.focus(); 
	}
	catch (everything) {   }
}
        
function ModalDialogRemoveWatch()
{
	ModalDialog.value = '';
	ModalDialog.eventhandler = '';
}
        
function ModalDialogShow(message, popup, args, EventHandler)
{    
	ModalDialogRemoveWatch();
	ModalDialog.eventhandler = EventHandler;	
	ModalDialogWindow = window.open(popup + "?Message=" + escape(message), '_blank', args);
	ModalDialogWindow.focus(); 
	ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);
}

function CallModalDialog(hiddenLabel, innerHTML, typeofconfirm, EventHandler)
{
hiddenLabel.innerHTML=innerHTML;
var w =(typeofconfirm?198:95);
if(hiddenLabel.offsetWidth > w)
{
w=hiddenLabel.offsetWidth;
}
w=w+25;
var h=hiddenLabel.offsetHeight;
if(h<20)
{
hiddenLabel.innerHTML=hiddenLabel.innerHTML +'<br>';
}
h=h+70;
var l = (screen.width-w)/2;
var t = (screen.height-h)/2;

ModalDialogShow(innerHTML, findBaseSite() + '/PopUps/'+(typeofconfirm?'Confirm':'Alert')+'.aspx','width=' + w + ',height=' + h + ',left=' + l + ',top=' + t, EventHandler)
}     

