/**
 * Copyright (c) 2003 MiEnterprise Pty Ltd. All rights reserved.
 * See the end of this file for the complete source history.
 */

function openDialogFull(mylink, windowname, winWidth, winHeight, scrollbars)
{
		ModalDialogRemoveWatch();
		var winLeft = (screen.width - winWidth) / 2;
		var winUp = (screen.height - winHeight) / 2;
	
		if (!window.focus)
			return true;

		var href = (typeof(mylink) == 'string' ? mylink : mylink.href);

		ModalDialogWindow = window.open(href, windowname, 'top=' + winUp + ',left=' + winLeft + ',toolbar=0 status=0,resizable=0,width=' + winWidth + ',height=' + winHeight + ',scrollbars='+scrollbars);
		
	if(navigator.userAgent.indexOf("msie")==-1 && navigator.userAgent.indexOf("MSIE")==-1) {
	   	ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);
	} else {		
	   	ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",60000);
	}
	
	
	return false;			
}


function openDialog(mylink, windowname)
{
	openDialogFull(mylink, windowname, 400, 100, 0);
}

function closeDialog(windowname)
{
	ModalDialogRemoveWatch();
	w=window.open('', windowname); 
	w.document.write('<body onLoad="window.close()"></body>');
	w.document.close();
}


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(Title,BodyText,Buttons,EventHandler)
 {

   ModalDialogRemoveWatch();
   ModalDialog.eventhandler = EventHandler;

   var args='width=350,height=125,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);

 }

/**
 * $Log: dialog.js,v $
 * Revision 1.3  2003/09/08 10:53:25  terry
 * Added closeDialog() function.
 *
 */


