<?php
$bgcol = array(MYCHECK_BGCOLOR_0, MYCHECK_BGCOLOR_1, MYCHECK_BGCOLOR_2, MYCHECK_BGCOLOR_3);
if(!@mysql_data_seek($rs, $startline)) {
	error_msg('該当のレコードがありません。<br><br><br><br>');
} else {
	$line = $startline;
?>
<script type="text/javascript">
function update_mycheck(ac, qz, ck) {
	var d = new Date();	// キャッシュを利用されないため
	$.get("mycheck-update.php?time="+d.getTime().toString(), {ac:ac,qz:qz,ck:ck});
	if (ck == 0) {
		$("#tr"+qz).css("background-color","<?= MYCHECK_BGCOLOR_0 ?>");
	} else if (ck == 1) {
		$("#tr"+qz).css("background-color","<?= MYCHECK_BGCOLOR_1 ?>");
	} else if (ck == 2) {
		$("#tr"+qz).css("background-color","<?= MYCHECK_BGCOLOR_2 ?>");
	} else if (ck == 3) {
		$("#tr"+qz).css("background-color","<?= MYCHECK_BGCOLOR_3 ?>");
	}
}
</script>
<?php
if ($rowcnt <= $endline) {
	$linemax = $rowcnt-1;
} else {
	$linemax = $endline;
}
// ------------------------ ランダム ------------------------
if ($http_arg['sort'] == 'rand') {
$rand_array = array();
if ($_GET['page'] == '' or $_GET['page'] == '1' or empty($_SESSION['study_rand_array'])) {
	for ($ix=0; $ix<$rowcnt; $ix++) {
		$rand_array[$ix] = $ix;
	}
	shuffle($rand_array);
	$_SESSION['study_rand_array'] = $rand_array;
} else {
	$rand_array = $_SESSION['study_rand_array'];
}
//	for ($ix=0; $ix<=$rowcnt-1; $ix++) {
//		print $rand_array[$ix]."：";
//	}
//	print "<br>";
mysql_data_seek($rs, $rand_array[$line]);
}
?>
<table id="study_list_table">
<?php
while ($rec=mysql_fetch_array($rs) and $line <= $linemax) {
	if ($rec['c_check'] == NULL) $rec['c_check'] = 0;
?>
	<tr class="study_list_table_data" id="tr<?= $rec['id_study'] ?>" style="background-color: <?= $bgcol[$rec['c_check']] ?>">
	<td class="study_list_category">
		<?= my_htmlspecialchars($rec['c_categoryName']) ?>
	</td>
	<td class="study_list_category">
		<?= my_htmlspecialchars($rec['c_category2Name']) ?>
	</td>
	<?php if ($_SESSION['current_id'] == $_SESSION['login_id']) { ?>
		<td class="study_mycheck_check" nowrap>
		<input type="hidden" name="ID_MYCHECK<?= $rec['id_study'] ?>" value="<?= $rec['id_mycheck'] ?>">
		<?php
		if ($rec['c_check'].'' == '') $rec['c_check'] = 0;
		?>
		<?php
		if (!strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) $sp = '&nbsp;';	//IE以外
		?>
		<?php for ($ix=3; $ix>=0; $ix--) { ?><input type="radio" name="check<?= $rec['id_study'] ?>" value="<?= $ix ?>"<? if ($rec['c_check'] == $ix) echo ' checked' ?> OnClick="update_mycheck(<?= $_SESSION['login_id'] ?>,<?= $rec['id_study'] ?>,<?= $ix ?>)"><?= $ix ?><?= $sp ?><?php } ?>
		</td>
	<?php } else { ?>
		<td class="study_mycheck_check_other" nowrap>
		<?php
		if ($rec['c_check'].'' == '') $rec['c_check'] = 0;
		for ($ix=3; $ix>=0; $ix--) {
			if ($rec['c_check'] == $ix) {
				echo '●'.$ix.'&nbsp;';
			} else {
				echo '○'.$ix.'&nbsp;';
			}
		}
		?>
		</td>
	<?php } ?>
	<?php
	if ($_COOKIE['study_display_question'] == 'off' or $_COOKIE['study_display_answer'] == 'off') {
		$qa_width = MYCHECK_QA_WIDTH_2;
	} else {
		$qa_width = MYCHECK_QA_WIDTH_1;
	}
	if ($_COOKIE['study_display_question'] == 'off') {
		$question_display = 'none';
	}
	if ($_COOKIE['study_display_answer'] == 'off') {
		$answer_display = 'none';
	}
	?>
	<td class="study_mycheck_question" style="display:<?= $question_display ?>; width=<?= $qa_width ?>;">
	<p><a href="http://www.google.com/search?q=<?= urlencode('"'.$rec['c_question'].'"') ?>" class="tooltip" target="_blank"><?= my_htmlspecialchars($rec['c_question'], $keystring) ?><span><?= my_htmlspecialchars($rec['c_answer']) ?></span></a></p>
	</td>
	<td class="study_mycheck_answer" style="display:<?= $answer_display ?>; width=<?= $qa_width ?>;">
	<p><a href="http://www.google.com/search?q=<?= urlencode('"'.$rec['c_answer'].'"') ?>" class="tooltip" target="_blank"><?= my_htmlspecialchars($rec['c_answer'], $keystring) ?><span><?= my_htmlspecialchars($rec['c_question']) ?></span></a></p>
	</td>
	</tr>
<?php
	$line++;
	if ($http_arg['sort'] == 'rand') {
		mysql_data_seek($rs, $rand_array[$line]);
	}
}
?>
</table>
<?php
}
?>
