$ui->setActions($id, "moveup", $moveup->render());
        } else {
            $ui->setActions($id, "moveup", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
        }
        if ($pos < $workflowusers->count()) {
            $ui->setActions($id, "movedown", $movedown->render());
        } else {
            $ui->setActions($id, "movedown", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
        }
        $ui->setActions($id, "delete", $deletestep->render());
        $ui->setImage($id, $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_user.gif");
    }
    $createstep = new Link();
    $createstep->setCLink("workflow_steps", 4, "workflow_create_user");
    $createstep->setCustom("idworkflow", $idworkflow);
    $createstep->setCustom("idworkflowitem", $idworkflowitem);
    $ui->setLink("spacer", NULL);
    $ui->setTitle("create", '<input class="text_medium" type="submit" name="adduser" value="' . i18n("Add User", "workflow") . '">');
    $ui->setLink("create", NULL);
    $content = $ui->render(false);
    return $content;
}
$tpl = new Template();
$tpl->set('s', 'NEW', createNewWorkflow());
$tpl->set('s', 'STEPS', getWorkflowList());
$tpl->set('s', 'EDITSTEP', editWorkflowStep($idworkflowitem));
$tpl->set('s', 'BORDERCOLOR', $cfg["color"]["table_border"]);
$frame = $tpl->generate($cfg["path"]["contenido"] . $cfg["path"]["plugins"] . "workflow/templates/template.workflow_steps.html", true);
$page = new UI_Page();
$page->setContent($frame);
$page->render();
        function foo(){return true;}

        /* Session-ID */
        var sid = "' . $sess->id . '";

        /* Create messageBox
           instance */
        box = new messageBox("", "", "", 0, 0);

        /* Function for deleting
           modules */

        function deleteWorkflow(idworkflow) {
            url  = "main.php?area=workflow";
            url += "&action=workflow_delete";
            url += "&frame=2";
            url += "&idworkflow=" + idworkflow;
            url += "&contenido=" + sid;
            parent.left_bottom.location.href = url;

        }
		</script>';
$sInitRowMark = "<script type=\"text/javascript\">\n                     if (document.getElementById('marked')) {\n                         row.markedRow = document.getElementById('marked');\n                     }\n                 </script>";
$msgboxInclude = '    <script type="text/javascript" src="scripts/messageBox.js.php?contenido=' . $sess->id . '"></script>';
$page = new UI_Page();
$page->addScript('include', $msgboxInclude);
$page->addScript('del', $delScript);
$page->addScript('refresh', $sScript);
$page->setMargin(0);
$page->setContent($content . $sInitRowMark);
$page->render();
    $idworkflow = $_GET['idworkflow'];
}
if ($idworkflow) {
    $sReloadScript = "<script type=\"text/javascript\">\n                         var left_bottom = top.content.frames['left'].frames['left_bottom'];\n                         var right_top = top.content.frames['right'].frames['right_top'];\n                         if (left_bottom) {\n                             var href = left_bottom.location.href;\n                             href = href.replace(/&action=workflow_delete/, '');\n                             left_bottom.location.href = href+'&idworkflow='+" . $idworkflow . ";\n                         }\n                         \n                         if (right_top) {\n                            right_top.location.href = right_top.location.href+'&idworkflow='+" . $idworkflow . ";\n                         }\n                     </script>";
} else {
    $sReloadScript = '';
}
//function formGenerateField ($type, $name, $initvalue, $width, $maxlen)
$form->setVar("area", $area);
$form->setVar("action", "workflow_save");
$form->setVar("idworkflow", $idworkflow);
$form->setVar("frame", $frame);
if ($workflow->virgin) {
    $name = i18n("New Workflow", "workflow");
    $header = i18n("Create new workflow", "workflow");
} else {
    $header = i18n("Edit workflow", "workflow");
    $description = $workflow->get("description");
    $name = $workflow->get("name");
    $created = $workflow->get("created");
    $author = $userclass->getRealname($workflow->get("idauthor"));
}
$form->addHeader($header);
$form->add(i18n("Workflow name", "workflow"), formGenerateField("text", "wfname", $name, 40, 255));
$form->add(i18n("Description", "workflow"), formGenerateField("textbox", "wfdescription", $description, 50, 10));
$form->add(i18n("Author", "workflow"), $author);
$form->add(i18n("Created", "workflow"), $created);
$page = new UI_Page();
$page->setContent($form->render(true));
$page->addScript('reload', $sReloadScript);
$page->render();