/*
 * Popup Java Script
 *
 * 모든 팝업은 공통으로 사용할 수 있기 때문에 여기에 함수를 등록해 처리한다.
 *
 * Copyright (c) 2014 gagamel (exrkorea.com)
 *
 * $Date: 2014-06-13$
 */

/**
 * @type   : function
 * @access : public
 * @desc   : 팝업창 window.open 에서 사용되는 방식으로 features 설정
 * <pre>
 *     cfOpenWindowPopup('/popup.do?cmd=getIDPassword', 'popup', 710, 610);
 *
 *     or
 *
 *     cfOpenWindowPopup('/popup.do?cmd=getIDPassword', 'popup', 710, 610, 1, 400, 200, 'no', '');
 * </pre>
 * @param  : theURL - 새창의 Url
 * @param  : winName - 새창의 name
 * @param  : width	- 넓이
 * @param  : height - 높이
 * @param  : center - 위치센터여부 1: 센터 else 임의 0
 * @param  : left - center 1 이 아닐 경우 세팅
 * @param  : top - center 1 이 아닐 경우 세팅
 * @param  : scrollbars - 스크롤 사용여부 'yes' or 'no'
 * @param  : resizable - 사이즈 조정여부 'yes' or 'no'
 * @param  : fstate - 새창의 기타 세부 설정
 * @return : None
 */
function cfOpenWindowPopup(theURL, winName, width, height, center, left, top, scrollbars, resizable, fstate) {
	var features = "width=" + width;
	features += ",height=" + height;

	var state = "";
	if (center == undefined) center = 1;
	if (scrollbars == undefined) scrollbars = 'no';
	if (fstate == undefined) fstate = '';
	if (left == undefined) left = 100;
	if (top == undefined) top = 100;
	if (resizable == undefined) resizable = 'no';

	if (center == 1) {
		if (fstate == "") {
			state = features + ", left=" + (screen.width-width)/2 + ",top=" + (screen.height-height)/2+",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=0,menubar=0";
		} else {
			state = fstate + ", " + features + ", left=" + (screen.width-width)/2 + ",top=" + (screen.height-height)/2+",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=0,menubar=0";
		}
	} else {
		if (fstate == "") {
			state = features + ", left=" + left + ",top=" + top +",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=0,menubar=0";
		} else {
			state = fstate + ", " + features + ", left=" + left + ",top=" + top +",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=0,menubar=0";
		}
	}

	var win = window.open(theURL, winName, state);
	win.focus();
}

/**
 * @type   : function
 * @access : public
 * @desc   : 모달팝업 오픈
 * <pre>
 *     cfnOpenModalPopup('/goods/detail?goodsCd=G2019060500022', '');
 * </pre>
 * @param  : actionUrl - 로딩 URL
 * @param  : oTarget - 로딩 URL을 표시할 target ID
 * @since  : 2019/06/05
 * @author : gagamel
 */
var cfnOpenModalPopup = function(actionUrl, oTarget) {
	var str = '<div class="popupWrap" id="' + oTarget + '"></div>';

	if ($('#'+ oTarget).length == 0) {
		$('body').append(str);
	}

	$("#" + oTarget).load(actionUrl, function() {
		uifnPopupOpen(oTarget);

		$('.schDate').datepicker({
			changeMonth: true,
			changeYear: true,
			defaultDate: $('.schDate').val()
		});
	});
}

/**
 * @type   : function
 * @access : public
 * @desc   : MD 목록 팝업
 * <pre>
 *     cfnOpenMdListPopup();
 *     or
 *     cfnOpenMdListPopup('fnResult');
 *     or
 *     cfnOpenMdListPopup('fnResult', '홍길동');
 * </pre>
 * @since  : 2020/11/04
 * @author : gagamel
 */
var cfnOpenMdListPopup = function(callbackfn, userNm) {
	var actionUrl = '/business/md/list/form';
	if (typeof(callbackfn) != 'undefined') actionUrl += "?callbackFn=" + callbackfn;
	if (typeof(userNm) != 'undefined') actionUrl += "&mdNm=" + encodeURIComponent(userNm) + '&searchGb=userNm';
	cfnOpenModalPopup(actionUrl, "popupMdList");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 상품등록/복사 팝업 오픈
 * <pre>
 *     cfnOpenGoodsRegisterPopup('N', 'G2014120100098');
 * </pre>
 * @param  : mode - 모드(상세:U, 복사:C). 필수
 * @param  : goodsCd - 상품코드. 옵션
 * @since  : 2019/06/12
 * @author : eskim
 */
var cfnOpenGoodsDetailPopup = function(mode, goodsCd) {
	var actionUrl = "/goods/detail/form?mode=" + mode;

	if (typeof(goodsCd) != "undefined") {
		actionUrl += "&goodsCd=" + goodsCd;
	}
	uifnPopupClose('popupGoodsDetail');
	cfnOpenModalPopup(actionUrl, 'popupGoodsDetail');
}

//
/**
 * @type   : function
 * @access : public
 * @desc   : 엑셀업로드 팝업 호출
 * <pre>
 *     cfnExcelUploadPopup('infoRsvtGoodsSave', 'infoRsvtGoodsExcelSave');
 * </pre>
 * @param  : procJob - 업무명
 * @param  : callBackFun - CallBack 함수
 * @since  : 2019/07/29
 * @author : ESKIM
 */
var cfnExcelUploadPopup = function(procJob, callBackFun) {
	var params = "?procJob=" + procJob;
	if (typeof(callBackFun) != 'undefined' & callBackFun != ""){
		params += "&callBackFun=" + callBackFun;
	};
	var actionUrl = "/common/excel/upload/popup/form" ;
	cfnOpenModalPopup(actionUrl+ params,'popupExcelUpload');
};

/**
 * @type   : function
 * @access : public
 * @desc   : 주문 상세 팝업
 * <pre>
 *     cfnOpenOrderDetailPopup('주문번호');
 * </pre>
 * @param  : orderNo - 주문번호:필수
 * @since  : 2019/12/10
 * @author : yhkim
 */
var cfnOpenOrderDetailPopup = function(ordNo) {
	var actionUrl = "/order/detail/info";
	if (typeof(ordNo) != 'undefined') actionUrl += "?ordNo=" + ordNo;
	cfnOpenModalPopup(actionUrl, "popupOrderDetail");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 이미지 미리보기  팝업 열기
 * <pre>
 *     cfnOpenImagePreViewPopup('custNo');
 * </pre>
 * @param  : Id - object id
 * @since  : 2019/12/12
 * @author : eskim
 */
//이미지 미리보기  팝업 열기
var cfnOpenImagePreViewPopup = function(id,imgUrl) {

	var str = '<div class="videoPopup" data-width="700" data-height="350" id="'+id+'" style="z-index:30">';
	str = str + '<button type="button" class="close" onclick="uifnPopupClose(\''+id+'\')"><i class="fa fa-times"></i></button>';
	str = str + '<img id="imagePreView" src="/image/no.png" onerror="this.src=\'/image/no.png\';" />';
	str = str + '</div>';

	if ($('#'+ id).length == 0) {
		$('body').append(str);
	}

	var $thisId = $("#"+id + ">.videoPopup");
	var popW = parseInt( $thisId.attr("data-width") );
	var popH = parseInt( $thisId.attr("data-height") );
	$("#imagePreView").attr("src", imgUrl);
	//$($thisId).css({display:"block"});
	$("#"+id).css({display:"block"});
}

/**
 * @type   : function
 * @access : public
 * @desc   : 비디오 팝업
 * <pre>
 *     cfnOpenGoodsVideoPopup('goodsVideoView', 'videoUrl','#goodsDetailVideoForm', 'Y' );
 * </pre>
 * @param  : Id - object id
 * @since  : 2019/12/16
 * @author : eskim
 */
//비디오 팝업 열기
var cfnOpenGoodsVideoPopup = function(id, objId, formid, type, fullUrl) {

	var src = $(formid).find("#"+objId).val();
	var str = '';
	str += '<div class="videoPopup"  style="width:700px; height:350px"  id="'+id+'">';
	str += '<button type="button" class="close" onclick="uifnPopupClose(\''+id+'\')"><i class="fa fa-times"></i></button>';
	//if(src.indexOf('http://')!=-1 || src.indexOf('https://')!=-1 && src.indexOf('youtube')==-1){
	if ("M" == type){
		str += '<iframe id="video" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>';
	}else{
		str +='<iframe id="video" frameborder="0" allow="encrypted-media" allowfullscreen></iframe>';
	}
	str += '</div>';

	if ($('#'+ id).length == 0) {
		$('body').append(str);
	}

	var $thisId = $("#"+id + ">.videoPopup");
	var popW = parseInt( $thisId.attr("data-width") );
	var popH = parseInt( $thisId.attr("data-height") );
	//if(src.indexOf('//')!=-1 || src.indexOf('//')!=-1 && src.indexOf('youtube')==-1){
	if ("M" == type){
		//$("#video").css({height:500, width:500});
		src = 'https://v.kr.kollus.com/' + src;
		$("#video").attr("src", src+"?player_version=html5");
	}else{
		$("#video").css({width:popW, height:popH});
		if (typeof(fullUrl) != 'undefined' && fullUrl != ""){
			$("#video").attr("src", src+"?enablejsapi=1&version=3&playerapiid=ytplayer");
		}else{
			src = 'https://www.youtube.com/embed/' + src + '?showinfo=0&rel=0&vp=hd1080&fs=0&wmode=opaque&enablejsapi=1';
			$("#video").attr("src", src+"&version=3&playerapiid=ytplayer");
		}
	}
	$("#"+id).css({display:"block"});
}

/**
 * @type   : function
 * @access : public
 * @desc   : 상품 이미지 보기
 * <pre>
 *     cfnOpenGoodsImagePopup('G2014120100098','BK','BLACK','U');
 * </pre>
 * @param  : goodsCd - 상품코드. 옵션
 * @since  : 2020/12/22
 * @author : eskim
 */
var cfnOpenGoodsImagePopup = function(goodsCd, colorCd, colorNm, mode) {
	var actionUrl = "/goods/image/form?goodsCd=" + goodsCd +"&colorCd=" + colorCd +"&colorNm=" + encodeURIComponent(colorNm)  +"&mode=" + mode;

	uifnPopupClose('popupGoodsImage');
	cfnOpenModalPopup(actionUrl, 'popupGoodsImage');
}


/**
 * @type   : function
 * @access : public
 * @desc   : 상품 이미지 보기
 * <pre>
 *     cfnOpenGoodsImageMassPopup('G2014120100098');
 * </pre>
 * @param  : goodsCd - 상품코드. 옵션
 * @since  : 2020/11/27
 * @author : eskim
 */
//var cfnOpenGoodsImageMassPopup = function(goodsCd, colorCd, colorNm, mode) {
//	var actionUrl = "/goods/image/mass/form?goodsCd=" + goodsCd +"&colorCd=" + colorCd +"&colorNm=" + encodeURIComponent(colorNm)  +"&mode=" + mode;

//	uifnPopupClose('popupGoodsImageMass');
//	cfnOpenModalPopup(actionUrl, 'popupGoodsImageMass');
//}

/**
 * @type   : function
 * @access : public
 * @desc   : 카테고리 조회 팝업
 * <pre>
 *     cfnOpenCategoryPopup('callbackfunction');
 * </pre>
 * @param  : callbackfunction -콜백함수
 * @since  : 2019/12/20
 * @author : sasa004
 */
var cfnOpenCategoryPopup = function(callbackfun, siteCd) {
	var actionUrl = "/display/category/popup/form";
	if (typeof(callbackfun) == 'undefined'){
		return;
	}
	actionUrl += "?callBackFun=" + callbackfun;
	if (typeof(siteCd) != 'undefined') actionUrl += "&siteCd=" + siteCd;
	cfnOpenModalPopup(actionUrl, "popupCategory");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 상품평 상세팝업
 * <pre>
 *     cfnOpenReviewDetailPopup(127);
 * </pre>
 * @param  : reviewSq - 상품평일련번호
 * @since  : 2021/04/26
 * @author : gagamel
 */
var cfnOpenReviewDetailPopup = function(reviewSq) {
	cfnOpenModalPopup('/marketing/review/detail/form?reviewSq=' + reviewSq, "popupReviewDetail");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 상품조회 팝업
 * <pre>
 *     cfnOpenGoodsPopup('goosCallbackFun');
 * </pre>
 * @param  : callbackfun - 콜백함수
 * @since  : 2020/01/17
 * @author : eskim
 */
var cfnOpenGoodsPopup = function(callbackfun) {
	var actionUrl = "/goods/popup/list/form";
	if (typeof(callbackfun) != 'undefined') actionUrl += "?callBackFun=" + callbackfun;

	cfnOpenModalPopup(actionUrl,'popupGoods');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 사은품조회 팝업
 * <pre>
 *     cfnOpenFreeGoodsPopup('callbackfn');
 * </pre>
 * @param  : callbackfun - 콜백함수
 * @since  : 2021/01/12
 * @author : xodud1202
 */
var cfnOpenFreeGoodsPopup = function(callbackFn) {
	var actionUrl = "/goods/freeGoods/popup/list/form";
	if (typeof(callbackFn) != 'undefined') actionUrl += "?callbackFn=" + callbackFn;
	uifnPopupClose('popupFreeGoodsList');
	cfnOpenModalPopup(actionUrl,'popupFreeGoodsList');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 전시/기획전 상품 순서변경 팝업
 * <pre>
 *     cfnOpenGoodsDispOrdChangePopup('goosCallbackFun');
 * </pre>
 * @param  : callbackfun - 콜백함수
 * @since  : 2020/01/30
 * @author : sasa004
 */
var cfnOpenGoodsDispOrdChangePopup = function(callbackfun, params) {
	var actionUrl = "/display/goods/dispord/change/popup/form";
	if (typeof(callbackfun) != 'undefined') actionUrl += "?callBackFun=" + callbackfun;
	if (typeof(params) != 'undefined') actionUrl += "&" + params;
	cfnOpenModalPopup(actionUrl,'popupGoodsDispOrdChange');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 포인트 조회 상세 팝업
 * <pre>
 *     cfnOpenPointDetailPopup('callbackfunction');
 * </pre>
 * @param  : callbackfunction -콜백함수
 * @since  : 2020/02/07
 * @author : jaewonHo
 */
var cfnOpenPointDetailPopup = function(callbackfun, siteCd, custNo) {
	var actionUrl = "/marketing/point/detail/popup/form";
	if (typeof(callbackfun) == 'undefined'){
		return;
	}
	actionUrl += "?callBackFun=" + callbackfun;
	if (typeof(siteCd) != 'siteCd') actionUrl += "&siteCd=" + siteCd;
	if (typeof(siteCd) != 'custNo') actionUrl += "&custNo=" + custNo;
	cfnOpenModalPopup(actionUrl, "popupPointDetail");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 쿠폰등록(수정) 팝업 cpnId존재시 수정모드
 * <pre>
 *     cfnCouponCreate(cpnId, 'couponCreateCallbackFun');
 * </pre>
 * @param  : callbackfun - 콜백함수
 * @since  : 2020/02/10
 * @author : LMC
 */
function cfnCouponCreatePopup(mode, cpnId, callbackfun){
	var actionUrl = "/marketing/coupon/popup/form?mode=" + mode;
	if (typeof(cpnId) != 'undefined') actionUrl += "&cpnId=" + cpnId;
	if (typeof(callbackfun) != 'undefined') actionUrl += "&callBackFun=" + callbackfun;
	cfnOpenModalPopup(actionUrl,'CouponRegForm');
}


/**
 * @type   : function
 * @access : public
 * @desc   : LMS 팝업
 * <pre>
 *     var param = {};
 *     param.elementCellPhnno = 'input[name=cellPhnno]';
 *     param.elementCustNo = 'input[name=custNo]';
 *     param.elementMaskingCellPhnno = 'textarea[name=elementMaskingCellPhnno]'; //선택
 *     paras.pageGb = 'delv'; // 선택
 *     cfnOpenLmsPopup(param);
 * </pre>
 * @since  : 2020/02/13
 * @author : jsshin
 */
var cfnOpenLmsPopup = function(param) {
	var actionUrl = '/customer/lms/popup/form?elementCellPhnno=' + encodeURIComponent(param.elementCellPhnno)
			+ '&elementCustNo=' + encodeURIComponent(param.elementCustNo);
	if (!gagajf.isNull(param.elementMaskingCellPhnno)) {
		actionUrl +='&elementMaskingCellPhnno=' + encodeURIComponent(param.elementMaskingCellPhnno);
	}
	if (!gagajf.isNull(param.pageGb)) {
		actionUrl +='&pageGb=' + param.pageGb;
	}
	cfnOpenModalPopup(actionUrl, 'popupLmsForm');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 메일 팝업
 * <pre>
 *     var param = {};
 *     param.elementRecipEmail = 'input[name=email]';
 *     param.elementCustNo = 'input[name=custNo]';
 *     param.elementMaskingEmail = 'input[name=maskingEmail]' 선택사항
 *     cfnOpenEmailPopup(param);
 * </pre>
 * @since  : 2020/02/13
 * @author : jsshin
 */
var cfnOpenEmailPopup = function(param) {
	var actionUrl = '/customer/email/popup/form?elementEmail=' + encodeURIComponent(param.elementEmail)
	+ '&elementCustNo=' + encodeURIComponent(param.elementCustNo);
	if(!gagajf.isNull(param.elementMaskingEmail)) {
		actionUrl += '&elementMaskingEmail=' + encodeURIComponent(param.elementMaskingEmail);
	}
	cfnOpenModalPopup(actionUrl, 'popupEmailForm');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 쿠폰발급팝업
 * @author : xyzp1539
 * @since  : 2021-01-21
 */
var cfnCpnPubForCustPopup = function(){
	var actionUrl = '/marketing/coupon/cpnPubForCust/popup/form';
	cfnOpenModalPopup(actionUrl, 'CpnPubForCustPopup');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 1:1문의 상세 팝업
 * @author : gagamel
 * @since  : 2020/12/24
 */
var cfnOpenOneToOneQnaDetailPopup = function(counselSq) {
	var actionUrl = '/customer/onetoone/qna/detail/form/' + counselSq;
	cfnOpenModalPopup(actionUrl, 'popupOneToOneQnaDetail');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 상품문의 상세 팝업
 * @author : gagamel
 * @since  : 2020/12/24
 */
var cfnOpenGoodsQnaDetailPopup = function(counselSq) {
	var actionUrl = '/customer/goods/qna/detail/form/' + counselSq;
	cfnOpenModalPopup(actionUrl, 'popupGoodsQnaDetail');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 메인전시 컨텐츠 수정 팝업 오픈
 * <pre>
 *     cfnOpenMainContentsPopup(cateCd, contentsLoc);
 * </pre>
 * @param  : contentsLoc - 컨텐츠 위치
 * @since  : 2020/02/25
 * @author : sasa004
 */
var cfnOpenMainContentsPopup = function(cateNo, contentsLoc, brandGroupNo) {
	var actionUrl = "/display/main/contents/popup/form?cateNo="+cateNo+"&contentsLoc=" + contentsLoc;
	if (typeof(brandGroupNo) != 'undefined') actionUrl += "&brandGroupNo=" + brandGroupNo;
	uifnPopupClose('popupMainContents');
	cfnOpenModalPopup(actionUrl, 'popupMainContents');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 룩북 배너 팝업 오픈
 * <pre>
 *     cfnOpenLookbookBannerPopup(lookbookSq,lookbookTitle);
 * </pre>
 * @param  : lookbookSq - 룩북 일련번호
 * 			 mode - 모드(N:신규, U:상세/수정, C:복사) 필수
 * @since  : 2020/02/25
 * @author : sasa004
 */
var cfnOpenLookbookBannerPopup = function(mode, lookbookSq) {
	var actionUrl = "/display/lookbook/banner/popup/form?mode="+mode;
	if (typeof(lookbookSq) != 'undefined') actionUrl += "&lookbookSq=" + lookbookSq;
	//if (typeof(lookbookTitle) != 'undefined') actionUrl += "&lookbookTitle=" + encodeURIComponent(lookbookTitle);
	//uifnPopupClose('popupLookbookBanner');
	cfnOpenModalPopup(actionUrl, 'popupLookbookBanner');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 회원상세 팝업
 * <pre>
 *     cfnOpenCustDetailPopup(custNo);
 * </pre>
 * @since  : 2020/03/02
 * @author : jsshin
 */
var cfnOpenCustDetailPopup = function(custNo) {
	var actionUrl = "/customer/detail/form/" + custNo;
	cfnOpenModalPopup(actionUrl,'popupCustomerDetail');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 매장POS 팝업
 * <pre>
 *     cfnOpenCustDetailPopup(delvLocCd);
 * </pre>
 * @since  : 2020/04/02
 * @author : jsshin
 */
var cfnPopPos =function(delvLocCd){
	var actionUrl = "/pos/login?delvLocCd="+delvLocCd;
	var popupWidth = 1830;
	var popupHeight = 850;

	var popupX = (window.screen.width / 2) - (popupWidth / 2);

	var popupY= (window.screen.height / 3) - (popupHeight / 3);

	if (typeof(delvLocCd) != 'undefined'){
		window.open(actionUrl, "_blank", "top="+popupY+", left="+popupX+", width="+popupWidth+", height="+popupHeight+", scrollbars=yes");
	}
}

/**
 * @type   : function
 * @access : public
 * @desc   : 쿠폰조회 팝업
 * <pre>
 *     var oParam = new Object();
 *     oParam.returnCode = 'input[name=cpnId]'; // 반환할코드
 *     oParam.returnName = 'input[name=cpnNm]'; // 반환할코드명칭
 *     oParam.processType = 'DELV'; // 콜백함수처리유형
 *     cfnOpenCouponRetrievePopup($('input[name=cpnNm]').val(), oParam);
 * </pre>
 * @param sName - 명칭. 필수
 * @param oParam - 파라미터 오브젝트. 필수
 * @since  : 2020/04/14
 * @author : gagamel
 */
var cfnOpenCouponRetrievePopup = function(sName, oParam) {
	var oEvt = window.event;
	if (oEvt.type == 'click') sName = '';
	var returnCode = oParam.returnCode;
	var returnName = oParam.returnName;

	var actionUrl = '/marketing/coupon/retrieve/form?cpnNm=' + encodeURIComponent(sName)
			+ '&returnCode=' + encodeURIComponent(returnCode)
			+ '&returnName=' + encodeURIComponent(returnName);

	if (typeof(oParam.processType) != 'undefined')
		actionUrl += '&processType=' + oParam.processType;

	cfnOpenModalPopup(actionUrl, 'popupCoupon');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 기획전 조회 팝업
 * <pre>
 *     cfnOpenPlanPopup('CallbackFun');
 * </pre>
 * @param  : callbackfun - 콜백함수
 * @since  : 2020/04/14
 * @author : yujung
 */
var cfnOpenPlanPopup = function(callbackfun) {
	var actionUrl = "/marketing/planning/list/popup";
	if (typeof(callbackfun) != 'undefined') actionUrl += "?callBackFun=" + callbackfun;

	cfnOpenModalPopup(actionUrl,'popupPlan');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 세트상품구성 팝업
 * <pre>
 *     cfnOpenGoodsSetPopup();
 * </pre>
 * @since  : 2020/06/11
 * @author : eskim
 */
var cfnOpenGoodsSetPopup = function() {
	var actionUrl = "/goods/set/form";

	uifnPopupClose('popupGoodsSet');
	cfnOpenModalPopup(actionUrl, 'popupGoodsSet');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 딜상품구성 팝업
 * <pre>
 *     cfnOpenGoodsDealPopup();
 * </pre>
 * @since  : 2020/06/11
 * @author : eskim
 */
var cfnOpenGoodsDealPopup = function() {
	var actionUrl = "/goods/deal/form";

	uifnPopupClose('popupGoodsDeal');
	cfnOpenModalPopup(actionUrl, 'popupGoodsDeal');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 아이콘 팝업
 * <pre>
 *     cfnOpenIconPopup();
 * </pre>
 * @since  : 2020/06/15
 * @author : eskim
 */
var cfnOpenIconPopup = function() {
	var actionUrl = "/goods/icon/form";

	uifnPopupClose('popupIcon');
	cfnOpenModalPopup(actionUrl, 'popupIcon');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 기획전 응모이벤트 참여자 조회 팝업
 * <pre>
 *     cfnOpenPlanAnswerPopup('planSeq');
 * </pre>
 * @param  : planSeq - 기획전 코드
 * @since  : 2020/06/24
 * @author : sasa004
 */
var cfnOpenPlanAnswerPopup = function(planSq) {
	var actionUrl = "/marketing/plan/answer/list/popup?planSq="+planSq;
	cfnOpenModalPopup(actionUrl,'popupPlanAnswer');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 상품상세 미리보기
 * <pre>
 *     cfnOpenFrontGoodsPopup('LCOPJ523_RE', '10');
 * </pre>
 * @param  : goodsCd - 상품코드
 * @param  : siteCd - 사이트코드
 * @since  : 2020/08/21
 * @author : swkim
 */
var cfnOpenFrontGoodsPopup = function(goodsCd) {
	var actionUrl = _frontUrl +"/goods/detail/form?goodsCd=" + goodsCd + '&adminYn=Y';

	window.open(actionUrl);
}

/**
 * @type   : function
 * @access : public
 * @desc   : 브랜드 목록 팝업
 * <pre>
 *     cfnOpenBrandListPopup('fnResult');
 *     or
 *     cfnOpenBrandListPopup('fnResult', 'S');
 *     or
 *     cfnOpenBrandListPopup('fnResult', 'S', 'TBJ');
 * </pre>
 * @since  : 2020/12/15
 * @author : eskim
 */
var cfnOpenBrandListPopup = function(callbackfn, multiGb, searchTxt) {
	var actionUrl = '/business/brand/search/form?callbackFn=' + callbackfn;
	if (typeof(multiGb) != 'undefined' && multiGb != null && multiGb == "M") actionUrl += "&multiGb=" + multiGb; else actionUrl += "&multiGb=S";
	if (typeof(searchTxt) != 'undefined') actionUrl += "&searchTxt=" + encodeURIComponent(searchTxt);
	cfnOpenModalPopup(actionUrl, "popupBrandList");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 브랜드 그룹 목록 팝업
 * <pre>
 *     cfnOpenBrandGroupListPopup('fnResult', 'S', 'S');
 * </pre>
 * @since  : 2021/02/23
 * @author : eskim
 */
var cfnOpenBrandGroupListPopup = function(callbackfn, multiGb, type) {
	var actionUrl = '/business/brand/group/popup/form?callbackFn=' + callbackfn;
	if (typeof(multiGb) != 'undefined' && multiGb != null && multiGb == "M") actionUrl += "&multiGb=" + multiGb; else actionUrl += "&multiGb=S";
	if (typeof(type) != 'undefined' && type != null && type == "C") actionUrl += "&type=" + type; else actionUrl += "&type=S";
	cfnOpenModalPopup(actionUrl, "popupBrandGroup");
}


/**
 * @type   : function
 * @access : public
 * @desc   : 프로모션 등록 팝업
 * <pre>
 *     cfnOpenFreeGoodsPromotionSetPopup('C');
 *     or
 *     cfnOpenFreeGoodsPromotionSetPopup('U', 11);
 * </pre>
 * @since  : 2020/12/21
 * @author : xodud1202
 */
var cfnOpenFreeGoodsPromotionSetPopup = function(gbn, freegiftSq) {
	var actionUrl = "/marketing/freegoods/promotion/popup/form?gbn=" + gbn;
	if (typeof(freegiftSq) != 'undefined') actionUrl += "&freegiftSq=" + freegiftSq;

	uifnPopupClose('popupFreeGoodsPromotionRegi');
	cfnOpenModalPopup(actionUrl, 'popupFreeGoodsPromotionRegi');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 공급업체 조회 팝업
 * <pre>
 *     cfnOpenCompanyListPopup('fnResult');										// callBack 함수만 나타내고, 싱글 선택 팝업
 *     or
 *     cfnOpenCompanyListPopup('fnResult', 'S');								// 1번 파라미터 : callBack 함수, 2번 파라미터 : S면 싱글 선택 팝업, M이면 멀티 선택 팝업
 *     or
 *     cfnOpenCompanyListPopup('fnResult', 'S', 'TBJ');							// 1번 파라미터 : callBack 함수, 2번 파라미터 : 선택구분, 3번 파라미터 : 팝업 default 검색어
 *     or
 *     cfnOpenCompanyListPopup('fnResult', 'S', 'TBJ', 'inputId');				// 문자열은 멀티구분 S이고, 결과가 하나일때 supplyCompCd값을 넣어줄 html tag id, S가 아니고, inputId가 존재하지 않으면 무조건 팝업이 열림.
 *     or
 *     cfnOpenCompanyListPopup('fnResult', 'S', 'TBJ', 'inputId', 'Y');			// '': 전체 공급업체(기본값), Y: 자사공급업체, N:입점공급업체
 *
 * </pre>
 * @since  : 2020/12/23
 * @author : xodud1202
 */
var cfnOpenCompanyListPopup = function(callbackfn, multiGb, searchTxt, inputId, selfYn) {
	var actionUrl = "/business/comapny/search/form?callbackFn=" + callbackfn;
	if (typeof(multiGb) != 'undefined' && multiGb != null && multiGb == "M") actionUrl += "&multiGb=" + multiGb; else actionUrl += "&multiGb=S";
	if (typeof(searchTxt) != 'undefined') actionUrl += "&searchTxt=" + encodeURIComponent(searchTxt);
	if (typeof(selfYn) != 'undefined') actionUrl += "&selfYn="+ selfYn ; else actionUrl += "&selfYn=" ;
	if(multiGb == "S") {
		if(searchTxt && searchTxt != "" && inputId && inputId != "") {
			var data = {  searchTxt : searchTxt, searchGb : "NAME"};
			var jsonData = JSON.stringify(data);

			gagajf.ajaxJsonSubmit('/business/supply/company/list', jsonData, function(result) {
				if(result && result.length == 1) {
					$("#" + inputId).val(result[0].supplyCompCd);
				} else {
					uifnPopupClose('popupCompanyList');
					cfnOpenModalPopup(actionUrl, 'popupCompanyList');
				}
			});
		} else {
			uifnPopupClose('popupCompanyList');
			cfnOpenModalPopup(actionUrl, 'popupCompanyList');
		}
	} else {
		uifnPopupClose('popupCompanyList');
		cfnOpenModalPopup(actionUrl, 'popupCompanyList');
	}
}

/**
 * @type   : function
 * @access : public
 * @desc   : 다다익선 등록 팝업
 * <pre>
 *     cfnOpenTmtbSetPopup();
 * </pre>
 * @param  : mode - 모드(N:신규, U:상세/수정, C:복사) 필수
 * @since  : 2020/12/29
 * @author : bin2107
 */
var cfnOpenMorebetterSetPopup = function(mode ,tmtbSeq) {
	var actionUrl = "/marketing/morebetterPopup/form?mode="+mode;
	if (typeof(tmtbSeq) != 'undefined') actionUrl += "&tmtbSeq=" + tmtbSeq;
	uifnPopupClose('popupMorebetterReg');
	cfnOpenModalPopup(actionUrl, 'popupMorebetterReg');
}


/**
 * @type   : function
 * @access : public
 * @desc   : 외부몰 조회 팝업
 * <pre>
 *     cfnOpenExtmallListPopup();
 * </pre>
 * @since  : 2020/12/23
 * @author : xodud1202
 */
var cfnOpenExtmallListPopup = function(callbackfn) {
	var actionUrl = "/ocm/extmall/search/form";
	if (typeof(callbackfn) != 'undefined') actionUrl += "?callbackFn=" + callbackfn;
	uifnPopupClose('popupExtmallList');
	cfnOpenModalPopup(actionUrl, 'popupExtmallList');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 공급벤더 팝업
 * <pre>
 *     var oParam = new Object();
 *     oParam.returnCode = 'input[name=supplyVendorCd]'; // 반환할코드
 *     oParam.returnName = 'input[name=supplyVendorNm]'; // 반환할코드명칭
 *     cfnOpenSupplyVendorPopup($('input[name=supplyVendorNm]').val(), oParam);
 * </pre>
 * @param sName - 명칭. 필수
 * @param oParam - 파라미터 오브젝트. 필수
 * @since  : 2021/01/18
 * @author : gagamel
 */
var cfnOpenSupplyVendorPopup = function(sName, oParam) {
	var oEvt = window.event;
	if (oEvt.type == 'click') sName = '';
	var returnCode = oParam.returnCode;
	var returnName = oParam.returnName;

	var actionUrl = '/business/supply/vendor/popup/form?supplyVendorNm=' + encodeURIComponent(sName)
			+ '&returnCode=' + encodeURIComponent(returnCode)
			+ '&returnName=' + encodeURIComponent(returnName);

	cfnOpenModalPopup(actionUrl, 'popupSupplyVendor');
}


/**
 * @type   : function
 * @access : public
 * @desc   : 카드목록 조회 팝업
 * <pre>
 *     cfnOpenCardListPopup('fnResult', 'G941_01|G941_02|');
 * </pre>
 * @since  : 2021/02/01
 * @author : eskim
 */
var cfnOpenCardListPopup = function(callBackFun, arrCard) {
	var actionUrl = "/marketing/card/list/popup/form?callBackFun=" + callBackFun;
	actionUrl += "&arrCard=" + arrCard;

	cfnOpenModalPopup(actionUrl, 'popupCardList');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 전시 상품 순서변경 팝업
 * <pre>
 *     cfnOpenGoodsDispOrdChangePopup('goosCallbackFun');
 * </pre>
 * @since  : 2021/02/18
 * @author : bin2107
 */
var cfnOpenGoodsDispOrdChangePopup = function(callbackfun, params) {
	var actionUrl = "/display/goods/dispord/change/popup/form";
	if (typeof(callbackfun) != 'undefined') actionUrl += "?callBackFun=" + callbackfun;
	if (typeof(params) != 'undefined') actionUrl += "&" + params;
	cfnOpenModalPopup(actionUrl,'popupGoodsDispOrdChange');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 메인전시 컨텐츠 멀티 수정 팝업 오픈
 * <pre>
 *     cfnOpenMainMultiContentsPopup(cateCd, contentsLoc);
 * </pre>
 * @since  : 2021/02/24
 * @author : bin2107
 */
var cfnOpenMainMultiContentsPopup = function(cateNo, contentsLoc, brandGroupNo) {
	var actionUrl = "/display/main/multicontents/popup/form?cateNo="+cateNo+"&contentsLoc=" + contentsLoc;
	if (typeof(brandGroupNo) != 'undefined') actionUrl += "&brandGroupNo=" + brandGroupNo;
	//uifnPopClose('popupMainMultiContents');
	cfnOpenModalPopup(actionUrl, 'popupMainMultiContents');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 제휴채널 팝업
 * <pre>
 *     cfnOpenGoodsPopup('goosCallbackFun');
 * </pre>
 * @param  : callbackfun - 콜백함수
 * @since  : 2020/01/17
 * @author : eskim
 */
var cfnOpenAfChannelPopup = function(callbackfun) {
	var actionUrl = "/business/channel/popup/form";
	console.log(callbackfun);
	if (typeof(callbackfun) == 'undefined'){
		return;
	}
	if (typeof(callbackfun) != 'undefined'){
		actionUrl += "?callBackFun=" + callbackfun;
	}

	cfnOpenModalPopup(actionUrl,'popupAfChannel');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 룩북 배너 피커 팝업 오픈
 * <pre>
 *     cfnOpenLookbookBannerPickerPopup(lookbookbSq,imgNm);
 * </pre>
 * @param  : lookbookbSq - 룩북 배너 일련번호 , imgNm - 이미지파일
 * @since  : 2021/03/09
 * @author : bin2107
 */
var cfnOpenLookbookBannerPickerPopup = function(lookbookbSq, imgNm) {
	var actionUrl = "/display/lookbook/banner/picker/popup/form?lookbookbSq="+lookbookbSq+"&imgNm="+imgNm;
	cfnOpenModalPopup(actionUrl, 'popupLookbookBannerPicker');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 메인전시 컨텐츠 GNB TAB 수정 팝업 오픈
 * <pre>
 *     cfnOpenMainGnbContentsPopup(cateCd, contentsLoc);
 * </pre>
 * @since  : 2021/03/10
 * @author : bin2107
 */
var cfnOpenMainGnbContentsPopup = function(cateNo, contentsLoc, brandGroupNo) {
	var actionUrl = "/display/main/gnbcontents/popup/form?cateNo="+cateNo+"&contentsLoc=" + contentsLoc;
	if (typeof(brandGroupNo) != 'undefined') actionUrl += "&brandGroupNo=" + brandGroupNo;
	cfnOpenModalPopup(actionUrl, 'popupMainGnbContents');
}

/**
 * @type   : function
 * @access : public
 * @desc   : 샵링커 주문수집 팝업
 * <pre>
 *     cfnOpenSlkOrderPopup('샵링커주문번호');
 * </pre>
 * @param  : orderNo - 샵링커주문번호:필수
 * @since  : 2021/05/31
 * @author : jmh
 */
var cfnOpenSlkOrderPopup = function(shoplinkerOrderId) {
	var actionUrl = "/shoplinker/order/collection/info";
	if (typeof(shoplinkerOrderId) != 'undefined') actionUrl += "?shoplinkerOrderId=" + shoplinkerOrderId;
	cfnOpenModalPopup(actionUrl, "popupSlkOrderDetail");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 샵링커 주문수집 팝업
 * <pre>
 *     cfnOpenSlkOrderPopup('샵링커주문번호');
 * </pre>
 * @param  : orderNo - 샵링커주문번호:필수
 * @since  : 2021/05/31
 * @author : jmh
 */
var cfnOpenExtmallOrderPopup = function(ordNo) {
	var actionUrl = "/shoplinker/order/extmall/info";
	if (typeof(ordNo) != 'undefined') actionUrl += "?ordNo=" + ordNo;
	cfnOpenModalPopup(actionUrl, "popupExtmallOrderDetail");
}

/**
 * @type   : function
 * @access : public
 * @desc   : 품목 목록 팝업
 * <pre>
 *     cfnOpenItemkindListPopup('fnResult');
 *     or
 *     cfnOpenItemkindListPopup('fnResult', 'S');
 *     or
 *     cfnOpenItemkindListPopup('fnResult', 'S', 'TBJ');
 * </pre>
 * @since  : 2021/07/16
 * @author : eskim
 */
var cfnOpenItemkindListPopup = function(callbackfn, multiGb, searchTxt) {
	var actionUrl = '/goods/itemkind/popup/form?callbackFn=' + callbackfn;
	if (typeof(multiGb) != 'undefined' && multiGb != null && multiGb == "M") actionUrl += "&multiGb=" + multiGb; else actionUrl += "&multiGb=S";
	if (typeof(searchTxt) != 'undefined') actionUrl += "&searchTxt=" + encodeURIComponent(searchTxt);
	cfnOpenModalPopup(actionUrl, "popupItemkindList");
}
