<!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>批量上傳相片</h3>
                <div class="article">
                	<form id="form1" name="form1" action="photoMulti.php" method="post">
                    	<fieldset style="width: 100%;">
                        	<p>
                            	<label>所屬相本</label>
                                <?# BookName ?>
                            </p>
                            <p>
                            	<label>相片</label>
                                <input type="button" id="btnMulti" name="btnMulti" value="瀏覽" />
                            </p>
                            <ul id="photoUL"></ul>
                            <p>
                            	<input type="button" id="btnOK" name="btnOK" value="確 定" />
								<input type="button" id="btnCancel" value="返 回" />
                            </p>
                            <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,allFiles){
		for(var i=0;i<allFiles.length;i++){
			$('#'+data["selectActionData"]).append(
				$('<li></li>').html('<a class="fancybox" href="'+allFiles[i]["url"]+'"><img src="'+allFiles[i]["url"]+'" style="width:50px; height:50px;"></a><input type="hidden" name="Image[]" value="'+allFiles[i]["url"]+'" />相片名稱：<input class="photoInp" type="text" name="PhotoName[]" value="'+PhotoName+'" />排序：<input class="photoInp" type="text" name="OrderNO[]" value="'+orderNO+'" /><input class="del" type="button" data-action="delItem" value="刪除" />')
			);
			orderNO = (parseInt(orderNO) + 10).toString();
		}
	}
	var orderNO = "<?# OrderNO ?>";
	var PhotoName = "<?# PhotoName ?>";
	$(function(){
		$(".fancybox").fancybox();
		$('#photoUL').on('click','input:button[data-action="delItem"]',function(){
			$(this).parent('li').remove();
		});

		$('#btnMulti').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'photoUL';
			finder.popup();
		});
		$('#btnOK').click(function(){
			if($('#photoUL li').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>