<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = path + "/common/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="<%=basePath %>admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />

<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>单图文编辑</title>
<style type="text/css">
	.matext{font-size: 16px; color: #0088CC; font-weight: bold;}
	.maimg{width: 100%; height: 150px;}
	.zhezhao{position:absolute;background-color:rgba(236,236,236,0.6);z-index:500; color:#fff!important;display: none;}
	.min_img{height: 70px;}
</style>
<script type="text/javascript">
<c:forEach begin='1' end='8' var='j'>
	var editor${j} = null;
</c:forEach>
</script>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 微信管理 <span class="c-gray en">&gt;</span> 多图文编辑 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20" align="center">
  <div class="text-c bk-gray radius box-shadow" style="width: 800px;">
	<div class="text-l bk-gray radius pd-5 f-16 c-black"  style="background-color: #E8F5FF; font-weight: bold;">&nbsp;添加多图文</div>
	<div class="text-c radius pt-10 pb-10" style="float: inherit;padding-left: 2%; padding-right: 2%;">
		<!-- 显示在左侧的素材 -->
		<div class="text-c f-l mt-10 mb-10" style="width:375px;background-color: #F8F8F8;">
			<!-- 一个图文素材 -->
			<c:if test="${!empty imgtxtMore }">
			<div class="text-c bk-gray radius box-shadow">
				<div class="text-l pl-10 pt-10 pr-10">
					<p>${imgtxtMore.createtime}</p>
				</div>
				<!-- 大图片 -->
				<div class="text-c pl-10 pb-10 pr-10 mt-10 box-shadow" style="border-bottom: 1px solid #F5FAFE;" id="maxzhezhao">
					<a href="javascript:void();" style="text-decoration: none;">
						<!-- 遮罩层 -->
						<div class="zhezhao va-m f-60" id="maxzhezhaoblack">
							<i class="Hui-iconfont" onclick="showEditDiv(1)">&#xe6df;</i>
						</div>
					</a>
					<div id="MaxsuonueImage" class="maimg bk-gray radius" style="position: relative;background-size:100% 100%; background-image: url('${imgtxtMore.imageurl}');"><!-- 这里将素材图片作为div背景放置 -->
						<div class="text-l" style="width: 100%;  filter:alpha(opacity:30);opacity:0.4; background-color: black;position: absolute;bottom: 0;"><!-- 放置标题 -->
							<p class="text-l f-16" style="font-weight: bold; color:white;" id="title1">${imgtxtMore.title }</p>
						</div>
					</div>
				</div>
				
					<c:if test="${!empty imgtxtMore.subVoList }">
						<c:forEach items="${imgtxtMore.subVoList }" var="voList" varStatus="count">
							<!-- 小图片 -->
							<div class="text-l min_img box-shadow lowImageText" onmouseover="minOverMouse(${count.index+2})" onmouseout="minLeaveMouse(${count.index+2})" style="border-bottom: 1px solid #F5FAFE;" id="minMoreImageText${count.index+2}">
								<!-- 遮罩层 -->
								<div class="zhezhao text-c f-30 minzhezhaoblack" id="minzhezhaoblack${count.index+2}">
									<a href="javascript:void();" onclick="showEditDiv(${count.index+2})" style="text-decoration: none;">
											<i class="Hui-iconfont">&#xe6df;</i>
									</a>&nbsp;&nbsp;
									<a href="javascript:void();" onclick="deleteMinImageText(${count.index+2})" style="text-decoration: none;">
											<i class="Hui-iconfont">&#xe6e2;</i>
									</a>
								</div>
								<div class="f-l mt-10  mt-10" style="width: 75%;">
									<p class="ml-10" id="title${count.index+2 }">${voList.title }</p>
								</div>
								<div class="f-r text-r  mt-5" style="width: 24%;">
									<img id="suonueImage${count.index+2}" src="${voList.imageUrl }" alt="缩略图"  style="width: 60px; height: 60px; margin-right: 10px;"> 
								</div>
							</div>
						</c:forEach>
					</c:if>
					<c:forEach begin="${fn:length(imgtxtMore.subVoList) + 2 }" end="8" var="count">
						<!-- 小图片 -->
						<div class="text-l min_img box-shadow lowImageText" onmouseover="minOverMouse(${count})" onmouseout="minLeaveMouse(${count})" style="border-bottom: 1px solid #F5FAFE; display: none;" id="minMoreImageText${count}">
							<!-- 遮罩层 -->
							<div class="zhezhao text-c f-30 minzhezhaoblack" id="minzhezhaoblack${count}">
								<a href="javascript:void();" onclick="showEditDiv(${count})" style="text-decoration: none;">
										<i class="Hui-iconfont">&#xe6df;</i>
								</a>&nbsp;&nbsp;
								<a href="javascript:void();" onclick="deleteMinImageText(${count})" style="text-decoration: none;">
										<i class="Hui-iconfont">&#xe6e2;</i>
								</a>
							</div>
							<div class="f-l mt-10  mt-10" style="width: 75%;">
								<p class="ml-10" id="title${count }">&nbsp;&nbsp;标题${count }</p>
							</div>
							<div class="f-r text-r  mt-5" style="width: 24%;">
								<img id="suonueImage${count }" src="" alt="缩略图"  style="width: 60px; height: 60px; margin-right: 10px;"> 
							</div>
						</div>
					</c:forEach>
				</c:if>
				<!-- 新增素材按钮 -->
				<div class="text-l pd-20 min_img box-shadow pb-5" style="border-bottom: 1px solid #F5FAFE;">
					<a href="javascript:void();" id="addMoreImageTextButton"  style="color:gray; text-decoration: none;">
						<div class="text-c bk-gray radius pd-20" style="border: 2px dashed gray;">
							<i class="Hui-iconfont">&#xe604;</i>增加一条
						</div>
					</a>
				</div>
			</div>
			
		</div>
		<!-- 显示在右侧的素材 -->
		<div class="text-c f-r mt-10 editerDiv" style="width: 375px; background-color: #F8F8F8;">
			<%-- <c:forEach begin="1" end="8" var="editerCount"> --%>
				<c:if test="${!empty imgtxtMore }">
					<form action="${pageContext.request.contextPath }/admin/wx/updateMoreImageText/${token}" method="post" id="myForm1" name="edit">
						<div class="text-c bk-gray radius box-shadow">
							<div  class="text-l pl-10 pt-10 pr-10">
								<span class="f-16"><font style="color: red;">*正在编辑1号图文</font><font style="font-size: 13px;"></font></span>
							</div>
							<input type="hidden" id="imageTextNO1" value="${imgtxtMore.imagetextno }">
							<div  class="text-l pl-10 pt-10 pr-10">
								<span class="f-16">标题<font style="color: red;">*</font><font style="font-size: 13px;">(必填，不能超过64个字)</font></span>
								<p><input type="text" value="${imgtxtMore.title }" name="moreImageTextTitle" id="moreImageTextTitle1" class="input-text radius size-M"/></p>
							</div>
							
							<div  class="text-l pl-10 pt-5 pr-10">
								<span class="f-16">封面<font style="color: red;">*</font><font style="font-size: 13px;">(必须上传一张图片, 大图片建议尺寸：360像素 * 200像素)</font></span>
								<p style="width: 300px;">
									<span class="btn-upload form-group" style="width: 300px;">
									  <input class="input-text upload-url radius" style="width: 180px;" value="${imgtxtMore.imageurl}"  type="text" name="moreImageTextImage" id="imageUrl1" readonly><a href="javascript:void();" class="btn btn-primary radius"><i class="Hui-iconfont" >&#xe642;</i> 浏览图片</a>
									  <input type="button" id="image1" style="width: 180px;" class="input-file">
									</span>
								</p>
							</div>
							
							<div  class="text-l pl-10 pt-10 pr-10">
								<span class="f-16">正文<font style="color: red;">*</font><font style="font-size: 13px;">(必填，不能超过10000个字符)</font></span>
								<p><textarea rows='10' cols='30' style='width:100%;' name="MoreImageTextMainText" id="mainImageTextMainText1">${imgtxtMore.content }</textarea></p>
							</div>
							
							<div  class="text-l pl-10 pt-5 pr-10">
								<c:if test="${empty imgtxtMore.clickouturl }">
									<span class="f-16"  id="outlink1"><a href="javascript:void();" style="color:#0088CC; text-decoration: none;">添加外链接</a></span>
									<p><input type='text' name='outLink' id='chain1' style="display: none;" class='input-text radius size-M'/></p>
								</c:if>
								<c:if test="${!empty imgtxtMore.clickouturl }">
									<span class="f-16"  id="outlink1"><span class='f-16'>外链接地址<br/><font style='font-size: 13px;'>(设置后，点击图文消息，不会进入图文详情，而进入外链所设地址)</font></span></span>
									<p><input type='text' name='outLink' id='chain1' style="display: block;" class='input-text radius size-M'/></p>
								</c:if>
							</div>
							
							<div  class="text-l pl-10 pt-5 pr-10">
								<c:if test="${empty imgtxtMore.sourceurl }">
									<span class="f-16"  id="originallink1"><a href="javascript:void();" style="color:#0088CC; text-decoration: none;">添加原文链接</a></span>
									<p><input type='text' name='originlLink' id='sourceURL1' style="display: none;" class='input-text radius size-M'/></p>
								</c:if>
								<c:if test="${!empty imgtxtMore.sourceurl }">
									<span class="f-16"  id="originallink1"><span class='f-16'>原文链接<font style='font-size: 13px;'>(在图文详情页面中会生成“阅读原文”链接)</font></span></span>
									<p><input type='text' name='originlLink' id='sourceURL1' style="display: block;" class='input-text radius size-M'/></p>
								</c:if>
							</div>
							
							<div  class="text-l pl-10 pt-20 pr-10 pb-20">
								<input class="btn btn-success radius" type="button" id="submitButton1" value="保存">&nbsp;&nbsp;&nbsp;
								<input class="btn disabled radius" type="button" value="取消">
							</div>
						</div>
					</form>
					
					<c:if test="${!empty imgtxtMore.subVoList }">
						<c:forEach items="${imgtxtMore.subVoList }" var="voList" varStatus="editerCount">
							<form action="${pageContext.request.contextPath }/admin/wx/updateMoreImageText/${token}" method="post" id="myForm${editerCount.index+2 }" style="display: none;" name="edit">
								<div class="text-c bk-gray radius box-shadow">
									<div  class="text-l pl-10 pt-10 pr-10">
										<span class="f-16"><font style="color: red;">*正在编辑${editerCount.index+2 }号图文</font><font style="font-size: 13px;"></font></span>
									</div>
									<input type="hidden" id="imageTextNO${editerCount.index+2 }" value="${voList.moreImageTextMD5 }"/>
									<div  class="text-l pl-10 pt-10 pr-10">
										<span class="f-16">标题<font style="color: red;">*</font><font style="font-size: 13px;">(必填，不能超过64个字)</font></span>
										<p><input type="text" value="${voList.title }" name="moreImageTextTitle" id="moreImageTextTitle${editerCount.index+2 }" class="input-text radius size-M"/></p>
									</div>
									
									<div  class="text-l pl-10 pt-5 pr-10">
										<span class="f-16">封面<font style="color: red;">*</font><font style="font-size: 13px;">(必须上传一张图片, 大图片建议尺寸：360像素 * 200像素)</font></span>
										<p style="width: 300px;">
											<span class="btn-upload form-group" style="width: 300px;">
											  <input class="input-text upload-url radius" style="width: 180px;" value="${voList.imageUrl }"  type="text" name="oneImageTextImage" id="imageUrl${editerCount.index+2 }" readonly><a href="javascript:void();" class="btn btn-primary radius"><i class="Hui-iconfont" >&#xe642;</i> 浏览图片</a>
											  <input type="button" name="" id="image${editerCount.index+2 }" style="width: 180px;" class="input-file">
											</span>
										</p>
									</div>
									
									<div  class="text-l pl-10 pt-10 pr-10">
										<span class="f-16">正文<font style="color: red;">*</font><font style="font-size: 13px;">(必填，不能超过10000个字符)</font></span>
										<p><textarea rows='10' cols='30' style='width:100%;' name="MoreImageTextMainText" id="mainImageTextMainText${editerCount.index+2 }">${voList.mainText }</textarea></p>
									</div>
									
									<div  class="text-l pl-10 pt-5 pr-10">
										<c:if test="${empty voList.clickOutUrl }">
											<span class="f-16"  id="outlink${editerCount.index+2 }"><a href="javascript:void();" style="color:#0088CC; text-decoration: none;">添加外链接</a></span>
											<p><input type='text' name='outLink' id='chain${editerCount.index+2 }' style="display: none;" class='input-text radius size-M'/></p>
										</c:if>
										<c:if test="${!empty voList.clickOutUrl }">
											<span class="f-16"  id="outlink${editerCount.index+2 }"><span class='f-16'>外链接地址<br/><font style='font-size: 13px;'>(设置后，点击图文消息，不会进入图文详情，而进入外链所设地址)</font></span></span>
											<p><input type='text' value="${voList.clickOutUrl }" name='outLink' id='chain${editerCount.index+2 }' style="display: block;" class='input-text radius size-M'/></p>
										</c:if>
									</div>
									
									<div  class="text-l pl-10 pt-5 pr-10">
										<c:if test="${empty voList.sourceUrl }">
											<span class="f-16"  id="originallink${editerCount.index+2 }"><a href="javascript:void();" style="color:#0088CC; text-decoration: none;">添加原文链接</a></span>
											<p><input type='text' name='originlLink' id='sourceURL${editerCount.index+2 }' style="display: none;" class='input-text radius size-M'/></p>
										</c:if>
										<c:if test="${!empty voList.sourceUrl }">
											<span class="f-16"  id="originallink${editerCount.index+2 }"><span class='f-16'>原文链接<font style='font-size: 13px;'>(在图文详情页面中会生成“阅读原文”链接)</font></span></span>
											<p><input type='text' value="${voList.sourceUrl }" name='originlLink' id='sourceURL${editerCount.index+2 }' style="display: block;" class='input-text radius size-M'/></p>
										</c:if>
									</div>
									
									<div  class="text-l pl-10 pt-20 pr-10 pb-20">
										<input class="btn btn-success radius" type="button" id="submitButton${editerCount.index+2 }" value="保存">&nbsp;&nbsp;&nbsp;
										<input class="btn disabled radius" type="button" value="取消">
									</div>
								</div>
							</form>
						</c:forEach>
					</c:if>
						<c:forEach begin="${fn:length(imgtxtMore.subVoList)+2 }" end="8" var="editerCount">
						<form action="${pageContext.request.contextPath }/admin/wx/updateMoreImageText/${token}" method="post" id="myForm${editerCount }" style="display: none;" name="noedit">
							<div class="text-c bk-gray radius box-shadow">
								<div  class="text-l pl-10 pt-10 pr-10">
									<span class="f-16"><font style="color: red;">*正在编辑${editerCount }号图文</font><font style="font-size: 13px;"></font></span>
								</div>
								<input type="hidden" id="imageTextNO${editerCount }" value=""/>
								<div  class="text-l pl-10 pt-10 pr-10">
									<span class="f-16">标题<font style="color: red;">*</font><font style="font-size: 13px;">(必填，不能超过64个字)</font></span>
									<p><input type="text" value="" name="moreImageTextTitle" id="moreImageTextTitle${editerCount }" class="input-text radius size-M"/></p>
								</div>
								
								<div  class="text-l pl-10 pt-5 pr-10">
									<span class="f-16">封面<font style="color: red;">*</font><font style="font-size: 13px;">(必须上传一张图片, 大图片建议尺寸：360像素 * 200像素)</font></span>
									<p style="width: 300px;">
										<span class="btn-upload form-group" style="width: 300px;">
										  <input class="input-text upload-url radius" style="width: 180px;" value=""  type="text" name="oneImageTextImage" id="imageUrl${editerCount }" readonly><a href="javascript:void();" class="btn btn-primary radius"><i class="Hui-iconfont" >&#xe642;</i> 浏览图片</a>
										  <input type="button" name="" id="image${editerCount }" style="width: 180px;" class="input-file">
										</span>
									</p>
								</div>
								
								<div  class="text-l pl-10 pt-10 pr-10">
									<span class="f-16">正文<font style="color: red;">*</font><font style="font-size: 13px;">(必填，不能超过10000个字符)</font></span>
									<p><textarea rows='10' cols='30' style='width:100%;' name="MoreImageTextMainText" id="mainImageTextMainText${editerCount }"></textarea></p>
								</div>
								
								<div  class="text-l pl-10 pt-5 pr-10">
									<span class="f-16"  id="outlink${editerCount }"><a href="javascript:void();" style="color:#0088CC; text-decoration: none;">添加外链接</a></span>
									<p><input type='text' name='outLink' id='chain${editerCount }' style="display: none;" class='input-text radius size-M'/></p>
								</div>
								
								<div  class="text-l pl-10 pt-5 pr-10">
									<span class="f-16"  id="originallink${editerCount }"><a href="javascript:void();" style="color:#0088CC; text-decoration: none;">添加原文链接</a></span>
									<p><input type='text' name='originlLink' id='sourceURL${editerCount }' style="display: none;" class='input-text radius size-M'/></p>
								</div>
								
								<div  class="text-l pl-10 pt-20 pr-10 pb-20">
									<input class="btn btn-success radius" type="button" id="submitButton${editerCount }" value="保存">&nbsp;&nbsp;&nbsp;
									<input class="btn disabled radius" type="button" value="取消">
								</div>
							</div>
						</form>
					</c:forEach>
				</c:if>
		</div>
	</div>
  </div>
</div>
<script type="text/javascript" src="<%=basePath %>admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="<%=basePath %>admin/lib/Validform/5.3.2/Validform.min.js"></script>  
<script type="text/javascript" src="<%=basePath %>admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="<%=basePath %>admin/js/H-ui.js"></script> 
<script type="text/javascript" src="<%=basePath %>admin/js/H-ui.admin.js"></script> 
<script charset="utf-8" src="<%=basePath %>other/kingedit/kindeditor-min.js"></script>
<script charset="utf-8" src="<%=basePath %>other/kingedit/lang/zh_CN.js"></script>
<script type="text/javascript">
	$(function() {
		//表单保存、数据验证   seriallize()
		<c:forEach begin="1" end="8" var="submitButtonId">
			$("#submitButton${submitButtonId}").click(function() {
				//alert($("#mainImageTextMainText${submitButtonId}").val());
				//var form1 = $("#myForm${submitButtonId}").serializeArray();
				//alert(JSON.stringify(form1));
				var count = 0;//编辑的个数
				var jsonData = [];
				for(var i = 1; i <= 8; i++) {
					if($("#myForm"+i).attr("name")=="edit") {
						count += 1;
						var title = $("#moreImageTextTitle"+i).val();//标题
						var cover = $("#imageUrl"+i).val();//封面
						var content = $("#mainImageTextMainText"+i).val();//内容
						var sourceurl = $("#sourceURL"+i).val()//外链
						var chain = $("#chain"+i).val();//原文
						var imageTextNo = $("#imageTextNO"+i).val();
						if(i == 1) {
							if(imageTextNo == "") {
								layer.msg('要修改的主图文无效！',{icon: 5,time:2000});
								return false;
							}
							if (title == "") {
								layer.msg('标题不能为空！',{icon: 5,time:2000});
								return false;
							}
							if (cover == "") {
								layer.msg('必须上传一个封面图片',{icon: 5,time:2000});
								return false;
							}
							if (chain == "" && content == "") {
								layer.msg('正文或外链接必须填写一项！',{icon: 5,time:2000});
								return false;
							}
						} else {
							if (title == "") {
								layer.msg('副图文标题不能为空！',{icon: 5,time:2000});
								return false;
							}
							if (cover == "") {
								layer.msg('副图文必须上传一个封面图片',{icon: 5,time:2000});
								return false;
							}
							if (chain == "" && content == "") {
								layer.msg('副图文正文或外链接必须填写一项！',{icon: 5,time:2000});
								return false;
							}
						}
						
						
						jsonData[count-1] = {
							rid : imageTextNo,
							title :title,
							cover :cover,
							content :content,
							sourceurl :sourceurl,
							chain :chain
						};
					}
					
				}
				
				//JSON.stringify(delTextId);
				//alert(delTextId.length);
				if(count >= 2) {
					var ajaxUrl = $("#myForm${submitButtonId}").attr("action");
					//alert(JSON.stringify(jsonData));
					var reqJSON = {"jsonData": JSON.stringify(jsonData)};
					if(delTextId.length > 0) {
						reqJSON = {"jsonData": JSON.stringify(jsonData),"jsonDelData": JSON.stringify(delTextId)};
					}
					$.post(ajaxUrl, reqJSON, function(data) {
						if(data.msg == "success") {
							layer.msg("修改成功!", {icon: 6,time:3000});
							location.href = "<%= path %>/admin/wx/showMaterialList";
						} else {
							layer.msg(data.msg, {icon: 5,time:3000});
						}
					});
				} else {
					layer.msg('最少需要两个多图文！',{icon: 5,time:3000});
				} 
			});
		</c:forEach>
	});

</script>
<!-- 页面上的一些处理 -->
<script type="text/javascript">
	var imageTextDivCount = ${fn:length(imgtxtMore.subVoList)};//统计图文素材的个数， 当添加到八个时，提示不能添加
	var delTextId = [];
	$(function() {
		
		//大图遮罩层的高款
		var maxImgWid = $("#maxzhezhao").width();
		var maxImgHei = $("#maxzhezhao").height();
		$("#maxzhezhaoblack").css("width",maxImgWid);
		$("#maxzhezhaoblack").css("height", maxImgHei);
		
		//大图的遮罩层显示和影藏
		$("#maxzhezhao").mouseover(function() {
			$("#maxzhezhaoblack").show();
		});
		$("#maxzhezhao").mouseleave(function() {
			$("#maxzhezhaoblack").hide();
		});
		
		<c:forEach begin="1" end="8" var="count"> 
			//点击添加外链接
			$("#outlink${count}").click(function() {
				$("#outlink${count}").html("<span class='f-16'>外链接地址<br/><font style='font-size: 13px;'>(设置后，点击图文消息，不会进入图文详情，而进入外链所设地址)</font></span>");
				$("#chain${count}").css("display","block");
			});
			
			//点击添加原文链接
			$("#originallink${count}").click(function() {
				$("#originallink${count}").html("<span class='f-16'>原文链接<font style='font-size: 13px;'>(在图文详情页面中会生成“阅读原文”链接)</font></span>");
				$("#sourceURL${count}").css("display","block");
			});
			
			$("#moreImageTextTitle${count}").bind("input propertychange", function(){
				var title = $("#moreImageTextTitle${count}").val();
				if(title.length > 36) {
					title = subString(title, 0, 36);
				}
				$("#title${count}").html(title);
			});
		</c:forEach>
		//添加图文素材按钮
		$("#addMoreImageTextButton").click(function() {
			if(imageTextDivCount >= 7) {
				layer.msg('最多添加8个图文素材',{icon: 5,time:2000});
				return false;
			}
			for(var i = 2; i <= 8; i++) {
				//是否隐藏
				var divDisplay = $("#minMoreImageText"+i).css("display");
				if(divDisplay == "none") {
					$("#minMoreImageText"+i).show();
					imageTextDivCount = imageTextDivCount+1;
					return false;
				}
			}
		});
		
	});
	
	//鼠标进入范围
	function minOverMouse(i) {
		//小图遮罩层的高宽
		var minImgWid = $("#minMoreImageText"+i).width();
		var minImgHei = $("#minMoreImageText"+i).height();
		//小图遮罩层的显示和影藏
		$("#minzhezhaoblack"+i).css("width", minImgWid);
		$("#minzhezhaoblack"+i).css("height", minImgHei);
		$("#minzhezhaoblack"+i).show();
	}
	
	//鼠标离开范围
	function minLeaveMouse(i) {
		$("#minzhezhaoblack"+i).hide();
	}
	
	//删除小图文
	function deleteMinImageText(i) {
		if(imageTextDivCount < 2) {
			layer.msg('最少添加两个素材',{icon: 5,time:2000});
			return false;
		} else {
			if($("#imageTextNO"+i).val() != "" && $("#imageTextNO"+i).val() != null) {
				delTextId.push($("#imageTextNO"+i).val());
				$("#imageTextNO"+i).val("")
			}
			$("#minMoreImageText"+i).css("display","none");
			$("#myForm"+i).attr("name","noedit");
			$("#myForm"+i).css("display","none");
			$("#myForm"+i).each(function() {
				$("#title"+i).html("标题"+i);
				$("#moreImageTextTitle"+i).val("");
				$("#imageUrl"+i).val("");//封面
				$("#mainImageTextMainText"+i).val("");//内容
				$("#sourceURL"+i).val("")//外链
				$("#chain"+i).val("");//原文
			});
			$("#suonueImage"+i).attr("src", "");
			imageTextDivCount = imageTextDivCount - 1;
			
		}
	}
	
	//点击小图文的编辑按钮
	function showEditDiv(i) {
		for(var j = 1; j <= 8; j++) {
			$("#myForm"+j).hide();
		}
		$("#myForm"+i).attr("name","edit");
		$("#myForm"+i).show();
	}
</script>
<script type="text/javascript">
	var options = {
	    	fileManagerJson : '<%= path %>/common/other/kingedit/jsp/file_manager_json.jsp',
	        uploadJson : '<%= path %>/common/other/kingedit/jsp/upload_json.jsp',
	        allowFileManager : true,
	        afterBlur: function(){this.sync();},
	        items : ['fullscreen', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
	                  'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
	                  'emoticons','insertorderedlist', 'insertunorderedlist']
	     }
	KindEditor.ready(function(K) {
	<c:forEach begin='1' end='8' var='j'>
        editor${j} = K.create('#mainImageTextMainText${j}',options);
	</c:forEach>
        prettyPrint();//给编辑器赋值必须添加这个属性
	});
	
	//配置上传插件
	KindEditor.ready(function(K) {
		var editor = K.editor({
			fileManagerJson : '<%= path %>/common/other/kingedit/jsp/file_manager_json.jsp',
            uploadJson : '<%= path %>/common/other/kingedit/jsp/upload_json.jsp',
			allowFileManager : true
		});
		
		<c:forEach begin='1' end='8' var='j'>
			K('#image${j}').click(function() {
				editor.loadPlugin('image', function() {
					editor.plugin.imageDialog({
						imageUrl : K('#imageUrl${j}').val(),
						clickFn : function(url, title, width, height, border, align) {
							K('#imageUrl${j}').val(url);
							//将图片回显到左侧的样板上        background-image:url('/ratfw/common/images/page/audio.png');
							
							if("${j}" == "1") {
								$("#MaxsuonueImage").css("background-image", "url("+url+")");
							} else {
								$("#suonueImage${j}").attr("src", url);
							}
							editor.hideDialog();
						}
					});
				});
			});
		</c:forEach>
		
	});
</script>
</body>
</html>