﻿// JScript 파일


function OnInsertBoardComment(lno, control, retUrl)
{
	var contents = document.getElementById(control).value;
	if(contents == '' || contents == null)
	{
		alert('정보를 기입해 주시기 바랍니다.');
		return;
	}
	if(confirm('댓글을 등록하시겠습니까?'))
	{
		AjaxService.InsertBoardComment(lno, contents, OnInsertBoardComment_CallBack);
	}
}

function OnInsertBoardComment_CallBack(value)
{
	if(value == "SUCCESS")
	{
		PageReload();
	}
	else if(value == "FAIL")
	{
		alert('댓글 등록을 실패했습니다.'); 
	}
	else if(value == "NOAUTH")
	{
		alert('로그인 하신 후 이용해 주세요.'); 
//		if(confirm('인증된 사용자만 댓글을 등록할 수 있습니다.\n로그인 페이지로 이동하시겠습니까?'))
//		{
//			location.href = '../MemberShip/Login.aspx';
//		}
	}
	else
	{
		alert(value);
	}
}

function OnInsertEventComment(eno, control, retUrl)
{
	var contents = document.getElementById(control).value;
	if(contents == '' || contents == null)
	{
		alert('정보를 기입해 주시기 바랍니다.');
		return;
	}
	if(confirm('댓글을 등록하시겠습니까?'))
	{
		AjaxService.InsertEventComment(eno, contents, OnInsertEventComment_CallBack);
	}
}

function OnInsertEventComment_CallBack(value)
{
	if(value == "SUCCESS")
	{
		PageReload();
	}
	else if(value == "FAIL")
	{
		alert('댓글 등록을 실패했습니다.'); 
	}
	else if(value == "NOAUTH")
	{
		if(confirm('인증된 사용자만 댓글을 등록할 수 있습니다.\n로그인 페이지로 이동하시겠습니까?'))
		{
			location.href = '../MemberShip/Login.aspx';
		}
	}
	else
	{
		alert(value);
	}
}


function OnDeleteBoardComment(cno)
{
	if(confirm('댓글을 삭제하시겠습니까?'))
	{
		AjaxService.DeleteBoardComment(cno, OnDeleteBoardComment_CallBack);
	}
}

function OnDeleteBoardComment_CallBack(value)
{
	if(value == "SUCCESS")
	{
		PageReload();
	}
	else if(value == "FAIL")
	{
		alert('댓글 등록을 실패했습니다.'); 
	}
	else if(value == "NOAUTH")
	{
		alert('권한 오류가 발생했습니다.'); 
	}
	else
	{
		alert('오류가 발생했습니다.');
	}
}

function OnDeleteEventComment(cno)
{
	if(confirm('댓글을 삭제하시겠습니까?'))
	{
		AjaxService.DeleteEventComment(cno, OnDeleteEventComment_CallBack);
	}
}

function OnDeleteEventComment_CallBack(value)
{
	if(value == "SUCCESS")
	{
		PageReload();
	}
	else if(value == "FAIL")
	{
		alert('댓글 등록을 실패했습니다.'); 
	}
	else if(value == "NOAUTH")
	{
		alert('권한 오류가 발생했습니다.'); 
	}
	else
	{
		alert('오류가 발생했습니다.');
	}
}


function viewVOD(url)
{
	window.open('./MediaPopup.aspx?url=' + url, 'GET', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=540,copyhistory=no');
}

function CheckSearchTextValid(ctrl)
{
	if(document.getElementById(ctrl).value.length <= 1)
	{
		alert('검색어는 2글자 이상이어야 합니다.');
		document.getElementById(ctrl).focus();
		return false;
	}
	else
	{
		return true;
	}
}