﻿function CheckComment() {
    var err = "";
    var temp = "";
    if (GetCtrlValue("ctl00_cphContentBody_LanguageID") == "1") { //Thai
        if (GetCtrlValue("ctl00_cphContent_txtFormMessage") == ""){ temp += "* ความคิดเห็น\n";}
        if (GetCtrlValue("ctl00_cphContent_txtFormBy") == ""){ temp += "* ชื่อผู้ออกความคิดเห็น\n";}
        if (GetCtrlValue("ctl00_cphContent_txtFormEmail") == ""){ temp += "* อีเมล\n";}
        if (temp !="" ){ err= "กรุณากรอกข้อมูลดังต่อไปนี้ให้สมบูรณ์\n" + temp;}
        temp = "";
        if (GetCtrlValue("ctl00_cphContent_txtFormEmail") != "") {
            if (isEmail(GetCtrlValue("ctl00_cphContent_txtFormEmail")) == false) { temp += "* อีเมลไม่ถูกต้อง\n"; }
        }
        if (GetCtrlValue("ctl00_cphContent_fulFormImage") != "") {
            if (isImageFile(GetCtrlValue("ctl00_cphContent_fulFormImage")) == false) { temp += "* ไฟล์ไม่ถูกต้อง อัพโหลดได้เฉพาะไฟล์รูปเท่านั้น\n"; }
        }
        if (temp !="" ){ err += "กรุณาตรวจสอบและกรอกข้อมูลใหม่ เนื่องจาก\n" + temp ;}
        temp = "";
    }
    else {
        if (GetCtrlValue("ctl00_cphContent_txtFormMessage") == ""){ temp += "* Comment\n";}
        if (GetCtrlValue("ctl00_cphContent_txtFormBy") == ""){ temp += "* Comment by\n";}
        if (GetCtrlValue("ctl00_cphContent_txtFormEmail") == ""){ temp += "* E-mail\n";}
        if (temp !="" ){ err= "Please input required data for completion as follow(s);\n" + temp;}
        temp = "";
        if (GetCtrlValue("ctl00_cphContent_txtFormEmail") != "") {
            if (isEmail(GetCtrlValue("ctl00_cphContent_txtFormEmail")) == false) { temp += "* Invalid email address\n"; }
        }
        if (GetCtrlValue("ctl00_cphContent_fulFormImage") != "") {
            if (isImageFile(GetCtrlValue("ctl00_cphContent_fulFormImage")) == false) { temp += "* Invalid image file, upload image only\n"; }
        }
        if (temp !="" ){ err += "Please verify the correctness of required data as follow(s);\n" + temp ;}
        temp = "";
    }
    if (err != "") {
        alert(err);
        return false;
    }
    else {
        __doPostBack('ctl00$cphContent$btnSend','');
        return true;
    }
}

function CommentDelete(ctlId) {
    var ctlName = ctlId.replace(/_/g, "$");
    //alert(ctlName + " " + "ctl00$cphContent$dlComment$ctl02$linkCommentDelete");
    if (GetCtrlValue("ctl00_cphContentBody_LanguageID") == "1") { //Thai
        if (confirm("ต้องการแจ้งลบความคิดเห็นนี้?") == true) {
            //__doPostBack('ctl00$cphContent$dlComment$ctl02$linkCommentDelete','');
            __doPostBack(ctlName,'');
            return true;
        }
        else {
            return false;
        }
    }
    else {
        if (confirm("ต้องการแจ้งลบความคิดเห็นนี้?") == true) {
            //__doPostBack('ctl00$cphContent$dlComment$ctl02$linkCommentDelete','');
            __doPostBack(ctlName,'');
            return true;
        }
        else {
            return false;
        }
    }
}

function SelectQuote(index) {
    GetCtrl("REPLY_ID").style.display = "block";
    GetCtrl("ctl00_cphContent_lblReplyNo").innerHTML = GetCtrlValue("CommentNo_" + index);
    SetCtrlValue("ctl00_cphContent_ReplyID", GetCtrlValue("CommentID_" + index));
}
