print "<!-- Form Functions -->\n";
print "<script type='text/javascript'>\n";
print "/* <![CDATA[ */\n";
print "function reload(pthis){//  reload form.php\n";
if ($_POST['del_ok'] == '1') {
    print "   parent.window.close();\n";
    print "   parent.opener.document.focus();\n";
    print "   parent.opener.document.forms[0].submit();\n";
    $theform = formFields($sysformID);
    nuRunQuery("DELETE FROM {$theform->sfo_table} WHERE {$theform->sfo_primary_key} = '{$recordID}'");
    $t = nuRunQuery("SELECT * FROM zzsys_object WHERE sob_zzsys_form_id = '{$sysformID}' and sob_all_type = 'subform'");
    while ($r = db_fetch_object($t)) {
        nuRunQuery("DELETE FROM {$r->sob_subform_table} WHERE {$r->sob_subform_foreign_key} = '{$recordID}'");
    }
    //----------create an array of hash variables that can be used in any "hashString"
    $arrayOfHashVariables1 = postVariablesToHashArray();
    //--values of this record
    $arrayOfHashVariables1['#id#'] = $theRecordID;
    //--this record's id
    $arrayOfHashVariables = recordToHashArray('zzsys_session', 'zzsys_session_id', $ses);
    //--session values (access level and user etc. )
    $arrayOfHashVariables = joinHashArrays($arrayOfHashVariables, $arrayOfHashVariables1);
    //--join the arrays together
    $nuHashVariables = $arrayOfHashVariables;
    //--added by sc 23-07-2009
    //----------allow for custom code----------------------------------------------
    eval(replaceHashVariablesWithValues($arrayOfHashVariables, $theform->sfo_custom_code_run_after_delete));
} else {
    print "   parent.frames['main'].document.forms[0].action = 'form.php?x=1&r={$recordID}&dir={$dir}&ses={$ses}&f={$sysformID}';\n";
    print "   parent.frames['main'].document.forms[0].submit();\n";
}
    $SF->ReadOnly = $_POST['readonly' . $SF->Name];
    $SF->ColumnName = array();
    for ($I = 0; $I < $SF->Columns; $I++) {
        if (in_array($_POST[$SF->Name . $I], $recordFields)) {
            $SF->ColumnName[] = $_POST[$SF->Name . $I];
        }
    }
    if ($SF->ReadOnly != 1) {
        //--will not update readonly subforms
        updateSubform($_POST, $SF, $recordID);
    }
}
//----------create an array of hash variables that can be used in any "hashString"
$sesVariables = recordToHashArray('zzsys_session', 'zzsys_session_id', $ses);
//--session values (access level and user etc. )
$sysVariables = postVariablesToHashArray();
//--values in $_POST
$arrayOfHashVariables = joinHashArrays($sysVariables, $sesVariables);
//--join the arrays together
$arrayOfHashVariables['#newID#'] = $recordID;
$nuHashVariables = $arrayOfHashVariables;
//--added by sc 23-07-2009
//----------allow for custom code----------------------------------------------
$code = replaceHashVariablesWithValues($arrayOfHashVariables, $form->sfo_custom_code_run_after_save);
if ($_GET['debug'] != '') {
    tofile('sfo_custom_code_run_after_save hash variables : debug value:' . $_GET['debug']);
    tofile(print_r($arrayOfHashVariables, true));
    tofile($code);
}
eval($code);
print "<html>\n";