﻿function ClearSearchTxt() {
    var txt = document.getElementById("ctl00_ct1_search_txtSearch");
    if (txt.value == "tìm kiếm") {
        txt.value = "";
    }
}

// do abuse hit
function DoAbuseHits(id) {
    PageMethods.DoAbuseHits(id, OnSuccess, OnError);
    // -- cancel postback
    return false;
}
function OnSuccess(result) {
    alert('Xin cảm ơn bạn, chúng tôi sẽ xem xét nội dung bài viết bạn vừa phản ánh');
}

// do update comment
function DoCreateComment(detail, questionId, clId, pcId) {
    PageMethods.UpdateComment(detail, questionId, clId, pcId, OnCreateCommentSuccess, OnError);
    
    // -- cancel postback
    return false;
}
function OnCreateCommentSuccess(result) {
    var text = result[0];
    var divC = result[1];
    var divP = result[2];

    if (divC == '') {
        divC = 'divCommentList';
    }
    if (divP == '') {
        divP = 'divPostComment';
    }
    
    var div = document.getElementById(divC);
    if (div != null) {
        // clear old text
        div.innerHTML = '';
        // set new text
        div.innerHTML = text;
    }
    var divTxt = document.getElementById(divP);
    if (divTxt != null) {
        divTxt.style.display = 'none';
    }
}

function OnError(error) {
    alert(error);
}

function ShowPostComment(txtId) {
    var divTxt = null;
    if (txtId == null) {
        divTxt = document.getElementById('divPostComment');
    }
    else {
        divTxt = document.getElementById(txtId);
    }
    
    if (divTxt != null) {
        var status = divTxt.style.display;
        if (status == '') {
            divTxt.style.display = 'none';
        }
        else {
            divTxt.style.display = '';
        }
    }
}