// MLUtil
if(typeof MLUtil == 'undefined')
	MLUtil = {};

// MLUtil.Popup
if(typeof MLUtil.Popup == 'undefined')
	MLUtil.Popup = {};

var wbsEvents = new Object;
var objBrowser = new classBrowser();
wbsEvents.length = 0;
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 0 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraWidth=parseFloat(getFFVersion)>=0.1? 0 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraFrameHeight=parseFloat(getFFVersion)>=0.1? 0 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraFrameWidth=parseFloat(getFFVersion)>=0.1? 0 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers

if (objBrowser.ie) {
	FFextraHeight = 0;
	FFextraWidth = 0;

	FFextraFrameHeight = 0;
	FFextraFrameWidth = 0;
} else if (objBrowser.ns) {
	FFextraHeight = 0;
	FFextraWidth = 0;

	FFextraFrameHeight = 0;
	FFextraFrameWidth = 0;
} else if (objBrowser.chrome) {
	FFextraHeight = 0;
	FFextraWidth = 0;

	FFextraFrameHeight = 0;
	FFextraFrameWidth = 0;
}

//===================================================================
// Browser Check
//===================================================================
function classBrowser() {
	var b = navigator.appName;
	if (b=="Netscape" && (navigator.appVersion.indexOf("Chrome") == -1)) this.b = "ns";
	else if (b=="Netscape" && (navigator.appVersion.indexOf("Chrome") > -1)) this.b = "chrome";
	else if (b=="Microsoft Internet Explorer") this.b = "ie";
	else if (b=="Opera") this.b = "op";
	else this.b = b;
	this.v = parseInt(navigator.appVersion);
	this.chrome = (this.b=="chrome");
	this.ns = (this.b=="ns" && this.v>=4);
	this.ns4 = (this.b=="ns" && this.v==4);
	this.ns5 = (this.b=="ns" && this.v==5);
	this.ie = (this.b=="ie" && this.v>=4);
	this.op = (this.b=="op" && this.v>=7);
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0);
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0);
	this.ie55 = (navigator.userAgent.indexOf('MSIE 5.5')>0);
	this.ie6 = (navigator.userAgent.indexOf('MSIE 6')>0);
	this.ie7 = (navigator.userAgent.indexOf('MSIE 7')>0);
	this.ie8 = (navigator.userAgent.indexOf('MSIE 8')>0);
	if (this.ie55) {
		this.v = 5.5;
		this.ie5 = false;
	}
	this.mac = (navigator.userAgent.indexOf('Mac')>0);
	if (this.ie5) this.v = 5;
	this.min = (this.ns||this.ie);
	
}

//===================================================================
// TitleWindow Control 클래스 정의
//===================================================================
MLUtil.Popup.Control = function() {};
MLUtil.Popup.Control.moduleReloadOption = null;
MLUtil.Popup.Control.moduleIsLoaded = false;
MLUtil.Popup.Control.moduleInitWidth = 0;
MLUtil.Popup.Control.moduleInitHeight = 0;
MLUtil.Popup.Control.modulePopupIframeName = "windowPanel_PopupFrame";
MLUtil.Popup.Control.modulePopupFormName = "windowPanel_formFramePopup";
MLUtil.Popup.Control.modulePopupLayerName = "windowPanel";
MLUtil.Popup.Control.modulePopupWindowBgLayerName = "layerWindowBackground";
MLUtil.Popup.Control.modulePopupWindowBgFilter = "alpha60";
MLUtil.Popup.Control.modulePopupLayerBgLayerName = "layerBackground";
MLUtil.Popup.Control.modulePopupLayerBgFilter = "alpha30";
MLUtil.Popup.Control.modulePopupPreloadImg = "windowPanel_PreloadImage";
MLUtil.Popup.Control.modulePopupPreloadImgUri = "http://image.twipl.net/images/common/large_indicator.gif";

MLUtil.Popup.Control.hideWindow = function() {
	if(objBrowser.ie)
		document.body.onmousewheel = null;
	else {
		document.removeEventListener('DOMMouseScroll', MLUtil.Popup.Control.onMouseWheelDisable, false);
		document.removeEventListener('DOMMouseScroll', MLUtil.Popup.Control.onMouseWheelEnableLayer, false);
	}
	MLUtil.Popup.Control.setDettachEvent(window, 'resize', MLUtil.Popup.Control.setResizeWindow);

	MLUtil.Popup.Control.hideWindowTerminate();
};

MLUtil.Popup.Control.hideWindowTerminate = function() {
	MLUtil.Popup.Control.setEnableWindowBackground();
	MLUtil.Popup.Control.onHideWindowBackground();
	
	if ($(MLUtil.Popup.Control.modulePopupIframeName)) {
		$(MLUtil.Popup.Control.modulePopupIframeName).hide();
		$(MLUtil.Popup.Control.modulePopupIframeName).remove();
	}
	if ($(MLUtil.Popup.Control.modulePopupLayerName)) {
		$(MLUtil.Popup.Control.modulePopupLayerName).hide();
		$(MLUtil.Popup.Control.modulePopupLayerName).remove();
	}
	if ($(MLUtil.Popup.Control.modulePopupFormName)) {
		$(MLUtil.Popup.Control.modulePopupFormName).remove();
	}

	MLUtil.Popup.Control.moduleIsLoaded = false;
};

MLUtil.Popup.Control.onMouseWheelDisable = function(avObjEvent) {
	if(!objBrowser.ie)
	{
		avObjEvent.preventDefault();
	}
	return false;
};

MLUtil.Popup.Control.setWindowWheel = function() {
	if(objBrowser.ie)
	{
		document.body.onmousewheel = MLUtil.Popup.Control.onMouseWheelDisable;
	}
	else
	{
		document.addEventListener('DOMMouseScroll', MLUtil.Popup.Control.onMouseWheelDisable, false);
	}
};

MLUtil.Popup.Control.setLayerWheel = function() {
	if(objBrowser.ie)
	{
		$(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.onmousewheel = MLUtil.Popup.Control.onMouseWheelDisable;
	}
	else
	{
		$(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.addEventListener('DOMMouseScroll', MLUtil.Popup.Control.onMouseWheelDisable, false);
	}
};

MLUtil.Popup.Control.onMouseWheelEnableLayer = function() {
	var divBody = $(MLUtil.Popup.Control.modulePopupIframeName);
	var wheelAmount = 100;
	var wheelDirection;
	if(objBrowser.ie)
		wheelDirection = -1*event.wheelDelta/Math.abs(event.wheelDelta);
	else
		wheelDirection = e.detail/Math.abs(e.detail);
	divBody.scrollTop += wheelDirection*wheelAmount;
};

MLUtil.Popup.Control.onClickMainBackground = function(objEvent) {
	MLUtil.Popup.Control.hideWindow();
	return;
	var contentHeight = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.documentElement.scrollHeight;
	var contentWidth = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.documentElement.scrollWidth;
	var oBody = MLUtil.Popup.Control.getBody();

	var objBackground = $(MLUtil.Popup.Control.modulePopupWindowBgLayerName);
	if(!objBackground)
	{
		objBackground = document.createElement('div');
		objBackground.setAttribute('id', MLUtil.Popup.Control.modulePopupWindowBgLayerName);
		objBackground.className = MLUtil.Popup.Control.modulePopupLayerBgFilter;
		document.body.appendChild(objBackground);
		objBackground.onclick = MLUtil.Popup.Control.onHideWindowBackground;
	}

	objBackground.style.height = oBody.height+document.body.scrollHeight+'px';
	objBackground.style.width = oBody.width+document.body.scrollWidth+'px';
	objBackground.style.display = 'block';
};

MLUtil.Popup.Control.onHideWindowBackground = function(objEvent) {
	var objBackground = $(MLUtil.Popup.Control.modulePopupWindowBgLayerName);
	if(objBackground) objBackground.style.display = 'none';
};

MLUtil.Popup.Control.setDisableWindowBackground = function() {
	var objBackground = $(MLUtil.Popup.Control.modulePopupLayerBgLayerName);
	var nWidth = 0;
	var nHeight = 0;

	if(!objBackground)
	{
		objBackground = document.createElement('div');
		objBackground.setAttribute('id', MLUtil.Popup.Control.modulePopupLayerBgLayerName);
		objBackground.className = MLUtil.Popup.Control.modulePopupWindowBgFilter;
		document.body.appendChild(objBackground);
		objBackground.onclick = MLUtil.Popup.Control.onClickMainBackground;
	}

	var oBody = MLUtil.Popup.Control.getBody();

	if (document.body.scrollHeight > oBody.height)
		nHeight = document.documentElement.scrollHeight;
	else
		nHeight = oBody.height;
		
	if (document.body.scrollWidth > oBody.width)
		nWidth = document.documentElement.scrollWidth;
	else
		nWidth = oBody.width;

	objBackground.style.height = nHeight + 'px';
	objBackground.style.width = nWidth + 'px';
	objBackground.style.display = 'block';
	document.body.width = '100%';
	document.body.height = '100%';

};

MLUtil.Popup.Control.setEnableWindowBackground = function() {
	var objBackground = $(MLUtil.Popup.Control.modulePopupLayerBgLayerName);
	if(objBackground) objBackground.style.display = 'none';
};


// 이벤트 추가
MLUtil.Popup.Control.setAttachEvent = function(obj, evt, func, useCapture)
{
	if(!useCapture) useCapture = false;
	if(obj.addEventListener)
	{
		obj.addEventListener(evt, func, useCapture);
		wbsEvents[wbsEvents.length]=[obj, evt, func, useCapture];
	}
	else if(obj.attachEvent)
	{
		obj.attachEvent('on'+evt, func);
		wbsEvents[wbsEvents.length]=[obj, evt, func, useCapture];
	}
};

// 이벤트 삭제
MLUtil.Popup.Control.setDettachEvent = function(obj, evt, func, useCapture)
{
	if(!useCapture) useCapture = false;
	if(obj.removeEventListener)
	{
		obj.removeEventListener(evt, func, useCapture);
	}
	else if(obj.detachEvent)
	{
		obj.detachEvent('on'+evt, func);
	}
};

MLUtil.Popup.Control.onLoadIframe = function(event, avNWidth, avNHeight) {
	
	/** Chorome에서의 레이어팝업 문제 처리 전 소스 **/
	/*var contentHeight = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.documentElement.scrollHeight;
	var contentWidth = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.documentElement.scrollWidth;
	var tempContentHeight = 0;
	var tempContentWidth = 0;*/
	var contentHeight = 0;
	var contentWidth = 0;
	var tempContentHeight = 0;
	var tempContentWidth = 0;
	
	/** Chrome에서의 레이어팝업이 정상적인 사이즈로 열리지 않는 문제 해결 - Start - **/
	var appVersion = navigator.appVersion;
	
	if(appVersion.indexOf("Chrome") != -1){
		contentHeight = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.height;
		contentWidth = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.width;
	}else{
		contentHeight = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.documentElement.scrollHeight;
		contentWidth = $(MLUtil.Popup.Control.modulePopupIframeName).contentWindow.document.documentElement.scrollWidth;		
	}

	/** Chrome에서의 레이어팝업이 정상적인 사이즈로 열리지 않는 문제 해결 - End - **/
	
	if (avNWidth != null && avNWidth != "" && avNWidth != "null" && avNWidth != "undefined") 
		tempContentWidth = parseInt(avNWidth);
	else
		tempContentWidth = parseInt(contentWidth);

	if (avNHeight != null && avNHeight != "" && avNHeight != "null" && avNHeight != "undefined") 
		tempContentHeight = parseInt(avNHeight);
	else
		tempContentHeight = parseInt(contentHeight);
	
	$(MLUtil.Popup.Control.modulePopupIframeName).style.width = "auto";
	$(MLUtil.Popup.Control.modulePopupIframeName).style.width = (contentWidth + FFextraFrameWidth) + "px";
	$(MLUtil.Popup.Control.modulePopupLayerName).style.width = "auto";
	$(MLUtil.Popup.Control.modulePopupLayerName).style.width = (contentWidth + FFextraWidth) + "px";

	$(MLUtil.Popup.Control.modulePopupIframeName).style.height = "auto";
	$(MLUtil.Popup.Control.modulePopupIframeName).style.height = (contentHeight + FFextraHeight) + "px";
	$(MLUtil.Popup.Control.modulePopupLayerName).style.height = "auto";
	$(MLUtil.Popup.Control.modulePopupLayerName).style.height = (contentHeight + FFextraHeight) + "px";

	if ($(MLUtil.Popup.Control.modulePopupPreloadImg))
		$(MLUtil.Popup.Control.modulePopupPreloadImg).remove();

	var oBody = MLUtil.Popup.Control.getBody();
	
	if(oBody.height-tempContentHeight <= 0)
		$(MLUtil.Popup.Control.modulePopupLayerName).style.top = oBody.top + 50 +'px';
	else
		$(MLUtil.Popup.Control.modulePopupLayerName).style.top = (oBody.top + (oBody.height / 2) - (tempContentHeight / 2)) +'px';
	$(MLUtil.Popup.Control.modulePopupLayerName).style.left = (oBody.left + (oBody.width / 2) - (tempContentWidth / 2)) +'px';

	if (Element.getStyle($(MLUtil.Popup.Control.modulePopupIframeName), "visibility") == "hidden")
		$(MLUtil.Popup.Control.modulePopupIframeName).style.visibility = "visible";

	//MLUtil.Popup.Control.setLayerWheel();
	MLUtil.Popup.Control.moduleIsLoaded = true;
	
	// 백그라운드 비활성 색
	MLUtil.Popup.Control.setDisableWindowBackground();
};

/*
// ------------------------------------------------------------
// 이용 방법
// ------------------------------------------------------------
// 팝업 띄우기
function onContentView(avStrFileUrl, guid, avStrTargetId) {
	MLUtil.Popup.Control.Open(avStrFileUrl, 'guid='+guid, 
		{
			frameObj: $("ifrm_memo"),
			layerID: avStrTargetId
		}
	);
}

// onclick
onclick="parent.onContentView('memo_view_popup.asp','<%=arrResult(1, i)%>','<%=변경되어야할 아이디%>')"

// inplace editor onsuccess
function onSuccess(transport, element) {
	//parent.ifrm_memo.location.reload();
	parent.MLUtil.Popup.Control.onReloadLayer(transport.responseText);
}

*/
MLUtil.Popup.Control.onReloadLayer = function(avStrContent) {
	var objOption = null;
	objOption = Object.extend(
				{
					frameObj: null,
					layerID: null,
					layerContent: null,
					ajaxDefine: {ajaxAction: false, ajaxUrl: null, ajaxParam: null}
				}, 
				MLUtil.Popup.Control.moduleReloadOption
	);

	if (!objOption.frameObj)
		return;

	if (objOption.layerID == null || objOption.layerID == "")
		return;

	if (objOption.ajaxDefine.ajaxAction) {
		if (objOption.frameObj.document.getElementById(objOption.layerID))
			new Ajax.Updater(objOption.frameObj.getElementById(avStrId), objOption.ajaxDefine.ajaxUrl, {postBody: objOption.ajaxDefine.ajaxParam}); 
	} else {
		if (avStrContent != null && avStrContent != "")
			if (objOption.frameObj.contentWindow.document.getElementById(objOption.layerID))
				objOption.frameObj.contentWindow.document.getElementById(objOption.layerID).innerHTML = avStrContent;	
	}
};

MLUtil.Popup.Control.getBodyInnerSize = function()
{
	var result = new Object;
	if(self.innerWidth)
	{
		result.width = self.innerWidth;
		result.height = self.innerHeight;
		return result;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict 紐⑤뱶
	{
		result.width = document.documentElement.clientWidth;
		result.height = document.documentElement.clientHeight;
		return result;
	}
	else if (document.body) { // �ㅻⅨ IE 釉뚮씪�곗 �
		result.width = document.body.clientWidth;
		result.height = document.body.clientHeight;
		return result;
	}
};

MLUtil.Popup.Control.getFrameBodySize = function(avObj)
{
	var result = new Object;
	if (avObj.document.documentElement && avObj.document.documentElement.clientHeight) // Explorer 6 Strict 紐⑤뱶
	{
		result.width = avObj.document.documentElement.clientWidth;
		result.height = avObj.document.documentElement.clientHeight;
		return result;
	}
	else if (avObj.document.body) { // �ㅻⅨ IE 釉뚮씪�곗 �
		result.width = avObj.document.body.clientWidth;
		result.height = avObj.document.body.clientHeight;
		return result;
	}
};

MLUtil.Popup.Control.getBodyScroll = function()
{
	var x,y;
	if(typeof(self.pageYOffset)!='undefined') 
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body)  
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	var result = new Object;
	result.left = x;
	result.top = y;
	return result;
};

MLUtil.Popup.Control.getBody = function()
{
	var oBodyScroll = MLUtil.Popup.Control.getBodyScroll();
	var oBodySize = MLUtil.Popup.Control.getBodyInnerSize();
	var oBody = new Object;
	oBody.width = oBodySize.width;
	oBody.height = oBodySize.height;
	oBody.top = oBodyScroll.top;
	oBody.left = oBodyScroll.left;

	return oBody;
};

MLUtil.Popup.Control.setResizeWindow = function() {

	var contentHeight = $(MLUtil.Popup.Control.modulePopupLayerName).getHeight();
	var contentWidth = $(MLUtil.Popup.Control.modulePopupLayerName).getWidth();

	if (MLUtil.Popup.Control.moduleInitWidth != null && MLUtil.Popup.Control.moduleInitWidth != "" && MLUtil.Popup.Control.moduleInitWidth != "null" && MLUtil.Popup.Control.moduleInitWidth != "undefined")
		tempContentWidth = parseInt(MLUtil.Popup.Control.moduleInitWidth);
	else
		tempContentWidth = parseInt(contentWidth);

	if (MLUtil.Popup.Control.moduleInitHeight != null && MLUtil.Popup.Control.moduleInitHeight != "" && MLUtil.Popup.Control.moduleInitHeight != "null" && MLUtil.Popup.Control.moduleInitHeight != "undefined") 
		tempContentHeight = parseInt(MLUtil.Popup.Control.moduleInitHeight);
	else
		tempContentHeight = parseInt(contentHeight);

	var oBody = MLUtil.Popup.Control.getBody();

	if(oBody.height-contentHeight <= 0)
		$(MLUtil.Popup.Control.modulePopupLayerName).style.top = oBody.top + 50 +'px';
	else
		$(MLUtil.Popup.Control.modulePopupLayerName).style.top = (oBody.top + (oBody.height / 2) - (tempContentHeight / 2)) +'px';
	$(MLUtil.Popup.Control.modulePopupLayerName).style.left = (oBody.left + (oBody.width / 2) - (tempContentWidth / 2)) +'px';
	
	// 백그라운드 비활성 색
	MLUtil.Popup.Control.setDisableWindowBackground();
};

MLUtil.Popup.Control.setUnloadEvent = function() {
	if(wbsEvents.length>0)
	{
		for(var i=0;i<wbsEvents.length;i++)
		{
			if(wbsEvents[i][0] == null) continue;
			MLUtil.Popup.Control.setDettachEvent(wbsEvents[i][0],wbsEvents[i][1],wbsEvents[i][2],wbsEvents[i][3]);
			wbsEvents[i][0] = null;
		}
	}
};

if(typeof(document.readyState)=='undefined')
{
	document.readyState = 0;
	MLUtil.Popup.Control.setAttachEvent(window, 'load', function(){document.readyState='complete';});
}
MLUtil.Popup.Control.setAttachEvent(window, 'unload', MLUtil.Popup.Control.setUnloadEvent);


//===================================================================
// TitleWindow 클래스 정의
//===================================================================
MLUtil.Popup.Handler = function() {
	var _id = null;	 
	var _bodyDiv = null;
	var _bodyFrame = null;
	var _preloadImage = null;
	var _preloadImageObject = null;
	var _bodyUrl = null;
	var _bodyParam = null;
	
	// 객체 초기화
	this.initFunc = function(avObjModule) 
	{
		this.objModule = Object.extend(
			{
				moduleID: null,
				moduleStyle: null,
				moduleHeadText: null,
				moduleBodyText: null,
				moduleDoModal: true,
				modulePositionX: null,
				modulePositionY: null,
				moduleWidth: "10px",
				moduleHeight: "10px",
				moduleInitHeight: null,
				moduleInitWidth: null,
				moduleScroll: false,
				moduleBrowserScroll: false,
				moduleDrag: false,
				moduleAutoResize: false,
				ajaxBodyDefine: {ajaxAction: false, ajaxUrl: null, ajaxParam: null, ajaxTarget: null},
				ajaxTailDefine: {ajaxAction: false, ajaxUrl: null, ajaxParam: null, ajaxTarget: null}
			}, 
			avObjModule
		);

		this._id = this.objModule.moduleID;

		// Head 영역 생성
		var tempObject = null;
		var tempObject1 = null;
		var tempTopObject = null;
		var tempClear = null;
		var tempBottomObject = null;
		var tempStyle = null;


		// Window 스타일 설정
		tempStyle = "position:absolute;";
		if (this.objModule.modulePositionX != null)
			tempStyle = tempStyle + ";left: " + this.objModule.modulePositionX;

		if (this.objModule.modulePositionY != null)
			tempStyle = tempStyle + ";top: " + this.objModule.modulePositionY;

		if (this.objModule.moduleWidth != null)
			tempStyle = tempStyle + ";width: " + this.objModule.moduleWidth;

		if (this.objModule.moduleHeight != null)
			tempStyle = tempStyle + ";height: " + this.objModule.moduleHeight;

		tempStyle = tempStyle + ";background: transparent";
		tempStyle = tempStyle + ";z-index:2000";

		this._bodyUrl = this.objModule.ajaxBodyDefine.ajaxUrl;
		this._bodyParam = this.objModule.ajaxBodyDefine.ajaxParam;
		
		/*if (this.objModule.ajaxBodyDefine.ajaxParam != null && this.objModule.ajaxBodyDefine.ajaxParam != "")
			tempSrcUrl = this.objModule.ajaxBodyDefine.ajaxUrl + "?" + this.objModule.ajaxBodyDefine.ajaxParam;
		else
			tempSrcUrl = this.objModule.ajaxBodyDefine.ajaxUrl;*/
		tempSrcUrl = "about:blank";
		
		// Body 프레임 오브젝트 생성
		this._bodyFrame	 = new Element('iframe', {
			"id": MLUtil.Popup.Control.modulePopupIframeName, 
			"name": MLUtil.Popup.Control.modulePopupIframeName, 
			"onload": "MLUtil.Popup.Control.onLoadIframe(this, '" + this.objModule.moduleInitWidth + "', '" + this.objModule.moduleInitHeight + "');", 
			"src": tempSrcUrl, 
			"style": "visibility:visible; margin:-1px 0 0 0; overflow:hidden; overflow-x:hidden; overflow-y:hidden; background: transparent; z-index:1000;", 
			"allowTransparency": "true", 
			"scrolling": "no", 
			"hspace": "0",  
			"vspace": "0", 
			"border": "0", 
			"frameborder": "0", 
			"width": "1px", 
			"height": "1px", 
			"marginwidth": "0", 
			"marginheight": "0"
		});	
		if (!objBrowser.ns)
			this._bodyFrame.observe('load', MLUtil.Popup.Control.onLoadIframe.bind(event, this, this.objModule.moduleInitWidth, this.objModule.moduleInitHeight));
		// Preloading Image 생성
		this._preloadImage = new Element('div', {id: MLUtil.Popup.Control.modulePopupPreloadImg});		

		// Body DIV 오브젝트 생성
		this._bodyDiv	 = new Element('div', {id: this._id, style: tempStyle});	
		this._bodyDiv.appendChild(this._preloadImage);
		this._bodyDiv.appendChild(this._bodyFrame);

		// 팝업 최상위 오브젝트 생성
		this._div = this._bodyDiv;	
	};
	

	this.showWindow = function() {
		if (document.getElementById(this._id)) return;

		// layer 생성
		document.body.appendChild($(this._div));
		
		// Form Action 처리를 위한 로직 추가
		var tempSrcUrl = null;
		if (this._bodyParam != null && (typeof this._bodyParam) == "object") {
			var arrKeys = Object.keys(this._bodyParam);
			var arrValues = Object.values(this._bodyParam);
			
			if (arrKeys != null) {
				var objForm = new Element('form', {name: MLUtil.Popup.Control.modulePopupFormName, id: MLUtil.Popup.Control.modulePopupFormName, action: this._bodyUrl, method: "get", target: MLUtil.Popup.Control.modulePopupIframeName});
				for (i=0; i<arrKeys.length; i++) {
					var strKey = arrKeys[i];
					var strValue = arrValues[i];
					
					if (strKey == null) continue;
					strValue = (strValue==null)?"":strValue;
					
					var objInput = new Element('input', {type: "hidden", name: strKey, value: strValue});
					objForm.appendChild(objInput);
				}
				document.body.appendChild(objForm);
				objForm.submit();
			}
		} else {
			if (this._bodyParam != null && this._bodyParam != "")
				tempSrcUrl = this._bodyUrl + "?" + this._bodyParam;
			else
				tempSrcUrl = this._bodyUrl;
			document.getElementById(MLUtil.Popup.Control.modulePopupIframeName).src = tempSrcUrl;
		}
		
		
		
		$(this._div).show();

		var oBody = MLUtil.Popup.Control.getBody();

		$(this._div).style.left = (oBody.left + (oBody.width / 2) - ($(this._preloadImage).getWidth() / 2)) +'px';
		$(this._div).style.top = (oBody.top + (oBody.height / 2) - ($(this._preloadImage).getHeight() / 2)) +'px';
		
		objPreLoadingImg = new Image();
		objPreLoadingImg.src = MLUtil.Popup.Control.modulePopupPreloadImgUri;
		objPreLoadingImg.width = 128;
		objPreLoadingImg.height = 128;
		$(this._preloadImage).appendChild(objPreLoadingImg);

		// 이벤트 핸들러 설정
		// 브라우저 휠 사용여부 설정
		if (!this.objModule.moduleBrowserScroll)
			MLUtil.Popup.Control.setWindowWheel();

		// 컨텐츠 영역 휠 사용여부 설정
        if (!this.objModule.moduleScroll)
			MLUtil.Popup.Control.setLayerWheel();

		if (this.objModule.moduleAutoResize)
			MLUtil.Popup.Control.setAttachEvent(window, 'resize', MLUtil.Popup.Control.setResizeWindow);

		// background disable 설정
		if (this.objModule.moduleDoModal)
			MLUtil.Popup.Control.setDisableWindowBackground();

		
	};

	// PRIVATE FUNCTIONS
	this._getId = function(prefix) { 
		return (prefix ? prefix + "_" : "") + this._id;
	};

	this.getElement = function() {
		return $(this._getId()) || $(this._div);
	};
};

MLUtil.Popup.Control.Open = function(avStrContentUrl, avStrContentParam, avObjOption, avNInitWidth, avNInitHeight) {

	var objWin = new MLUtil.Popup.Handler();
	objWin.initFunc(
		{
			moduleID: MLUtil.Popup.Control.modulePopupLayerName,
			moduleStyle: null,
			moduleHeadText: null,
			moduleBodyText: null,
			moduleTailText: null,
			moduleDoModal: true,
			moduleBackgroundOnClick: true,
			modulePositionX: null,
			modulePositionY: null,
			moduleWidth: "128px",
			moduleHeight: "128px",
			moduleInitWidth: avNInitWidth,
			moduleInitHeight: avNInitHeight,
			moduleScroll: false,
			moduleBrowserScroll: false,
			moduleDrag: false,
			moduleAutoResize: true,
			ajaxBodyDefine: {ajaxAction: true, ajaxUrl: avStrContentUrl, ajaxParam: avStrContentParam, ajaxTarget: null},
			ajaxTailDefine: {ajaxAction: false, ajaxUrl: null, ajaxParam: null, ajaxTarget: null}
		}
	);

	if (avNInitWidth != null && avNInitWidth != "" && avNInitWidth != "null" && avNInitWidth != "undefined")
		MLUtil.Popup.Control.moduleInitWidth = parseInt(avNInitWidth);

	if (avNInitHeight != null && avNInitHeight != "" && avNInitHeight != "null" && avNInitHeight != "undefined")
		MLUtil.Popup.Control.moduleInitHeight = parseInt(avNInitHeight);

	if (avObjOption == null || avObjOption == "")
		MLUtil.Popup.Control.moduleReloadOption = null;
	else
		MLUtil.Popup.Control.moduleReloadOption = avObjOption;
	objWin.showWindow();
};

MLUtil.Popup.Control.OpenWithScroll = function(avStrContentUrl, avStrContentParam, avObjOption, avNInitWidth, avNInitHeight) {
	var objWin = new MLUtil.Popup.Handler();
	objWin.initFunc(
		{
			moduleID: MLUtil.Popup.Control.modulePopupLayerName,
			moduleStyle: null,
			moduleHeadText: null,
			moduleBodyText: null,
			moduleTailText: null,
			moduleDoModal: true,
			moduleBackgroundOnClick: true,
			modulePositionX: null,
			modulePositionY: null,
			moduleWidth: "128px",
			moduleHeight: "128px",
			moduleInitWidth: avNInitWidth,
			moduleInitHeight: avNInitHeight,
			moduleScroll: true,
			moduleBrowserScroll: true,
			moduleDrag: false,
			moduleAutoResize: true,
			ajaxBodyDefine: {ajaxAction: true, ajaxUrl: avStrContentUrl, ajaxParam: avStrContentParam, ajaxTarget: null},
			ajaxTailDefine: {ajaxAction: false, ajaxUrl: null, ajaxParam: null, ajaxTarget: null}
		}
	);

	if (avNInitWidth != null && avNInitWidth != "" && avNInitWidth != "null" && avNInitWidth != "undefined")
		MLUtil.Popup.Control.moduleInitWidth = parseInt(avNInitWidth);

	if (avNInitHeight != null && avNInitHeight != "" && avNInitHeight != "null" && avNInitHeight != "undefined")
		MLUtil.Popup.Control.moduleInitHeight = parseInt(avNInitHeight);

	if (avObjOption == null || avObjOption == "")
		MLUtil.Popup.Control.moduleReloadOption = null;
	else
		MLUtil.Popup.Control.moduleReloadOption = avObjOption;
	objWin.showWindow();
};

/* 팝업창 닫기 */
function doClosePopup() {
	parent.MLUtil.Popup.Control.hideWindow();
}

/* 사진 회전하기 */
function onRotateImage(strFileId, strThumbUrl) {
	var strFileIds = "";
	var strDoUrl = "/common/popup/popup_rotate_preview.do";
	var strDoParams = "FileId=" + strFileId + "&ThumbUrl=" + strThumbUrl;
	
	MLUtil.Popup.Control.Open(strDoUrl, strDoParams);
}

//레이어 팝업 닫기
MLUtil.Observe.AttachOnload(closePopupKeyDown);

function closePopupKeyDown(e){
	document.onkeydown = function (e){
	    if (!e) e = window.event;
	    if (e.keyCode == 27){
	    	if(document.getElementById("windowPanel")){
	    		MLUtil.Popup.Control.hideWindow();
	    	}
	    }
	};  
}
