function fs_SaveFormat($hook)
{
    global $added_time, $old_db_arr;
    if ($added_time) {
        $news_id = $added_time;
    } else {
        $news_id = $old_db_arr[0];
    }
    // edit
    $format = stripslashes($_POST['fs_format']);
    $xfields = new XfieldsData();
    $xfields->set($format, $news_id, FS_FORMAT_XFIELD);
    $xfields->save();
}
function edit_tbs($hook)
{
    global $id, $bg, $_POST;
    if ($_POST['deletetb'] == "yes") {
        $xfdel = new XfieldsData();
        $arraytbs = $xfdel->fetch($id, 'trackbacks');
        foreach ($_POST['deltbid'] as $null => $thisid) {
            unset($arraytbs[$thisid]);
        }
        $xfdel->set($arraytbs, $id, 'trackbacks');
        $xfdel->save();
    }
    echo <<<JSCRIPT
<script type="text/javascript">
<!--
function check_uncheck_all_tbs() {
\tvar frm = document.trackbacks;
\tfor (var i=0;i<frm.elements.length;i++) {
\t\tvar elmnt = frm.elements[i];
\t\tif (elmnt.type=='checkbox') {
\t\t\tif(frm.cmbox.checked == true){ elmnt.checked=true; }
            else{ elmnt.checked=false; }
\t\t}
\t}
\tif(frm.cmbox.checked == true){ frm.cmbox.checked = true; }
    else{ frm.cmbox.checked = false; }
}

-->
</script>
JSCRIPT;
    echo "<table>\t\r\n\t<tr>\r\n\t<td colspan=\"3\">\r\n\t<h1>Trackbacks</h1>\r\n\t</td>\r\n\t</tr>\r\n\t<tr>";
    $xf = new XfieldsData();
    $arrayoftbs = $xf->fetch($id, 'trackbacks');
    if (empty($arrayoftbs)) {
        echo "<td colspan=\"3\"><h2>No Trackbacks</h2></td></tr></table>";
    } else {
        echo "<td style=\"padding-right: 10px;\"><h2>Blog's Name</h2></td><td style=\"padding-right: 10px;\"><h2>Time Tracked</h2></td></tr>";
        echo '<form method="post" name="trackbacks" action="' . $PHP_SELF . '">';
        foreach ($arrayoftbs as $time => $tbarray) {
            if ($flag == 1) {
                $bg = "alternate";
                $flag = 0;
            } else {
                $bg = "alternate2";
                $flag = 1;
            }
            $tbtime = date("D, d F Y h:i:s", $time);
            echo "<td class=\"{$bg}\"><a href=\"" . stripslashes($tbarray['url']) . "\" target=\"_blank\">" . stripslashes($tbarray['blog_name']) . "</a></td><td class=\"{$bg}\">" . $tbtime . "<td class=\"{$bg}\"><input type=\"checkbox\" name=\"deltbid[]\" value=\"{$time}\" /></td></tr>";
        }
        echo "<tr><td></td><td><p style=\"text-align:right;\">delete all?</p></td><td><input type=\"checkbox\" name=\"cmbox\" value=\"all\" onclick=\"javascript:check_uncheck_all_tbs()\" /></td></tr><tr><td></td><td colspan=\"2\"><p style=\"text-align:right;\"><input type=\"submit\" value=\"Delete Selected\" /></p></td>";
        echo "<input type=\"hidden\" name=\"newsid\" value=\"{$id}\" /><input type=\"hidden\" name=\"deletetb\" value=\"yes\" /><input type=\"hidden\" name=\"action\" value=\"editnews\" /><input type=\"hidden\" name=\"mod\" value=\"editnews\" /></form>";
        echo "</table>";
    }
}
function edc_save()
{
    global $added_time;
    global $old_db_arr;
    global $item_db;
    $allow = edc_getsavedvalue("", $old_db_arr, $added_time);
    $xfields = new XfieldsData();
    if ($allow[added]) {
        $news_id = $allow[added];
    } else {
        $news_id = $allow[edit];
    }
    if ($allow[edit] && $item_db[0] != $old_db_arr[0]) {
        $news_id = $item_db[0];
        $xfields = new XfieldsData();
        $xfields->delete($news_id);
        $xfields->save();
        $news_id = $allow[edit];
    }
    $xfields->set($allow[allow], $news_id, EDC_COMMENTS_XFIELD);
    $xfields->set($allow[stop], $news_id, EDC_STOPCOMMENTS_FIELD);
    $xfields->save();
}