function goLogin() {

    if (document.getElementById("modalLayer")) {
        showModalBox();
        document.frm.ruser.focus();
        return;
    }

    fnLogin();
}

function fnLogin() {

	var f = document.frm;

    if (f.ruser && f.ruser.value.length < 1) {
        alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
        f.ruser.focus();
        return;
    }
	if (f.ruser && f.ruser.value.getByteLength() < 4) {
        alert("ÃÖ¼Ò 4Byte(¿µ¹®, ¼ýÀÚ 4ÀÚ ¶Ç´Â ÇÑ±Û 2ÀÚ)¸¦ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.");
        f.ruser.select();
        return;
	}
	if (f.ruser && f.ruser.value.getByteLength() > 50) {
        alert("±ÛÀÚ ¼ö°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù.\n50Byte±îÁö ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
        f.ruser.select();
        return;
	}

    if (f.rpass && f.rpass.value.length < 1) {
        alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
        f.rpass.focus();
        return;
    }
	if (f.rpass && f.rpass.value.getByteLength() < 4) {
        alert("ÃÖ¼Ò 4Byte(¿µ¹®, ¼ýÀÚ 4ÀÚ)¸¦ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.");
        f.rpass.select();
        return;
	}
	if (f.rpass && f.rpass.value.getByteLength() > 20) {
        alert("±ÛÀÚ ¼ö°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù.\n20Byte±îÁö ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
        f.rpass.select();
        return;
	}

	f.action = "/board/fragment/login.jsp";
	f.target = "ifrm";
	f.submit();
}

function fnLoginCancle() {

    document.frm.ruser.value = "";
    document.frm.rpass.value = "";
    hideModalBox();
}

function goLogout() {

	var f = document.frm;

	f.action = "/board/fragment/logout.jsp";
	f.target = "ifrm";
	f.submit();
}

function goList(pnum, rpage) {

	var f = document.frm;

    f.cpage.value = pnum;
	f.wmode.value = "l";
	f.action = rpage;
	f.target = "";
	f.submit();
}

function goView(seq, rpage) {

	var f = document.frm;

    f.encoding = "application/x-www-form-urlencoded";
	f.sqnum.value = seq;
	f.wmode.value = "v";
	f.action = rpage;
	f.target = "";
	f.submit();
}

function goWrite(rpage) {

	var f = document.frm;

	f.wmode.value = "w";
	f.action = rpage;
	f.target = "";
	f.submit();
}

function goEdit(seq, rpage) {

	var f = document.frm;

	f.sqnum.value = seq;
	f.wmode.value = "e";
	f.action = rpage;
	f.target = "";
	f.submit();
}

function goReply(seq) {

	var f = document.frm;

	f.sqnum.value = seq;
	f.wmode.value = "r";
	f.target = "";
	f.submit();
}

function goSave() {

	var f = document.frm;

	if (f.ruser && f.ruser.value.length < 1) {
	    alert("¼º¸íÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
	    f.ruser.focus();
	    return;
	}
	if (f.ruser && f.ruser.value.getByteLength() < 4) {
        alert("ÃÖ¼Ò 4Byte(¿µ¹®, ¼ýÀÚ 4ÀÚ ¶Ç´Â ÇÑ±Û 2ÀÚ)¸¦ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.");
        f.ruser.select();
        return;
	}
	if (f.ruser && f.ruser.value.getByteLength() > 50) {
        alert("±ÛÀÚ ¼ö°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù.\n50Byte±îÁö ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
        f.ruser.select();
        return;
	}

	if (f.rpass && f.rpass.value.length < 1) {
	    alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
	    f.rpass.focus();
	    return;
	}
	if (f.rpass && f.rpass.value.getByteLength() < 4) {
        alert("ÃÖ¼Ò 4Byte(¿µ¹®, ¼ýÀÚ 4ÀÚ)¸¦ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.");
        f.rpass.select();
        return;
	}
	if (f.rpass && f.rpass.value.getByteLength() > 20) {
        alert("±ÛÀÚ ¼ö°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù.\n20Byte±îÁö ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
        f.rpass.select();
        return;
	}

	if (f.rphone && f.rphone.value.length < 1) {
	    alert("¿¬¶ôÃ³¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
	    f.rphone.focus();
	    return;
	}
	if (f.rphone && !f.rphone.value.isPhoneNum()) {
        alert("¿¬¶ôÃ³ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.\nÀüÈ­¹øÈ£ ¶Ç´Â ÈÞ´ëÀüÈ­¹øÈ£ Çü½ÄÀ¸·Î ÀÔ·ÂÇØÁÖ¼¼¿ä.");
        f.rphone.select();
        return;
	}

	if (f.rmail && f.rmail.value.length < 1) {
	    alert("ÀÌ¸ÞÀÏ ÁÖ¼Ò¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
	    f.rmail.focus();
	    return;
	}
	if (f.rmail && !f.rmail.value.isEmail()) {
        alert("ÀÌ¸ÞÀÏ ÁÖ¼ÒÇü½ÄÀÌ ¾Æ´Õ´Ï´Ù.");
        f.rmail.select();
        return;
	}

	if (f.subject.value.length < 1) {
	    alert("Á¦¸ñÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
	    f.subject.focus();
	    return;
	}
	if (f.subject.value.getByteLength() < 4) {
        alert("ÃÖ¼Ò 10Byte(¿µ¹®, ¼ýÀÚ 10ÀÚ, ÇÑ±Û 5ÀÚ)¸¦ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.");
        f.subject.select();
        return;
	}

	if (f.content.value.length < 1) {
	    alert("³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
	    f.content.focus();
	    return;
	}
	if (f.content.value.getByteLength() < 20) {
        alert("ÃÖ¼Ò 20Byte(¿µ¹®, ¼ýÀÚ 20ÀÚ, ÇÑ±Û 10ÀÚ)¸¦ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.");
        f.content.select();
        return;
	}

	f.action = "/board/write.jsp";
	f.target = "ifrm";
	f.submit();
}

function goDelete() {

	if (confirm("»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) {
        if (document.getElementById("modalLayer")) {
            showModalBox();
            document.frm.rpass.focus();
            return;
        }

        fnDelete();
    }
}

function fnDelete() {

	var f = document.frm;

    if (f.rpass && f.rpass.value.length < 1) {
        alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
        f.rpass.focus();
        return;
    }

	f.wmode.value = "d";
	f.action = "/board/delete.jsp";
	f.target = "ifrm";
	f.submit();
}

function fnDeleteCancle() {

    document.frm.rpass.value = "";
    hideModalBox();
}

function showModalBox() {

    document.getElementById("modalBackground").style.width = document.body.clientWidth;
    document.getElementById("modalBackground").style.height = document.body.clientHeight;
    document.getElementById("modalLayer").style.width = document.body.clientWidth;
    document.getElementById("modalLayer").style.height = document.body.clientHeight;
    document.getElementById("modalBackground").style.display = "block";
    document.getElementById("modalLayer").style.display = "block";
}

function hideModalBox() {

    document.getElementById("modalLayer").style.display = "none";
    document.getElementById("modalBackground").style.display = "none";
}

function fnDownload(seq, fseq) {

	var f = document.frm;

	f.sqnum.value = seq;
	f.fsnum.value = fseq;
	f.action = "/board/fragment/download.jsp";
	f.target = "ifrm";
	f.submit();
}


