/*<RMJSDep>SharedServices\ClientScripts\ModalWindow;SharedServices\ClientScripts\WindowUtils;SharedServices\ClientScripts\RMWJSResource.js.aspx</RMJSDep>*/

function CloseEditWindow()
{
	ConfigureWindowOpener();
	if (IsWindowOpenerValid())
	{
		window.opener.focus();
	}
	
    window.close();
}

function RegisterDivContainer(ContainerId)
{
    if(!isIE())
    {
        try
        {
            var Container = document.getElementById(ContainerId);
            var obj = {overflowMode : RM.Lib.WebForms.DivOverflowMode.Both, element : Container};
            Array.insert(RM.Lib.WebForms.DivOverflowUtils._managedDivs, 0, obj);
        }
        catch(e)
        {
            return;
        }
    }
}

function SubmitWindowOpener()
{
	ConfigureWindowOpener();
	
	if (!IsWindowOpenerValid())
	  return;
	  
	if ((window.opener.ModalWindow) &&
	    (!window.opener.ModalWindow.closed))
	    MarkWindowOpenerForRefresh();
	else
	    SubmitWindow(window.opener);
}

function MarkWindowOpenerForRefresh()
{
	ConfigureWindowOpener();
	if (IsWindowOpenerValid())
        window.opener.ModalDoRefresh = true;
}

function SubmitWindow(pWindow)
{
    if (pWindow.__doPostBack!=null)
        pWindow.__doPostBack('','');
    else
    {
      var theForm = pWindow.document.forms[0];
      
      if (!theForm.onsubmit || (theForm.onsubmit() != false)) 
	      theForm.submit();
	  }
}

function EditDeleteOnClick(srcElementId, JSLibWebCaptionConfirmaExclusao)
{
    var srcElement = document.getElementById(srcElementId);
    
    try
    {        
        if(RMWShowMessageInModalPopup)
        {            
            $ModalConfirm(JSLibWebCaptionConfirmaExclusao, '__doPostBack("' + srcElement.getAttribute('name') + '", "");');//donotlocalize
            return false;
        }
        else
        {
            result = confirm(JSLibWebCaptionConfirmaExclusao);                         
        }
    }
    catch(e)
    {
        return true;
    }
    
    return result;    
}
var RMWShowModalPopupOnEditSave = null;
function OnEditSaveClick(ShowModal)
{
    RMWShowModalPopupOnEditSave = ShowModal;
}

