/*<RMJSDep>SharedServices\ClientScripts\ModalWindow;SharedServices\ClientScripts\ModalWindow</RMJSDep>*/
var ProcParamsPageURL;
var ClientOnGetKeyValues;

RMWActionProcessControl = function RMWActionProcessControl(_window, ControlId)
{
    this.DomObj  = _window.document.getElementById(ControlId);
    this._window = _window;
    if (!this.DomObj)
        return null;
}

RMWActionProcessControl.prototype.ExecuteProcess = function ExecuteProcess(ProcessActionId, KeyValues, ShowParams, DefaultParams)
{
    if(ShowParams)
    {
        var newWindowUrl = ProcParamsPageURL;
        var urlCharConnector;
        
        if (newWindowUrl.indexOf('?') != -1)
	        urlCharConnector = '&';
        else
	        urlCharConnector = '?';
		
        newWindowUrl = ProcParamsPageURL + urlCharConnector + "ActionID=" + ProcessActionId + "&KeyValues=" + KeyValues + "&ProcessActionControlId=" + this.DomObj.id;//donotlocalize
        
        this._window.open(newWindowUrl, "_blank", "Height=450px,Width=800px,Top=50,Left=50,help=no,status=yes,scroll=no,edge=raised,resizable=yes");
        //    ShowModalWindow(ProcParamsPageURL + "?ActionID=" + ProcessActionId + "&KeyValues=" + KeyValues, "_blank", "Height=450px,Width=800px,Top=50,Left=50,help=no,status=no,scroll=no,edge=raised,resizable=yes", true);
    }
    else
        this.ExecuteProcessOnServer(ProcessActionId, KeyValues, DefaultParams);
}

RMWActionProcessControl.prototype.ExecuteProcessOnServer = function ExecuteProcessOnServer(ProcessActionId, KeyValues, Parameters)
{
    if (Parameters == null)
        Parameters = "";
        
    this.DomObj.value = ProcessActionId + "," + Parameters + "," + KeyValues;
    this._window.__doPostBack(this.DomObj.name,'');
}

function ProcParamsWindowOnLoad()
{
    ConfigureWindowOpener();
}

function ProcParamsWindowCancel()
{
    window.close();
}

function ProcParamsWindowOK(ProcessControlID, ProcessActionId, KeyValues, Parameters)
{
    var processControl = new RMWActionProcessControl(window.opener, ProcessControlID);
    processControl.ExecuteProcessOnServer(ProcessActionId, KeyValues, Parameters);
    window.close();
}
