//version:1.0
//author: BrianChao
//locale : taiwan
 
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(path,arguments,args,EventHandler)
 {
	
   //
   ModalDialogRemoveWatch();
	if(EventHandler!=null)
		ModalDialog.eventhandler = EventHandler;
	else
   		ModalDialog.eventhandler = 'ReturnMethodA()';//EventHandler;

	ModalDialog.value = arguments;

	args = args +",toolbar=0,left=325,top=300,location=0,status=0,menubar=0,scrollbars=0,resizable=0";
   ModalDialogWindow=window.open(path,"",args); 

   ModalDialogWindow.focus(); 
   ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);

 }
 
function CloseForm(Response) 
{ 
	window.opener.ModalDialog.value = Response; 
	window.close(); 
} 
     
     
function ReturnMethodA()
{
	try{
	    //document.getElementById("modalreturn2").value = ModalDialog.value;
	    ModalDialogRemoveWatch();
    }
    catch(E){}
}