<script type="text/javascript">
function updateCheck(id, no, chkd) {
	var d = new Date();	// キャッシュを利用されないため
	if (chkd) {
		chk = 1;
	} else {
		chk = 0;
	}
	$.get("check-update.php?time="+d.getTime().toString(), {id:id,no:no,chk:chk});
	if (chkd) {
		color = "<?= CHECKED_BGCOLOR ?>";
	} else {
		color = "<?= UNCHECK_BGCOLOR ?>";
	}
	$("#ck"+id+"_"+no).css("background-color",color);
}
function checkOnAll() {
	$(".proc_check input[@type='checkbox']").attr('checked', true);
	return false;
}
function checkOffAll() {
	$(".proc_check input[@type='checkbox']").attr('checked', false);
	return false;
}
function winOpen(){
//	Chrome,Safariでも別ウンドウで何回でも開くため
	w = window.open("do-proc.php?<?= $_SERVER['QUERY_STRING'] ?>", "abookOpen");
	document.frm0.target = "abookOpen";
}
</script>
	<form id="abook_form" name="frm0" method="POST" action="do-proc.php?<?= $_SERVER['QUERY_STRING'] ?>" onSubmit="winOpen()">
	<input class="" type="button" onClick="return checkOnAll()" value="全てチェック">
	<input class="" type="button" onClick="return checkOffAll()" value="チェッククリア">
	<input class="" type="submit" name="Maps" value="マップ">
	<input type="hidden" name="option" value="世界遺産">
<?php
	foreach ($order_tbl as $id=>$item) {
		if ($item['get_order_name'] == $_GET['sort']) {
			$sortorder = $item['order_by'];
			break;
		}
	}
	if ($sortorder == '') {
		$sortorder  = 'id_abook desc';
	}
?>
	<input type="hidden" name="sortOrder" value="<?= $sortorder ?>">
<?php
	$chk_use = array();
	$sqlchk = "select * from m_check_caption where id_account = " . $_SESSION['current_id'];
	$sqlchk .= " and ( c_caption1 <> '' or c_caption2 <> '' or c_caption3 <> '' or c_caption4 <> '' or c_caption5 <> '' )";
	$rs_chk = my_mysql_query($sqlchk);
	if (mysql_num_rows($rs_chk) <> 0) {
		$rec = mysql_fetch_array($rs_chk);
		if ($rec) {
			echo '<p id="check_caption_box">';
			for ($ix=1; $ix<=5; $ix++) {
				if ($rec['c_caption'.$ix] <> '') {
					$chk_use[$ix] = True;
					echo '<span class="check_caption"><b>'.roman_number($ix).'</b>：&nbsp;'.$rec['c_caption'.$ix].'</span>&nbsp;&nbsp;';
				} else{
					$chk_use[$ix] = False;
				}
			}
			echo '</p>';
		}
	}
?>
	<table id="abook_list_table">
	<tr>
		<th></th>
		<th>世界遺産</th>
		<?php
			for ($ix=1; $ix<=5; $ix++) {
				if ($chk_use[$ix]) {
		?>
			<th><?= roman_number($ix) ?></th>
		<?php
				}
			}
		?>
		<th nowrap>Ref.&nbsp;</th>
		<th>国 / 緯度・経度</th>
	</tr>
<?php
	mysql_data_seek($rs, $startline);
	$line = $startline;
	while ($rec=mysql_fetch_array($rs) and $line<=$endline) {
		if ($rec['c_privacy'] == 444) {
			$list_tr = 'abook_list_privacy';
		} else {
			$list_tr = '';
		}
?>
	<tr class="<?= $list_tr ?>">
	<td class="abook_list_td a_check">
		<span class="proc_check"><input type="checkbox" name="check[]" value="<?= $rec['id_abook'] ?>"></span>
	</td>
	<td class="abook_list_td s_name">
		<p><a href="http://whc.unesco.org/en/list/<?= my_htmlspecialchars($rec['c_phone1']) ?>" target="_blank"><?= my_htmlspecialchars($rec['c_name1']) ?></a>&nbsp;
		<a href="http://translate.google.com/translate?prev=hp&hl=ja&js=y&u=http://whc.unesco.org/en/list/<?= my_htmlspecialchars($rec['c_phone1']) ?>" class="unesco_translate" target="_blank">→日本語</a></p>
		<p><?= my_htmlspecialchars($rec['c_name2']) ?></p>
	</td>
	<?php
		for ($ix=1; $ix<=5; $ix++) {
			if ($chk_use[$ix]) {
	?>
		<td class="abook_list_mycheck" nowrap>
		<?php if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { //IE ?>
	<input id="ck<?= $rec['id_abook'] ?>_<?= $ix ?>" style="margin-top:3px; vertical-align:text-bottom;" type="checkbox" value="1"<?= $rec['c_check'.$ix] == 1 ? ' checked style="background-color:'.CHECKED_BGCOLOR.'"' : ' style="background-color:'.UNCHECK_BGCOLOR.'"' ?> OnClick="updateCheck(<?= $rec['id_abook'] ?>,<?= $ix ?>,this.checked)">
		<?php } else { ?>
	<span id="ck<?= $rec['id_abook'] ?>_<?= $ix ?>" style="padding:3px; background-color:<?= $rec['c_check'.$ix] == 1 ? CHECKED_BGCOLOR : UNCHECK_BGCOLOR ?>">
	<input style="margin-top:6px; vertical-align:text-bottom;" type="checkbox" value="1"<?= $rec['c_check'.$ix] == 1 ? ' checked' : '' ?> OnClick="updateCheck(<?= $rec['id_abook'] ?>,<?= $ix ?>,this.checked)"></span>
		<?php }  ?>
		</td>
	<?php
			}
		}
	?>
	<td class="abook_list_td s_phone" nowrap>
		<p><?= my_htmlspecialchars($rec['c_phone1']) ?></p>
	</td>
	<td class="abook_list_td s_address">
		<p><?= my_htmlspecialchars($rec['c_memo']) ?></p>
		<p><?= my_htmlspecialchars($rec['c_address2']) ?></p>
	<?php
		$address = my_htmlspecialchars($rec['c_address1']);
		$addr_enc = urlencode($address);
	?>
		<p><?= my_htmlspecialchars($rec['c_address1']) ?>
	<?php
		if ($address <> '') {
			echo '&nbsp;<a href="http://maps.google.co.jp/maps?q='.$addr_enc.'" target="_blank" class="map_s_href">→地図</a>';
		}
	?>
		</p</p>
	</td>
	</tr>
<?php
		$line++;
	}
?>
	</table>
	</form>
