﻿function ctlTimKiemDoanhNghiep_ChangeTextDefaultPro(obj, string) {
    if (obj.value == '') {
        obj.value = string;
        //obj.style.color = '#666666'
    }
    else
        if (obj.value == string) {
        //obj.style.color = '#666666'
    }
    else {
        //obj.style.color = '#000000'
    }
}

function ctlTimKiemDoanhNghiep_ChangeTextFocusPro(obj, string) {
    if (obj.value == string) {
        obj.value = '';
        //obj.color = '#000000'
    }
}
function ctlTimKiemDoanhNghiep_btnTimKiem_click(ctlID) {
    var URL;
    var path = document.getElementById(ctlID + "_txtPath").value;
    var TuKhoa = string_ChuanXau(document.getElementById(ctlID + "_txtThongTin").value);
    var MaTinh = ctlUserList_LayGiaTri(ctlID + "_ddlTinh");
    var LoaiDN = ctlUserList_LayGiaTri(ctlID + "_ddlLoaiDN");    
    //if (parseInt(MaTinh) > 0) {
    while (TuKhoa.indexOf(".") >= 0) {
        TuKhoa = TuKhoa.replace('.', ' ');
    }
    if (TuKhoa == "Thông tin tìm kiếm!") {
        TuKhoa = "_";
    }
    URL = path + "/tim-nhanh-doanh-nghiep-bat-dong-san/" + MaTinh + "/" + LoaiDN + "/" + TuKhoa + ".html"
    document.location = URL;
    //Chủ đầu tư tìm kiếm!
    //}
}

function ctlTimKiemDoanhNghiep_txt_onEnter(txtID, txtOldValue, ctlID) {
    var txt = document.getElementById(txtID);
    if (txtOldValue == txt.value) {
        ctlTimKiemDoanhNghiep_btnTimKiem_click(ctlID);
    }
}

function ctlTimKiemDoanhNghiep_txt_onkeydown(txt, e) {
    var keynum;
    var keychar;

    if (window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    if (keynum == 13) {
        var i;
        var ctlID = "", strTg;
        var txtID = txt.id;

        for (i = txtID.length - 1; i >= 0; i--) {
            if (txtID.charAt(i) == "_") {
                ctlID = txtID.substring(0, i);
                strTg = txtID.substring(i + 1);
                break;
            }
        }
        setTimeout("ctlTimKiemDoanhNghiep_txt_onEnter('" + txt.id + "', '" + txt.value + "', '" + ctlID + "');", 100);
    }
    return true;
}
