﻿var $$ = function(id) { return document.getElementById(id); };
var J_Area = $$("H_Area").value;
var J_HotArea = $$("H_HotArea").value;
var J_Type = $$("H_Type").value;
var J_HouseValue = $$("H_HouseValue").value;
function goSearch() {
    var key = $$('tb_search').value;
    if (key == "请输入经纪人姓名" || key == "请输入企业店铺名称" || key == "请输入小区名或位置") key = "";
    if ($$('select').value == 0) {
        //window.location.href = "list-" + J_Area + "-" + J_HotArea + "-" + J_Type + "-" + J_HouseValue + "----.vhtml?Key=" + key;
        window.location.href = "Search.aspx?Key=" + encodeURIComponent(key) + "&Area=" + J_Area + "&HotArea=" + J_HotArea + "&Type=" + J_Type + "&HouseValue=" + J_HouseValue;
    }
    else if ($$('select').value == 1) window.location.href = '/CommonInfo/Member/BrokerList.aspx?SeaType=30&Title=' + encodeURIComponent(key);
    else if ($$('select').value == 2) window.location.href = '/sale/Search.aspx?Key=' + encodeURIComponent(key);
    else if ($$('select').value == 3) window.location.href = '/rent/Search.aspx?Key=' + encodeURIComponent(key);
}

var _selectBorough;
function selectBorough(v) {
    if (v == "") {
        key = "";
        return;
    }
    clearTimeout(_selectBorough);
    _selectBorough = setTimeout("selectBoroughajax('" + v.replace("'", "") + "');", 150);
}

function selectBoroughajax(v) {
    if (!v) return;
    if (v == "") return;
    var ajax = new eAjax();
    ajax.callBack = function(result) {
        if (result) {

            document.getElementById('tr_addborough').style.display = '';
            document.getElementById('tr_addborough').style.zIndex = 10000;
            document.getElementById('tr_addborough').innerHTML = result;
        }
    }
    if (document.getElementById('select').value == 0)
        ajax.get("Include/SelectPlot.aspx?Size=5&name=" + v);
}
function sSmallBorough(bname) {
    if (bname != "") document.getElementById("tb_search").value = bname;
    document.getElementById('tr_addborough').style.display = 'none';
    window.location.href = '/plot/Search.aspx?Key=' + encodeURIComponent(bname);
}
function checkblur(obj) {
    var chanelvalue = $$('select').value;
    if (obj.value == '') {
        if (chanelvalue == 0 || chanelvalue == 2 || chanelvalue == 3) obj.value = '请输入小区名或位置';
        if (chanelvalue == 1) obj.value = '请输入经纪人姓名';
    }
}
function checkfocus(obj) {
    var chanelvalue = $$('select').value;
    if ((chanelvalue == 0 || chanelvalue == 2 || chanelvalue == 3) && obj.value == '请输入小区名或位置') obj.value = '';
    if (chanelvalue == 1 && obj.value == '请输入经纪人姓名') obj.value = '';
}
function SelectChanel() {
    //判断频道
    $$('tr_addborough').style.display = 'none';
    var chanelvalue = $$('select').value;
    var obj = $$('tb_search');
    if (chanelvalue == 0 || chanelvalue == 2 || chanelvalue == 3) {
        if (obj.value == '' || obj.value == '请输入经纪人姓名')
            obj.value = '请输入小区名或位置';
    }
    if (chanelvalue == 1)//经纪人
    {
        if (obj.value == '' || obj.value == '请输入小区名或位置')
            obj.value = '请输入经纪人姓名';
    }
    if (chanelvalue == 0) {
        selectBoroughajax($$('tb_search').value.replace("'", ""))
        $$('tr_addborough').style.display = '';
    }
    if (chanelvalue != 0) $$('tr_addborough').style.display = 'none';
}


