var DLG = {};

var DLGSUCC = {};

var bAlerting = false;
var nextActionFunc = null;
DLG.MyAlert = {
	start: function(msg, nWidth){
		var w = 413;
		
		if(nWidth != null)
			w = nWidth;
						
		var options = {
			url: "/dlg/template.aspx?type=alert&msg=" + encodeURIComponent(msg),
			params:"",
			title: "알림",
			width: w,
			onDestroy : this.onDestroy
		}		
		this.modal = FMW.MyModal(options);		
	},
	show : function(msg,w)
	{
		if(bAlerting)
			return;
			
		bAlerting = true;
		this.start(msg,w);
	},	
	hide : function()
	{
		this.modal.destroy();delete this.modal;
	},
	onDestroy : function()
	{
		bAlerting = false;
	}
};

function myAlert(msg,nextAction)
{
	if(nextAction == "undefined" || nextAction == null || nextAction == undefined)
		nextActionFunc = null;
	else	
		nextActionFunc = nextAction;

	DLG.MyAlert.show(msg);
}

function GetProfitableWidth()
{
	var w;
	w = Screen.getDocumentWidth() - 50;
	if(w > 415)
		w = 415;

	return w;
}

function myAlert2(msg,nextAction,w)
{
	if(nextAction == "undefined" || nextAction == null || nextAction == undefined)
		nextActionFunc = null;
	else	
		nextActionFunc = nextAction;

	DLG.MyAlert.show(msg,GetProfitableWidth());
}

function myAlertHide()
{
	DLG.MyAlert.hide();
	
	if(nextActionFunc)
		nextActionFunc();
}

DLG.MyConfirm = {
	start: function(msg, event){
		var w = 413;

		var options = {
			url: "/dlg/template.aspx?type=confirm&msg=" + encodeURIComponent(msg),
			params:"",
			title: "확인",
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	destroy : function(){
		this.modal.destroy();delete this.modal;
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

function myConfirm(msg,nextAction)
{
	nextActionFunc = nextAction;
	DLG.MyConfirm.show(msg);
}
function myConfirmAction()
{
	myConfirmHide();
	nextActionFunc();
}
function myConfirmHide()
{
	DLG.MyConfirm.destroy();
}

DLG.UploadTodayCommentImg = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "이미지 업로드",
			url: "/dlg/pop_uploadimg.aspx?type=todaycommentimg&succfunc=DLG.UploadTodayCommentImg.onsucc&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	onsucc : function(val,path)
	{
		// 성공
		var ajaxURL = "/ajax/saveImg.aspx";
		var data = "";
		data += "&type=todaycomment_img";
		data += "&val=" + val;
		data += "&path=" + encodeURIComponent(path);
		
		PostData(ajaxURL,data,DLG.UploadTodayCommentImg.onsucc_save);
	},	
	onsucc_save : function(res)
	{
		var r = setJSON(res);		
		DLG.UploadTodayCommentImg.hide();

		// reload
		document.location.reload();
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	doaction : function()
	{
    var oform = iframetarget;
    oform.uploadfile();
	}
};

DLG.joinch = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "채널 가입",
			url: "/dlg/pop_joinch.aspx?type=join&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.outch = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "채널 탈퇴",
			url: "/dlg/pop_joinch.aspx?type=out&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

var bFileUploaded = false;
DLG.UploadFile = {
	doaction : function()
	{
		var oform = iframetarget;
		oform.uploadfile();
	},
	init_caption : function()
	{
		$('fileController').innerHTML = "<iframe name='iframetarget' src='/service/uploadfile.aspx?succfunc=DLG.UploadFile.uploaded_caption&val=' width='460' height='30' frameborder='0'></iframe>";
	},
	uploaded_caption : function(val, path)
	{		
		DLG.UploadFile.uploaded_caption_layer(path);
				
		var oform = document.formPds;
		path += ";";
		oform.files.value += path;
	},
	uploaded_caption_layer : function(path)
	{
		var oform = document.formPds;
		var n = parseInt(oform.nUploadedFile.value) + 1;
		oform.nUploadedFile.value = n;
		
		var ajaxURL = "/service/GetFileInfo.aspx";
		var data = "";
		data += "&path=" + encodeURIComponent(path);
				
		PostData(ajaxURL,data,DLG.UploadFile.GetUploadedFileInfo);
	},
	DeleteFile : function(path)
	{	
		var fid = path.substr(0,8);
		fid += "_";
		fid += path.substr(9,path.length-9);
		fid = "fid" + fid;

		// 노드 삭제
		document.getElementById(fid).parentNode.removeChild(document.getElementById(fid));
		
		var oform = document.formPds;
		path += ";";
		oform.delfiles.value += path;

		var oform = document.formPds;
		var n = parseInt(oform.nUploadedFile.value) - 1;
		
		oform.nUploadedFile.value = n;
				
		if(n <= 0)
		{
			// 파일이 없다.
			$('uploadedFiles').innerHTML = "<table><tr><td height='30'>첨부된 파일이 없습니다.</td></tr></table>";
			bFileUploaded = false;
		}
	},
	GetUploadedFileInfo : function(res)
	{		
		var rs = res.responseXML;
		var fpath = rs.documentElement.getElementsByTagName("path")[0].firstChild.nodeValue;
		var fname = rs.documentElement.getElementsByTagName("name")[0].firstChild.nodeValue;
		var fsize = rs.documentElement.getElementsByTagName("fsize")[0].firstChild.nodeValue;

		if(!bFileUploaded)
		{
			$('uploadedFiles').innerHTML = "";
			bFileUploaded = true;
		}

		// 성공
		var template = $('uploadedFileTemplate').innerHTML;
		template = nplace(template,"#FNAME#", fname);
		template = nplace(template,"#FPATH#", fpath);
		template = nplace(template,"#FSIZE#", CalcBytes(parseInt(fsize)));
		
		var fid = fpath.substr(0,8);
		fid += "_";
		fid += fpath.substr(9,fpath.length-9);
		fid = "fid" + fid;
		
		template = nplace(template,"#FPATHID#", fid);
		
		$('uploadedFiles').innerHTML += template;

		// 업로드프레임 초기화
		DLG.UploadFile.init_caption();		
	}
};

DLG.UploadGuestCommentImg = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "이미지 업로드",
			url: "/dlg/pop_uploadimg.aspx?type=guestcommentimg&succfunc=DLG.UploadGuestCommentImg.onsucc&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	onsucc : function(val,path)
	{
		// 성공
		var ajaxURL = "/ajax/saveImg.aspx";
		var data = "";
		data += "&type=guestcomment_img";
		data += "&val=" + val;
		data += "&path=" + encodeURIComponent(path);
		
		PostData(ajaxURL,data,DLG.UploadGuestCommentImg.onsucc_save);
	},	
	onsucc_save : function(res)
	{
		var r = setJSON(res);		
		DLG.UploadGuestCommentImg.hide();

		// reload
		document.location.reload();
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	doaction : function()
	{
    var oform = iframetarget;
    oform.uploadfile();
	}
};

var UploadImgTemplateType = "";
DLG.UploadImgTemplate = {
	start: function(ty, succ, val, event){
		UploadImgTemplateType = ty;
		var w = 338;
		var options = {
			title : "이미지 업로드",
			url: "/dlg/pop_uploadimg.aspx?type="+ty+"&succfunc="+succ+"&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	onsucc : function(val,path)
	{
		// 성공
		var ajaxURL = "/ajax/saveImg.aspx";
		var data = "";
		data += "&type=" + UploadImgTemplateType;
		data += "&val=" + val;
		data += "&path=" + encodeURIComponent(path);
		
		PostData(ajaxURL,data,DLG.UploadImgTemplate.onsucc_save);
	},
	onsucc_save : function(res)
	{
		var r = setJSON(res);		
		DLG.UploadImgTemplate.hide();

		// reload
		document.location.reload();
	},
	show : function(ty,succ,val,event)
	{
		this.start(ty,succ,val,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	doaction : function()
	{
    var oform = iframetarget;
    oform.uploadfile();
	}
};

DLG.UploadTodayImg = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "이미지 업로드",
			url: "/dlg/pop_uploadimg.aspx?type=todayimg&succfunc=DLG.UploadTodayImg.onsucc&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	onsucc : function(val,path)
	{
		// 성공
		var ajaxURL = "/ajax/saveImg.aspx";
		var data = "";
		data += "&type=myhometoday_img";
		data += "&val=" + val;
		data += "&path=" + encodeURIComponent(path);
		
		PostData(ajaxURL,data,DLG.UploadTodayImg.onsucc_save);
	},	
	onsucc_save : function(res)
	{
		var r = setJSON(res);		
		DLG.UploadTodayImg.hide();

		// reload
		document.location.reload();
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	doaction : function()
	{
    var oform = iframetarget;
    oform.uploadfile();
	}
};

DLG.askimg = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "이미지 업로드",
			url: "/dlg/pop_uploadimg.aspx?type=askimg&succfunc=DLG.askimg.onsucc&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	onsucc : function(val,path)
	{
		// 성공
		var ajaxURL = "/ajax/saveImg.aspx";
		var data = "";
		data += "&type=askimg";
		data += "&val=" + val;
		data += "&path=" + encodeURIComponent(path);

		PostData(ajaxURL,data,DLG.askimg.onsucc_save);
	},	
	onsucc_save : function(res)
	{
		var r = setJSON(res);		
		DLG.askimg.hide();

		// reload
		document.location.reload();
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	doaction : function()
	{
    var oform = iframetarget;
    oform.uploadfile();
	}
};

DLG.ansimg = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "이미지 업로드",
			url: "/dlg/pop_uploadimg.aspx?type=ansimg&succfunc=DLG.ansimg.onsucc&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	onsucc : function(val,path)
	{
		// 성공
		var ajaxURL = "/ajax/saveImg.aspx";
		var data = "";
		data += "&type=ansimg";
		data += "&val=" + val;
		data += "&path=" + encodeURIComponent(path);

		PostData(ajaxURL,data,DLG.ansimg.onsucc_save);
	},	
	onsucc_save : function(res)
	{
		var r = setJSON(res);		
		DLG.ansimg.hide();

		// reload
		document.location.reload();
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	doaction : function()
	{
    var oform = iframetarget;
    oform.uploadfile();
	}
};

DLG.UploadGuestImg = {
	start: function(val, event){
		var w = 338;
		var options = {
			title : "이미지 업로드",
			url: "/dlg/pop_uploadimg.aspx?type=guestimg&succfunc=DLG.UploadGuestImg.onsucc&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},
	onsucc : function(val,path)
	{
		// 성공
		var ajaxURL = "/ajax/saveImg.aspx";
		var data = "";
		data += "&type=myhomeguest_img";
		data += "&val=" + val;
		data += "&path=" + encodeURIComponent(path);
		
		PostData(ajaxURL,data,DLG.UploadGuestImg.onsucc_save);
	},	
	onsucc_save : function(res)
	{
		var r = setJSON(res);		
		DLG.UploadGuestImg.hide();

		// reload
		document.location.reload();
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	doaction : function()
	{
    var oform = iframetarget;
    oform.uploadfile();
	}
};

DLG.MyInfo = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "정보수정",
			url: "/dlg/pop_myinfo.aspx?val="+val,
			width: w
		}
		this.modal = FMW.MyModal(options);
	},	
	show : function(mode,event)
	{
		this.start(mode,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.CaptionCommentReply = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "댓글달기",
			url: "/dlg/pop_reply.aspx?type=captioncomment&val="+val,
			width: w,
			onLoadFunc: this.onloaddlg
		}			
		this.modal = FMW.MyModal(options);
	},
	setfocus : function()
	{
		document.scomment.comment.focus();
	},	
	onloaddlg : function()
	{
		setTimeout(DLG.CaptionCommentReply.setfocus, 1000);
	},	
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.VodCommentReply = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "댓글달기",
			url: "/dlg/pop_reply.aspx?type=vodcomment&val="+val,
			width: w,
			onLoadFunc: this.onloaddlg
		}			
		this.modal = FMW.MyModal(options);
	},
	setfocus : function()
	{
		document.scomment.comment.focus();
	},	
	onloaddlg : function()
	{
		setTimeout(DLG.VodCommentReply.setfocus, 1000);
	},	
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.chselans = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "답변선택",
			url: "/dlg/pop_selectans.aspx?type=ch&val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},	
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.selans = {
	start: function(val, event){
		var w = 400;
		var options = {
			title: "답변선택",
			url: "/dlg/pop_selectans.aspx?val="+val,
			width: w
		}			
		this.modal = FMW.MyModal(options);
	},	
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.ansc = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "댓글달기",
			url: "/dlg/pop_reply.aspx?type=asksc&val="+val,
			width: w,
			onLoadFunc: this.onloaddlg
		}	
		this.modal = FMW.MyModal(options);
	},
	setfocus : function()
	{
		document.scomment.comment.focus();
	},
	onloaddlg : function()
	{
		setTimeout(DLG.ansc.setfocus, 1000);
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.CommentReplyModal = {
	start: function(ty,val, event){
		var w = 338;
		var options = {
			title: "댓글달기",			
			url: "/dlg/pop_reply.aspx?type="+ty+"&val="+val,
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	setfocus : function()
	{
		document.scomment.comment.focus();
	},
	onloaddlg : function()
	{
		setTimeout(DLG.CommentReplyModal.setfocus, 1000);
	},
	show : function(ty,msg,event)
	{
		this.start(ty,msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.TodayReplyModal = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "댓글달기",
			url: "/dlg/pop_reply.aspx?val="+val,
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	setfocus : function()
	{
		document.scomment.comment.focus();
	},
	onloaddlg : function()
	{
		setTimeout(DLG.TodayReplyModal.setfocus, 1000);
	},
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.GuestReplyModal = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "댓글달기",
			url: "/dlg/pop_reply.aspx?type=guest&val="+val,
			width: w,
			onLoadFunc: this.onloaddlg
		}
			
		this.modal = FMW.MyModal(options);
	},
	setfocus : function()
	{
		document.scomment.comment.focus();
	},	
	onloaddlg : function()
	{
		setTimeout(DLG.GuestReplyModal.setfocus, 1000);
	},	
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.SendMessage = {
	start: function(val, event){
		var w = 338;
		var options = {
			title: "메시지 보내기",
			url: "/dlg/pop_sendmessage.aspx?nick="+encodeURIComponent(val),
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	setfocus : function()
	{
		document.formmessage.contents.focus();
	},	
	onloaddlg : function()
	{
		setTimeout(DLG.SendMessage.setfocus, 1000);
	},	
	show : function(msg,event)
	{
		this.start(msg,event);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.Friends = {
	accept : function(val,event)
	{
		this.start("accept",val,false,event);
	},		
	del : function(val,event)
	{
		this.start("del",val,false,event);
	},		
	reject : function(val,event)
	{
		this.start("reject",val,false,event);
	},		
	reject2 : function(val,event)
	{
		this.start("reject2",val,false,event);
	},
	add : function(val,event)
	{
		this.start("add",val,true,event);
	},		
	start: function(ty, val, onloadfunc ,event){
		var w = 338;
		if(onloadfunc)
		{
			var options = {
				title: "친구관리",
				url: "/dlg/pop_friends.aspx?type="+ty+"&val="+encodeURIComponent(val),
				width: w,
				onLoadFunc: this.onloaddlg
			}
			this.modal = FMW.MyModal(options);
		}
		else
		{
			var options = {
				title: "친구관리",
				url: "/dlg/pop_friends.aspx?type="+ty+"&val="+encodeURIComponent(val),
				width: w
			}
			this.modal = FMW.MyModal(options);
		}
	},
	setfocus : function()
	{
		document.formmessage.contents.focus();
	},	
	onloaddlg : function()
	{
		setTimeout(DLG.SendMessage.setfocus, 1000);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.AddToMyDic = {
	start: function(val, w){
		var w = 338;
		var options = {
			title: "단어장에 추가하기",
			url: "/dlg/pop_addtodic.aspx",
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg,GetProfitableWidth());
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	onloaddlg : function()
	{
		// 단어장 그룹 가져오기
		var oform = document.formdic;
		
		var ajaxURL = "/ajax/xmlAddToDicContents.aspx";
		var data = "";
		
		data += FormSerialize("formdic");
		
		PostData(ajaxURL,data,DLG.AddToMyDic.onsuccGetContents);
	},		
	onsuccGetContents : function(res)
	{
		$('xmlDicGroupContents').innerHTML = getXmlContents(res);
	}
};

DLG.dic = {
	del : function(val)
	{
		var w = 338;
		var url = "/dlg/pop_dic.aspx?type=del&val="+encodeURIComponent(val);
		
		var options = {
			title: "단어장 관리",
			url: url,
			width: w
		}
		this.modal = FMW.MyModal(options);
	},	
	delword : function(val)
	{
		var w = 338;
		var url = "/dlg/pop_dic.aspx?type=delword&val="+encodeURIComponent(val);

		var options = {
			title: "단어장 관리",
			url: url,
			width: w
		}
		this.modal = FMW.MyModal(options);
	},	
	mod : function(val,name)
	{
		var w = 338;
		var url = "/dlg/pop_dic.aspx?type=mod&val="+encodeURIComponent(val)+"&name="+encodeURIComponent(name);

		var options = {
			title: "단어장 관리",
			url: url,
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	onloaddlg : function()
	{
		// 단어장 그룹 가져오기
		setTimeout(DLG.dic.setfocus, 1000);
	},
	setfocus : function()
	{
		document.formdicmod.modname.focus();
	}	
};

var gFriendsChMemVal;
DLG.FriendsChMem = {
	start: function(val, w){
		gFriendsChMemVal = val;
		var w = 338;
		var options = {
			title: "채널에 가입한 친구들",
			url: "/dlg/pop_friendschmem.aspx?val="+val,
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg);
	},	
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},
	onloaddlg : function()
	{
		// 단어장 그룹 가져오기
		DLG.FriendsChMem.pagingFriendsMemCh(1);
	},		
	onsuccGetContents : function(res)
	{
		$('xmlFriendsChContents').innerHTML = getXmlContents(res);
	},	
	pagingFriendsMemCh : function(val)
	{
		$('xmlFriendsChContents').innerHTML = "<img src='/images/loading.gif'>";
		
		// 단어장 그룹 가져오기
		var ajaxURL = "/ajax/xmlFriendsChMem.aspx";
		var data = "val="+gFriendsChMemVal;
		data += "&page="+val;		
		GetData(ajaxURL,data,DLG.FriendsChMem.onsuccGetContents);		
	}
};

var szSelMDBMode = "";
var nSelMDBPaging = 1;
DLG.SelMDB = {
	start: function(val, w){
		var w = 540;
		var options = {
			title: "디비 검색",
			url: "/dlg/pop_selmdb.aspx",
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg);
	},
	showmanage : function(msg)
	{
		szSelMDBMode = "manage";
		this.start(msg);		
	},
	shownonofficial : function(msg)
	{
		szSelMDBMode = "nonofficial";
		this.start(msg);		
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},	
	loadMDB : function(n)
	{
		nSelMDBPaging = n;
				
		var ajaxURL = "/ajax/xmlGetMDB.aspx";
		var data = "page=" + nSelMDBPaging;
		data += "&mode=";
		data += szSelMDBMode;
		data += "&";
		data += FormSerialize("formmdb");

		GetData(ajaxURL,data,DLG.SelMDB.onsuccGetContents);		
	},
	onloaddlg : function()
	{
		DLG.SelMDB.loadMDB(1);
	},		
	onsuccGetContents : function(res)
	{
		$('xmlMDB').innerHTML = getXmlContents(res);
		
		// 포커스 두기..
		setTimeout(DLG.SelMDB.setfocusskey , 1000);
	},
	setfocusskey : function()
	{
		document.formmdb.skey.focus();
	},	
	paging : function(n)
	{
		DLG.SelMDB.loadMDB(n);
	},
	select : function(n)
	{
		document.formPds.mcode.value=n;
		DLG.SelMDB.getDBName(n);
		DLG.SelMDB.hide();
	},
	regTmpDB : function()
	{
		// 단어장 그룹 가져오기
		var oform = document.formmdb;
		if(!VD.utils.chkBlank(oform.reg,"정보를 입력해주세요."))
			return;

		var ajaxURL = "/ajax/xmlRegMDBName.aspx";
		var data = "";		
		data += FormSerialize("formmdb");
		
		PostData(ajaxURL,data,DLG.SelMDB.onsucc_regTmpDB);
	},
	onsucc_regTmpDB : function(res)
	{
		var r = setJSON(res);				
		document.formPds.mcode.value = r["mcode"];
		$('selectedDB').innerHTML = r["msg"];
		
		DLG.SelMDB.hide();
	},	
	getDBName : function(n)
	{
		var ajaxURL = "/ajax/xmlGetMDBName.aspx";
		var data = "mcode=" + n;

		GetData(ajaxURL,data,DLG.SelMDB.onsucc_getDBName);	
	},
	onsucc_getDBName : function(res)
	{
		$('selectedDB').innerHTML = getXmlContents(res);
	}
};

DLG.InputMDB = {
	start: function(val, w){
		var w = 540;
		var options = {
			title: "디비 입력",
			url: "/dlg/pop_selmdb.aspx?type=input",
			width: w,
			onLoadFunc: this.onloaddlg
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg);
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	},	
	onloaddlg : function()
	{
		var ajaxURL = "/ajax/xmlInputMDB.aspx";
		var data = "";
		GetData(ajaxURL,data,DLG.InputMDB.onsuccGetContents);		
	},		
	onsuccGetContents : function(res)
	{
		$('xmlMDB').innerHTML = getXmlContents(res);
	}
};

DLG.BuyVod = {
	start: function(val, w){
		var w = 400;
		var options = {
			title: "프리미엄 스터디",
			url: "/dlg/prem_vod.aspx?uid="+val,
			width: w
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg);
	},
	load : function(ourl)
	{
		PostData(ourl,"",DLG.BuyVod.onloadurl);		
	},
	buy : function(uid)
	{
		this.load('/dlg/prem_vod_bought.aspx?uid='+uid);
	},
	onloadurl : function(res)
	{
		$('contentsmodal0').innerHTML=res.responseText;
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.Singo = {
	start: function(val, w){
		var w = 400;
		var options = {
			title: "신고하기",
			url: "/dlg/singo.aspx?uid="+val,
			width: w
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg);
	},
	doit : function()
	{
		var oform = document.singo;
		if(!VD.utils.chkBlank(oform.contents,"정보를 입력해주세요."))
			return;

		var ajaxURL = "/ajax/singo.aspx";
		var data = "";
		data += FormSerialize("singo");
		
		PostData(ajaxURL,data,DLG.Singo.onsucc);
	},
	onsucc : function(res)
	{		
		myAlert("관리자 확인후 신속히 처리하겠습니다.");
		DLG.Singo.hide();
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.PointLogVod = {
	start: function(val){
		var w = 400;
		var options = {
			title: "포인트 적립상황",
			url: "/dlg/point_log_vod.aspx?uid="+val,
			width: w
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg);
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};

DLG.DownloadVOD = {
	start: function(val, w){
		var w = 400;
		var options = {
			title: "다운로드",
			url: "/dlg/download.aspx?uid="+val,
			width: w
		}
		this.modal = FMW.MyModal(options);
	},
	show : function(msg)
	{
		this.start(msg);
	},
	hide : function()
	{	
		this.modal.destroy();delete this.modal;
	}
};