<?php
	require("__include-common.php");
	require("../account/__logincheck.php");

	_account_change($_GET['uid']);

	if (isset($_POST["path"]) && $_POST["path"] <> '') {
		$open_path = $_POST["path"];
	} elseif ($_GET["path"] <> '') {
		$open_path = $_GET["path"];
	}
	$open_path = str_replace("//", "/", str_replace("\\", "/", right_slash_strip($open_path)));
	if ($open_path == "") {
		if ($_SESSION['photo_open_path'] <> "") {
			$open_path = $_SESSION['photo_open_path'];
		} else {
			$open_path = $_SESSION['login_friends_album_folder_'.$_SESSION['current_id']];
			if ($open_path == "") {
				$open_path = DEFAULT_IMAGES_FOLDER;
			}
		}
	}
	if (defined("photo_LIMITED_IMAGES_FOLDER") and photo_LIMITED_IMAGES_FOLDER <> '') {
		if ($_SESSION['システム管理者'] <> "YES" or photo_LIMITED_ADMIN_NOLIMIT <> 'YES') {
			$len = strlen(photo_LIMITED_IMAGES_FOLDER);
			if (substr($open_path, 0, $len) <> photo_LIMITED_IMAGES_FOLDER) {
				$open_path = photo_LIMITED_IMAGES_FOLDER;
			}
		}
	}
	if ($_GET['imgmax'] <> '') {
		$_SESSION['photo_imgmax'] = $_GET['imgmax'];
	}
	if ($_GET['vss'] <> '') {
		$_SESSION['video_thumb_ss'] = $_GET['vss'];
	}
	if ($_SESSION['photo_imgmax'].'' == '') {
		$_SESSION['photo_imgmax'] = IMAGE_MAX_DEFAULT;
	}
	if ($_GET['mode'].'' <> '') {
		$_SESSION['photo_view_mode'] = $_GET['mode'];
		setcookie('photo_view_mode', $_SESSION['photo_view_mode'], time() + LOGIN_COOKIE_EXPIRE, "/");
	} else {
		if (isset($_COOKIE['photo_view_mode'])) {
			$_SESSION['photo_view_mode'] = $_COOKIE['photo_view_mode'];
		}
	}
	if ($_SESSION['photo_view_mode'] == '') {
		$_SESSION['photo_view_mode'] = 't';
	}
	if ($_GET['page'].'' <> '') {
		$page = intval($_GET['page']);
		if ($page < 1) {
			$page = 1;
		}
	} else {
		$page = 1;
	}
	if ($_GET['auto'].'' <> '') {
		$_SESSION['slide_view_auto'] = $_GET['auto'];
	}
	if ($_GET['rep'].'' <> '') {
		$_SESSION['slide_view_repeat'] = $_GET['rep'];
	}
	if ($_GET['flv'].'' <> '') {
		$_SESSION['slide_flv_preview'] = $_GET['flv'];
		setcookie('slide_flv_preview', $_SESSION['slide_flv_preview'], time() + LOGIN_COOKIE_EXPIRE, "/");
	} else {
		if (isset($_COOKIE['slide_flv_preview'])) {
			$_SESSION['slide_flv_preview'] = $_COOKIE['slide_flv_preview'];
		}
	}
	if ($_GET['ssize'].'' <> '') {
		$_SESSION['slide_main_size'] = $_GET['ssize'];
	} elseif ($_SESSION['slide_main_size'].'' == '') {
		$_SESSION['slide_main_size'] = SLIDE_MAIN_SIZE;
	}
	if ($_GET['it'].'' <> '') {
		$_SESSION['slide_interval_time'] = $_GET['it'];
	} elseif ($_SESSION['slide_interval_time'].'' == '') {
		$_SESSION['slide_interval_time'] = SLIDE_INTERVAL_TIME;
	}
	if ($_SESSION['photo_open_path'] <> $open_path) {
		$_SESSION['photo_open_path'] = $open_path;
		$_SESSION['photo_subdir_count'] = 0;
		$_SESSION['photo_img_count'] = 0;
		unset($_SESSION['photo_subdir']);
		unset($_SESSION['photo_img']);
		unset($_SESSION['photo_img_type']);
		get_target_path_info($open_path);
	}
	$add_meta = '';
	if ($_SESSION['photo_view_mode'] == 's' and $_SESSION['slide_view_auto'] == 'on') {
		if ($page < ceil($_SESSION['photo_img_count'])) {
			$add_meta = '<meta http-equiv="refresh" content="'.$_SESSION['slide_interval_time'].';';
			$add_meta .= 'url='.$_SERVER['SCRIPT_NAME'].'?page='.strval($page+1);
			$add_meta .= '&path='.urlencode($open_path);
			$add_meta .= '&mode=s">';
		} elseif ($_SESSION['slide_view_repeat'] == 'on') {
			$add_meta = '<meta http-equiv="refresh" content="'.$_SESSION['slide_interval_time'].';';
			$add_meta .= 'url='.$_SERVER['SCRIPT_NAME'].'?page=1';
			$add_meta .= '&path='.urlencode($open_path);
			$add_meta .= '&mode=s">';
		}
	}
	html_header(HTML_TITLE, '', '', '', $add_meta);
	page_header(False);		//ログイン表示なし
	contents_header();
	photo_body($open_path, $page);
	page_footer();
	html_footer();
	exit();
?>
<?php
function photo_body($open_path, $page) {
	view_photo_dir($open_path, $page);
	if ($_SESSION['photo_view_mode'] == 's') {
		view_photo_slide($open_path, $page, $_SESSION['slide_view_auto']);
	} elseif ($_SESSION['photo_view_mode'] == 'b') {
		view_photo_thumbnail_b($open_path, $page);
	} else {
		view_photo_thumbnail($open_path, $page);
	}
}
function get_target_path_info($open_path) {
	$path_SJIS = mb_convert_encoding($open_path, 'SJIS-win', 'UTF-8');
	if ($dir = opendir($path_SJIS)) {
		$subdir_count = 0;
		$img_count = 0;
		$files = scandir($path_SJIS);
		foreach ($files as $file) {
			if ($file != "." && $file != "..") {
				if (is_dir($path_SJIS . "/" . $file)) {
					$_SESSION['photo_subdir'][++$subdir_count]
						= mb_convert_encoding($file, 'UTF-8', 'SJIS-win');
				} elseif (is_img_filename($file)) {
					$_SESSION['photo_img'][++$img_count]
						= mb_convert_encoding($file, 'UTF-8', 'SJIS-win');
				} else {
					if (photo_VIDEO_FFMPEG == "YES") {
						if (is_video_filename($file)) {
							$_SESSION['photo_img'][++$img_count]
							= mb_convert_encoding($file, 'UTF-8', 'SJIS-win');
							$_SESSION['photo_img_type'][$img_count] = 'video';
						}
					}
				}
			}
		}
		closedir($dir);
	}
	$_SESSION['photo_subdir_count'] = $subdir_count;
	$_SESSION['photo_img_count'] = $img_count;
}
function view_photo_dir($open_path, $page) {
?>
<div id="photo_body">
<div id="photo_header">
	<form name="frm0" action="<?= $_SERVER['SCRIPT_NAME'] ?>" method="post">
		<input type="button" name="" value="↑" onClick="location.href='<?= $_SERVER['SCRIPT_NAME'] ?>?path=<?= urlencode(up_folder_path($open_path)) ?>'">
		<input class="text" type="text" name="path" value="<?= my_htmlspecialchars($open_path) ?>" size=50>
		<input type="submit" name="path_change" value="変更">
		<?php
			change_view_mode($_SESSION['photo_view_mode'], $open_path, $page);
			change_view_thumb_ss($page);
			if ($_SESSION['photo_view_mode'] == 's') {
				change_view_slide_option($page);
			} else {
				select_page_images_max($_SESSION['photo_imgmax']);
			}
		?>
	</form>
</div>
<div id="photo_dir_change">
<?php
	foreach ($_SESSION['photo_subdir'] as $subdir) {
?>
		<a href="<?= $_SERVER['SCRIPT_NAME'] ?>?path=<?= urlencode($open_path."/".$subdir) ?>"><?= $subdir ?></a>
<?php
	}
?>
</div>
<?php
}
function view_photo_thumbnail($open_path, $page) {
	$img_count = $_SESSION['photo_img_count'];
	$start_count = ($page - 1) * $_SESSION['photo_imgmax'] + 1;		//開始番号を算出
	$end_count = $page * $_SESSION['photo_imgmax'];				//終了番号を算出
	$pagemax = ceil($img_count / $_SESSION['photo_imgmax']);		//取得したファイル数から最終頁を算出
	if ($end_count > $img_count) {
		$end_count = $img_count;
	}
?>
<div id="photo_image_size_change" style="padding:5;">
<input type="button" value="最小" onClick="setSizeImage(<?= SMALL_SIZE ?>)">
<input type="button" value="小さく" onClick="resizeImage(-<?= UPDOWN_SIZE ?>)">
<input type="button" value="大きく" onClick="resizeImage(<?= UPDOWN_SIZE ?>)">
<input type="button" value="中" onClick="setSizeImage(<?= MID_SIZE ?>)">
<input type="button" value="大" onClick="setSizeImage(<?= BIG_SIZE ?>)">
<input type="button" value="最大" onClick="setSizeImage(<?= MAX_SIZE ?>)">
</div>
<div id="photo_images_view_box">
<?php
	if ($start_count <= $end_count) {
		photo_page_control($img_count, $page, $pagemax, $open_path);
		for ($ix=$start_count; $ix<=$end_count; $ix++) {
			$filename = $_SESSION['photo_img'][$ix];
			$filepath = $open_path . "/" . $filename;
			if ($_SESSION['photo_img_type'][$ix] == 'video') {
				$getimg = "video-jpeg.php?file=".urlencode($filepath)."&ss=".$_SESSION['video_thumb_ss'];
				$click = "video-view.php?file=".urlencode($filepath);
				$height_size = SMALL_SIZE - 2;
				$border_style = VIDEO_THUMBNAIL_BORDER;
			} else {
			//	$getimg = "../scripts/php/img-size-change.php?img=".urlencode($filepath)."&size=".MAX_SIZE;
				$getimg = "img-view.php?img=".urlencode($filepath);
				$click = $getimg;
				$height_size = SMALL_SIZE;
				$border_style = '';
			}
?>
			<span class="popup">
			<img id="<?= $id ?>" class="thumbs" src="<?= $getimg ?>" height=<?= $height_size ?> style="<?= $border_style ?>" alt="<?= $filename ?>" title="<?= $filename ?>" align=top onDblClick="window.open('<?= $click ?>');return false;"/>
			</span>
<?php
		}
	}
?>
</div>
</div>
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script type="text/javascript">
<!--
var imgsize = <?= SMALL_SIZE ?>;
var bigid = 0;
$(function(){
	// HTMLロード後に実行したい初期化コード
	$(".thumbs").click(function(){
		if ($(this).height() != imgsize) {
			$(this).height(imgsize);
		} else {
			//alert("bigidは「"+bigid+"」です");
			$("#"+bigid).height(imgsize);	//前に大きくしたアイコンを小さくする
			$(this).height(imgsize*2);
			bigid = $(this).attr("id");
		}
	});
});
function resizeImage(up_down) {
	setSizeImage(imgsize + up_down);
}
function setSizeImage(size) {
	imgsize = size;
	$("img.thumbs").height(size);
}
-->
</script>
<?php
}
function view_photo_thumbnail_b($open_path, $page) {
	$img_count = $_SESSION['photo_img_count'];
	$start_count = ($page - 1) * $_SESSION['photo_imgmax'] + 1;		//開始番号を算出
	$end_count = $page * $_SESSION['photo_imgmax'];				//終了番号を算出
	$pagemax = ceil($img_count / $_SESSION['photo_imgmax']);		//取得したファイル数から最終頁を算出
	if ($end_count > $img_count) {
		$end_count = $img_count;
	}
?>
<div id="photo_image_size_change" style="padding:5;">
<input type="button" value="最小" onClick="setSizeImage(<?= SMALL_SIZE ?>)">
<input type="button" value="小さく" onClick="resizeImage(-<?= UPDOWN_SIZE ?>)">
<input type="button" value="大きく" onClick="resizeImage(<?= UPDOWN_SIZE ?>)">
<input type="button" value="中" onClick="setSizeImage(<?= MID_SIZE ?>)">
<input type="button" value="大" onClick="setSizeImage(<?= BIG_SIZE ?>)">
<input type="button" value="最大" onClick="setSizeImage(<?= MAX_SIZE ?>)">
</div>
<div class="vCenter">
	<ul>
<?php
	if ($start_count <= $end_count) {
		photo_page_control($img_count, $page, $pagemax, $open_path);
		for ($ix=$start_count; $ix<=$end_count; $ix++) {
			$filename = $_SESSION['photo_img'][$ix];
			$filepath = $open_path . "/" . $filename;
			if ($_SESSION['photo_img_type'][$ix] == 'video') {
				$width_height = "width";
				$getimg = "video-jpeg.php?file=".urlencode($filepath)."&ss=".$_SESSION['video_thumb_ss'];
				$click = "video-view.php?file=".urlencode($filepath);
				$height_size = SMALL_SIZE;
				$border_style = VIDEO_THUMBNAIL_BORDER;
			} else {
				list($width, $height) = getimagesize(mb_convert_encoding($filepath, 'SJIS-win', 'UTF-8'));
				if ($width > $height) {
					$width_height = "width";
				} else {
					$width_height = "height";
				}
				$getimg = "img-view.php?img=".urlencode($filepath);
				$click = $getimg;
				$height_size = SMALL_SIZE;
				$border_style = '';
			}
			$frame_size = SMALL_SIZE + 6;
?>
			<li class="thumbs" style="width:<?= $frame_size ?>px; height:<?= $frame_size ?>px;">
			<!--[if gte IE 6]><span></span><![endif]-->
			<p class="thumbs" style="width:<?= $frame_size ?>px; height:<?= $frame_size ?>px;">
			<img id="<?= $id ?>" class="thumbs_<?= $width_height ?>" src="<?= $getimg ?>" <?= $width_height ?>=<?= $height_size ?> style="line-height:<?= SMALL_SIZE ?>px;<?= $border_style ?>" alt="<?= $filename ?>" title="<?= $filename ?>" onClick="window.open('<?= $click ?>');return false;"/>
			</p>
			</li>
<?php
		}
	}
?>
	</ul>
</div>
</div>
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script type="text/javascript">
<!--
var imgsize = <?= SMALL_SIZE ?>;
function resizeImage(up_down) {
	setSizeImage(imgsize + up_down);
}
function setSizeImage(size) {
	imgsize = size;
	$("img.thumbs_width").width(size);
	$("img.thumbs_height").height(size);
	frame_size = String(size+6)+"px";
	$("li.thumbs").css("width", frame_size)
		      .css("height", frame_size);
	$("p.thumbs").css("width", frame_size)
		     .css("height", frame_size);
}
-->
</script>
<?php
}
function view_photo_slide($open_path, $page, $auto_mode) {
	$img_count = $_SESSION['photo_img_count'];
?>
<div id="photo_images_main_view">
<?php
	if ($page <= $img_count) {
		photo_page_control($img_count, $page, $img_count, $open_path, SLIDE_SMALL_NUM, '枚');
		$filename = $_SESSION['photo_img'][$page];
		$filepath = $open_path . "/" . $filename;
		$filepath_url = urlencode($filepath);
		if ($_SESSION['photo_img_type'][$page] == 'video') {
			$getimg = "video-jpeg.php?file=".$filepath_url."&ss=".$_SESSION['video_thumb_ss'];
			$click = "video-view.php?file=".$filepath_url;
			$height_size = $_SESSION['slide_main_size'] - 2;
			$border_style = VIDEO_THUMBNAIL_BORDER;
		} else {
			list($width, $height) = getimagesize(mb_convert_encoding($filepath, 'SJIS-win', 'UTF-8'));
			$getimg = "img-view.php?img=".$filepath_url;
			$click = $getimg;
			$height_size = $_SESSION['slide_main_size'];
			$border_style = '';
		}
?>
		<div id="slide_main_img" style="background-color: <?= SLIDE_MAIN_BG_COLOR ?>;">
<?php
		if (VIDEO_PREVIEW == 'YES' && $_SESSION['slide_flv_preview'] == 'on' && is_preview_video_filename($filepath)) {
?>
		<script type="text/javascript" src="../scripts/JWPlayer/swfobject.js"></script>
		<script type="text/javascript" src="../scripts/JWPlayer/movie_preview.js"></script>
		<p id="movie_preview">The player will show in this paragraph</p>
		<script type="text/javascript">
			movie_preview("movie_preview", "<?= $click ?>", "<?= $height_size ?>", "<?= $height_size ?>", "<?= $getimg ?>");
		</script>
		<p class="photo_file_name" style="text-align: center;"><?= $filename ?></p>
<?php
		} else {
?>
		<table style="margin-left: auto; margin-right: auto;"><tr><td>
		<a href="<?= $click ?>" target="_blank">
		<img id="<?= $id ?>" class="bicubic" src="<?= $getimg ?>" height=<?= $height_size ?> style="<?= $border_style ?>" alt="<?= $filename ?>" title="<?= $filename ?>" align=top onDblClick="window.open('<?= $click ?>');return false;" />
		</a><p class="photo_file_name" style="text-align: center;"><?= $filename ?></p>
		</td>
		<?php if (JIGSAW_PUZZLE_CREATE == 'YES') { ?>
		<td><a href="jigsaw.php?img=<?= $filepath_url ?>" target="_blank" id="pop_jigsaw">ジグソー</a></td>
		<?php } ?>
		</tr></table>
<?php
		}
?>
		</div>
<?php
	}
?>
</div>
<?php
	if ($auto_mode == 'on') return;
?>
<div id="photo_images_small_view" style="background-color: <?= SLIDE_SMALL_BG_COLOR ?>;">
<?php
	$end_count = $page + SLIDE_SMALL_NUM - 1;
	if ($end_count > $img_count) {
		$end_count = $img_count;
	}
	if ($page <= $img_count) {
		for ($ix=$page; $ix<=$end_count; $ix++) {
			$filename = $_SESSION['photo_img'][$ix];
			$filepath = $open_path . "/" . $filename;
			if ($_SESSION['photo_img_type'][$ix] == 'video') {
				$getimg = "video-jpeg.php?file=".urlencode($filepath)."&ss=".$_SESSION['video_thumb_ss'];
				$height_size = SLIDE_SMALL_SIZE - 2;
				$border_style = VIDEO_THUMBNAIL_BORDER;
			} else {
				$getimg = "img-view.php?img=".urlencode($filepath);
				$height_size = SLIDE_SMALL_SIZE;
				$border_style = '';
			}
?>
			<span class="small_img">
			<a href="<?= $_SERVER['SCRIPT_NAME'] ?>?page=<?= $ix ?>&path=<?= urlencode($open_path) ?>&mode=<?= $_SESSION['photo_view_mode'] ?>"><img id="<?= $id ?>" class="bicubic" src="<?= $getimg ?>" height=<?= $height_size ?> style="<?= $border_style ?>" alt="<?= $filename ?>" title="<?= $filename ?>" align=top /></a>
			</span>
<?php
		}
	}
?>
</div>
<?php
}
function change_view_mode($view_mode, $open_path, $page) {
?>
	<script language="JavaScript">
	<!--
	function RadioViewMode(sel)
	{
		window.location.href = '<?= $_SERVER['SCRIPT_NAME'] ?>?mode=' + sel+ '&path=<?= urlencode($open_path) ?>';
	}
	//-->
	</script>
	<input type="radio" onClick="RadioViewMode('t')"<?= $view_mode == 't' ? ' checked' : '' ?>>サムネイル
	<input type="radio" onClick="RadioViewMode('b')"<?= $view_mode == 'b' ? ' checked' : '' ?>>サムネイル(B)
	<input type="radio" onClick="RadioViewMode('s')"<?= $view_mode == 's' ? ' checked' : '' ?>>スライド
	<a href="slide.php?path=<?= urlencode($open_path) ?>&page=<?= $page ?>" style="margin: 0 3px;">全画面</a>
<?
}
function change_view_thumb_ss($page) {
?>
	<script language="JavaScript">
	<!--
	function SelectionVideoSS(form, sel)
	{
		for (i = 0; i < sel.options.length; i++) {
			if (sel.options[i].selected == true) {
				window.location.href = '<?= $_SERVER['SCRIPT_NAME'] ?>?vss=' + escape(sel.options[i].value) + '&imgmax=<?= $_SESSION['photo_imgmax'] ?>' + '&mode=<?= $_SESSION['photo_view_mode'] ?>' + '&page=<?= $page ?>';
			}
		}
	}
	//-->
	</script>
	動画秒：<select name="" onchange="SelectionVideoSS(this.form, this)">
	<?php
		for ($video_ss=0; $video_ss <= 20; $video_ss+=2) {
	?>
		<option value="<?= $video_ss ?>"<?= $video_ss == $_SESSION['video_thumb_ss'] ? " selected" : "" ?>><?= $video_ss ?>
	<?php
		}
	?>
		</select>
<?
}
function change_view_slide_option($page) {
?>
	<br>
	<script language="JavaScript">
	<!--
	function SelectionSliedeMainSize(form, sel)
	{
		for (i = 0; i < sel.options.length; i++) {
			if (sel.options[i].selected == true) {
				window.location.href = '<?= $_SERVER['SCRIPT_NAME'] ?>?ssize=' + escape(sel.options[i].value) + '&imgmax=<?= $_SESSION['photo_imgmax'] ?>' + '&mode=<?= $_SESSION['photo_view_mode'] ?>' + '&page=<?= $page ?>';
			}
		}
	}
	//-->
	</script>
	画像サイズ：<select name="" onchange="SelectionSliedeMainSize(this.form, this)">
	<?php
		$keyary = explode(",", SLIDE_MAIN_SIZE_SELECT);
		foreach ($keyary as $size) {
	?>
		<option value="<?= $size ?>"<?= $size == $_SESSION['slide_main_size'] ? " selected" : "" ?>><?= $size ?> px
	<?php
		}
	?>
		</select>
	<script language="JavaScript">
	<!--
	function CheckboxOnOff(pName, onOff) {
		if (onOff == 'on') {
			cbOnOff = pName + '=off';
		} else {
			cbOnOff = pName + '=on';
		}
		window.location.href = '<?= $_SERVER['SCRIPT_NAME'] ?>?' + cbOnOff + '&imgmax=<?= $_SESSION['photo_imgmax'] ?>' + '&mode=<?= $_SESSION['photo_view_mode'] ?>' + '&page=<?= $page ?>';
	}
	function SelectionSlideInterval(form, sel) {
		for (i = 0; i < sel.options.length; i++) {
			if (sel.options[i].selected == true) {
				window.location.href = '<?= $_SERVER['SCRIPT_NAME'] ?>?it=' + escape(sel.options[i].value) + '&imgmax=<?= $_SESSION['photo_imgmax'] ?>' + '&mode=<?= $_SESSION['photo_view_mode'] ?>' + '&page=<?= $page ?>';
			}
		}
	}
	//-->
	</script>
	<input type="checkbox" name="" value="on" onClick="CheckboxOnOff('auto','<?= $_SESSION['slide_view_auto'] ?>')"<?= $_SESSION['slide_view_auto'] == 'on' ? ' checked' : '' ?>>オートプレイ
	間隔：<select name="" onchange="SelectionSlideInterval(this.form, this)">
	<?php
		for ($video_it=1; $video_it <= 10; $video_it++) {
	?>
		<option value="<?= $video_it ?>"<?= $video_it == $_SESSION['slide_interval_time'] ? " selected" : "" ?>><?= $video_it ?>秒
	<?php
		}
	?>
		</select>
	<input type="checkbox" name="" value="on" onClick="CheckboxOnOff('rep','<?= $_SESSION['slide_view_repeat'] ?>')"<?= $_SESSION['slide_view_repeat'] == 'on' ? ' checked' : '' ?>>繰り返し
	<input type="checkbox" name="" value="on" onClick="CheckboxOnOff('flv','<?= $_SESSION['slide_flv_preview'] ?>')"<?= $_SESSION['slide_flv_preview'] == 'on' ? ' checked' : '' ?>>FLVプレビュー
<?
}
function select_page_images_max($pageline) {
?>
	<script language="JavaScript">
	<!--
	function SelectionImageMax(form, sel)
	{
		for (i = 0; i < sel.options.length; i++) {
			if (sel.options[i].selected == true) {
				window.location.href = '<?= $_SERVER['SCRIPT_NAME'] ?>?imgmax=' + escape(sel.options[i].value) + '&mode=<?= $_SESSION['photo_view_mode'] ?>';
			}
		}
	}
	//-->
	</script>
	頁枚数：<select name="" onchange="SelectionImageMax(this.form, this)">
	<?php
		$keyary = explode(",", IMAGE_MAX_SELECT);
		foreach ($keyary as $keytmp) {
	?>
		<option value="<?= $keytmp ?>"<?= $pageline == $keytmp ? " selected" : "" ?>><?= $keytmp ?>
	<?php
		}
	?>
		</select>
<?
}
function photo_page_control($img_count, $page, $pagemax, $open_path, $skip_num=0, $page_suffix='頁') {
?>
<div class="photo_page_control">
<span class="photo_page_control_info">
	<span class="choice">枚数：<span class="photo_rowcnt"><?= $img_count ?></span>枚</span>&nbsp;
	<span class="choice"><span class="photo_page"><?= $page ?></span>/<span class="photo_pagemax"><?= $pagemax ?></span><?= $page_suffix ?></span>
</span>
<span class="photo_page_control_move">
<?php
	$parm = '&path='.urlencode($open_path).'&mode='.$_SESSION['photo_view_mode'];
	$label = '[←先頭]';
		if ($page > 1) {
			page_move($label, 1, $parm);
		} else {
			page_no_move($label);
		}
		if ($skip_num <> 0) {
	$label = '[←スキップ ('.$skip_num.')]';
			if ($page-$skip_num > 0) {
				page_move($label, $page-$skip_num, $parm);
			} else {
				page_no_move($label);
			}
		}
	$label = '[←前]';
		if ($page > 1) {
			page_move($label, $page-1, $parm);
		} else {
			page_no_move($label);
		}
	$label = '[→次]';
		if ($page < $pagemax) {
			page_move($label, $page+1, $parm);
		} else {
			page_no_move($label);
		}
		if ($skip_num <> 0) {
	$label = '[→スキップ ('.$skip_num.')]';
			if ($page+$skip_num <= $pagemax) {
				page_move($label, $page+$skip_num, $parm);
			} else {
				page_no_move($label);
			}
		}
	$label = '[→最後]';
		if ($page < $pagemax) {
			page_move($label, $pagemax, $parm);
		} else {
			page_no_move($label);
		}
?>
</span>
</div>
<?php
}
function page_move($label, $move_page, $parm) {
?>
	<span><a href="<?= $_SERVER['SCRIPT_NAME'] ?>?page=<?= $move_page ?><?= $parm ?>"><?= $label ?></a></span>
<?php
}
function page_no_move($label) {
?>
	<span class="link_off"><?= $label ?></span>
<?php
}
?>
