/* 실 제거 등에 사용되는 일반적인 팝업 레이어 */
var popupData;
var showPopup = function(event, title, message, execFunc, left,secFunc) {
	if(popupData && popupData.container) {
		document.body.removeChild(popupData.container);
	}
	pageX =  event.clientX; 


	if(left) pageX -= left;
	popupData = {};
	popupData.container = document.createElement('div');
	popupData.container.innerHTML = '<div class="popup w400"><div class="upper"><a href="#" onclick="popupCancel();return false"><img src="/images/common/popup_close.gif" alt="닫기"></a></div><div class="content"><div class="title">' + title + '</div><p>' + message + '</p><div class="btn"><a href="#" onclick="popupSubmit();return false"><img src="/images/common/btn_p_ok.gif" alt="확인"></a><a href="#" onclick="popupCancel();return false"><img src="/images/common/btn_p_cancel.gif" alt="취소"></a></div></div></div>';
	popupData.container.style.cssText = 'position:absolute;left:' + pageX + 'px;top:' +($(window).scrollTop() +  event.clientY) + 'px';
	popupData.execFunc = execFunc;
	
	document.body.appendChild(popupData.container);
	if(secFunc) secFunc();
};

var popupSubmit = function() {
	if(!popupData) return;
	
	var execFunc = popupData.execFunc;
	execFunc();
	popupCancel();

};
var popupCancel = function() {
	if(!popupData) return;

	document.body.removeChild(popupData.container);
	popupData.container = null;
	popupData.execFunc = null;
	popupData = null;
};

/* 페이지 전체에 사용되는 로그인 레이어 */
var showLoginPopup = function() {
	Layer.load('/ajax/showLoginPopup.php', 'ajax');
};


var showLevelPopup = function(lev) { 
	Layer.load('/ajax/showLevelPopup.php?lev='+lev, 'ajax');
};



/* 이전 진짜 window.open으로 띄우는 팝업 */
var openWindowPopup = function(href, target, left, top, width, height) {
	window.open(href, target, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0');
};
var openGamgulPopup = function(ancher) {
	openWindowPopup(ancher.href, '_gamgul', 50, 50, 540, 600);
};


