<!DOCTYPE html>
<html lang="ko"
	  xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : MainContentsPopupForm.html
 * @desc    : 메인전시 컨텐츠 수정 팝업 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================

 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.2.23    bin2107     최초 작성
 *******************************************************************************
 -->
<div class="modalPopup" data-width="1500" th:with="imgGoodsUrl=${@environment.getProperty('upload.goods.view')}, uxImgUrl=${@environment.getProperty('domain.uximage')}, imgUrl=${@environment.getProperty('upload.image.view')}">
	<div class="panelStyle">
		<div class="panelTitle">
			<h2 id="popTitle" th:text="${contentsLoc}"></h2>
			<button type="button" class="close" onclick="fnMainContentsPopupFormClose()"><i class="fa fa-times"></i></button>
		</div>
		<div class="panelContent">
			<ul class="panelBar">
				<li class="aL">
					<span class="cBlue">* 상단으로 드래그&amp;드랍하여 순서 변경 가능합니다.</span>
				</li>
				<li class="aR">
					<button type="button" class="btn btn btn-base btn-sm" id="btnPopAddRow">컨텐츠 추가</button>
					<button type="button" class="btn btn btn-dark btn-sm" id="btnPopSave">임시저장</button>
					<input type="hidden" name="uploadDefaultUrlPop" id="uploadDefaultUrlPop" th:value="${@environment.getProperty('upload.image.view') + '/contents/'}"/>
				</li>
			</ul>
		</div>
		<form style="height:600px; width:1470px; overflow:auto;" id="popSortable">
		</form>
	</div>
</div>

<script type="text/javascript" src="/ux/plugins/summernote/summernote.js?v=2020103001"></script>
<script type="text/javascript" src="/ux/plugins/gaga/gaga.summernote.js?v=2021053101"></script>
<script type="text/javascript" src="/ux/plugins/gaga/gaga.kollus.js"></script>
<script th:inline="javascript">
	/*<![CDATA[*/
	var cateNo = [[${cateNo}]];
	var contentsLoc = [[${contentsLoc}]];
	var brandGroupNo = [[${brandGroupNo}]];
	var contentsLocArr = gagajf.convertToArray([[${contentsLocList}]]);
	var tdWidth = $("#sortable").find("td").width();
	var tdDeleteWidth = parseInt(tdWidth/11, 10);
	tdWidth = tdWidth - tdDeleteWidth;
	var cate1List = [[${cate1List}]];

	var tableLen = 0;		// 테이블 ID

	// 컨텐츠 미리보기 리스트
	var fnGetContentsPreviewList = function() {
		$("#popSortable").html('');
		var data = {cateNo : cateNo
			,contentsLoc : contentsLoc
			,brandGroupNo : brandGroupNo
		};
		var jsonData = JSON.stringify(data);
		gagajf.ajaxJsonSubmit('/display/contents/preview/list', jsonData, fnCreatePopLayout);
	}

	// 데이터 뿌리기
	var createIdx = 0;
	var fnCreatePopLayout = function(result) {
		var html = '';
		var descIdx = '';

		for(var i=0; i<result.length; i++){
			descIdx = i;
			var dispStdt = result[i].dispStdt.split(" ");
			var dispEddt = result[i].dispEddt.split(" ");
			var cate1No = result[i].contentsType;
			html += '<table class="frmStyle mcTable" style="margin-bottom:30px" id="mcTable'+i+'">';
			html += '<input type="hidden" name="tableIdx" value="'+i+'" data-id="'+i+'">';
			html += '<colgroup>';
			html += '<col style="width:10%;"/>';
			html += '<col style="width:55%;"/>';
			html += '<col/>';
			html += '</colgroup>';
			html += '<thead><tr><th>전시일시</th><td><input name="dispStdt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출시작일" data-valid-type="calendar" value="'+dispStdt[0]+'"/>';
			html += '<select name="stTimeHour" required="required" data-valid-name="노출기간 시작시간">';
			html += fnCreateTimeOption(24, dispStdt[1].split(":")[0]);
			html += '</select>';
			html += '<select name="stTimeMin" required="required" data-valid-name="노출기간 시작시간">';
			html += fnCreateTimeOption(60, dispStdt[1].split(":")[1]);
			html += '</select>';
			html += '<span> ~ </span>';
			html += '<input name="dispEddt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출종료일" data-valid-type="calendar" value="'+dispEddt[0]+'"/>';
			html += '<select name="edTimeHour" required="required" data-valid-name="노출기간 종료시간">';
			html += fnCreateTimeOption(24, dispEddt[1].split(":")[0]);
			html += '</select>';
			html += '<select name="edTimeMin" required="required" data-valid-name="노출기간 종료시간">';
			html += fnCreateTimeOption(60, dispEddt[1].split(":")[1]);
			html += '</select>';
			html += '<input name="dispOrd" type="text" class="w80"placeholder="전시순서" style="margin-left:5px; text-align:center" value="'+result[i].dispOrd+'"/>';
			html += '</td>';
			if(contentsLoc!='SCM002' && contentsLoc!='SCM003'){
				html += '<td class="aL">';
				if(contentsLoc!='SMM005'  && contentsLoc!='SMM011' && contentsLoc!='SBM012' && contentsLoc!='SBMM012' && contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SMM003' && contentsLoc!='SMM004'  && contentsLoc!='SMM006'
						&& contentsLoc!='SBM007' && contentsLoc!='SBM008' && contentsLoc!='SBM009' && contentsLoc!='SBM010' && contentsLoc!='SBM011' && contentsLoc!='SBM013' && contentsLoc!='SBM017' && contentsLoc!='SBM018' && contentsLoc!='SBM019'
						&& contentsLoc!='SOM003' && contentsLoc!='SOM004'  && contentsLoc!='SCM004' && contentsLoc!='SBM004' && contentsLoc!='SCM001'){
					html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddTitlePopRow(this);">타이틀추가</button>';
				}
				if(contentsLoc=='SMM002' || contentsLoc=='SBMM004'){
					html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddSubTextPopRow(this);">서브텍스트추가</button>';
				}
				if(contentsLoc=='SBM005' || contentsLoc=='SBMM005'){
					html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddBrandDescRow(this ,\'add\','+i+');">브랜드소개추가</button>';
				}
				if(contentsLoc!='SMM005' && contentsLoc!='SBM005' && contentsLoc!='SBMM005' && contentsLoc!='SGNB001' && contentsLoc!='SGNB002'  && contentsLoc!='SMM011' && contentsLoc!='SBM012' && contentsLoc!='SBMM012' && contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SMM003' && contentsLoc!='SMM004' && contentsLoc!='SMM006'
					&& contentsLoc!='SBM007' && contentsLoc!='SBM008' && contentsLoc!='SBM009' && contentsLoc!='SBM010' && contentsLoc!='SBM011' && contentsLoc!='SBM013' && contentsLoc!='SBM017' && contentsLoc!='SBM018' && contentsLoc!='SBM019' && contentsLoc!='SOM003' && contentsLoc!='SOM004'  && contentsLoc!='SCM004' && contentsLoc!='SBM004' && contentsLoc!='SCM001'){
					html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddImgPopRow(this);">이미지추가</button>';
				}
				if(contentsLoc!='SMM011' && contentsLoc!='SBM012' && contentsLoc!='SBMM012' && contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SMM003' && contentsLoc!='SMM006'  && contentsLoc!='SCM004' && contentsLoc!='SBM004' && contentsLoc!='SCM001' && contentsLoc!='SMM005'
						&& contentsLoc!='SBM007' && contentsLoc!='SBM008' && contentsLoc!='SBM009' && contentsLoc!='SBM010' && contentsLoc!='SBM011' && contentsLoc!='SBM013' && contentsLoc!='SBM017' && contentsLoc!='SBM018' && contentsLoc!='SBM019' && contentsLoc!='SOM003' && contentsLoc!='SOM004' ){
					html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddLinkPopRow(this);">링크추가</button>';
				}
				html += '<button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteContentsRow(this);">삭제</button></td>';
			}
			html += '</tr>';
			if(contentsLoc=='SBM004' || contentsLoc=='SBM005' || contentsLoc=='SBMM004' || contentsLoc=='SBMM005'){
				html += '<tr class="cateTypeTr">';
				html += '	<th>클릭시<br>페이지창</th>';
				html += '	<td colspan="3">';
				if(result[i].contentsType=='SELF'){
					html += '		<label class="rdoBtn"><input type="radio" name="pageTarget'+i+'" value="SELF" checked="checked"/>현재창</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="pageTarget'+i+'" value="BLANK" />새창</label>';
				}else{
					html += '		<label class="rdoBtn"><input type="radio" name="pageTarget'+i+'" value="SELF" />현재창</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="pageTarget'+i+'" value="BLANK" checked="checked"/>새창</label>';
				}
				html += '	</td>';
				html += '</tr>';
			}
			if(contentsLoc=='SMM011' || contentsLoc=='SBM012' || contentsLoc=='SBMM012'){
				html += '<tr class="cateTypeTr">';
				html += '	<th>동영상구분</th>';
				html += '	<td colspan="3">';
				if(result[i].strVar1=='Y'){
					html += '		<label class="rdoBtn"><input type="radio" name="tvPlayer'+i+'" value="Y" onclick="fnChangeTvPlayer(this,'+i+');" checked="checked" />YouTube</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="tvPlayer'+i+'" value="M" onclick="fnChangeTvPlayer(this,'+i+');"/>MP4</label>';
				}else{
					html += '		<label class="rdoBtn"><input type="radio" name="tvPlayer'+i+'" value="Y" onclick="fnChangeTvPlayer(this,'+i+');" />YouTube</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="tvPlayer'+i+'" value="M" onclick="fnChangeTvPlayer(this,'+i+');" checked="checked" />MP4</label>';
				}
				html += '	</td>';
				html += '</tr>';
				html += '<tr class="cateTypeTr" name="tvY'+i+'">';
				html += '	<th>미디어<br>컨텐츠키</th>';
				html += '	<td colspan="3">';
				html += '		<input name="tvMediaKey'+i+'" type="text" class="w150" maxlength="200" data-valid-name="미디어 컨텐츠키" value="'+result[i].strVar2+'" ';
				if(result[i].strVar1=='M'){
					html += ' disabled="disabled" ';
				}
				html += '/>';
				html += '	</td>';
				html += '</tr>';
				if(result[i].strVar1=='M' && (result[i].strVar2==null || result[i].strVar2=='')){
					html += '<tr class="cateTypeTr" name="tvM'+i+'">';
					html +='	<th>파일첨부<em class="required" title="필수"></em></th>';
					html +='	<td class="infoTxt" colSpan="5">';
					html +='		<div class="uFile w300">';
					html +='			<input id="file'+i+'" name="file" type="file" class="uFileInput w300" onchange="fnVideoFileUpload(this, '+i+')"/>';
					html +='			<label for="file'+i+'" class="uFileLabel">파일선택</label>';
					html +='			<input type="hidden" name="kufKey" value="'+result[i].strVar3+'"/>';
					html +='			<input type="hidden" name="kmcKey"/>';
					html +='		</div>';
					html +='	</td>';
					html += '</tr>';
				}
			}
			if(contentsLoc=='SGNB001'){
				var src = '';
				var src2 = '';
				html += '<tr class="cateTypeTr">';
				html += '	<th>유형선택</th>';
				html += '	<td colspan="3">';
				html += '		<label class="rdoBtn"><input type="radio" name="cateType'+i+'" value="OPEN" onclick="fnChangeGnbCateType(this,'+i+');"';
				if(result[i].contentsType=='OPEN'){
					html += ' checked="checked" ';
				}
				html += '/>오픈배너</label>';
				html += '		<label class="rdoBtn"><input type="radio" name="cateType'+i+'" value="IMG" onclick="fnChangeGnbCateType(this,'+i+');" ';
				if(result[i].contentsType=='IMG'){
					html += ' checked="checked" ';
				}
				html += '/>이미지배너</label>';
				html += '		<label class="rdoBtn"><input type="radio" name="cateType'+i+'" value="TEXT" onclick="fnChangeGnbCateType(this,'+i+');" ';
				if(result[i].contentsType=='TEXT'){
					html += ' checked="checked" ';
				}
				html += '/>텍스트배너</label>';
				html += '	</td>';
				html += '</tr>';

				if(!gagajf.isNull(result[i].imgPath1)){
					src = $("#uploadDefaultUrlPop").val().replace('/contents/', '')+result[i].imgPath1;
					src2 = $("#uploadDefaultUrlPop").val().replace('/contents/', '')+result[i].imgPath2;
				}

				html += '<tr name="imgPopRow" id="openBanner0" ';
				if(result[i].contentsType=='TEXT'){
					html += '	style="display:none;"';
				}
				html += '>';
				html += '	<th>띠배너<br>이미지</th>';
				html += '	<td><div class="uFile w300">';
				html += '			<input id="filePop_'+i+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, '+i+', 0)"/>';
				html += '			<label for="filePop_'+i+'" class="uFileLabel">파일선택</label>';
				html += '			<input type="hidden" name="imgPath" value="'+result[i].imgPath1+'"/>';
				html += '			<input type="hidden" name="newImgFile" value="" />';
				html += '		</div>';
				html += '	<div id="imgViewPop_'+i+'" class=';
				if(src!=''){
					html += '"on">';
				}else{
					html += '"off">';
				}
				html += '		<img id="bannerPreViewUrlPop_'+i+'" src="'+src+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>';
				html += '	</div></td>';
				html += '</tr>';

				html += '<tr class="cateTypeTr" name="openBannerTypeTr'+i+'" id="openBannerTypeTr" ';
				if(result[i].contentsType!='OPEN'){
					html += '	style="display:none;"';
				}
				html += '>';
				html += '	<th>확장형 배너<br>유형</th>';
				html += '	<td colspan="3">';
				if(result[i].strVar7=='IMG'){
					html += '		<label class="rdoBtn"><input type="radio" name="openBannerType'+i+'" value="IMG" onclick="fnChangeOpenBannerType(this,'+i+');" checked="checked"/>이미지형</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="openBannerType'+i+'" value="HTML" onclick="fnChangeOpenBannerType(this,'+i+');"/>HTML형</label>';
				}else{
					html += '		<label class="rdoBtn"><input type="radio" name="openBannerType'+i+'" value="IMG" onclick="fnChangeOpenBannerType(this,'+i+');" />이미지형</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="openBannerType'+i+'" value="HTML" onclick="fnChangeOpenBannerType(this,'+i+');" checked="checked"/>HTML형</label>';
				}
				html += '	</td>';
				html += '</tr>';

				html += '<tr name="imgPopRow" id="openBanner1" ';
				if(result[i].contentsType=='OPEN' && result[i].strVar7=='IMG'){
					html += '	style="display:table-row;"';
				}else{
					html += '	style="display:none;"';
				}
				// if((result[i].contentsType!='IMG') || result[i].contentsType!='OPEN' && result[i].strVar7!='IMG'){
				// 	html += '	style="display:none;"';
				// }
				html +='>';
				html += '	<th>오픈배너<br>이미지</th>';
				html += '	<td><div class="uFile w300">';
				html += '			<input id="filePop_100'+i+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, 100'+i+', 1)"/>';
				html += '			<label for="filePop_100'+i+'" class="uFileLabel">파일선택</label>';
				html += '			<input type="hidden" name="imgPath" value="'+result[i].imgPath2+'"/>';
				html += '			<input type="hidden" name="newImgFile" value="" />';
				html += '		</div>';
				html += '	<div id="imgViewPop_100'+i+'" class=';
				if(src!='' && result[i].imgPath2 != ''){
					html += '"on">';
				}else{
					html += '"off">';
				}
				html += '		<img id="bannerPreViewUrlPop_100'+i+'" src="'+src2+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src2\'));"/>';
				html += '	</div></td>';
				html += '</tr>';

				html += '<tr name="imgPopRow" id="openBanner2" ';
				if(result[i].contentsType!='OPEN' || result[i].strVar7!='HTML'){
					html += '	style="display:none;"';
				}
				html += '>';
				html += '	<input type="hidden" name="htmlDesc'+i+'" id="htmlDesc'+i+'" value="'+result[i].html.replaceAll("\"","\'")+'">';
				html += '	<th>오픈배너<br>HTML</th>';
				html += '	<td class="padT10"><div class="tabJrContArea">';
				html += '		<textarea class="textareaR3 summernote" name="openBannerDesc'+i+'" id="openBannerDesc'+i+'" ></textarea>';
				html += '	</div>';
				html += '	</td>';
				html += '</tr>';

				html += '	<tr name="tabBgColorRow'+i+'"';
				if(result[i].contentsType=='TEXT'){
					html += 'style="display:none;"';
				}
				html += ' >';
				html += '		<th>배경 RGB코드</th>';
				html += '		<td><input name="gnbBgColor' + i + '" type="text" maxlength="200" data-valid-name="배경 RGB코드" value="' + result[i].strVar5 + '"/></td>';
				html += '	</tr>';

				html += '	<tr name="tabShowYnRow'+i+'"';
				if(result[i].contentsType!='OPEN'){
					html += 'style="display:none;"';
				}
				html += ' >';
				html += '		<th>확장형 배너<br>닫기 버튼<br>노출여부</th>';
				html += '		<td>';
				if(result[i].strVar8=='Y'){
					html += '			<label class="rdoBtn"><input type="radio" name="todayYn'+i+'" value="Y" checked="checked"/>노출</label>';
					html += '			<label class="rdoBtn"><input type="radio" name="todayYn'+i+'" value="N" />비노출</label>';
				}else{
					html += '			<label class="rdoBtn"><input type="radio" name="todayYn'+i+'" value="Y" />노출</label>';
					html += '			<label class="rdoBtn"><input type="radio" name="todayYn'+i+'" value="N" checked="checked"/>비노출</label>';
				}

				html += '		</td>';
				html += '	</tr>';
			}
			if(contentsLoc=='SGNB002'){
				html += '<tr class="cateTypeTr">';
				html += '	<th>유형선택</th>';
				html += '	<td colspan="3">';
				html += '		<label class="rdoBtn"><input type="radio" name="cateType'+i+'" value="TEXT" onclick="fnChangeGnbCateType(this,'+i+');" ';
				if(result[i].contentsType=='TEXT'){
					html += ' checked="checked" ';
				}
				html += '/>텍스트배너</label>';
				html += '	</td>';
				html += '</tr>';
			}
			if(contentsLoc=='SCM002' || contentsLoc=='SCM003'){
				html += '		<tr>';
				html += '			<th>전시 설정</th>';
				html += '			<td>';
				if(result[i].useYn=='Y'){
					html += '				<label class="rdoBtn"><input type="radio" name="dispYn" value="Y" checked="checked"/>노출</label>';
					html += '				<label class="rdoBtn"><input type="radio" name="dispYn" value="N"/>비노출</label>';
				}else{
					html += '				<label class="rdoBtn"><input type="radio" name="dispYn" value="Y"/>노출</label>';
					html += '				<label class="rdoBtn"><input type="radio" name="dispYn" value="N" checked="checked"/>비노출</label>';
				}
				html += '			</td>';
				if(result[i].contentsLoc=='SCM003'){
					html += '			<th>상품 노출 개수</th>';
					html += '			<td>';
					if(result[i].strVar1=='10'){
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="10" checked="checked"/>10개</label>';
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="20"/>20개</label>';
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="30"/>30개</label>';
					}else if(result[i].strVar1=='20'){
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="10"/>10개</label>';
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="20" checked="checked"/>20개</label>';
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="30"/>30개</label>';
					}else{
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="10"/>10개</label>';
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="20"/>20개</label>';
						html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="30" checked="checked"/>30개</label>';
					}
					html += '			</td>';
				}
				html += '		</tr>';
			}
			if(contentsLoc=='SMM001' || contentsLoc=='SOM001'){
				html += '<tr>';
				html += '	<th>컨텐츠유형</th>';
				html += '	<td class="planArea" name="planArea" id="planArea'+i+'" colspan="3">';
				if(result[i].strVar5=='P'){
					html += '		<label class="rdoBtn"><input type="radio" name="contentsType'+i+'" value="P" onclick="fnChangeContentsType(this,'+i+');" checked="checked"/>기획전</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="contentsType'+i+'" value="E" onclick="fnChangeContentsType(this,'+i+');"/>이벤트</label>';
				}else{
					html += '		<label class="rdoBtn"><input type="radio" name="contentsType'+i+'" value="P" onclick="fnChangeContentsType(this,'+i+');" />기획전</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="contentsType'+i+'" value="E" onclick="fnChangeContentsType(this,'+i+');" checked="checked"/>이벤트</label>';
				}
				if(result[i].strVar5=='P') {
					html += '		<input type="text" class="w100 inputPlan" name="planSq' + i + '" value="' + result[i].strVar6 + '"/>';
					html += '		<button type="button" class="btn btn btn-dark btn-sm btnPlan" onclick="fnSearchPlan(' + i + ');">기획전검색</button>';
				}else{
					html += '		<input type="text" class="w100 inputPlan" name="planSq' + i + '" value="" style="display: none;"/>';
					html += '		<button type="button" class="btn btn btn-dark btn-sm btnPlan" onclick="fnSearchPlan(' + i + ');" style="display: none;">기획전검색</button>';
				}
				html += '	</td>';
				html += '</tr>';
				html += '<tr>';
				html += '	<th>썸네일 <br>글자 색상</th>';
				html += '	<td colspan="3">';
				if(result[i].strVar7=='BLACK'){
					html += '		<label class="rdoBtn"><input type="radio" name="thumTextColor'+i+'" value="BLACK" checked="checked"/>BLACK</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="thumTextColor'+i+'" value="WHITE" />WHITE</label>';
				}else{
					html += '		<label class="rdoBtn"><input type="radio" name="thumTextColor'+i+'" value="BLACK" />BLACK</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="thumTextColor'+i+'" value="WHITE" checked="checked"/>WHITE</label>';
				}
				html += '	</td>';
				html += '</tr>';
			}
			if(contentsLoc=='SMM005'){
				html += '<tr>';
				html += '	<th>배너유형</th>';
				html += '	<td class="bannerArea" id="bannerArea'+i+'">';
				if(result[i].contentsType=='1'){
					html += '		<label class="rdoBtn"><input type="radio" name="bannerType'+i+'" value="1" checked="checked" onclick="fnChangeHalfBannerType(this,'+i+', 1);">1단</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="bannerType'+i+'" value="2" onclick="fnChangeHalfBannerType(this,'+i+', 2);">2단</label>';
				}else{
					html += '		<label class="rdoBtn"><input type="radio" name="bannerType'+i+'" value="1" onclick="fnChangeHalfBannerType(this,'+i+', 1);">1단</label>';
					html += '		<label class="rdoBtn"><input type="radio" name="bannerType'+i+'" value="2" checked="checked" onclick="fnChangeHalfBannerType(this,'+i+', 2);">2단</label>';
				}
				html += '	</td>';
				html += '</tr>';

				var src = '';
				src = $("#uploadDefaultUrlPop").val().replace('/contents/', '');

				html += '<tr name="imgPopRow" id="halfBanner0">\n';
				html += '	<th>1단<br>이미지</th>\n';
				html += '	<td><div class="uFile w300">\n';
				html += '			<input id="filePop_'+i+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, '+i+', 0)"/>\n';
				html += '			<label for="filePop_'+i+'" class="uFileLabel">파일선택</label>\n';
				html += '			<input type="hidden" name="imgPath" value="'+result[i].imgPath1+'"/>\n';
				html += '			<input type="hidden" name="newImgFile" value="" />\n';
				html += '		</div>\n';
				html += '	<div id="imgViewPop_'+i+'" class=';
				if(result[i].imgPath1 !=''){
					html += '"on">';
				}else{
					html += '"off">';
				}
				html += '		<img id="bannerPreViewUrlPop_'+i+'" src="'+src+result[i].imgPath1+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>\n';
				html += '	</div></td>\n';
				html += '</tr>\n';

				html += '<tr name="linkPopRow" id="link1dep">\n';
				html += '	<th>1단 링크<br>(없으면 #)<br>(메인은 /)</th>\n';
				html += '	<td><input name="link" type="text" maxLength="200" required="required" data-valid-name="링크" placeholder="외부 URL 입력시 https:// 붙여주세요. ex)https://www.levis-kids.co.kr" value="'+result[i].strVar1+'"></td>\n';
				html += '	<td class="aL">\n';
				html += '	</td>\n';
				html += '</tr>\n';

				html += '<tr name="imgPopRow" id="halfBanner1"';
				if(result[i].contentsType=='1') {
					html += ' style="display: none;"';
				}
				html +=' >\n';
				html += '	<th>2단<br>이미지</th>\n';
				html += '	<td><div class="uFile w300">';
				html += '			<input id="filePop_100'+i+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, 100'+i+', 1)"/>\n';
				html += '			<label for="filePop_100'+i+'" class="uFileLabel">파일선택</label>\n';
				html += '			<input type="hidden" name="imgPath" value="'+result[i].imgPath2+'"/>\n';
				html += '			<input type="hidden" name="newImgFile" value="" />\n';
				html += '		</div>\n';
				html += '	<div id="imgViewPop_100'+i+'" class=';
				if(result[i].imgPath2!=''){
					html += '"on">';
				}else{
					html += '"off">';
				}
				html += '		<img id="bannerPreViewUrlPop_100'+i+'" src="'+src+result[i].imgPath2+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>\n';
				html += '	</div></td>\n';
				html += '</tr>\n';

				html += '<tr name="linkPopRow" id="link2dep" ';
				if(result[i].contentsType=='1') {
					html += ' style="display: none;" ';
				}
				html += '>\n';
				html += '	<th>2단 링크<br>(없으면 #)<br>(메인은 /)</th>\n';
				html += '	<td><input name="link" type="text" maxLength="200" required="required" data-valid-name="링크" placeholder="외부 URL 입력시 https:// 붙여주세요. ex)https://www.levis-kids.co.kr" value="'+result[i].strVar2+'"></td>\n';
				html += '	<td class="aL">\n';
				html += '	</td>\n';
				html += '</tr>\n';
			}
			html += '</thead><tbody>';
			if(contentsLoc!='SCM002' && contentsLoc!='SCM003' && contentsLoc!='SMM011' && contentsLoc!='SBM012' && contentsLoc!='SBMM012' && contentsLoc!='SMM005'){
				for(var j=1; j<5; j++){
					var strTitle = eval("result["+i+"].strTitle" + j);
					var imgPath = eval("result["+i+"].imgPath" + j);
					var strVar = eval("result["+i+"].strVar" + j);
					var subText = eval("result["+i+"].subText" + j);
					if(strTitle!=null && strTitle!='null' && strTitle!='' ){
						html += fnAddTitlePopRow(strTitle);
					}
					if(contentsLoc!='SGNB001' && contentsLoc!='SGNB002'){
						if(contentsLoc=='SMM001' || contentsLoc=='SBM004' || contentsLoc=='SOM001'){
							if(j<3){
								html += fnAddImgPopRow(imgPath, j);
							}
						}else{
							if(imgPath!=null && imgPath!='null' && imgPath!='' ){
								html += fnAddImgPopRow(imgPath, j);
							}
						}
					}
					if(strVar!=null && strVar!='null' && strVar!='' ){
						html += fnAddLinkPopRow(strVar);
					}
					if(contentsLoc=='SBM005'){
						// if(subText!=null && subText!='null' && subText!='' ){
						if(j==1){
							html += fnAddBrandDescRow(subText);
						}
						// }
					}else if(contentsLoc=='SMM001'){
						if(subText!=null && subText!='null' && subText!='' ){
							html += fnAddSubTextPopRow(subText);
						}else{
							if(j == 1){
								html += fnAddSubTextPopRow();
							}
						}
					}else{
						if(subText!=null && subText!='null' && subText!='' ){
							html += fnAddSubTextPopRow(subText);
						}
					}
				}
			}

			html += '</tbody></table>';
		}
		$("#popSortable").append(html);
		$("#popSortable").sortable();
		$('.schDate').datepicker("destroy");
		$('.schDate').datepicker({
			changeMonth: true,
			changeYear: true,
			defaultDate: $('.schDate').val()
		});

		// SGNB001 일때 확장형 배너 summernote
		if(contentsLoc=='SGNB001'){
			fnOpenBannerSummernote();
		}
		if(contentsLoc=='SBM005'){
			fnBrandDesc();
		}

		tableLen = $(".mcTable").length;
	}

	var fnOpenBannerSummernote = function (){
		$('.mcTable').each(function(){
			let idx = $(this).find('[name=tableIdx]').val();
			let bannerCateType = $("#mcTable"+idx).find('input:radio[name=cateType'+idx+']:checked').val();

			// if(bannerCateType=='OPEN'){
				let htmlDesc = $("#mcTable"+idx).find('input[name=htmlDesc'+idx+']').val();
				var snOptions1 = gagaSn.getToolbarOptions('media');
				gagaSn.createSummernote(snOptions1, '#openBannerDesc'+idx);
				// gagaSn.setContents('#openBannerDesc'+idx, '');
				$('#openBannerDesc'+idx).summernote('code', htmlDesc);
			// }
		});
	}

	var fnChangeTvPlayer = function (obj,idx){
		let tvPlayer = $("#mcTable"+idx).find("input:radio[name=tvPlayer"+idx+"]:checked").val();

		if(tvPlayer == 'Y'){
			$(obj).closest("table").find("[name=tvY"+idx+"]").show();
			$(obj).closest("table").find("[name=tvM"+idx+"]").hide();
			$(obj).closest("table").find("[name=tvMediaKey"+idx+"]").prop('disabled',false);
		}else{
			$(obj).closest("table").find("[name=tvY"+idx+"]").show();
			$(obj).closest("table").find("[name=tvM"+idx+"]").show();
			$(obj).closest("table").find("[name=tvMediaKey"+idx+"]").prop('disabled',true);
		}
	}

	var fnChangeOpenBannerType = function (obj, idx){
		let openBannerType = $("#mcTable"+idx).find("input:radio[name=openBannerType"+idx+"]:checked").val();

		if(openBannerType == 'IMG'){
			$(obj).closest("table").find("[id=openBanner1]").show();
			$(obj).closest("table").find("[id=openBanner2]").hide();
		}else{
			$(obj).closest("table").find("[id=openBanner1]").hide();
			$(obj).closest("table").find("[id=openBanner2]").show();
		}
	}

	var fnChangeGnbCateType = function (obj, idx){
		let cateType = $("#mcTable"+idx).find("input:radio[name=cateType"+idx+"]:checked").val();

		if(cateType=='OPEN'){
			$(obj).closest("table").find("[name=tabBgColorRow"+idx+"]").show();
			$(obj).closest("table").find("[name=tabShowYnRow"+idx+"]").show();
			$(obj).closest("table").find("[name=openBannerTypeTr"+idx+"]").show();
			console.log($(obj).closest("table").find("input:radio[name=openBannerType"+idx+"]:checked").val());
			if($(obj).closest("table").find("input:radio[name=openBannerType"+idx+"]:checked").val()=='HTML'){
				$(obj).closest("table").find("input:radio[name=openBannerType"+idx+"]:input[value=HTML]").prop('checked',true);
				$(obj).closest("table").find("[id=openBanner2]").show();
			}else{
				$(obj).closest("table").find("input:radio[name=openBannerType"+idx+"]:input[value=IMG]").prop('checked',true);
				$(obj).closest("table").find("[id=openBanner2]").hide();
			}
			$(obj).closest("table").find("[id=openBanner0]").show();
			$(obj).closest("table").find("[id=openBanner1]").show();

			// $(obj).closest("table").find("[name=file]").closest('div').find('label').text('파일선택');
			// $(obj).closest("table").find("[name=imgPath]").val('');
			// $(obj).closest("table").find("[name=newImgFile]").val('');
			// $("#bannerPreViewUrlPop_0").attr('src', '');
			// $("#imgViewPop_0").removeClass("on").addClass("off");
			// $("#bannerPreViewUrlPop_1").attr('src', '');
			// $("#imgViewPop_1").removeClass("on").addClass("off");
		}else if(cateType=='IMG'){
			$(obj).closest("table").find("[name=tabBgColorRow"+idx+"]").show();
			$(obj).closest("table").find("[name=tabShowYnRow"+idx+"]").hide();
			$(obj).closest("table").find("[name=openBannerTypeTr"+idx+"]").hide();
			$(obj).closest("table").find("input:radio[name=openBannerType"+idx+"]:input[value=IMG]").prop('checked',true);
			$(obj).closest("table").find("[id=openBanner0]").show();
			$(obj).closest("table").find("[id=openBanner1]").hide();
			$(obj).closest("table").find("[id=openBanner2]").hide();
			// $(obj).closest("table").find("[name=file]").closest('div').find('label').text('파일선택');
			// $(obj).closest("table").find("[name=imgPath]").val('');
			// $(obj).closest("table").find("[name=newImgFile]").val('');
			// $("#bannerPreViewUrlPop_0").attr('src', '');
			// $("#imgViewPop_0").removeClass("on").addClass("off");
			// $("#bannerPreViewUrlPop_1").attr('src', '');
			// $("#imgViewPop_1").removeClass("on").addClass("off");
		}else if(cateType=='TEXT'){
			$(obj).closest("table").find("[name=tabBgColorRow"+idx+"]").hide();
			$(obj).closest("table").find("[name=tabShowYnRow"+idx+"]").hide();
			$(obj).closest("table").find("[name=openBannerTypeTr"+idx+"]").hide();
			$(obj).closest("table").find("input:radio[name=openBannerType"+idx+"]:input[value=IMG]").prop('checked',true);
			$(obj).closest("table").find("[id=openBanner0]").hide();
			$(obj).closest("table").find("[id=openBanner1]").hide();
			$(obj).closest("table").find("[id=openBanner2]").hide();
			// $(obj).closest("table").find("[name=file]").closest('div').find('label').text('파일선택');
			// $(obj).closest("table").find("[name=imgPath]").val('');
			// $(obj).closest("table").find("[name=newImgFile]").val('');
			// $("#bannerPreViewUrlPop_0").attr('src', '');
			// $("#imgViewPop_0").removeClass("on").addClass("off");
			// $("#bannerPreViewUrlPop_1").attr('src', '');
			// $("#imgViewPop_1").removeClass("on").addClass("off");
			if($(obj).closest("table").find("[name=title]").length < 1){
				fnAddTitlePopRow($(obj));
			}
			if($(obj).closest("table").find("[name=link]").length < 1){
				fnAddLinkPopRow($(obj));
			}
		}
	}

	/**
	 * 컨텐츠 추가 버튼
	 */
	var dataIdx=0;
	$("#btnPopAddRow").on("click", function (){
		dataIdx = tableLen;
		if(contentsLoc=='SCM002' || contentsLoc=='SCM003'){
			if($(".mcTable").length > 0){
				mcxDialog.alert('컨텐츠 추가를 1개 이상 할 수 없습니다.');
				return;
			}
		}

		var html = '<table class="frmStyle mcTable" style="margin-bottom:30px" id="mcTable'+dataIdx+'">\n';
		html += '<input type="hidden" name="tableIdx" value="'+dataIdx+'" data-id="'+dataIdx+'">\n';
		html += '<colgroup>\n';
		html += '<col style="width:10%;"/>\n';
		html += '<col style="width:55%;"/>\n';
		html += '<col/>\n';
		html += '</colgroup>\n';
		html += '<thead><tr><th>전시일시</th><td><input name="dispStdt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출시작일" data-valid-type="calendar"/>\n';
		html += '<select name="stTimeHour" required="required" data-valid-name="노출기간 시작시간">';
		html += fnCreateTimeOption(24);
		html += '</select>\n';
		html += '<select name="stTimeMin" required="required" data-valid-name="노출기간 시작시간">';
		html += fnCreateTimeOption(60);
		html += '</select>\n';
		html += '<span> ~ </span>\n';
		html += '<input name="dispEddt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출종료일" data-valid-type="calendar"/>\n';
		html += '<select name="edTimeHour" required="required" data-valid-name="노출기간 종료시간">';
		html += fnCreateTimeOption(24,23);
		html += '</select>\n';
		html += '<select name="edTimeMin" required="required" data-valid-name="노출기간 종료시간">';
		html += fnCreateTimeOption(60,59);
		html += '</select>\n';
		html += '<input name="dispOrd" type="text" class="w80"placeholder="전시순서" style="margin-left:5px; text-align:center"/>\n';
		html += '</td>\n';
		html += '<td class="aL">\n';
		if(contentsLoc!='SCM002' && contentsLoc!='SCM003' && contentsLoc!='SMM011' && contentsLoc!='SBM012' && contentsLoc!='SBMM012' && contentsLoc!='SMM003' && contentsLoc!='SMM004' && contentsLoc!='SMM006'
				&& contentsLoc!='SBM007' && contentsLoc!='SBM008' && contentsLoc!='SBM009' && contentsLoc!='SBM010' && contentsLoc!='SBM011' && contentsLoc!='SBM013' && contentsLoc!='SBM017' && contentsLoc!='SBM018' && contentsLoc!='SBM019'
				&& contentsLoc!='SOM003' && contentsLoc!='SOM004'  && contentsLoc!='SCM004' && contentsLoc!='SMM005'){
			if(contentsLoc!='SMM005'){
				html += '<button type="button" class="btn btn-base btn-lg"';
				if(contentsLoc=='SMM001' || contentsLoc=='SOM001' || contentsLoc=='SBM004' || contentsLoc=='SCM001'){
					html += ' style="display:none;" ';
				}
				html+= ' id="addTitle'+dataIdx+'" onclick="fnAddTitlePopRow(this);">타이틀추가</button>\n';
			}
			if(contentsLoc=='SMM001' || contentsLoc=='SMM002' || contentsLoc=='SBM004' || contentsLoc=='SBMM004' || contentsLoc=='SCM001' || contentsLoc=='SOM001'){
				html += '<button type="button" class="btn btn-base btn-lg"';
				if(contentsLoc=='SMM001' || contentsLoc=='SOM001'|| contentsLoc=='SBM004' || contentsLoc=='SCM001'){
					html += ' style="display:none;" ';
				}
				html += ' id="addSubText'+dataIdx+'" ';
				if(contentsLoc=='SBM004' || contentsLoc=='SCM001'){
					html += ' style="display:none;" ';
				}
				html += ' onclick="fnAddSubTextPopRow(this);">서브텍스트추가</button>\n';
			}
			if(contentsLoc=='SBM005' || contentsLoc=='SBMM005'){
				html += '<button type="button" class="btn btn-base btn-lg" id="addBrandDesc'+dataIdx+'" onclick="fnAddBrandDescRow(this,\'add\','+dataIdx+');">브랜드소개추가</button>\n';
			}
			if(contentsLoc!='SBM005' && contentsLoc!='SBMM005' && contentsLoc!='SGNB001' && contentsLoc!='SGNB002' && contentsLoc!='SMM005') {
				html += '<button type="button" class="btn btn-base btn-lg"';
				if(contentsLoc=='SMM001' || contentsLoc=='SOM001' || contentsLoc=='SBM004' || contentsLoc=='SCM001'){
					html += ' style="display:none;" ';
				}
				html += ' id="addImg'+dataIdx+'" onclick="fnAddImgPopRow(this);">이미지추가</button>\n';
			}
			if(contentsLoc=='SMM001' || contentsLoc=='SOM001' || contentsLoc=='SBM004'){
				html += '<button type="button" style="display: none;" class="btn btn-base btn-lg" id="addMobImg'+dataIdx+'" onclick="fnAddMobImgPopRow(this, '+dataIdx+');">모바일이미지추가</button>\n';
			}
			html += '<button type="button" class="btn btn-base btn-lg"';
			if(contentsLoc=='SMM001' || contentsLoc=='SOM001' || contentsLoc=='SBM004' || contentsLoc=='SCM001'){
				html += ' style="display:none;" ';
			}
			html += ' id="addLink'+dataIdx+'" onclick="fnAddLinkPopRow(this);">링크추가</button>\n';
		}
		html += '<button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteContentsRow(this);">삭제</button></td>\n';
		html += '</tr>\n';
		if(contentsLoc=='SBM004' || contentsLoc=='SBM005' || contentsLoc=='SBMM004' || contentsLoc=='SBMM005'){
			html += '<tr class="cateTypeTr">\n';
			html += '	<th>클릭시<br>페이지창</th>\n';
			html += '	<td colspan="3">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="pageTarget'+dataIdx+'" value="SELF" checked="checked"/>현재창</label>\n';
			html += '		<label class="rdoBtn"><input type="radio" name="pageTarget'+dataIdx+'" value="BLANK" />새창</label>\n';
			html += '	</td>\n';
			html += '</tr>\n';
		}
		if(contentsLoc=='SMM011' || contentsLoc=='SBM012' || contentsLoc=='SBMM012'){
			html += '<tr class="cateTypeTr">\n';
			html += '	<th>동영상구분</th>\n';
			html += '	<td colspan="3">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="tvPlayer'+dataIdx+'" value="Y" onclick="fnChangeTvPlayer(this,'+dataIdx+');" checked="checked" />YouTube</label>\n';
			html += '		<label class="rdoBtn"><input type="radio" name="tvPlayer'+dataIdx+'" value="M" onclick="fnChangeTvPlayer(this,'+dataIdx+');"/>MP4</label>\n';
			html += '	</td>\n';
			html += '</tr>\n';
			html += '<tr class="cateTypeTr" name="tvY'+dataIdx+'">\n';
			html += '	<th>미디어<br>컨텐츠키</th>\n';
			html += '	<td colspan="3">\n';
			html += '		<input name="tvMediaKey'+dataIdx+'" type="text" class="w150" maxlength="200" data-valid-name="미디어 컨텐츠키" value=""/>\n';
			html += '	</td>\n';
			html += '</tr>\n';
			html += '<tr class="cateTypeTr" name="tvM'+dataIdx+'" style="display: none;">\n';
			html +='	<th>파일첨부<em class="required" title="필수"></em></th>\n';
			html +='	<td class="infoTxt" colSpan="5">\n';
			html +='		<div class="uFile w300">\n';
			html +='			<input id="file'+dataIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnVideoFileUpload(this, '+dataIdx+')"/>\n';
			html +='			<label for="file'+dataIdx+'" class="uFileLabel">파일선택</label>\n';
			html +='			<input type="hidden" name="kufKey"/>\n';
			html +='			<input type="hidden" name="kmcKey"/>\n';
			html +='		</div>\n';
			html +='	</td>\n';
			html += '</tr>\n';
		}
		if(contentsLoc=='SGNB001'){
			html += '<tr class="cateTypeTr">\n';
			html += '	<th>유형선택</th>\n';
			html += '	<td colspan="3">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="cateType'+dataIdx+'" value="OPEN" onclick="fnChangeGnbCateType(this,'+dataIdx+');" checked="checked"/>오픈배너</label>\n';
			html += '		<label class="rdoBtn"><input type="radio" name="cateType'+dataIdx+'" value="IMG" onclick="fnChangeGnbCateType(this,'+dataIdx+');"/>이미지배너</label>\n';
			html += '		<label class="rdoBtn"><input type="radio" name="cateType'+dataIdx+'" value="TEXT" onclick="fnChangeGnbCateType(this,'+dataIdx+');"/>텍스트배너</label>\n';
			html += '	</td>\n';
			html += '</tr>\n';

			var src = '';
			html += '<tr name="imgPopRow" id="openBanner0">\n';
			html += '	<th>띠배너<br>이미지</th>\n';
			html += '	<td><div class="uFile w300">\n';
			html += '			<input id="filePop_'+dataIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, '+dataIdx+', 0)"/>\n';
			html += '			<label for="filePop_'+dataIdx+'" class="uFileLabel">파일선택</label>\n';
			html += '			<input type="hidden" name="imgPath" value=""/>\n';
			html += '			<input type="hidden" name="newImgFile" value="" />\n';
			html += '		</div>\n';
			html += '	<div id="imgViewPop_'+dataIdx+'" class=';
			if(src!=''){
				html += '"on">';
			}else{
				html += '"off">';
			}
			html += '		<img id="bannerPreViewUrlPop_'+dataIdx+'" src="'+src+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>\n';
			html += '	</div></td>\n';
			html += '</tr>\n';

			html += '<tr class="cateTypeTr" name="openBannerTypeTr'+dataIdx+'" id="openBannerTypeTr">\n';
			html += '	<th>확장형 배너<br>유형</th>\n';
			html += '	<td colspan="3">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="openBannerType'+dataIdx+'" value="IMG" onclick="fnChangeOpenBannerType(this,'+dataIdx+');" checked="checked"/>이미지형</label>\n';
			html += '		<label class="rdoBtn"><input type="radio" name="openBannerType'+dataIdx+'" value="HTML" onclick="fnChangeOpenBannerType(this,'+dataIdx+');"/>HTML형</label>\n';
			html += '	</td>\n';
			html += '</tr>\n';

			html += '<tr name="imgPopRow" id="openBanner1">\n';
			html += '	<th>오픈배너<br>이미지</th>\n';
			html += '	<td><div class="uFile w300">';
			html += '			<input id="filePop_100'+dataIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, 100'+dataIdx+', 1)"/>\n';
			html += '			<label for="filePop_100'+dataIdx+'" class="uFileLabel">파일선택</label>\n';
			html += '			<input type="hidden" name="imgPath" value=""/>\n';
			html += '			<input type="hidden" name="newImgFile" value="" />\n';
			html += '		</div>\n';
			html += '	<div id="imgViewPop_100'+dataIdx+'" class=';
			if(src!=''){
				html += '"on">';
			}else{
				html += '"off">';
			}
			html += '		<img id="bannerPreViewUrlPop_100'+dataIdx+'" src="'+src+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>\n';
			html += '	</div></td>\n';
			html += '</tr>\n';

			html += '<tr name="imgPopRow" id="openBanner2" style="display: none;">\n';
			html += '	<input type="hidden" name="htmlDesc'+dataIdx+'" id="htmlDesc'+dataIdx+'" value="">\n';
			html += '	<th>오픈배너<br>HTML</th>\n';
			html += '	<td class="padT10"><div class="tabJrContArea">\n';
			html += '		<textarea class="textareaR3 summernote" name="openBannerDesc'+dataIdx+'" id="openBannerDesc'+dataIdx+'"></textarea>\n';
			html += '	</div>\n';
			html += '	</td>\n';
			html += '</tr>\n';

			html += '	<tr name="tabBgColorRow'+dataIdx+'">\n';
			html += '		<th>배경 RGB코드</th>\n';
			html += '		<td><input name="gnbBgColor'+dataIdx+'" type="text" maxlength="200" data-valid-name="배경 RGB코드" value=""/></td>\n';
			html += '	</tr>\n';
			html += '	<tr name="tabShowYnRow'+dataIdx+'">\n';
			html += '		<th>확장형 배너<br>닫기 버튼<br>노출여부</th>\n';
			html += '		<td>\n';
			html += '			<label class="rdoBtn"><input type="radio" name="todayYn'+dataIdx+'" value="Y" checked="checked"/>노출</label>\n';
			html += '			<label class="rdoBtn"><input type="radio" name="todayYn'+dataIdx+'" value="N" />비노출</label>\n';
			html += '		</td>\n';
			html += '	</tr>\n';
		}
		if(contentsLoc=='SGNB002'){
			html += '<tr class="cateTypeTr">\n';
			html += '	<th>유형선택</th>\n';
			html += '	<td colspan="3">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="cateType'+dataIdx+'" value="TEXT" onclick="fnChangeGnbCateType(this,'+dataIdx+');" checked="checked"/>텍스트배너</label>\n';
			html += '	</td>\n';
			html += '</tr>\n';
		}
		if(contentsLoc=='SCM002' || contentsLoc=='SCM003'){
			html += '		<tr>\n';
			html += '			<th>전시 설정</th>\n';
			html += '			<td>\n';
			html += '				<label class="rdoBtn"><input type="radio" name="dispYn" value="Y" checked="checked"/>노출</label>\n';
			html += '				<label class="rdoBtn"><input type="radio" name="dispYn" value="N"/>비노출</label>\n';
			html += '			</td>\n';
			if(contentsLoc=='SCM003'){
				html += '			<th>상품 노출 개수</th>\n';
				html += '			<td>\n';
				html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="10" checked="checked"/>10개</label>\n';
				html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="20"/>20개</label>\n';
				html += '				<label class="rdoBtn"><input type="radio" name="dispCnt" value="30"/>30개</label>\n';
				html += '			</td>\n';
			}
			html += '		</tr>\n';
		}
		if(contentsLoc=='SMM001' || contentsLoc=='SOM001'){
			html += '<tr>\n';
			html += '	<th>컨텐츠유형</th>\n';
			html += '	<td class="planArea" name="planArea" id="planArea'+dataIdx+'" colspan="3">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="contentsType'+dataIdx+'" value="P" onclick="fnChangeContentsType(this,'+dataIdx+');" checked="checked"/>기획전</label>\n';
			html += '		<label class="rdoBtn"><input type="radio" name="contentsType'+dataIdx+'" value="E" onclick="fnChangeContentsType(this,'+dataIdx+');"/>이벤트</label>\n';
			html += '		<input type="text" class="w100 inputPlan" name="planSq'+dataIdx+'" value=""/>\n';
			html += '		<button type="button" class="btn btn btn-dark btn-sm btnPlan" onclick="fnSearchPlan('+dataIdx+');">기획전검색</button>\n';
			html += '	</td>\n';
			html += '</tr>\n';
			html += '<tr>\n';
			html += '	<th>썸네일 <br>글자 색상</th>\n';
			html += '	<td colspan="3">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="thumTextColor'+dataIdx+'" value="BLACK" checked="checked"/>BLACK</label>\n';
			html += '		<label class="rdoBtn"><input type="radio" name="thumTextColor'+dataIdx+'" value="WHITE" />WHITE</label>\n';
			html += '	</td>\n';
			html += '</tr>\n';
		}
		if(contentsLoc=='SMM005'){
			html += '<tr>\n';
			html += '	<th>배너유형</th>\n';
			html += '	<td class="bannerArea" id="bannerArea'+dataIdx+'">\n';
			html += '		<label class="rdoBtn"><input type="radio" name="bannerType'+dataIdx+'" value="1" checked="checked" onclick="fnChangeHalfBannerType(this,'+dataIdx+', 1);">1단</label>';	/*onclick="fnChangeBannerType(this,1);"\n*/
			html += '		<label class="rdoBtn"><input type="radio" name="bannerType'+dataIdx+'" value="2" onclick="fnChangeHalfBannerType(this,'+dataIdx+', 2);">2단</label>\n';
			html += '	</td>\n';
			html += '</tr>\n';
			var src = '';
			html += '<tr name="imgPopRow" id="halfBanner0">\n';
			html += '	<th>1단<br>이미지</th>\n';
			html += '	<td><div class="uFile w300">\n';
			html += '			<input id="filePop_'+dataIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, '+dataIdx+', 0)"/>\n';
			html += '			<label for="filePop_'+dataIdx+'" class="uFileLabel">파일선택</label>\n';
			html += '			<input type="hidden" name="imgPath" value=""/>\n';
			html += '			<input type="hidden" name="newImgFile" value="" />\n';
			html += '		</div>\n';
			html += '	<div id="imgViewPop_'+dataIdx+'" class=';
			if(src!=''){
				html += '"on">';
			}else{
				html += '"off">';
			}
			html += '		<img id="bannerPreViewUrlPop_'+dataIdx+'" src="'+src+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>\n';
			html += '	</div></td>\n';
			html += '</tr>\n';

			html += '<tr name="linkPopRow" id="link1dep">\n';
			html += '	<th>1단 링크<br>(없으면 #)<br>(메인은 /)</th>\n';
			html += '	<td><input name="link" type="text" maxLength="200" required="required" data-valid-name="링크" placeholder="외부 URL 입력시 https:// 붙여주세요. ex)https://www.levis-kids.co.kr"></td>\n';
			html += '	<td class="aL">\n';
			html += '	</td>\n';
			html += '</tr>\n';

			html += '<tr name="imgPopRow" id="halfBanner1" style="display: none;">\n';
			html += '	<th>2단<br>이미지</th>\n';
			html += '	<td><div class="uFile w300">';
			html += '			<input id="filePop_100'+dataIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnGnbFileUpload(this, 100'+dataIdx+', 1)"/>\n';
			html += '			<label for="filePop_100'+dataIdx+'" class="uFileLabel">파일선택</label>\n';
			html += '			<input type="hidden" name="imgPath" value=""/>\n';
			html += '			<input type="hidden" name="newImgFile" value="" />\n';
			html += '		</div>\n';
			html += '	<div id="imgViewPop_100'+dataIdx+'" class=';
			if(src!=''){
				html += '"on">';
			}else{
				html += '"off">';
			}
			html += '		<img id="bannerPreViewUrlPop_100'+dataIdx+'" src="'+src+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>\n';
			html += '	</div></td>\n';
			html += '</tr>\n';

			html += '<tr name="linkPopRow" id="link2dep" style="display: none;">\n';
			html += '	<th>2단 링크<br>(없으면 #)<br>(메인은 /)</th>\n';
			html += '	<td><input name="link" type="text" maxLength="200" required="required" data-valid-name="링크" placeholder="외부 URL 입력시 https:// 붙여주세요. ex)https://www.levis-kids.co.kr"></td>\n';
			html += '	<td class="aL">\n';
			html += '	</td>\n';
			html += '</tr>\n';
		}
		html += '</thead><tbody>\n';
		html += '</tbody></table>\n';

		$("#popSortable").prepend(html);
		$("#popSortable").sortable();
		$('.schDate').datepicker("destroy");
		$('.schDate').datepicker({
			changeMonth: true,
			changeYear: true,
			defaultDate: $('.schDate').val()
		});
		if(contentsLoc=='SMM001' || contentsLoc=='SOM001' || contentsLoc=='SBM004' || contentsLoc=='SCM001' || contentsLoc == 'SMM002'){
			$("#addTitle"+dataIdx).click();
			$("#addSubText"+dataIdx).click();
			$("#addLink"+dataIdx).click();
			$("#addImg"+dataIdx).click();
			if(contentsLoc=='SMM001' || contentsLoc=='SOM001' || contentsLoc=='SBM004'){
				$("#addMobImg"+dataIdx).click();
			}
		}
		if(contentsLoc=='SGNB002' || contentsLoc=='SMM008' || contentsLoc=='SBM006' || contentsLoc=='SBM014' || contentsLoc=='SBM015' || contentsLoc=='SBM016' || contentsLoc=='SCM005' || contentsLoc=='SOM005' || contentsLoc=='SAD001'){
			$("#addTitle"+dataIdx).click();
			if(contentsLoc=='SMM008'|| contentsLoc=='SBM006' || contentsLoc=='SBM014' || contentsLoc=='SBM015' || contentsLoc=='SBM016' || contentsLoc=='SCM005' || contentsLoc=='SOM005' || contentsLoc=='SAD001'){
				$("#addImg"+dataIdx).click();
			}
			$("#addLink"+dataIdx).click();
		}

		if(contentsLoc=='SGNB001'){
			$("#addLink"+dataIdx).click();
			gagaSn.setContents('#openBannerDesc'+dataIdx, '');
		}

		if(contentsLoc == 'SBM005'){
			$("#addTitle"+dataIdx).click();
			$("#addBrandDesc"+dataIdx).click();
			$("#addLink"+dataIdx).click();
		}

		fnResetDispOrd();
		tableLen = tableLen+1;
	});

	var fnVideoFileUpload = function (obj, idx){
		var file = obj.files[0];

		gagaKollus.upload('Display', file, $(obj).find('input[name=kufKey]'));
	}

	var fnChangeBannerType = function (obj, idx){
		if(idx==1){
			$(obj).closest("table").find("[id=bannerImgTr1]").show();
			$(obj).closest("table").find("[id=bannerLinkTr1]").show();
			$(obj).closest("table").find("[id=bannerImgTr2]").hide();
			$(obj).closest("table").find("[id=bannerLinkTr2]").hide();
		}else{
			$(obj).closest("table").find("[id=bannerImgTr1]").show();
			$(obj).closest("table").find("[id=bannerLinkTr1]").show();
			$(obj).closest("table").find("[id=bannerImgTr2]").show();
			$(obj).closest("table").find("[id=bannerLinkTr2]").show();
		}
	}

	// 몰메인>메인롤링배너 컨텐츠유형 선택시
	var fnChangeContentsType = function (obj, idx){
		var radioVal = $(obj).closest("td").find("input[name=contentsType"+idx+"]:checked").val();
		if(radioVal=='P'){
			$("#planArea"+idx+" .inputPlan").show();
			$("#planArea"+idx+" .btnPlan").show();
		}else{
			$("#planArea"+idx).find("input[name=planSq"+idx+"]").val('');
			$("#planArea"+idx+" .inputPlan").hide();
			$("#planArea"+idx+" .btnPlan").hide();
		}
	}

	// 몰메인>메인롤링배너 기획전 조회
	var tableDataId = 0;
	var fnSearchPlan = function (idx){
		cfnOpenPlanPopup('callbackPlanPopup');
		tableDataId = idx;
	}

	var callbackPlanPopup = function (result){
		$("#mcTable"+tableDataId+" .planArea").find("input[name=planSq"+tableDataId+"]").val(result[0].planSq);
		$("#mcTable"+tableDataId).find("tr[name=titlePopRow]").find("input[name=title]").val(result[0].planNm);
		$("#mcTable"+tableDataId).find("tr[name=subTextPopRow]").find("input[name=subText]").val(result[0].dtlTitle1);
		$("#mcTable"+tableDataId).find("tr[name=linkPopRow]").find("input[name=link]").val('/planning/detail/form?planSq='+result[0].planSq);
		$("#mcTable"+tableDataId).find("tr[id=mobImgPop]").find("input[name=imgPath]").val(result[0].mainPimg);
		if(!gagajf.isNull(result[0].mainPimg)){
			let pcImgIdx = $("#mcTable"+tableDataId).find('.pcImg').find('input[name=imgIdx]').attr('pcImg-idx');
			if(contentsLoc=='SOM001'){
				$("#mcTable"+tableDataId).find('.pcImg').find("#bannerPreViewUrlPop_"+pcImgIdx).attr('src', $("#uploadDefaultUrlPop").val().replace('/contents/', '')+result[0].mainPimg);
				$("#mcTable"+tableDataId).find('.pcImg').find("#imgViewPop_"+pcImgIdx).removeClass("off").addClass("on");
			}
			$("#mcTable"+tableDataId).find('.mobImg').find("#bannerPreViewUrlPop_"+tableDataId).attr('src', $("#uploadDefaultUrlPop").val().replace('/contents/', '')+result[0].mainPimg);
			$("#mcTable"+tableDataId).find('.mobImg').find("#imgViewPop_"+tableDataId).removeClass("off").addClass("on");
		}

		let stdt = result[0].dispStdt.split(" ");
		let eddt = result[0].dispEddt.split(" ");
		let stdtTime;
		let eddtTime;

		$("#mcTable"+tableDataId).find("[name=dispStdt]").val(stdt[0]);
		$("#mcTable"+tableDataId).find("[name=dispEddt]").val(eddt[0]);
		if(!gagajf.isNull(stdt[1])){
			stdtTime = stdt[1].split(":");
		}
		if(!gagajf.isNull(eddt[1])){
			eddtTime = eddt[1].split(":");
		}
		$("#mcTable"+tableDataId).find("[name=stTimeHour]").val(stdtTime[0]+'시').prop("selected", true);
		$("#mcTable"+tableDataId).find("[name=stTimeMin]").val(stdtTime[1]+'분').prop("selected", true);
		$("#mcTable"+tableDataId).find("[name=edTimeHour]").val(eddtTime[0]+'시').prop("selected", true);
		$("#mcTable"+tableDataId).find("[name=edTimeMin]").val(eddtTime[1]+'분').prop("selected", true);
	}

	// SMM001 데이터 validation 체크
	function smm001DataValidation(){
		var dataBool = true;
		let dupCnt = 0;
		$(".mcTable").each(function(i){
			var thisIdx = $(this).find("input[name=tableIdx]").val();
			var contentsTypeVal = $(this).find("input:radio[name=contentsType"+thisIdx+"]:checked").val();
			var textColorVal = $(this).find("input:radio[name=thumTextColor"+thisIdx+"]:checked").val();
			var imgVal = $(this).find(".pcImgFile").find("input[name=imgPath]").val();
			var newImgVal = $(this).find(".pcImgFile").find("input[name=newImgFile]").val();
			var mImgVal = $(this).find(".mobImgFile").find("input[name=imgPath]").val();
			var mNewImgVal = $(this).find(".mobImgFile").find("input[name=newImgFile]").val();

			if(gagajf.isNull(contentsTypeVal)){
				mcxDialog.alert((i+1)+'번째 컨텐츠 유형을 선택해주세요.');
				dupCnt++;
				return false;
			}
			if(contentsTypeVal=='P'){
				if(gagajf.isNull($(this).find("input[name=planSq"+thisIdx+"]").val())){
					mcxDialog.alert((i+1)+'번째 기획전 번호를 입력해주세요.');
					$(this).find("input[name=planSq"+thisIdx+"]").focus();
					dupCnt++;
					return false;
				}
			}
			if(gagajf.isNull(textColorVal)){
				mcxDialog.alert((i+1)+'번째 썸네일 글자 색상을 선택해주세요.');
				dupCnt++;
				return false;
			}
			if(gagajf.isNull(imgVal) && gagajf.isNull(newImgVal)){
				mcxDialog.alert((i+1)+'번째 이미지를 선택해주세요.');
				dupCnt++;
				return false;
			}
			if(gagajf.isNull(mImgVal) && gagajf.isNull(mNewImgVal)){
				mcxDialog.alert((i+1)+'번째 모바일용 이미지를 선택해주세요.');
				dupCnt++;
				return false;
			}
		});
		// if(!dataBool){
		// 	return false;
		// }else{
		// 	return true;
		// }
		if(dupCnt==0){
			return true;
		}
	}

	// 전시 일시 체크
	function dateValidation(){
		var dateBool = true;
		let dupCnt = 0;
		$(".mcTable").each(function(i){
			var thisIdx = $(this).find("input[name=tableIdx]").val();
			var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
			var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";

			let fromDate = dispStdt.replace(/[^0-9]/g, '');
			let toDate = dispEddt.replace(/[^0-9]/g, '');
			if(fromDate > toDate){
				mcxDialog.alert((i+1) +"번째 " +"시작일자는 종료일자 보다 클 수 없습니다.");
				$(this).find('input[name=dispStdt]').focus();
				// dateBool = false;
				dupCnt++;
				return false;
			}
		});
		// if(!dateBool){
		// 	return false;
		// }else{
		// 	return true;
		// }
		if(dupCnt==0){
			return true;
		}
	}

	// 동영상 확장자 체크
	function videoValidation(){
		var dataBool = true;
		let dupCnt = 0;
		$(".mcTable").each(function(i){
			var thisIdx = $(this).find("input[name=tableIdx]").val();
			if($(this).find("input:radio[name=tvPlayer"+thisIdx+"]:checked").val()=='M' && ($(this).find("input[name=tvMediaKey"+thisIdx+"]").val()==null || $(this).find("input[name=tvMediaKey"+thisIdx+"]").val()=='')){
				var fileName = $(this).find("input:file[name=file]").val();
				var ext =  fileName.split('.').pop().toLowerCase();
				if(ext!='mp4'&&ext!='MP4'){
					mcxDialog.alert((i+1) +'번째 ' +ext+'파일은 업로드 하실 수 없습니다.');
					$(this).find("input:radio[name=tvPlayer"+thisIdx+"]").focus();
					dupCnt++;
					return false;
				}
			}
		});

		// if(!dataBool){
		// 	return false;
		// }else{
		// 	return true;
		// }
		if(dupCnt==0){
			return true;
		}
	}

	var bannerDataValidation = function (){
		var dataBool = true;
		let dupCnt = 0;
		$(".mcTable").each(function(i) {
			var thisIdx = $(this).find("input[name=tableIdx]").val();
			var bannerType = $(this).find("input[name=bannerType"+thisIdx+"]:checked").val();

			if(bannerType == 1){
				if(gagajf.isNull($("#mcTable"+thisIdx+" #halfBanner0").find("input[name=imgPath]").val())){
					if(gagajf.isNull($("#mcTable"+thisIdx+" #halfBanner0").find("input[name=newImgFile]").val())){
						mcxDialog.alert((i+1) +'번째 컨텐츠 1단 이미지를 선택해주세요.');
						dupCnt++;
						return false;
					}
				}

				if(gagajf.isNull($("#mcTable"+thisIdx+" #link1dep").find("input[name=link]").val())){
					mcxDialog.alert((i+1) +'번째 컨텐츠 1단 링크를 입력해주세요.');
					dupCnt++;
					return false;
				}
			}else{
				if(gagajf.isNull($("#mcTable"+thisIdx+" #halfBanner0").find("input[name=imgPath]").val())){
					if(gagajf.isNull($("#mcTable"+thisIdx+" #halfBanner0").find("input[name=newImgFile]").val())){
						mcxDialog.alert((i+1) +'번째 컨텐츠 1단 이미지를 선택해주세요.');
						dupCnt++;
						return false;
					}
				}

				if(gagajf.isNull($("#mcTable"+thisIdx+" #link1dep").find("input[name=link]").val())){
					mcxDialog.alert((i+1) +'번째 컨텐츠 1단 링크를 입력해주세요.');
					dupCnt++;
					return false;
				}

				if(gagajf.isNull($("#mcTable"+thisIdx+" #halfBanner1").find("input[name=imgPath]").val())){
					if(gagajf.isNull($("#mcTable"+thisIdx+" #halfBanner1").find("input[name=newImgFile]").val())){
						mcxDialog.alert((i+1) +'번째 컨텐츠 2단 이미지를 선택해주세요.');
						dupCnt++;
						return false;
					}
				}

				if(gagajf.isNull($("#mcTable"+thisIdx+" #link2dep").find("input[name=link]").val())){
					mcxDialog.alert((i+1) +'번째 컨텐츠 2단 링크를 입력해주세요.');
					dupCnt++;
					return false;
				}
			}
		});
		if(dupCnt==0){
			return true;
		}
		// if(!dataBool){
		// 	return false;
		// }else{
		// 	return true;
		// }
	}

	var dateNullValidation = function (){
		var dateBool = true;
		let dupCnt = 0;
		$(".mcTable").each(function(i){
			if(gagajf.isNull($(this).find("[name=dispStdt]").val())){
				mcxDialog.alert((i+1) +"번째 " +"시작일자를 입력해주세요.");
				$(this).find('input[name=dispStdt]').focus();
				// dateBool = false;
				dupCnt++;
				return false;
			}

			if(gagajf.isNull($(this).find("[name=dispEddt]").val())){
				mcxDialog.alert((i+1) +"번째 " +"종료일자를 입력해주세요.");
				$(this).find('input[name=dispEddt]').focus();
				// dateBool = false;
				dupCnt++;
				return false;
			}

			var thisIdx = $(this).find("input[name=tableIdx]").val();
			var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
			var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";

			let fromDate = dispStdt.replace(/[^0-9]/g, '');
			let toDate = dispEddt.replace(/[^0-9]/g, '');
			if(fromDate > toDate){
				mcxDialog.alert((i+1) +"번째 " +"시작일자는 종료일자 보다 클 수 없습니다.");
				$(this).find('input[name=dispStdt]').focus();
				// dateBool = false;
				dupCnt++;
				return false;
			}
		});
		// if(!dateBool){
		// 	return false;
		// }else{
		// 	return true;
		// }
		if(dupCnt==0){
			return true;
		}
	}

	/**
	 * 임시저장
	 */
	var dataArr = [];
	$("#btnPopSave").on("click", function (){
		if(contentsLoc != 'SMM005'){
			if (!gagajf.checkRequired("#popSortable")) {
				return;
			}
		}else{
			// 전시일시 체크
			if(!dateNullValidation()){
				return false;
			}
		}

		// 전시일시 체크
		if(!dateValidation()){
			return false;
		}

		if(contentsLoc=='SMM011' || contentsLoc=='SBM012'){
			if(!videoValidation()){
				return false;
			}
		}

		if(contentsLoc=='SMM001' || contentsLoc=='SOM001'){
			if(!smm001DataValidation()){
				return false;
			}
		}

		if(contentsLoc == 'SMM005'){
			if(!bannerDataValidation()){
				return false;
			}
		}

		var titleBool = true;
		$("#popSortable").find('input[name=title]').each(function(idx, title) {
			if ($(title).val()==''){
				titleBool = false;
				$(title).focus();
				gagajf.alertMessage($(title), 'input');
				return;
			}
		});
		if(!titleBool){
			return false;
		}
		dataArr = [];
		$("#popSortable table").each(function(){
			var newImgFileArr = [];
			var imgPath1 = '';
			var imgPath2 = '';
			var imgPath3 = '';
			var imgPath4 = '';
			var strVar1 = '';
			var strVar2 = '';
			var strVar3 = '';
			var strVar4 = '';
			var strVar5 = '';
			var strVar6 = '';
			var strVar7 = '';
			var strVar8 = '';
			var strTitle1 = '';
			var strTitle2 = '';
			var strTitle3 = '';
			var strTitle4 = '';
			var subText1 = '';
			var subText2 = '';
			var subText3 = '';
			var subText4 = '';
			var contentsType = '';
			var useYn = 'Y';
			var html = '';
			var i = 1;
			$(this).find('input[name=imgPath]').each(function(){
				eval("imgPath" + i + "='"+$(this).val()+"'");
				i++;
			});
			$(this).find('input[name=newImgFile]').each(function(){
				newImgFileArr.push($(this).val());
			});
			i = 1;
			$(this).find('input[name=title]').each(function(){
				var title = $(this).val().replace(/[\']/gi, "\\'");
				eval("strTitle" + i + "='"+title+"'");
				i++;
			});
			i = 1;
			$(this).find('input[name=link]').each(function(){
				_mall = [[${@environment.getProperty('domain.front')}]];
				var val = $(this).val();
				val = val.replace('https:'+_mall, '');
				val = val.replace('http:'+_mall, '');
				val = val.replace(_mall, '');
				eval("strVar" + i + "='"+val+"'");
				i++;
			});

			i = 1;
			$(this).find('input[name=subText]').each(function(){
				var subText = $(this).val().replace(/[\']/gi, "\\'");
				eval("subText" + i + "='"+subText+"'");
				i++;
			});

			if(contentsLoc=='SBM005'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				subText1 = $(this).find("textarea[id=brandDesc"+thisIdx+"]").val();
			}

			if(contentsLoc=='SMM011' || contentsLoc=='SBM012' || contentsLoc=='SBMM012'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				strVar1 = $(this).find("input:radio[name=tvPlayer"+thisIdx+"]:checked").val();
				strVar2 = $(this).find("input[name=tvMediaKey"+thisIdx+"]").val();
				strVar3 = $(this).find("input[name=kufKey]").val();
			}

			var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
			var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";

			var dispOrd = $(this).find("[name=dispOrd]").val();

			if(contentsLoc=='SBM004' || contentsLoc=='SBM005' || contentsLoc=='SBMM004' || contentsLoc=='SBMM005'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				contentsType = $(this).find("input:radio[name=pageTarget"+thisIdx+"]:checked").val();
			}
			if(contentsLoc=='SGNB001'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				contentsType = $(this).find("input:radio[name=cateType"+thisIdx+"]:checked").val();
				strVar5 = $(this).find("input[name=gnbBgColor"+thisIdx+"]").val();
				strVar6 = $(this).find("input[name=gnbTextColor"+thisIdx+"]").val();
				strVar8 = $(this).find("input:radio[name=todayYn"+thisIdx+"]:checked").val();
				if(contentsType=='OPEN'){
					strVar7 = $(this).find("input:radio[name=openBannerType"+thisIdx+"]:checked").val();
				}else{
					strVar7 = '';
				}
				if($(this).find("input:radio[name=openBannerType"+thisIdx+"]:checked").val() == 'HTML'){
					html = $(this).find("textarea[name=openBannerDesc"+thisIdx+"]").val();
				}
			}
			if(contentsLoc=='SGNB002'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				contentsType = $(this).find("input:radio[name=cateType"+thisIdx+"]:checked").val();
			}

			if(contentsLoc=='SMM001' || contentsLoc=='SOM001'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				strVar5 = $(this).find("input:radio[name=contentsType"+thisIdx+"]:checked").val();
				strVar6 = $(this).find("input[name=planSq"+thisIdx+"]").val();
				strVar7 = $(this).find("input:radio[name=thumTextColor"+thisIdx+"]:checked").val();
			}

			if(contentsLoc=='SMM005'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				contentsType = $(this).find("input:radio[name=bannerType"+thisIdx+"]:checked").val();
			}

			if(contentsLoc=='SCM002' || contentsLoc=='SCM003'){
				useYn = $(this).find("input:radio[name=dispYn]:checked").val();
			}
			if(contentsLoc=='SCM003'){
				strVar1 = $(this).find("input:radio[name=dispCnt]:checked").val();
			}

			var data = {cateNo : cateNo
				, contentsLoc : contentsLoc
				, contentsType : contentsType
				, dispStdt : dispStdt
				, dispEddt : dispEddt
				, newImgFileArr : newImgFileArr
				, imgPath1 : imgPath1
				, imgPath2 : imgPath2
				, imgPath3 : imgPath3
				, imgPath4 : imgPath4
				, strVar1 : strVar1
				, strVar2 : strVar2
				, strVar3 : strVar3
				, strVar4 : strVar4
				, strVar5 : strVar5
				, strVar6 : strVar6
				, strVar7 : strVar7
				, strVar8 : strVar8
				, strTitle1 : strTitle1
				, strTitle2 : strTitle2
				, strTitle3 : strTitle3
				, strTitle4 : strTitle4
				, subText1 : subText1
				, subText2 : subText2
				, subText3 : subText3
				, subText4 : subText4
				, useYn : useYn
				, dispOrd : dispOrd
				, brandGroupNo : brandGroupNo
				, html : html
			};

			dataArr.push(data);
		});

		if(dataArr.length==0){
			var data = {cateNo : cateNo
				, contentsLoc : contentsLoc
				, brandGroupNo : brandGroupNo
			};
			dataArr.push(data);
		}else{
			var dataArrSort = [];
			dataArr.forEach(function(item, index){
				if(dataArr[index].dispOrd>0){
					for(var i=1; i<dataArr.length; i++){
						if(i>index){
							if(dataArr[index].dispOrd==dataArr[i].dispOrd){
								dataArr[i].dispOrd = Number(dataArr[i].dispOrd) + 1;
							}
						}
					}
				}
			});
			dataArr.forEach(function(item, index){
				if(dataArr[index].dispOrd != ''){
					dataArrSort[dataArr[index].dispOrd-1] = item;
				}
			});
			dataArr.forEach(function(item, index){
				if(dataArr[index].dispOrd == ''){
					var empty = false;
					for(var i=0; i<dataArrSort.length; i++){
						if(typeof dataArrSort[i] == 'undefined'){
							dataArrSort[i] = item;
							empty = true;
							break;
						}
					};
					if(!empty){
						dataArrSort.push(item);
					}
				}
			});
			dataArr = dataArrSort;
		}

		var jsonData = JSON.stringify(dataArr);
		// console.log('jsonData::'+jsonData);
		mcxDialog.confirm('컨텐츠를 저장 하시겠습니까?', {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function(){
				gagajf.ajaxJsonSubmit('/display/contents/preview/save', jsonData, fnGetContentsPreviewList);
			}
		});
	});

	/**
	 * 파일첨부
	 */
	var fnPopFileUpload = function (obj, ind){
		var file = obj.files[0];

		file.name = 'test';
		if (typeof(file) == 'undefined'){
			return;
		}
		console.log('ind>>>>'+ind);
		// 파일 업로드
		gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents'
				, file
				, function(result) {
					$(obj).closest('div').find('input:hidden[name=newImgFile]').val(result.newFileName);
					$("#bannerPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultUrlPop").val()+result.newFileName);
					$("#imgViewPop_"+ind).removeClass("off").addClass("on");
				}
				, 'image'
		);
	}

	/**
	 * GNB배너 파일 첨부
	 */
	var fnGnbFileUpload = function (obj, ind, num){
		var file = obj.files[0];

		file.name = 'test';
		if (typeof(file) == 'undefined'){
			return;
		}
		var $obj = $(obj);
		console.log('data-id::'+$("#mcTable"+ind).find('input[name=tableIdx]').val());

		// 파일 업로드
		gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents'
				, file
				, function(result) {
					$(obj).closest('div').find('input:hidden[name=newImgFile]').val(result.newFileName);
					$("#bannerPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultUrlPop").val()+result.newFileName);
					$("#imgViewPop_"+ind).removeClass("off").addClass("on");
				}
				, 'image'
		);
	}

	/**
	 * 링크추가
	 */
	var fnAddLinkPopRow = function (param){
		var val = typeof param=='object'?'#':param;
		var html = '<tr name="linkPopRow">';
		html += '<th>링크 (없으면 #)<br>(메인은 /)</th>';
		html += '<td><input name="link" type="text" maxlength="200" required="required" data-valid-name="링크" placeholder="외부 URL 입력시 https:// 붙여주세요. ex)https://www.levis-kids.co.kr" value="'+val+'"/></td>';
		if(contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SCM001' && contentsLoc!='SBM004' && contentsLoc!='SMM005'){
			html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
		}
		html += '</tr>';
		if(typeof param == 'object'){
			if(contentsLoc=='SMM005'){
				if($(param).closest("table").find("tbody").find("tr[name=linkPopRow]").length>1){
					mcxDialog.alert("링크는 최대 2개까지 등록 가능합니다");
					return;
				}
			}else{
				if($(param).closest("table").find("tbody").find("tr[name=linkPopRow]").length>0){
					mcxDialog.alert("링크는 1개까지 등록 가능합니다");
					return;
				}
			}

			$(param).closest("table").find("tbody").append(html);
		}else{
			return html;
		}
	}

	/**
	 * 서브텍스트추가
	 */
	var fnAddSubTextPopRow = function (param){
		var val = typeof param=='object'?'':param;
		if(gagajf.isNull(val)){
			val = '';
		}
		var html = '<tr name="subTextPopRow">'
		html += '<th>서브텍스트</th>';
		html += '<td><input type="text" name="subText" maxlength="200" value="'+val+'"/></td>';
		if(contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SCM001' && contentsLoc!='SBM004'){
			html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
		}
		html += '</tr>';
		if(typeof param == 'object'){
			if($(param).closest("table").find("tbody").find("tr[name=subTextPopRow]").length>0){
				mcxDialog.alert("서브텍스트는 1개까지 등록 가능합니다");
				return;
			}
			$(param).closest("table").find("tbody").append(html);
		}else{
			return html;
		}
	}

	/**
	 * 브랜드 소개추가
	 */
	var brandDescIndex = 0;
	var fnAddBrandDescRow = function (param , gubun, idx){
		if(gubun=='add'){
			var thisIdx = $("#mcTable"+idx).find("input[name=tableIdx]").val();
			brandDescIndex = thisIdx;
		}

		var val = typeof param=='object'?'':param;
		if(!gagajf.isNull()){
			val = val.replaceAll('&lt;','<').replaceAll('&gt;', '>').replaceAll('&quot;', '"');
		}

		var html = '<tr name="subTextPopRow">'
		html += '<th>브랜드소개';
		html += '<br/>';
		html += '<span id="brandDescContent'+brandDescIndex+'">0</span>/4,000Byte';
		html += '</th>';
		html += '<td>';
		html += '<textarea class="textareaR4" style="resize: none;" name="subText" id="brandDesc'+brandDescIndex+'" onkeyup="cfnGetTextLength(this, 4000, $(\'#brandDescContent'+brandDescIndex+'\'));" >'+val+'</textarea>';
		html += '</td>';
		html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
		html += '</tr>';
		if(typeof param == 'object'){
			brandDescIndex++;
			if($(param).closest("table").find("tbody").find("tr[name=subTextPopRow]").length>0){
				mcxDialog.alert("브랜드소개는 1개까지 등록 가능합니다");
				return;
			}
			$(param).closest("table").find("tbody").append(html);
		}else{
			brandDescIndex++;
			return html;
		}
	}

	/**
	 * 이미지 추가
	 */
	var imgIndex = 0;
	var fnAddImgPopRow = function (param, idx){
		var src = '';
		var imgPath = '';
		if(typeof param!='object'){
			src = $("#uploadDefaultUrlPop").val().replace('/contents/', '')+param;
			imgPath = param;
		}
		var html = '<tr class="pcImg" name="imgPopRow">';
		html += '<input type="hidden" name="imgIdx" pcImg-idx="'+imgIndex+'" />';
		if(idx>1){
			if(contentsLoc != 'SMM005'){
				html += '<th>모바일용 이미지';
			}else{
				html += '<th>이미지';
			}
		}else{
			html += '<th>이미지';
		}
		html += '</th>';
		html += '<td><div class="uFile w300';
		if(idx>1){
			html += ' mobImgFile';
		}else{
			html += ' pcImgFile';
		}
		html +=' ">';
		html += '<input id="filePop_'+imgIndex+'" name="file" type="file" class="uFileInput w300" onchange="fnPopFileUpload(this, '+imgIndex+')"/>';
		html += '<label for="filePop_'+imgIndex+'" class="uFileLabel">파일선택</label>';
		html += '<input type="hidden" name="imgPath" value="'+imgPath+'"/>';
		html += '<input type="hidden" name="newImgFile" value="" />';
		html += '</div>';
		html += '<div id="imgViewPop_'+imgIndex+'" class=';
		if(src!='' && imgPath !=''){
			html += '"on">';
		}else{
			html += '"off">';
		}
		html += '<img id="bannerPreViewUrlPop_'+imgIndex+'" src="'+src+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>';
		html += '</div></td>';
		if(contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SCM001' && contentsLoc!='SBM004' && contentsLoc!='SMM005'){
			html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
		}
		html += '</tr>';
		if(typeof param == 'object'){
			if(contentsLoc=='SMM005'){
				if($(param).closest("table").find("tbody").find("tr[name=imgPopRow]").length>1){
					mcxDialog.alert("이미지는 최대 2개까지 등록 가능합니다");
					return;
				}
			}else{
				if(contentsLoc=='SMM001' || contentsLoc=='SBM004'|| contentsLoc=='SOM001'){

				}else{
					if($(param).closest("table").find("tbody").find("tr[name=imgPopRow]").length>0){
						mcxDialog.alert("이미지는 1개까지 등록 가능합니다");
						return;
					}
				}
			}
			imgIndex++;
			$(param).closest("table").find("tbody").append(html);
			return html;
		}else{
			imgIndex++;
			return html;
		}
	}

	/**
	 * 모바일용 이미지 추가
	 */
	var imgMobIndex = 0;
	var fnAddMobImgPopRow = function (param , idx){
		imgMobIndex = idx;
		var src = '';
		var imgPath = '';
		if(typeof param!='object'){
			src = $("#uploadDefaultUrlPop").val().replace('/contents/', '')+param;
			imgPath = param;
		}
		var html = '<tr class="mobImg" name="imgPopRow" id="mobImgPop">';
		html += '<th>모바일용 이미지';
		html += '</th>';
		html += '<td><div class="uFile w300 mobImgFile">';
		html += '<input id="filePop_100'+imgMobIndex+'" name="file" type="file" class="uFileInput w300" onchange="fnPopFileUpload(this, 100'+imgMobIndex+')"/>';
		html += '<label for="filePop_100'+imgMobIndex+'" class="uFileLabel">파일선택</label>';
		html += '<input type="hidden" name="imgPath" value="'+imgPath+'"/>';
		html += '<input type="hidden" name="newImgFile" value="" />';
		html += '</div>';
		html += '<div id="imgViewPop_100'+imgMobIndex+'" class=';
		if(src!=''){
			html += '"on">';
		}else{
			html += '"off">';
		}
		html += '<img id="bannerPreViewUrlPop_100'+imgMobIndex+'" src="'+src+'" style="height:100px; max-width:500px;"  onclick="cfnOpenImagePreViewPopup(\'bannerPreimgViewPop\',$(this).attr(\'src\'));"/>';
		html += '</div></td>';
		if(contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SCM001' && contentsLoc!='SBM004'){
			html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
		}
		html += '</tr>';
		if(typeof param == 'object'){
			if(contentsLoc=='SMM005'){
				if($(param).closest("table").find("tbody").find("tr[name=imgPopRow]").length>1){
					mcxDialog.alert("이미지는 최대 2개까지 등록 가능합니다");
					return;
				}
			}else{
				if(contentsLoc=='SMM001' || contentsLoc=='SBM004'|| contentsLoc=='SOM001'){

				}else{
					if($(param).closest("table").find("tbody").find("tr[name=imgPopRow]").length>0){
						mcxDialog.alert("이미지는 1개까지 등록 가능합니다");
						return;
					}
				}
			}
			imgMobIndex++;
			$(param).closest("table").find("tbody").append(html);
		}else{
			imgMobIndex++;
			return html;
		}
	}

	/**
	 * 타이틀추가
	 */
	var fnAddTitlePopRow = function (param){
		var val = typeof param=='object'?'':param;
		var html = '<tr name="titlePopRow">';
		html += '<th>타이틀</th>';
		html += '<td><input name="title" type="text" maxlength="200" data-valid-name="타이틀" value="'+val+'"/></td>';
		if(contentsLoc!='SMM001' && contentsLoc!='SOM001' && contentsLoc!='SCM001' && contentsLoc!='SBM004'){
			html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
		}
		html += '</tr>';
		if(typeof param == 'object'){
			if($(param).closest("table").find("tbody").find("tr[name=titlePopRow]").length>0){
				mcxDialog.alert("타이틀은 1개까지 등록 가능합니다");
				return;
			}
			$(param).closest("table").find("tbody").append(html);
		}else{
			return html;
		}
	}

	// 컨텐츠 행삭제
	var fnDeleteContentsRow = function (obj){
		mcxDialog.confirm('삭제시 전시순서가 초기화됩니다. 삭제하시겠습니까?', {
			cancelBtnText: "취소",
			sureBtnText: "확인",
			sureBtnClick: function(){
				$(obj).closest("table").remove();
				fnResetDispOrd();
			}
		});
	}

	// 행삭제
	var fnDeleteTrRow = function (obj){
		$(obj).closest("tr").remove();
	}

	// 컨텐츠 추가 날짜 설정
	var fnCreateTimeOption = function(val, sel) {
		var html = '';
		for(var i=0; i<val; i++){
			var time = 0;
			if(i<10){
				time = '0'+i;
			}else {
				time = i;
			}
			var select = false;
			if(sel==time){
				select = true;
			}
			if(val==24){
				time += '시';
			}else if(val==60){
				time += '분';
			}
			html += '<option value="'+time+'"';
			if(select){
				html += 'selected="selected"';
			}
			html += '>'+time+'</option>';
		}
		return html;
	}

	// 동영상파일 선택 시
	$('#popSortable input[name=file]').on('change', function() {
		var file = this.files[0];

		gagaKollus.upload('Display', file, $('input[name=kufKey]'));
	});

	// 창닫기
	var fnMainContentsPopupFormClose = function (){
		uifnPopupClose('popupMainContents');
	}

	var fnResetDispOrd = function (){
		$('.mcTable').each(function (idx){
			$(this).find('input[name=dispOrd]').val(idx+1);
			if(contentsLoc=='SBM005'){
				var thisIdx = $(this).find("input[name=tableIdx]").val();
				$(this).find('textarea[name=subText]').attr('id','brandDesc'+thisIdx);
			}
		});
	}

	let fnBrandDesc = function (){
		$(".mcTable").each(function (idx){
			console.log('idx:'+idx);
			if(!gagajf.isNull($(this).find('textarea[name=subText]').val())){
				console.log('idx:>'+idx);
				cfnGetTextLength($(this).find('textarea[name=subText]'), 4000, $('#brandDescContent'+idx));
			}
		});
	}

	var fnChangeHalfBannerType = function (obj, tableNum, num){
		if(num==1){
			$("#mcTable"+tableNum+" #halfBanner1").find("input[name=imgPath]").val('');
			$("#mcTable"+tableNum+" #halfBanner1").find("input[name=newImgFile]").val('');
			$("#mcTable"+tableNum+" #halfBanner1 #imgViewPop_100"+tableNum).removeClass("on");
			$("#mcTable"+tableNum+" #halfBanner1 #bannerPreViewUrlPop_100"+tableNum).attr("src","");
			$("#mcTable"+tableNum+" #halfBanner1 .uFileLabel").text('');
			$("#mcTable"+tableNum+" #link2dep").find("input[name=link]").val('');
			$("#mcTable"+tableNum+" #halfBanner1").hide();
			$("#mcTable"+tableNum+" #link2dep").hide();
		}else{
			$("#mcTable"+tableNum+" #halfBanner1").show();
			$("#mcTable"+tableNum+" #link2dep").show();
		}
	}

	$(document).ready(function() {
		$("#popTitle").text("["+contentsLoc+"] "+gagaAgGrid.lookupValue(contentsLocArr, contentsLoc));

		$("#popSortable").disableSelection();
		fnGetContentsPreviewList();

		$("#popSortable").sortable({
			stop: function(event, ui) {
				//fnResetTabIdx();
				fnResetDispOrd();
			}
		});

	});
	/*]]>*/
</script>

</html>
