<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理後臺</title>
<meta name="keywords" content="管理後臺" />
<meta name="description" content="管理後臺" />
<script src="/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
<!-- 瀏覽用燈箱片效果 -->
<link rel="stylesheet" href="/jquery/fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="/jquery/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
</head>
<body>
	<div class="wrapper">
    	<?# header ?>
    	<div class="wrap">
        	<?# sidePage ?>
            <div class="contentMain">
            	<h3><?# editTitle ?></h3>
                <div class="article" style="width: 100%;">
                    <form id="form1" name="form1" action="photoEdit.php" method="post">
                        <fieldset style="width: 100%;">
                        	<div class="titleTyp"><p>相片/影片資訊</p></div>
                            <div style=" background: rgba(75, 141, 248, 0.07); padding: 10px 0;">
                            	<p>
                                	<label>所屬相本</label>
                                    <?# BookName ?>
                                </p>
                                <p>
                                    <label>相片/影片名稱</label>
                                    <input type="text" id="PhotoName" name="PhotoName" value="<?# PhotoName ?>" maxlength="50" style="width: 300px;" />
                                </p>
                                <p>
                                    <label>種類</label>
                                    <select id="PhotoType" name="PhotoType">
                                        <option value="1">相片</option>
                                        <option value="2">影片</option>
                                    </select>
                                </p>
                                <div class="writList">
                                	<label style="float: left;">相片</label>
                                    <a id="aImg" class="fancybox"><img id="imgImg" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="Image" name="Image" value="<?# Image ?>" />
                                    <input type="button" id="btnImg" name="btnImg" value="瀏覽" />
                                </div>
                                <p>
                                    <label>影片</label>
                                    <input type="text" id="Movie" name="Movie" value="<?# Movie ?>" maxlength="512" style="width: 300px;" /><span style="margin:0 0 0 5px;
                                    color: #F00;">請貼上youtube影片連結。( 例 : https://youtu.be/8RU6Fs3Q1T8 )</span>
                                </p>
                                <div class="writList">
                                    <label>相片/影片說明</label>
                                    <div class="ckeList"><textarea id="Introduction" name="Introduction" style="width:540px; height:100px;"><?# Introduction ?></textarea></div>
                                </div>
                                <p>
                                    <label>啟用</label>
                                    <input type="radio" name="Visible" value="1" />啟用
                                    <input type="radio" name="Visible" value="0" />不啟用
                                </p>
                                <p>
                                    <label>排序</label>
                                    <input type="text" id="OrderNO" name="OrderNO" value="<?# OrderNO ?>" onkeypress="if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false;" style="width: 300px;" />
                                </p>
                            </div>
                            <p>
                                <input type="button" id="btnOK" name="btnOK" value="確 定" />
								<input type="button" id="btnCancel" value="返 回" />
                            </p>
                            <input type="hidden" id="id" name="id" value="<?# id ?>" />
                            <input type="hidden" id="bookID" name="bookID" value="<?# bookID ?>" />
                            <input type="hidden" id="pUrl2" name="pUrl2" value="<?# pUrl2 ?>" />
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
        <?# footer ?>
    </div>
<script>
<!--
	function SetFileField(fileUrl,data){
		$('#'+data["selectActionData"]).val(fileUrl);
		$('#'+data["selectActionData"]).change();
	}
	$(function(){
		$(".fancybox").fancybox();

		$('#PhotoType').change(function(){
			if($(this).val() == '1'){
				$('#imgTR').css('display','table-row');
				$('#movTR').css('display','none');
			}else if($(this).val() == '2'){
				$('#imgTR').css('display','none');
				$('#movTR').css('display','table-row');
			}else{
				$('#imgTR').css('display','none');
				$('#movTR').css('display','none');
			}
		});

		$('#PhotoType').val("<?# PhotoType ?>");
		$('#PhotoType').change();
		$('input:radio[name="Visible"][value="<?# Visible ?>"]').attr('checked',true);

		$('#Image').change(function(){
			if($(this).val() == ''){
				$('#imgImg').attr('src','');
				$('#imgImg').css('display','none');
				$('#aImg').attr('href','');
			}else{
				$('#imgImg').attr('src',$(this).val());
				$('#imgImg').css('display','block');
				$('#aImg').attr('href',$(this).val());
			}
		});
		$('#Image').change();

		$('#btnImg').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'Image';
			finder.popup();
		});
		$('#btnOK').click(function(){
			if($('#PhotoType').val() == '1'){
				if($('#Image').val() == ''){
					alert('相片不可空白!');
					return false;
				}
			}else if($('#PhotoType').val() == '2'){
				if($('#Movie').val() == ''){
					alert('影片不可空白!');
					$('#Movie').focus();
					return false;
				}
			}else{
				alert('請選擇種類!');
				$('#PhotoType').focus();
				return false;
			}
			if($('input:radio[name="Visible"]:checked').size() == 0){
				alert('請選擇是否啟用此相片/影片!');
				return false;
			}
			$('#form1').submit();
		});
		$('#btnCancel').click(function(){
			if($('#pUrl2').val() == '')
				location.href = 'bookList.php';
			else
				location.href = $('#pUrl2').val();
		});
	});
//-->
</script>
</body>
</html>