<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() {
	$("input:checkbox[name^='check']").attr('checked', true);
	return false;
}
function checkOffAll() {
	$("input:checkbox[name^='check']").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()">
<?php	if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { ?>
	<input class="" type="button" onClick="return checkOnAll()" value="全てチェック" style="width:5.8em">
	<input class="" type="button" onClick="return checkOffAll()" value="チェッククリア" style="width:6.2em">
	<input class="" type="submit" name="Email" value="電子メール宛名" style="width:7.2em">
	<input class="" type="submit" name="Maps" value="マップ" style="width:3.6em">
	<input class="" type="submit" name="MapsV3" value="マップ(V3)" style="width:5.2em">
	<input class="" type="submit" name="PDF" value="葉書宛名書き" style="width:6.4em">
<?php	} else { ?>
	<input class="" type="button" onClick="return checkOnAll()" value="全てチェック">
	<input class="" type="button" onClick="return checkOffAll()" value="チェッククリア">
	<input class="" type="submit" name="Email" value="電子メール宛名">
	<input class="" type="submit" name="Maps" value="マップ">
	<input class="" type="submit" name="MapsV3" value="マップ(V3)">
	<input class="" type="submit" name="PDF" value="葉書宛名書き">
<?php	} ?>
	<input type="checkbox" name="差出人" value="印刷"<?php if ($_COOKIE['abook_print_sender'] == '印刷' ) echo ' checked';  ?>>差出人印刷&nbsp;
	差出人名：<input type="text" name="差出人名" value="<?= $_COOKIE['abook_print_sender_name'] ?>" size=12>
	連名：<input type="text" name="連名" value="<?= $_COOKIE['abook_print_sender_renmei'] ?>" size=12>
<?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
	global $chk_use;	// list-my-add-filter.phpでセット
?>
	<table id="abook_list_table">
	<tr>
		<th></th>
		<?php
			for ($ix=1; $ix<=5; $ix++) {
				if ($chk_use[$ix]) {
		?>
			<th><?= roman_number($ix) ?></th>
		<?php
				}
			}
		?>
		<th colspan=3>名前</th>
		<th>分類</th>
<?php if ($_SESSION['abook_email_off'] <> 'off') { ?>
		<th>電話</th>
		<th>EMailアドレス</th>
<?php } ?>
		<th>〒</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">
		<input type="checkbox" name="check[]" value="<?= $rec['id_abook'] ?>">
	</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:6px; 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:6px; 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 a_name">
		<p><a href="<?= $_SERVER['SCRIPT_NAME'] ?>?<?= query_from_http_arg_pool($http_arg, 'key') ?>&key=<?= urlencode(my_htmlspecialchars($rec['c_name1']).' '.my_htmlspecialchars($rec['c_name2'])) ?>" class="tooltip"><?= my_htmlspecialchars($rec['c_name1']) ?><span><?= my_htmlspecialchars($rec['c_yomi1']) ?> <?= my_htmlspecialchars($rec['c_yomi2']) ?></span></a></p>
	</td>
	<td class="abook_list_td a_name">
		<p><a href="<?= $_SERVER['SCRIPT_NAME'] ?>?<?= query_from_http_arg_pool($http_arg, 'key') ?>&key=<?= urlencode(my_htmlspecialchars($rec['c_name1']).' '.my_htmlspecialchars($rec['c_name2'])) ?>" class="tooltip"><?= my_htmlspecialchars($rec['c_name2']) ?><span><?= my_htmlspecialchars($rec['c_yomi1']) ?> <?= my_htmlspecialchars($rec['c_yomi2']) ?></span></a></p>
	</td>
	<td class="abook_list_td a_renmei<?= $_SESSION['abook_email_off'] == 'off' ? '_long' : '' ?>">
		<p><?= my_htmlspecialchars($rec['c_renmei']) ?></p>
	</td>
	<td class="abook_list_td a_category">
		<?= my_htmlspecialchars($rec['c_categoryName']) ?>
	</td>



	<?php if ($_SESSION['abook_email_off'] <> 'off') { ?>
	<td class="abook_list_td a_phone" nowrap>
		<p><?= my_htmlspecialchars($rec['c_phone1']) ?></p>
		<p><?= my_htmlspecialchars($rec['c_phone2']) ?></p>
	</td>
	<td class="abook_list_td a_email">
		<p><a href="mailto:<?= urlencode(my_htmlspecialchars($rec['c_name1']).my_htmlspecialchars($rec['c_name2']).'様') ?>&lt;<?= my_htmlspecialchars($rec['c_email']) ?>&gt;"><?= my_htmlspecialchars($rec['c_email']) ?></a></p>
		<p><?= my_htmlspecialchars($rec['c_memo']) ?></p>
	</td>
	<?php } ?>
	<td class="abook_list_td a_zip">
		<p><?= my_htmlspecialchars($rec['c_zip1']) ?>-<?= my_htmlspecialchars($rec['c_zip2']) ?></p>
		<p><a class="kenmei" href="?cat=<?= $_GET['cat'] ?>&ken=<?= $rec['c_kenid'] ?>"><?= my_htmlspecialchars($rec['c_kenmei']) ?></a></p>
	</td>
	<td class="abook_list_td a_address<?= $_SESSION['abook_email_off'] == 'off' ? '_long' : '' ?>">
	<?php
		$address = my_htmlspecialchars($rec['c_address1']);
		$addr_enc = urlencode($address);
	?>
		<p><?= my_htmlspecialchars($rec['c_address1']) ?>
		<?php if ($_SESSION['abook_email_off'] <> 'off') { ?>
		</p><p>
		<?php } ?>
		<?= my_htmlspecialchars($rec['c_address2']) ?>
	<?php
		if ($address <> '') {
			echo '&nbsp;<a href="http://maps.google.co.jp/maps?q='.$addr_enc.'" target="_blank" class="map_href">→地図</a>&nbsp;<a href="http://maps.google.co.jp/maps?ie=UTF8&f=d&ttype=dep&dirflg=r&saddr='.urlencode($_SESSION['login_friends_home_address_'.$_SESSION['current_id']]).'&daddr='.$addr_enc.'" target="_blank" class="route_href">→経路</a>';
		}
	?>
		</p>
	</td>
	</tr>
<?php
		$line++;
	}
?>
	</table>
	</form>
