<?
session_start();

$document = array();
$script = "";
$init = "";

require "../lib/getnpost.php";
require "../lib/config.php";
require "../lib/dbconnect.php";
require "../lib/auth.php";
require "../lib/common.php";
require "listlib.php";

require "community_common.php";

function mkWholeList(
	&$document, &$script, &$init, $page, $sn=0, $ss=1, $sc=1, $st=""
) {
}

function mkList(
	&$document, &$script, &$init, $bdid, $page, $sn=0, $ss=1, $sc=1, $st=""
) {
	global $BOARD_MAXLINE, $BOARD_MAXPAGE;
	global $PSYCHEID, $PsycheAdmin;

	if (!$page) $page = 1;

	$ste = urlencode($st);

	$document['main'] .= <<<EOS
            <table width="670" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td>{$document['caption']}</td>
              </tr>
            </table>

EOS;

	mkListTable(&$document, $bdid, $page, 0, $sn, $ss, $sc, $st);

	if ($bdid != 13 || $PsycheAdmin) {
		$writestring = <<<EOS
<a href="write.php?bdid=$bdid&page=$page&sn=$sn&ss=$ss&sc=$sc&st=$ste"><img src="/images/b_write.gif" width="52" height="20" border="0"></a>

EOS;
	} else {
		$writestring = "";
	}

	$document['main'] .= <<<EOS
            <table width="670" border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td width="421"> 
<form id="searchform" action="{$_SERVER['PHP_SELF']}" method="get"
 onsubmit="return checkSearch();" />
<input type="checkbox" id="sn" name="sn" value="1"
 class="smallcheckbox" $snChecked />ÀÌ¸§
<input type="checkbox" id="ss" name="ss" value="1"
 class="smallcheckbox" $ssChecked />Á¦¸ñ
<input type="checkbox" id="sc" name="sc" value="1"
 class="smallcheckbox" $scChecked />³»¿ë

<input type="text" id="st" name="st" value="$st" class="box01" />
<input type="image" src="/images/b_search.gif" width="51" height="20" align="absmiddle">
<input type="hidden" id="bdid" name="bdid" value="$bdid" />
<input type="hidden" id="page" name="page" value="$page" />
</form>
</td>
                <td width="249" align="right">
<a href="{$_SERVER['PHP_SELF']}?bdid=$bdid&page=$page"><img src="/images/b_list.gif" width="52" height="20" border="0"></a>
$writestring
                </td>
              </tr>
            </table>

EOS;

	$script .= <<<EOS
function checkSearch() {
	f = document.getElementById("searchform");

	if (
		!f.sn.checked &&
		!f.ss.checked &&
		!f.sc.checked
	) {
		alert("°Ë»ö Ç×¸ñÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.");

		return false;
	}

	if (!f.st.value) {
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		f.st.focus();

		return false;
	}

	return true;
}

EOS;
}

## Start

if (!$bdid) $bdid = 1;	// ÀÚÀ¯°Ô½ÃÆÇ

if ($bdid) {
	mkBoardCommon($document, $bdid);

	mkList(
		$document, $script, $init, $bdid, $page, $sn, $ss, $sc, $st
	);
} elseif ($wholelist) {
	mkWholeList(
		$document, $script, $init, $page, $sn, $ss, $sc, $st
	);
} else {
	header("Location: /");

	return;
}

require "community_template.php";
?>
