<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="participants.aspx.cs" Inherits="view.flow.participants" %>

<html><head>
  <meta http-equiv="X-UA-Compatible"content="IE=EmulateIE7"/>
  <meta http-equiv="Content-Type" content='text/html; charset=utf-8' />
  <title>workflow participants</title>
  <link href='../skin/view.css' type='text/css' rel='stylesheet'>
  <script language=javascript>document.write("<script type='text/javaScript' src='../common/view"+location.search.substring(1)+".js'><\/script>");</script>
  <script type='text/javascript' src='../common/view.js'></script>
</head>

<body scroll=no>
<fieldset style='margin:10px 10px 0px 10px;'><legend><script language=javaScript>document.write(translate['participants']);</script></legend>
<div style='height:320px;overflow:auto;' id=oUserList runat=server><div>&nbsp;</div><div><input type=checkbox name="{!sender}"><img src="../images/userX10.gif" border=0> <script language=javaScript>document.write(translate['taskSender']);</script></div><div><input type=checkbox name="{!responsor}"><img src="../images/userX10.gif" border=0> <script language=javaScript>document.write(translate['lastProcResponsor']);</script></div><div style="border-top:#ccc 1px solid;border-bottom:#ccc 1px solid;padding:2 0;margin:10 0;"><input type=checkbox id=oDefaultAllSelected name="{!defaultAllSelected}"><script language=javaScript>document.write(translate['defaultAllSelected']);</script></div><div>&nbsp;Expression <input type=text id=oExpression size=55></div></div></fieldset>
<fieldset style='margin:0px 10px;'><legend><script language=javaScript>document.write(translate['participateMode']);</script></legend>
<script language=javaScript>document.write(translate['participateModeList']);</script>
</fieldset>
<script language=javaScript>
workflowActionsShow('okCancel');

var nPos = dialogArguments.value.indexOf('modeX=');
var sPaticipants, sMode, sStep;
if (nPos >= 0) {
    sPaticipants = ',' + dialogArguments.value.substr(0, nPos);
    sMode = dialogArguments.value.substr(nPos+6, 1);
    sStep = dialogArguments.value.substr(dialogArguments.value.indexOf('stepX=')+6);
}
else {
    sPaticipants = ',' + dialogArguments.value;
    sMode = '0';
    sStep = '';
}

var ec,e;

if (sPaticipants.indexOf(",$$") == 0) {
    var n = sPaticipants.indexOf("{!defaultAllSelected},");
    if(n > 0) {
        document.getElementById('oDefaultAllSelected').checked = true;
        document.getElementById('oExpression').value = sPaticipants.substr(3, n-3);
    }
    else
        document.getElementById('oExpression').value = sPaticipants.substr(3);
}
else {
    ec = document.getElementsByTagName('INPUT');
    for (var i = 0; i < ec.length; i++) {
        e = ec[i];
        if (e.type == 'checkbox' && e.name && sPaticipants.indexOf(',' + e.name + ',') > -1)
            e.checked = true;
    }
}

if (sMode != '0')
    document.getElementById('oMode').checked = true;

ec = document.getElementsByName('oStep');
for (var i = 0; i < ec.length; i++) {
    e = ec[i];
    if (e.value == sStep) {
        e.checked = true;
        break;
    }
}

function onActionBefore(nActionId, sName, bPostForm) {
    if (nActionId > 0) {
        var s = '';
        if(document.getElementById('oExpression').value.length > 0) {
            s += "$$" + document.getElementById('oExpression').value;
            e = document.getElementById('oDefaultAllSelected');
            if (e.checked)
                s += e.name + ',';
        }
        else {
            ec = document.getElementsByTagName('INPUT');
            for (var i = 0; i < ec.length; i++) {
                e = ec[i];
                if (e.type == 'checkbox' && e.name && e.checked)
                    s += e.name + ',';
            }
        }
        s += 'modeX=' + (document.getElementById('oMode').checked ? '1,' : '0,');
        ec = document.getElementsByName('oStep');
        for (var i = 0; i < ec.length; i++) {
            e = ec[i];
            if (e.checked) {
                s += 'stepX=' + e.value;
                break;
            }
        }
        dialogArguments.value = s;
    }
    self.close();
    return 0; //prevent from submitting
}
</script>
</body>
</html>