<?php
	require("__include-common.php");
	require("../account/__logincheck.php");
	require("img-view-include.php");
	if ($_SESSION['photo_open_path'] == '') {
		header("Location: index.php");
	}
	if (empty($_SESSION['photo'])) {
		header("Location: index.php");
	}
	if (empty($_SESSION['photo_img_count'])) {
		header("Location: index.php");
	}
	if ($_SESSION['photo_img_count'] < 1) {
		header("Location: index.php");
	}
	$open_path = $_SESSION['photo_open_path'];
	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+1) <> photo_LIMITED_IMAGES_FOLDER.'/') {
				header("Location: index.php");
			}
		}
	}
	if ($_GET['page'].'' <> '') {
		$page = intval($_GET['page']);
		if ($page < 1) {
			$page = 1;
		}
	} else {
		$page = 1;
	}
	$slidemode = $_GET['slidemode'].'';
	if ($_GET['auto'].'' <> '') {
		if ($_GET['auto'] == 'chg') {
			if ($_SESSION['slide_fullview_auto'] == 'on') {
				$_SESSION['slide_fullview_auto'] = 'off';
			} else {
				$_SESSION['slide_fullview_auto'] = 'on';
			}
		} else {
			$_SESSION['slide_fullview_auto'] = $_GET['auto'];
		}
		setcookie('slide_fullview_auto', $_SESSION['slide_fullview_auto'], time() + LOGIN_COOKIE_EXPIRE, '/');
	} else {
		if (isset($_COOKIE['slide_fullview_auto'])) {
			$_SESSION['slide_fullview_auto'] = $_COOKIE['slide_fullview_auto'];
		}
	}
	if ($_GET['rep'].'' <> '') {
		if ($_GET['rep'] == 'chg') {
			if ($_SESSION['slide_view_repeat'] == 'on') {
				$_SESSION['slide_view_repeat'] = 'off';
			} else {
				$_SESSION['slide_view_repeat'] = 'on';
			}
		} else {
			$_SESSION['slide_view_repeat'] = $_GET['rep'];
		}
		setcookie('slide_view_repeat', $_SESSION['slide_view_repeat'], time() + LOGIN_COOKIE_EXPIRE, '/');
	} else {
		if (isset($_COOKIE['slide_view_repeat'])) {
			$_SESSION['slide_view_repeat'] = $_COOKIE['slide_view_repeat'];
		}
	}
	if ($_GET['fade'].'' <> '') {
		if ($_GET['fade'] == 'chg') {
			if ($_SESSION['slide_view_fade'] == 'on') {
				$_SESSION['slide_view_fade'] = 'off';
			} else {
				$_SESSION['slide_view_fade'] = 'on';
			}
		} else {
			$_SESSION['slide_view_fade'] = $_GET['fade'];
		}
		setcookie('slide_view_fade', $_SESSION['slide_view_fade'], time() + LOGIN_COOKIE_EXPIRE, '/');
	}
	if ($_SESSION['slide_view_fade'] == '') {
		if (isset($_COOKIE['slide_view_fade'])) {
			$_SESSION['slide_view_fade'] = $_COOKIE['slide_view_fade'];
		} elseif (photo_SLIDE_FADEIN_USE == 'YES') {
			$_SESSION['slide_view_fade'] = 'on';
		}
	}
	if ($_GET['lean'].'' <> '') {
		if ($_GET['lean'] == 'chg') {
			if ($_SESSION['slide_view_lean'] == 'on') {
				$_SESSION['slide_view_lean'] = 'off';
			} else {
				$_SESSION['slide_view_lean'] = 'on';
			}
		} else {
			$_SESSION['slide_view_lean'] = $_GET['lean'];
		}
		setcookie('slide_view_lean', $_SESSION['slide_view_lean'], time() + LOGIN_COOKIE_EXPIRE, '/');
	}
	if ($_SESSION['slide_view_lean'] == '') {
		if (isset($_COOKIE['slide_view_lean'])) {
			$_SESSION['slide_view_lean'] = $_COOKIE['slide_view_lean'];
		}
	}
	if ($_SESSION['システム管理者'] == 'YES' and photo_DELETE_FILE_USE == 'YES' and $_GET['del'] <> '') {
		if ($_GET['page'] <> $_GET['del']) {
			header("Location: index.php");
		}
		$del_file = $_SESSION['photo'][$page-1]['file'];
		$open_path_SJIS = myfile_ENCODE($open_path);
		$trash_dir_SJIS = $open_path_SJIS.photo_DELETE_TRASH_DIR;
		if (!@opendir($trash_dir_SJIS)) {
			@mkdir($trash_dir_SJIS);
		}
		$del_file_SJIS = myfile_ENCODE($del_file);
		$trash_file_SJIS = $trash_dir_SJIS.$del_file_SJIS;
		if (file_exists($trash_file_SJIS)) {
			error_exit("削除済みの同名ファイルが存在します。", True);
		}
		rename(myfile_ENCODE($open_path.'/'.$del_file), $trash_file_SJIS);
		@unlink($open_path_SJIS.photo_RESIZE_DIR_SMALL.$del_file_SJIS);
		@unlink($open_path_SJIS.photo_RESIZE_DIR_THUMB.$del_file_SJIS);
		if (is_ext_filename_str($del_file, VIDEO_PREVIEW_CONVERT)) {
			@unlink($open_path_SJIS.VIDEO_PREVIEW_CONVERT_FLV_DIR.$del_file_SJIS.'.flv');
		}
		array_splice($_SESSION['photo'], $page-1, 1);	// unset()では駄目
		--$_SESSION['photo_img_count'];
		if ($_SESSION['photo_img_count'] < $page) {
			--$page;
		}
		if ($page < 1) {
			header("Location: index.php");
		}
	}
	$filename = $_SESSION['photo'][$page-1]['file'];
	$filepath = $open_path.'/'.$filename;
	if ($_SESSION['photo'][$page-1]['type'] == 'video' and photo_VIDEO_FFMPEG == 'YES' and $_SESSION['slide_flv_preview'] == 'on' and $slidemode <> 'ajax') {
		// 動画の再生時間を取得 (ffmpegのstderrを利用)
		$ret = shell_exec('ffmpeg -i "'.myfile_ENCODE($filepath).'" 2>&1');
		$time = trim(get_intag($ret, 'duration:', ',', $pos=0));
		$time_ar = explode(":", $time);
		$interval_time = (int)$time_ar[0]*3600+(int)$time_ar[1]*60+(int)$time_ar[2] + 2;
	} else {
		$interval_time = $_COOKIE['slide_interval_time'];
	}
	$add_meta = '';
	if ($_SESSION['slide_fullview_auto'] == 'on' and $slidemode <> 'ajax') {
		if ($page < ceil($_SESSION['photo_img_count'])) {
			$add_meta = '<meta http-equiv="refresh" content="'.$interval_time.';';
			$add_meta .= 'url='.$_SERVER['SCRIPT_NAME'].'?page='.strval($page+1);
		//	$add_meta .= '&path='.urlencode($open_path);
			$add_meta .= '&mode=s&slidemode='.$slidemode.'">';
		} elseif ($_SESSION['slide_view_repeat'] == 'on') {
			$add_meta = '<meta http-equiv="refresh" content="'.$interval_time.';';
			$add_meta .= 'url='.$_SERVER['SCRIPT_NAME'].'?page=1';
		//	$add_meta .= '&path='.urlencode($open_path);
			$add_meta .= '&mode=s&slidemode='.$slidemode.'">';
		}
	}
	$filename = $_SESSION['photo'][$page-1]['file'];
	if (VIDEO_PREVIEW == 'YES' && $_SESSION['slide_flv_preview'] == 'on' && $slidemode <> 'ajax' && is_preview_video_filename($filename) && is_ext_filename_str($filename, VIDEO_PREVIEW_CONVERT)) {
		$filepath = $open_path.'/'.$filename.'.flv';	// JWPlayerは拡張子が.flvでないと駄目なため
	} else {
		$filepath = $open_path.'/'.$filename;
	}
	$filepath_url = urlencode($filepath);
	if ($_SESSION['photo'][$page-1]['type'] == 'video') {
		$mov_thumb_file = mov_thumb_file($filepath, $_SESSION['video_thumb_ss']);
		$mov_thumb_SJIS = myfile_ENCODE($mov_thumb_file);
		if (!file_exists($mov_thumb_SJIS)) {	// video-jpeg.php の前にJPEGを作成しておく。getimagesize()のため
			exec('ffmpeg -vframes 1 -i "'.myfile_ENCODE($filepath).'" -f image2 -ss '.$_SESSION['video_thumb_ss'].' "'.$mov_thumb_SJIS.'"');
		}
		$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;
		list($width, $height) = getimagesize($mov_thumb_SJIS);
	} else {
		$small_file = img_view($filepath, '', '', 0, '', '', 'smallname');
			// img-view.php の前にsmall画像を作成しておく。EXIF縦横回転画像の縦横をgetimagesize()で正しく読み取るため
		$getimg = "img-view.php?img=".$filepath_url;
		list($width, $height) = getimagesize(myfile_ENCODE($small_file));
	}
	if ($_COOKIE['document_clientWidth'].'' <> '' and $_COOKIE['document_clientHeight'].'' <> '') {
		$clientWidth = intval($_COOKIE['document_clientWidth']);
		$clientHeight = intval($_COOKIE['document_clientHeight']);
		$client_height_per_width = $clientHeight / $clientWidth;
		if ($width and $width > 0) {
			$height_per_width = $height / $width;
			if ($height_per_width and $height_per_width < $client_height_per_width) {
				$img_style = 'width: 100%;';
			} else {
				$img_style = 'height: 100%;';
			}
		} else {
			$img_style = 'height: 100%;';
		}
	} else {
		$img_style = 'height: 100%;';
	}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<?php if ($add_meta <> '') echo $add_meta."\n"; ?>
<meta http-equiv="Content-Language" content="ja">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta name="author" content="ok.2nd">
<?php	if ($slidemode <> 'ajax') { ?>
<title><?= $filename ?></title>
<?php	} else { ?>
<title>MyHome アルバム スライドショー(Ajax)</title>
<?php	} ?>
<style>
* { margin: 0px; padding: 0px; }
html,body {
	width: 100%;
	height: 100%;
	overflow: hidden;
}
img {
	-ms-interpolation-mode: bicubic;
	<?= $img_style ?>
}
div#slide_view {
	text-align: center;
	width: 100%;
	height: 100%;
<?php 	if ($slidemode <> 'wallpaper') { ?>
	background-color: #000000; */
<?php	} ?>
}
div#move_control {
	position: absolute;
	top: 0px; left: 0px;
	width: 100%; height: 100%;
	z-index: 1;
}
#move_control table {
	width:100%; height: 100%;
}
td#left {
	height: 90%;
	text-align: left;
}
td#right {
	height: 90%;
	text-align: right;
}
td#bottom {
	height: 10%;
	text-align: center;
	vertical-align: bottom;
}
.move {
	color: #ffffff;
	text-decoration: none;
	font-size: 200%;
}
.return {
	color: #ffffff;
	text-decoration: none;
	font-size: 200%;
	margin: 0 5px;
}
.auto {
	color: #ffffff;
	text-decoration: none;
	font-size: 100%;
	margin: 0 5px;
}
.page {
	color: #ffffff;
	font-size: 100%;
	margin: 0 5px;
}
</style>
<script src="../scripts/cookie.js"></script>
<script src="../scripts/jquery.js"></script>
<script src="../scripts/jquery.cookie.js"></script>
<script>
if (loadCookie('slide_interval_time')) {
	interval_time = Number(loadCookie('slide_interval_time'));
} else {
	interval_time = <?= SLIDE_INTERVAL_TIME ?>;
}
</script>
</head>
<?php	if ($slidemode == 'ajax') { ?>
<body onload="imgFadeChangeOnLoad()">
<?php
	if ($page < $_SESSION['photo_img_count']) {
		$next_page = $page + 1;
	} else {
		$next_page = 1;
	}
?>
<script>
var autoSlide = true;
function setTimeoutAutoImgChange(interval_time) {
	if (autoSlide == true) {
		setTimeout('autoImgChange()', interval_time*1000);
	}
}
function imgFadeChangeOnLoad() {
	$("#img_slide_main_1").attr("src", "img-get.php?page=<?= $next_page ?>");
	setTimeoutAutoImgChange(interval_time);
	$('#auto_interval_time').html(interval_time);
}
</script>
<?php 	} elseif ($slidemode == 'wallpaper' or $_SESSION['slide_view_fade'] == 'on') { ?>
<body style="background-image: url('<?= $getimg ?>');">
<?php	} else {?>
<body>
<?php	} ?>
<div id="slide_view">
<?php 	if ($slidemode <> 'wallpaper') { ?>
	<?php if ($_SESSION['photo_img_count'] <> 0) { ?>
	<?php
		if (VIDEO_PREVIEW == 'YES' && $_SESSION['slide_flv_preview'] == 'on' && $slidemode <> 'ajax' && is_preview_video_filename($filepath)) {
			if (is_ext_filename_str($click, VIDEO_PREVIEW_WMV)) {
	?>
		<script src="../scripts/JWPlayer/silverlight.js"></script>
		<script src="../scripts/JWPlayer/wmvplayer.js"></script>
		<script src="../scripts/JWPlayer/movie_preview.js"></script>
		<div id="movie_preview">the player will be placed here</div>
		<script>
			wmv_preview("movie_preview", "<?= $click ?>", document.body.clientWidth-40, document.body.clientHeight-20);
		</script>
	<?php
			} else {
	?>
		<script src="../scripts/JWPlayer/swfobject.js"></script>
		<script src="../scripts/JWPlayer/movie_preview.js"></script>
		<div id="movie_preview">the player will be placed here</div>
		<script>
			movie_preview("movie_preview", "<?= $click ?>", document.body.clientWidth-40, document.body.clientHeight-20);
		</script>
	<?php
			}
	?>
		<div class="photo_file_name" style="text-align: center;"><?= $filename ?></div>
	<?php
		} else {
			if ($_SESSION['slide_view_fade'] == 'on' or $slidemode == 'ajax') {
	?>
		<script>
		$(function() {
			$("#img_slide_main_0").fadeTo(<?= photo_SLIDE_FADEIN_TIME ?>, 1.0);
		});
		</script>
	<?php
				$img_opt = 'opacity: 0.0; -moz-opacity: 0.0; filter: alpha(opacity=0);';
			}
			if ($_SESSION['slide_view_lean'] == 'on') {
				$deg = mt_rand(0,8);
				if ($_SESSION['album_slide_rotate_minus']) {
					$_SESSION['album_slide_rotate_minus'] = false;
					$minus = '-';
				} else {
					$_SESSION['album_slide_rotate_minus'] = true;
				}
				$rotate = 'rotate('.$minus.$deg.'deg);';
				$marginTop = mt_rand(20,60);
				$img_opt_rotate = ' height: 85%;';
				$img_opt_rotate .= ' border: 16px solid white;';
				$img_opt_rotate .= ' margin-top: '.$marginTop.'px;';
				$img_opt_rotate .= ' -webkit-transform: '.$rotate;
				$img_opt_rotate .= ' -moz-transform: '.$rotate;
			}
	?>
		<img name="img_slide_main_0" id="img_slide_main_0" src="<?= $getimg ?>" alt="<?= $filename ?>" title="<?= $filename ?>" style="<?= $img_opt ?><?= $img_opt_rotate ?>">
	<?php	if ($slidemode == 'ajax') { ?>
		<img name="img_slide_main_1" id="img_slide_main_1" src="" alt="" title="" style="<?= $img_opt ?> display:none;">
	<?php	} ?>
	<?php
		}
	?>
	<?php } ?>
<?php	} ?>
<div>
<div id="move_control">
<table>
<tr>
<td id="left">
<?php
	if ($page > 1) {
		$move_prev = $page - 1;
	} else {
		if ($_SESSION['slide_view_repeat'] == 'on') { 
			$move_prev = $_SESSION['photo_img_count'];
		} else {
			$move_prev = $page;
		}
	}
?>
<?php if ($slidemode <> 'ajax') {	// ***************** ?>
	<a class="move" href="?page=<?= $move_prev ?>&slidemode=<?= $slidemode ?>">&lt;</a>
<?php }					// ***************** ?>
</td>
<td id="right">
<?php
	if ($page < $_SESSION['photo_img_count']) {
		$move_next = $page + 1;
	} else {
		if ($_SESSION['slide_view_repeat'] == 'on') { 
			$move_next = 1;
		} else {
			$move_next = $page;
		}
	}
?>
<?php if ($slidemode <> 'ajax') {	// ***************** ?>
	<a class="move" href="?page=<?= $move_next ?>&slidemode=<?= $slidemode ?>">&gt;</a>
<?php }					// ***************** ?>
</td>
</tr>
<tr>
<td id="bottom" colspan=2>
<?php if ($slidemode <> 'ajax') {	// ***************** ?>
	<a class="return" href="index.php?page=<?= $page ?>&mode=s">×</a>
	<?php if ($_SESSION['slide_fullview_auto'] == 'on') { ?>
	<a class="auto" href="?page=<?= $page ?>&auto=off&slidemode=<?= $slidemode ?>">Auto <span style="color: #ffff40">On (<span id="auto_interval_time"><?= $_COOKIE['slide_interval_time'] ?></span>)</span></a>
	<?php } else { ?>
	<a class="auto" href="?page=<?= $page ?>&auto=on&slidemode=<?= $slidemode ?>">Auto Off</a>
	<?php } ?>
	<?php if ($_SESSION['slide_view_repeat'] == 'on') { ?>
	<a class="auto" href="?page=<?= $page ?>&rep=off&slidemode=<?= $slidemode ?>">Repeat <span style="color: #ffff40">On</span></a>
	<?php } else { ?>
	<a class="auto" href="?page=<?= $page ?>&rep=on&slidemode=<?= $slidemode ?>">Repeat Off</a>
	<?php } ?>
	<?php if ($_SESSION['slide_view_fade'] == 'on') { ?>
	<a class="auto" href="?page=<?= $page ?>&fade=off&slidemode=<?= $slidemode ?>">Fade <span style="color: #ffff40">On</span></a>
	<?php } else { ?>
	<a class="auto" href="?page=<?= $page ?>&fade=on&slidemode=<?= $slidemode ?>">Fade Off</a>
	<?php } ?>
	<?php if ($_SESSION['slide_view_lean'] == 'on') { ?>
	<a class="auto" href="?page=<?= $page ?>&lean=off&slidemode=<?= $slidemode ?>">Lean <span style="color: #ffff40">On</span></a>
	<?php } else { ?>
	<a class="auto" href="?page=<?= $page ?>&lean=on&slidemode=<?= $slidemode ?>">Lean Off</a>
	<?php } ?>
	<?php if ($slidemode == 'wallpaper') { ?>
	<a class="auto" href="?page=<?= $page ?>">Wallpaper <span style="color: #ffff40">On</span></a>
	<?php } else { ?>
	<a class="auto" href="?page=<?= $page ?>&slidemode=wallpaper">Wallpaper Off</a>
	<?php } ?>
<?php }					// ***************** ?>
	<span class="page"><span id="current_page"><?= $page ?></span> / <?= $_SESSION['photo_img_count'] ?></span>
<?php if ($slidemode == 'ajax') {	// ***************** ?>
	<span id="auto_on" style="color: #ffff40">Auto (<span id="auto_interval_time"></span>)</span>
	<span id="auto_off" style="color: #ffffff;display:none">Auto Off</span>
<?php }					// ***************** ?>
</td>
</tr>
</table>
</div>
<?php
	if ($page + SLIDE_SMALL_NUM < $_SESSION['photo_img_count']) {
		$skip_next = $page + SLIDE_SMALL_NUM;
	} else {
		$skip_next = $_SESSION['photo_img_count'];
	}
	if ($page - SLIDE_SMALL_NUM > 1) {
		$skip_back = $page - SLIDE_SMALL_NUM;
	} else {
		$skip_back = 1;
	}
?>
<script>
document.onkeydown = keyPress;
<?php if ($slidemode == 'ajax') {	// ***************** ?>
page = <?= $page ?>;
photo_img_count = <?= $_SESSION['photo_img_count'] ?>;
function autoImgChange() {
	if (page < photo_img_count) {
		++page;
	} else {
		page = 1;
	}
	if (page < photo_img_count) {
		nxt = page + 1;
	} else {
		nxt = 1;
	}
	imageChange(page, nxt);
}
sw = false;
slide_view_lean = "<?= $_SESSION['slide_view_lean'] ?>";
function imageChange(mov, nxt) {
	if (!sw) {
		c_p = "0";
		a_p = "1";
		rMinus = "";
	} else {
		c_p = "1";
		a_p = "0";
		rMinus = "-";
	}
	sw = !sw;
	$("#img_slide_main_"+c_p).fadeTo(<?= photo_SLIDE_AJAX_FADEOUT_TIME ?>, 0.0,
		function() {
			$("#img_slide_main_"+c_p).css("display","none");
			$("#img_slide_main_"+c_p).attr("src", "img-get.php?page="+nxt);
			$("#img_slide_main_"+a_p).css("display","");
			if (slide_view_lean == "on") {
				var rDeg = Math.floor(Math.random() * 9);
				var rotate = "rotate(" + rMinus + rDeg + "deg)"
				var marginTop = 20 + Math.floor(Math.random() * 61);
				$("#img_slide_main_"+a_p).css("height","85%");
				$("#img_slide_main_"+a_p).css("border", "16px solid white");
				$("#img_slide_main_"+a_p).css("margin-top", marginTop + "px");
				$("#img_slide_main_"+a_p).css('-webkit-transform', rotate);
				$("#img_slide_main_"+a_p).css("-moz-transform", rotate);
			}
			$("#img_slide_main_"+a_p).fadeTo(<?= photo_SLIDE_AJAX_FADEIN_TIME ?>, 1.0,
				function(){
					setTimeoutAutoImgChange(interval_time);
					$('#auto_interval_time').html(interval_time);
				}
			);
			$("#current_page").html(mov);
		}
	);
}
<?php }					// ***************** ?>
function keyPress( e ) {
	// IEでは e は未定義
	// 第一引数の e が未定義なら、window.event を使う。
	// by http://d.hatena.ne.jp/language_and_engineering/20081124/1227474876
	e = e || window.event;
	//alert( "キーコード：" + e.keyCode );
	if (e.keyCode == 27) {						// ESC ：Exit, Return to index.php
<?php
	if ($_SESSION['photo_view_mode'] == 's') {
		$index_page = $page;
	} else {
		$index_page = floor(($page - 1) / $_SESSION['photo_imgmax']) + 1;
	}
?>
		location.href = "index.php?page=<?= $index_page ?>";
	} else if (e.keyCode >= 49 && e.keyCode<=57) {			// 1～9 ：Auto 時間間隔変更
		intervalTimer(e.keyCode-48);
<?php if ($slidemode != 'ajax') {	// ***************** ?>
	} else if (e.keyCode == 37 || e.keyCode == 100 || e.keyCode == 33 || e.keyCode == 29) {	// ←, Page Up, 無変換 ：Page Prev
		window.location.href = "?page=<?= $move_prev ?>&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 39 || e.keyCode == 102 || e.keyCode == 34) {	// →, Page Down ：Page Next
		window.location.href = "?page=<?= $move_next ?>&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 13 || e.keyCode == 32) {		// Enter, Space ：Page Next
		window.location.href = "?page=<?= $move_next ?>&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 9 ) {					// Tab ：Page Skip(10)
		window.location.href = "?page=<?= $skip_next ?>&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 240 ) {					// Caps Lock ：Page Skip(10) Back
		window.location.href = "?page=<?= $skip_back ?>&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 36) {					// Home ：Page Top
		window.location.href = "?page=1&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 35) {					// End ：Page Last
		window.location.href = "?page=<?= $_SESSION['photo_img_count'] ?>&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 65) {					// A ：Auto On/Off
		window.location.href = "?page=<?= $page ?>&auto=chg&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 70) {					// F ：Fade On/Off
		window.location.href = "?page=<?= $page ?>&fade=chg&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 82) {					// R ：Repeat On/Off
		window.location.href = "?page=<?= $page ?>&rep=chg&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 76) {					// L ：Lean On/Off
		window.location.href = "?page=<?= $page ?>&lean=chg&slidemode=<?= $slidemode ?>";
	} else if (e.keyCode == 87) {					// W ：Wallpaper On/Off
		<?php if ($slidemode == 'wallpaper') { ?>
			window.location.href = "?page=<?= $page ?>";
		<?php } else { ?>
			window.location.href = "?page=<?= $page ?>&slidemode=wallpaper";
		<?php } ?>
<?php 	if ($_SESSION['システム管理者'] == 'YES' and photo_DELETE_FILE_USE == 'YES') { ?>
	} else if (e.keyCode == 46) {					// Delete ：Delete File
		window.location.href = "?page=<?= $page ?>&del=<?= $page ?>&slidemode=<?= $slidemode ?>";
<?php	} ?>
<?php }	else {				// ***************** ?>
	} else if (e.keyCode == 65) {					// A ：Auto On/Off
		if (autoSlide) {
			autoSlide = false;
			$('#auto_on').css("display","none");
			$('#auto_off').css("display","");
		} else {
			autoSlide = true;
			$('#auto_on').css("display","");
			$('#auto_off').css("display","none");
			autoImgChange();
		}
<?php }					// ***************** ?>
	} else {					// その他 (ファンクションキーなどを有効にするため)
		return true;
	}
	return false;
}
function intervalTimer(msec) {
	interval_time = msec;
	saveCookie('slide_interval_time', String(interval_time), 365);
	$('#auto_interval_time').html(interval_time);
}
</script>
<script>
$(function(){
	var w = document.body.clientWidth || document.documentElement.clientWidth;
	var h = document.body.clientHeight || document.documentElement.clientHeight;
	$.cookie('document_clientWidth',w,{ expires: 365 });
	$.cookie('document_clientHeight',h,{ expires: 365 });
});
</script>
</body>
</html>
<?php
function get_width_height($img_file, &$width, &$height) {	// UTF-8
	$resize_SJIS = myfile_ENCODE(resize_filename__($img_file, photo_RESIZE_DIR_SMALL));
	if (file_exists($resize_SJIS)) {
		list($width, $height) = getimagesize($resize_SJIS);
	} else {
		list($width, $height) = getimagesize(myfile_ENCODE($img_file));
	}
}
function resize_filename__($img_file, $dir) {			// UTF-8
	$resize_dir = up_folder_path($img_file).$dir;
	return ($resize_dir.basename($img_file));
}
function mov_thumb_file($file_name, $ss) {		// UTF-8
	$mov_thumb_dir = up_folder_path($file_name).photo_RESIZE_DIR_THUMB;
	if (!@opendir(myfile_ENCODE($mov_thumb_dir))) {
		@mkdir(myfile_ENCODE($mov_thumb_dir));
	}
	$basename = basename($file_name);
	$pos = mb_strrpos($basename, '.');
	if ($ss.'' == '') $ss = 0;
	return ($mov_thumb_dir.left($basename,$pos).'-'.$ss.'.jpg');
}
?>
