﻿function Ov(id) {
    $get(id).className = "sayOv";
}
function Ou(id) {
    $get(id).className = "sayOu";
}
function GoTV(obj) {
    if (obj.className == "iconEnglish fl") {
        setTypingMode(4);
        obj.className = "iconVietnamese fl";
        obj.title = "Tắt gõ tiếng Việt";
    }
    else {
        setTypingMode(0);
        obj.className = "iconEnglish fl";
        obj.title = "Bật gõ tiếng Việt";
    }
}

function setGoTV() {
    var obj = $get("idImgGTV");
    if (mdict.indexOf("V") == 0) {
        setTypingMode(4);
        obj.className = "iconVietnamese fl";
        obj.title = "Tắt gõ tiếng Việt";
    }
    else {
        setTypingMode(0);
        obj.className = "iconEnglish fl";
        obj.title = "Bật gõ tiếng Việt";
    }
}
function onkeyup_Complete(wd) {
    if (wd != null && wd.value != "" && wd.value != 'undefined') {
        Show_CompleteWord(mdict, wd.value);
    }
    else {
        $get("divComplete").style.display = "none";
        hideSound(0); //1 an 0 hien                                                                
    }
}

function Show_CompleteWord(dict, wrd) {
    if (wrd == null || wrd == "") { return; }

    if (AjaxFuncs.CheckStrWord(dict, wrd).value < 0) {
        return;
    }
    AjaxFuncs.getCompleteWord(dict, wrd, language_vg, callback_Show_CompleteWord);
}
function Close_CompleteMtd() {
    $get("divComplete").InnerHTML = "";
    $get("divComplete").style.display = "none";
    hideSound(0); //1 an 0 hien         
}
function Enter() {

    if ($get("ComboboxDict") != null) { mdict = $get("ComboboxDict").value; }
    var wrd = $get("txtword").value;
    if (wrd == "") { return; }
    $get("divComplete").style.display = 'none';
    wrd = trim(wrd);
    if (wrd == word) { return; }
    //window.location.href = encodeURIComponent(wrd) + "?t=" + mdict;
    window.location.href =setPage()+"?k="+ encodeURIComponent(wrd)+"&t="+mdict;          
}

function cw(wrd)//in list mean
{
    if ($get("ComboboxDict") != null) { mdict = $get("ComboboxDict").value; }
    if (wrd.innerHTML == word) { return; }
    var m_wrd = wrd.innerHTML.replace("<b>", "").replace("</b>", "").replace("<B>", "").replace("</B>", "");
    //window.location.href = encodeURIComponent(m_wrd) + "?t=" + mdict;
    window.location.href = setPage() + "?k=" + encodeURIComponent(m_wrd) + "&t=" + mdict;                
}
function st(dict, i, n, vt, ncount) {
    var j = 0;
    if (i == n) {
        for (j = 0; j <= n; j++) {
            if ($get("spmn" + dict + j) != null) {
                $get("spmn" + dict + j).className = "ct";
            }
            if ($get("tb_" + dict + j) != null) {
                $get("tb_" + dict + j).style.display = "";
            }
        }
        if ($get("spmn" + dict + i) != null) {
            $get("spmn" + dict + i).className = "st";
        }
    }
    else {
        for (j = 0; j <= n; j++) {
            if ($get("spmn" + dict + j) != null) {
                $get("spmn" + dict + j).className = "ct";
            }

            if ($get("tb_" + dict + j) != null) {
                $get("tb_" + dict + j).style.display = "none";
            }
        }
        if ($get("spmn" + dict + i) != null) {
            $get("spmn" + dict + i).className = "st";
        }
        if ($get("tb_" + dict + i)) {
            $get("tb_" + dict + i).style.display = "";
        }
    }

    if ($get("content_" + vt).style.display == "none") {
        Open_Close("ico_", "content_", vt, ncount);
    }

}
function setPage() {
    return "tu-dien-truc-tuyen.aspx";
}

function changedict(dict) {
    if ($get("txtword").value != "") {
        //window.location.href = encodeURIComponent($get("txtword").value) + "?t=" + dict.id;
        window.location.href = setPage() + "?k=" + encodeURIComponent($get("txtword").value) + "&t=" + dict.id;
    }
    else {
        $get("ComboboxDict_text").innerHTML = $get(dict.id).innerHTML;
        $get("ComboboxDict").value = dict.id;
        $get('cbbSel').style.display = 'none';
        mdict = dict.id;
        setGoTV();
    }
}

function M_OverComplete(wrd) {
    if (flag == 1) {
        wrd.style.cursor = "";
        setPosSelect_mtd();
        if (node != -1) {
            $get(node).className = "completeout";
        }
    }
    else {
        if (node >= 0) {
            $get("0").className = "completeout";
            $get(node).className = "completeout";
        }
        wrd.className = "completeover";
        node = (wrd.id) * 1;
    }
}

function M_outComplete(wrd) {
    if (wrd.style.cursor != "") {
        if (node >= 0) {
            $get(node).className = "completeout";
            wrd.className = "completeout";
        }
    }
    flag = 0;
}


function setvalueall(CHTA_flag) {
    if (CHTA_flag == "1") { if ($get("chta_1")) { startIn(); } }
    if ($get(mdict)) { $get(mdict).selected = true; }
}

var numIn = 1;
var lccc = 0;
function doall() {
    if ($get("chta_" + numIn)) {
        $get("chta_" + (numIn - 1)).style.display = "none";
        $get("chta_" + numIn).style.display = "";
        lccc = 1;
        numIn++;
    }
    else if (lccc == 1) {
        $get("chta_" + (numIn - 1)).style.display = "none";
        $get("chta_0").style.display = "";
        numIn = 1;
    }
}

var idin = null;
function startIn() {
    idin = setInterval("doall()", 5000);
}

function StopIn() {
    clearInterval(idin);
}

function closeComplete() {
    if ($get("divComplete").style.display == "") {
        if ($get("divComplete").className == 'bordervien') {
            $get("divComplete").style.display = "none";
        }
    }

}


function Open_Close(ico_, content_, i, n) {
    var id = ico_ + i;
    var idcontent = content_ + i;
    if ($get(idcontent).style.display == "none") {
        $get(id).className = "icon_cbbD";
        $get(idcontent).style.display = "";
        $get(id).title = "Đóng";

    }
    else {
        $get(id).className = "icon_cbbM";
        $get(idcontent).style.display = "none";
        $get(id).title = "Mở";
    }


    var fl = false;
    for (var j = 0; j < n; j++) {
        if ($get(content_ + j).style.display == "") {
            fl = true;
            break;
        }
    }
    if (fl == true) {
        if ($get("idiconAll")) {
            $get("idiconAll").className = "icon_cbbDall";
            $get("idiconAll").innerHTML = "Đóng tất cả";
        }
    }
    else {
        if ($get("idiconAll")) {
            $get("idiconAll").className = "icon_cbbMall";
            $get("idiconAll").innerHTML = "Mở tất cả";
        }
    }



}
function Open_CloseAll(n) {
    if ($get("idiconAll")) {
        if ($get("idiconAll").className == "icon_cbbDall") {
            $get("idiconAll").className = "icon_cbbMall";
            $get("idiconAll").innerHTML = "Mở tất cả";
            for (var j = 0; j < n; j++) {
                $get("content_" + j).style.display = "none";
                $get("ico_" + j).className = "icon_cbbM";
            }
        }
        else {
            $get("idiconAll").className = "icon_cbbDall";
            $get("idiconAll").innerHTML = "Đóng tất cả";
            for (var j = 0; j < n; j++) {
                $get("content_" + j).style.display = "";
                $get("ico_" + j).className = "icon_cbbD";
            }
        }
    }
}
function onDoubleClick(w) { }