﻿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 ShowModalDialog(url)
 {
   var args='width=600 ,height=500,left=325,top=300,toolbar=0,modal=1,';
       args+='location=0,status=0,menubar=0,scrollbars=1,resizable=0';  
   ModalDialogWindow = window.open(url,"",args); 
   ModalDialogWindow.focus(); 
 }
function ModalDialogShowUrl(url,EventHandler)
 {
   ModalDialogRemoveWatch();
   ModalDialog.eventhandler = EventHandler;
   var args='width=290 ,height=270,left=325,top=300,toolbar=0,modal=1,';
       args+='location=0,status=0,menubar=0,scrollbars=1,resizable=0';  
   ModalDialogWindow = window.open(url,"",args); 
   ModalDialogWindow.focus(); 
   ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);
 }
 
function ModalDialogShow(EventHandler)
 {
   ModalDialogRemoveWatch();
   ModalDialog.eventhandler = EventHandler;
   var args='width=290 ,height=270,left=325,top=300,toolbar=0,modal=1,';
       args+='location=0,status=0,menubar=0,scrollbars=1,resizable=0';  
   ModalDialogWindow = window.open("http://www.freezones.ir/PersianControls/JalaliCalendar.aspx","",args); 
   ModalDialogWindow.focus(); 
   ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);
 }
function DoSubmit(action)
{
    document.getElementById('txtAction').value = action;
    submit();
}
function SetReturnSelectedDate()
  {
    if (ModalDialog.value != '')
       { 
            document.getElementById('pdatepicker1_txtDate').value =  ModalDialog.value;
       }
       ModalDialogRemoveWatch();
    //alert('YesNoCancelReturnMethod has just executed.');
  }
function SetReturnStartSelectedDate()
  {
    if (ModalDialog.value != '')
       { 
            document.getElementById('pStartEndDatePicker_txtStartDate').value =  ModalDialog.value;
       }
       ModalDialogRemoveWatch();
    //alert('YesNoCancelReturnMethod has just executed.');
  }
  function SetReturnEndSelectedDate()
  {
    if (ModalDialog.value != '')
       { 
            document.getElementById('pStartEndDatePicker_txtEndDate').value =  ModalDialog.value;
       }
       ModalDialogRemoveWatch();
    //alert('YesNoCancelReturnMethod has just executed.');
}
