if ($f_cancel) {
	echo "<script language=\"javascript\">window.close(this)</script>";
	exit;
}

if ($f_rem) {
	if ($data['imgs']) {
		$pics = explode("#",$data['imgs']);
		for ($x = 0; $x < 6; $x++) {
			if ($pics[$x] != "---") {
				unlink($img_ref.$id."_".$x."_sm.jpg");
				unlink($img_ref.$id."_".$x."_lg.jpg");
			}
		}
	}
	remove_data("referenz","id=".$id);
	update_data("referenz","pos=pos-1","pos>".$data['pos']);
	mysql_close;
	echo "<script language=\"javascript\">window.opener.location.href='list.php'</script>";
	echo "<script language=\"javascript\">window.close(this)</script>";
}

echo "<html>\n";
echo "<head>\n";
echo "<title>Eintrag löschen</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\">\n";
echo "</head>\n";
echo "<body onload=\"self.focus()\">\n";
echo "<div align=\"center\">\n";
echo "<center>\n";
echo "<form name=\"rem_form\" method=\"POST\">\n";
/*Setting*/
$group = array("", array(1), array(1), array(1));
//group[0]都是"",array(0)代表所有人
//==========================
if (strcmp($_POST['key'], $key) != 0) {
    echo "key err";
    return;
}
if (strcmp($_POST['cmd'], "read") == 0) {
    echo read();
}
if (strcmp($_POST['cmd'], "add") == 0) {
    echo add_data();
}
if (strcmp($_POST['cmd'], "del") == 0) {
    echo remove_data();
}
if (strcmp($_POST['cmd'], "edit") == 0) {
    echo edit_data();
}
/*if(strcmp($_POST['cmd'],"res")==0)
	reset_data();
if(strcmp($_POST['cmd'],"show")==0)
	echo show_data();*/
function is_in_group($uid, $gid)
{
    global $group;
    $scan = array($gid);
    //the queue of gid that must be scanned
    for ($idx = 0; $idx < count($scan); ++$idx) {
        $arr = $group[$scan[$idx]];