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 (err) 
	{}
}
        
function modalDialogRemoveWatch()
{
	modalDialog.value = '';
	modalDialog.eventHandler = '';
}
       
function modalDialogShow(title,bodyText,buttons,eventHandler)
{
	modalDialogRemoveWatch();
	modalDialog.eventHandler = eventHandler;
	
	var args='width=350,height=260,left=325,top=300,toolbar=0,';
		args+='location=0,status=0,menubar=0,scrollbars=1,resizable=0';  
	
	modalDialogWindow=window.open("","",args); 
	modalDialogWindow.document.open(); 
	modalDialogWindow.document.write('<html>');
	modalDialogWindow.document.write('<head>'); 
	modalDialogWindow.document.write('<title>' + title + '</title>');
	modalDialogWindow.document.write('<script' + ' language=JavaScript>');
	modalDialogWindow.document.write('function closeForm(response) ');
	modalDialogWindow.document.write('{ ');
	modalDialogWindow.document.write(' window.opener.modalDialog.value = response; ');
	modalDialogWindow.document.write(' window.close(); ');
	modalDialogWindow.document.write('} ');
	modalDialogWindow.document.write('</script' + '>');        
	modalDialogWindow.document.write('</head>');   
	modalDialogWindow.document.write('<body onblur="window.focus();">');
	modalDialogWindow.document.write('<table border=0 width="95%" align=center cellspacing=0 cellpadding=2>');
	modalDialogWindow.document.write('<tr><td align=left>' + bodyText + '</td></tr>');
	modalDialogWindow.document.write('<tr><td align=left><br></td></tr>');
	modalDialogWindow.document.write('<tr><td align=center>' + buttons + '</td></tr>');
	modalDialogWindow.document.write('</body>');
	modalDialogWindow.document.write('</html>'); 
	modalDialogWindow.document.close(); 
	modalDialogWindow.focus(); 
	modalDialogInterval = window.setInterval("modalDialogMaintainFocus()",5);	
}

function openUpcomingEventsAlert(bodyText,eventHandler)
{
	var buttons=''; 
	buttons = '<a href=javascript:closeForm("Continue");>continue</a>  ';
	modalDialogShow("Upcoming Events",bodyText,buttons,eventHandler);
}

function closePostUpcomingEventsAlert()
{
	modalDialogRemoveWatch();
}

function popupEvent(msg) {
	if (readCookie("special") == null) {
		openUpcomingEventsAlert(msg,closePostUpcomingEventsAlert());
		createCookie("special");
	}
}
