<?php
	require("__include-common.php");
	require("../account/__logincheck.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) <> 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') {
		$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;
		$img_style = 'height: 100%;';
	} else {
	//	if (photo_JPEG_ROTATE == 'YES') {	// 廃止機能
			$getimg = "img-view.php?img=".$filepath_url;
			get_width_height($img_file, &$width, &$height);
	//	} else {
	//		list($width, $height) = getimagesize(myfile_ENCODE($filepath));
	//		$getimg = "img-view.php?img=".$filepath_url;
	//	}
		if ($width > $height) {
			$img_style = 'width: 100%;';
		} else {
			$img_style = 'height: 100%;';
		}
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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 type="text/css">
* { 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 type="text/javascript" src="../scripts/cookie.js"></script>
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script type="text/javascript" src="../scripts/jquery.cookie.js"></script>
<script type="text/javascript">
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 type="text/javascript">
function imgFadeChangeOnLoad() {
	$("#img_slide_main_1").attr("src", "img-get.php?page=<?= $next_page ?>");
	setTimeout('autoImgChange()', interval_time*1000);
	$('#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 onload="pixasticImageOnLoad()">
<script type="text/javascript" src="../scripts/pixastic/pixastic.core.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/blur.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/brightness.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/coloradjust.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/desaturate.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/glow.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/hsl.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/lighten.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/posterize.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/sepia.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/sharpen.js"></script>
<script type="text/javascript" src="../scripts/pixastic/actions/solarize.js"></script>
<script type="text/javascript">
function pixasticImageOnLoad() {
	photo_pixastic = loadCookie("photo_pixastic_stack");
	if (photo_pixastic && photo_pixastic != "false") {
		pixastic = photo_pixastic.split(",");
		for(var ix in pixastic){
			pixasticAction(pixastic[ix]);
		}
	}
}
function pixasticAction(action) {
	if (action == "contrast") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "brightness", {brightness:0,contrast:0.3});
	} else if (action == "red") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "coloradjust", {red:0.1,green:0,blue:0});
	} else if (action == "green") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "coloradjust", {red:0,green:0.1,blue:0});
	} else if (action == "blue") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "coloradjust", {red:0,green:0,blue:0.1});
	} else if (action == "glow") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "glow", {amount:0.1,radius:1.0});
	} else if (action == "saturation") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "hsl", {hue:0,saturation:20,lightness:0});
	} else if (action == "lighten") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "lighten", {amount:0.1});
	} else if (action == "posterize") {
		posterize = loadCookie("photo_pixastic_posterize");
		Pixastic.process(document.getElementById("img_slide_main_0"), "posterize", {levels:posterize});
	} else if (action == "sharpen") {
		Pixastic.process(document.getElementById("img_slide_main_0"), "sharpen", {amount:0.2});
	} else {	// desaturate, sepia, solarize, blur
		Pixastic.process(document.getElementById("img_slide_main_0"), action);
	}
}
</script>
<?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 type="text/javascript" src="../scripts/JWPlayer/silverlight.js"></script>
		<script type="text/javascript" src="../scripts/JWPlayer/wmvplayer.js"></script>
		<script type="text/javascript" src="../scripts/JWPlayer/movie_preview.js"></script>
		<div id="movie_preview">the player will be placed here</div>
		<script type="text/javascript">
			wmv_preview("movie_preview", "<?= $click ?>", document.body.clientWidth-40, document.body.clientHeight-20);
		</script>
	<?php
			} else {
	?>
		<script type="text/javascript" src="../scripts/JWPlayer/swfobject.js"></script>
		<script type="text/javascript" src="../scripts/JWPlayer/movie_preview.js"></script>
		<div id="movie_preview">the player will be placed here</div>
		<script type="text/javascript">
			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 type="text/javascript">
		$(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 style="color: #ffff40">Auto (<span id="auto_interval_time"></span>)</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 language="JavaScript">
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(){
					setTimeout('autoImgChange()', interval_time*1000);
					$('#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
		location.href = "index.php?page=<?= $page ?>&mode=s";
	} 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 == 243 ) {					// 半角/全角 ：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 {					// その他 (ファンクションキーなどを有効にするため)
		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>
</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));
}
?>
