<?php
	if ($_COOKIE['svg_thumbs_width'].'' <> '') {
		$svg_width = $_COOKIE['svg_thumbs_width'];
	} else {
		$svg_width = svg_THUMBS_DEF_WIDTH;
	}
	$svg_height = $svg_width * svg_HIGHT_PER_WIDTH;
?>
<div>
<script type="text/javascript">
var svg_width = <?= $svg_width ?>;
function resizeSvgSize(up_width) {
	setSvgSize(svg_width + up_width);
}
function setSvgSize(width) {
	width = Number(width);
	if (width < <?= svg_THUMBS_MIN_WIDTH ?>) {
		return;
	}
	if (width > <?= svg_THUMBS_MAX_WIDTH ?>) {
		return;
	}
	svg_width = width;
	height = Number(width)*<?= svg_HIGHT_PER_WIDTH ?>;
	$("svg.thumbs").width(width);
	$("svg.thumbs").height(height);
	$("div.list_thumb_box").width(width+4);
	$("#svgWidth").val(width);
	$.cookie('svg_thumbs_width', width, { expires: 365 });
	$.cookie('svg_thumbs_height', height, { expires: 365 });
}
function selectSvgSize() {
	width = $("#svgWidth").val();
	setSvgSize(width);
}
</script>
サイズ：<select id="svgWidth" onChange="selectSvgSize()">
<?php	for ($size=svg_THUMBS_MIN_WIDTH; $size<=svg_THUMBS_MAX_WIDTH; $size+=svg_THUMBS_UPDOWN_WIDTH) { ?>
<option value="<?= $size ?>"<?= $size == $svg_width ? ' selected' : '' ?>><?= $size ?>
<?php	} ?>
</select>
<input type="button" value="小さく" onClick="resizeSvgSize(-<?= svg_THUMBS_UPDOWN_WIDTH ?>)">
<input type="button" value="大きく" onClick="resizeSvgSize(<?= svg_THUMBS_UPDOWN_WIDTH ?>)">
<input type="button" value="最小" onClick="setSvgSize(<?= svg_THUMBS_MIN_WIDTH ?>)">
<input type="button" value="最大" onClick="setSvgSize(<?= svg_THUMBS_MAX_WIDTH ?>)">
</div>
<?php
	mysql_data_seek($rs, $startline);
	$line = $startline;
	while ($rec=mysql_fetch_array($rs) and $line<=$endline) {
?>
	<div class="list_thumb_box" style="width: <?= $svg_width+4 ?>px">
		<div style="float:left;">
			<a style="text-decoration: none;" title="<?= my_htmlspecialchars($rec['c_subject']) ?>" href="view.php?id=<?= $rec['id_svg'] ?>&move=<?= $line ?>&row=<?= $rowcnt ?>&page=<?= $page ?>&<?= query_from_http_arg_pool($http_arg) ?>">
<?php
		$svg = preg_replace('/" height="/i', ' ', $rec['c_svgdata'], 1);
		$svg = preg_replace('/<svg width="/i', '<svg class="thumbs" width="'.$svg_width.'" height="'.$svg_height.'" viewBox="0 0 ', $svg, 1);
?>
			<div class="list_svg_data"><?= $svg ?></div></a>
		</div>
		<div class="list_caption">
		<span class="list_subject"><?= $rec['id_svg'] ?>:<?= my_htmlspecialchars($rec['c_subject']) ?></span><br>
		<span class="list_handle">by <a href="list.php?ac=<?= $rec['id_account'] ?>"><?= my_htmlspecialchars($rec['c_handle']) ?></a></span>
		</div>
	</div>
<?php
		$line++;
	}
?>
<?php
function svg_date_view($datetime) {
	$view_date = date_from_mysql("y/m/d H:i:s", $datetime);
	$now_date = date("y/m/d");
	if (left($view_date,8) == $now_date) {
		return '<span class="svg_today">'.$view_date.'</span>';
	} else {
		$before_week = date("y/m/d", mktime(0, 0, 0, intval(date("n")), intval(date("j"))-6, intval(date("Y"))));
		if (left($view_date,8) >= $before_week) {
			return '<span class="svg_recent_day">'.$view_date.'</span>';
		}
	}
	return $view_date;
}
?>
