﻿Forum = function()
{
    this.DidSubmit = false;
}

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) 
{ 
    var ment = $get(ctlID).value; 
    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 > 100)
    {
        img.width = 100;
    }
}

Forum.Search = function(table)
{
    var targetVal = $get("Key1").value;
    if(targetVal.length < 2)
    {
        alert("검색어는 2글자 이상 입력해 주십시오");
        $get("Key1").focus();
        return false;
    }
    
    var part = $get("Part").options[$get("Part").selectedIndex].value;
    var url = "/Search/Default.aspx?TBL=" + table + "&PRT=" + part + "&KEY=" + encodeURI(targetVal);

    location.href=url;
}

Forum.EnterSubmit = function() {

    if (event.keyCode == 13)
        $get("SearchImg").click();
}

Forum.CheckAutoBr = function(ctl, content) {

    if ($get(ctl).checked) {
        $get(content).setAttribute('wrap', 'hard');
    }
    else {
        $get(content).setAttribute('wrap', 'off');
    }
}

//Forum.CheckSubmitTwice = function()
//{
//    if(this.DidSubmit) 
//        return true;
//    else
//    {
//        this.DidSubmit = true;
//        return false;
//    }
//}