﻿Forum = {}
Forum.ConfirmDelete = function()
{
	if(confirm("정말로 삭제하시겠습니까?"))
	{
		return true;
	}
	else
	{
		return false;
	}
}

Forum.DataDoesNotExist = function (table, page)
{
    alert("글이 존재하지 않습니다\n\n글이 삭제되었거나, 접근이 불가능합니다");
    location.href = "Default.aspx?TBL=" + table + "&PGN=" + page;
}

Forum.DoNotDelete = function (table, page)
{
    alert("글을 삭제한 권한이 없습니다");
    location.href = "Default.aspx?TBL=" + table + "&PGN=" + page;
}

Forum.MustFillComment = function(ctlID, ctlWriter, ctlPwd) 
{ 
    var writer = $get(ctlWriter).value;
    var password = $get(ctlPwd).value;
    var ment = $get(ctlID).value; 
    
    if (writer.length == 0) {
        alert("작성자명을 입력해 주세요.");
        $get(ctlWriter).focus();
        return false;
    }
    
    if (password.length == 0) {
        alert("비밀번호를 입력해 주세요.");
        $get(ctlPwd).focus();
        return false;
    }
    
    ment = Common.ReplaceAll(ment, " ", ""); 
    ment = Common.ReplaceAll(ment, "\t", ""); 
    ment = Common.ReplaceAll(ment, "\r", ""); 
    ment = Common.ReplaceAll(ment, "\n", ""); 
    if(ment.length == 0) 
    { 
        alert("커멘트를 입력해 주세요"); 
        $get(ctlID).select(); 
        return false; 
    }	
    return true; 
}

Forum.ConfirmDelete = function()
{ 
    if(confirm("삭제하시겠습니까?")) 
        return true; 
    else 
        return false;
}	

Forum.ShowMyListMessage = function (part, querystring)
{
/*
 returnValue = -1 : 이미 찜 제한개수를 넘었다면 -1을 반환한다
 returnValue = 0  : 이미 찜이 되어있는 것이라면 0을 반환한다.
 returnValue = 1  : 정상처리
 */
    if(part == 1)
    {
        alert("[마이 리스트]에 저장되었습니다");
    }
    else if(part == 0)
    {
        alert("이미 [마이 리스트]에 들어있는 글입니다");
    }
    else if(part == -1)    
    {
        alert("[마이 리스트]가 가득 차서 더 이상 저장할 수 없습니다");
    }
    
    location.href = "Content.aspx?" + querystring;
}

Forum.ChangeForumList = function(srcElement)
{
    var forumName = srcElement.options[srcElement.selectedIndex].value;
    location.href = "Default.aspx?TBL=" + forumName;
}

Forum.SetSelectedForumName = function (selectCtl, forumName)
{
    for(var i=0; i <selectCtl.options.length; i++)
    {
        if(selectCtl.options[i].value == forumName)
        {
            selectCtl.options[i].selected = true;
            return;
        }
    }
}

Forum.ResizeImage = function(img)
{
    if(img.width > 80)
    {
        img.width = 80;
    }
}

/* 최지훈 추가 */
Forum.CheckValidInput = function() {
    if (!Forum.CheckEmptyValue(document.getElementById("hidWriter").value, "작성자")) {
        return false;
    }
    
    // 로그인된 상태에만 작성할 수 있는 FXQNA 게시판에 경우는 비밀번호 필수 입력 체크를 넘김니다. - 황보세현
    if (document.getElementById("hidTable").value != "FXQNA") {
        if (!Forum.CheckEmptyValue(document.getElementById("hidPassword").value, "비밀번호")) {
            return false;
        }
    }

    if (!Forum.CheckEmptyValue(document.getElementById("hidSubject").value, "제목")) {
        return false;
    }

    if (!Forum.CheckEmptyValue(document.getElementById("hidContent").value, "본문")) {
        return false;
    }

    return true;
}

Forum.CheckEmptyPassword = function(ctlID) 
{
    if (! Forum.CheckEmptyValue(ctlID, "비밀번호")) {
        return false;
    }
    
    return true;
}

Forum.CheckEmptyValue = function(objTextID, alertText) {
    if (document.getElementById(objTextID).value == "") {
        alert(alertText + "(을)를 입력하세요.");
        document.getElementById(objTextID).focus();
        return false;
    }
    
    return true;
}
/* 최지훈 추가 */
