$(document).ready(function () {
    var dText = "请填写小区名称";
    var Ttext = "请填写房源编号";
    var urll = "detail.aspx";
    var tempMark = 0;
    /*----------------------------------基本取数据后台设置------------------------------------*/
 
    var baseHUrl = "/Handler/SearchManager/SearchManager.ashx?Action=";
    var baseFUrl = "/Handler/Front/IndexOp.ashx?Action=";
    var searchUrl = "search.aspx";
    var search_rentUrl = "search_rent.aspx";
    var agentsUrl = "agents_list.aspx";
    var isFOn = {};
    var isCOn = {};
    var closeFun = function (dom, type) {
        setTimeout(function () {
            if (!isCOn[type] && !isFOn[type] && dom.data("ChildMenu")) {
                dom.data("ChildMenu").remove();
                dom.data("ChildMenu", null);
                //$("iframe[name='testIframe" + type + "']").remove();
            }
        }, 30);
    };
    $("body").find("#buildTopCanDo a").hover(function () {
        var showType = $(this).attr("isShow"), tDom, childMHtml = "", self = this;
        isFOn[showType] = true;
        if (showType) {
            switch (showType) {
                case "1":
                    {
                        childMHtml += "<div class=\"navbox-02\">";
                        childMHtml += "<a href=\"/house/list.php?fid=2&city_id=1\">出售房源</a>";
                        childMHtml += "<a href=\"/house/listall.php?fid=2&ordertype=levelstime\" upCol=\"todayNow\" upVal=\"1\">推荐房源</a>";
                        childMHtml += "<a href=\"/house/listall.php?fid=2\" upCol=\"todayNow\" upVal=\"1\">今日房源</a>";
                        childMHtml += "<a href=\"/house/post.php?fid=2&city_id=1\">房源登记</a>";
                        childMHtml += "</div>";
                    }
                    break;
                case "2":
                    {
                        childMHtml += "<div class=\"navbox-02\">";
                        childMHtml += "<a href=\"/house/list.php?fid=1&city_id=1\">出租房源</a>";
                        childMHtml += "<a href=\"/house/listall.php?fid=1&ordertype=levelstime\" upCol=\"todayNow\" upVal=\"1\">推荐房源</a>";
                        childMHtml += "<a href=\"/house/listall.php?fid=1\" upCol=\"todayNow\" upVal=\"1\">今日房源</a>";
                        childMHtml += "<a href=\"/house/post.php?fid=1\">房源登记</a>";
                        childMHtml += "</div>";
                    }
                    break;
                case "9":
                    {
                       childMHtml += "<div class=\"navbox-02\">";
                        childMHtml += "<a href=\"/house/list.php?fid=2&city_id=1&sortid=2&price=&room_type=&fitment=&fyxz=%C9%CC%C6%CC\">商铺</a>";
					    childMHtml += "<a href=\"/house/list.php?fid=2&city_id=1&sortid=2&price=&room_type=&fitment=&fyxz=%B3%A7%B7%BF\">厂房</a>";
                        childMHtml += "<a href=\"/house/list.php?fid=2&city_id=1&sortid=2&price=&room_type=&fitment=&fyxz=%B2%D6%BF%E2\">仓库</a>";
					    childMHtml += "<a href=\"/house/list.php?fid=2&city_id=1&sortid=2&price=&room_type=&fitment=&fyxz=%D0%B4%D7%D6%C2%A5\">写字楼</a>";
                        childMHtml += "<a href=\"/house/list.php?fid=2&city_id=1&sortid=2&price=&room_type=&fitment=&fyxz=%B9%A4%D2%B5%D3%C3%B5%D8\">工业用地</a>";

					    childMHtml += "</div>";
                    }
                    break;
                case "4":
                    {
                       childMHtml += "<div class=\"navbox-02\">";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=983\">锦绣店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=988\">莲东店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=984\">德立店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=989\">裕锦店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=990\">龙州店</a>";
						childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=991\">曹溪店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=985\">美誉店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=992\">新城店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=993\">松涛店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=994\">登高店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=995\">国贸店</a>";
						childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=986\">丰华店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=987\">华韵店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=996\">上杭店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=997\">武平店</a>";
                        childMHtml += "<a href=\"/news/bencandy.php?fid=47&id=998\">连城店</a>";
                        childMHtml += "</div>";
                    }
                    break;
                case "5":
                    {
                        childMHtml += "<div class=\"navbox-02\">";
                        childMHtml += "<a href=\"/house/list.php?fid=5&city_id=1\">楼盘展示</a>";
                        childMHtml += "<a href=\"/news/list.php?fid=55\">楼盘资讯</a>";
                        childMHtml += "<a href=\"/news/list.php?fid=54\">最新代理</a>";
                        childMHtml += "<a href=\"/house/listall.php?fid=2&ordertype=levelstime\">推荐楼盘</a>";
                        childMHtml += "</div>";
                    }
                    break;
                case "6":
                    {
                        childMHtml += "<div class=\"navbox-02\">";
                        childMHtml += "<a href=\"/news/list.php?fid=31\">购房须知</a>";
                        childMHtml += "<a href=\"/news/list.php?fid=32\">二手房资讯</a>";
                        childMHtml += "<a href=\"/news/list.php?fid=33\">楼盘动态</a>";
                        childMHtml += "<a href=\"/news/list.php?fid=34\">房产政策</a>";
                        childMHtml += "<a href=\"/news/list.php?fid=48\">分析报告</a>";
                        childMHtml += "</div>";
                    }
                    break;

                case "7":
                    {
                        childMHtml += "<div class=\"navbox-02\">";
                        childMHtml += "<a href=\"/abouts/gywm.htm\">关于我们</a>";
                        childMHtml += "<a href=\"/abouts/zzjg.htm\">组织架构</a>";
                        childMHtml += "<a href=\"/abouts/gslc.htm\">公司历程</a>";
                        childMHtml += "<a href=\"/abouts/zzry.htm\">资质荣誉</a>";
                        childMHtml += "<a href=\"/abouts/sfbz.htm\">收费标准</a>";
                        childMHtml += "<a href=\"/abouts/jmls.htm\">加盟连锁</a>";
						childMHtml += "<a href=\"/abouts/mtsc.htm\">媒体宣传</a>";
						childMHtml += "<a href=\"/abouts/map.htm\">网站地图</a>";
						childMHtml += "<a href=\"/abouts/jobs.htm\">人才招聘</a>";
                        childMHtml += "</div>";
                    }
                    break;
            } if (!$(this).data("ChildMenu")) {
                tDom = $(childMHtml);
                tDom.find("a").click(function () {
                    var type = $(this).attr("upCol");
                    var val = $(this).attr("upVal");
                    if (type && val) {
                        var setit = {};
                        setit[type] = val;
                        _f.cookie(setit, { type: "set" });
                    }
                });
                tDom.hover(function () {
                    isCOn[showType] = true;
                }, function () {
                    isCOn[showType] = false;
                    closeFun($(self), showType);
                });
                $(this).data("ChildMenu", tDom);
                $(this).after($(this).data("ChildMenu"));
                //var coverDiv = $("<iframe name=\"testIframe" + showType + "\" frameborder=\"0\" style=\" position:absolute;\" height=\"" + $(this).data("ChildMenu").height() + "px\"   width=\"" + $(this).data("ChildMenu").width() + "px\">");
                //$("iframe[name!='testIframe" + showType + "']").remove();
                $(this).data("ChildMenu").after(coverDiv);
            }
        }
    }, function () {
        var showType = $(this).attr("isShow");
        if (showType) {
            isFOn[showType] = false;
            closeFun($(this), showType);
        }
    });

    /*----------------------------------写入Cookie------------------------------------*/

    _f.setNowSet(nowCityBianHao);
    //_f.cookie({ nowCityBianHao: nowCityBianHao }, { type: "set", time: 5 * 24 * 60 * 60 * 1000 });

    /*----------------------------------新闻动态切换功能------------------------------------*/
    _o.bc({ bd: $("#newsClickDivBase"), c: "a", dc: "", cc: "selected", of: function (i, _i) {
																					
        $(".NewsBoxBody").css("display", "none");
        $("#showNewsDiv" + _i.attr("href")).css("display", "block");
    }, occ: function () { return true; }
    });


    /*----------------------------------我是业主我要置业切换------------------------------------*/
    _o.bc({ bd: $(".Index_BtnBoxLable"), c: "a", dc: "", cc: "selected", of: function (i, _i) {
        $(".Index_BtnBoxBody").find(".btn").css("display", "none");
        $(".Index_BtnBoxBody").find(".btn").eq(i).css("display", "block");
    }, occ: function () { return true; }
    });
    /*----------------------------------精品房源/租房信息切换------------------------------------*/
    _o.bc({ bd: $(".HouseInfoLable"), c: "a", dc: "", cc: "selected", of: function (i, _i) {
        $(".HouseInfoBody").find(".HouseSingle").css("display", "none");
        $(".HouseInfoBody").find(".HouseSingle").eq(i).css("display", "block");
        $(".HouseInfoBody").find(".class").css("display", "none");
        $(".HouseInfoBody").find(".class").eq(i).css("display", "block");
    }, occ: function () { return true; }
    });

    var nowfangshi = "卖房";
    /*----------------------------------搜索卖房/租房切换------------------------------------*/

    $("div.SearchBtn").find("li").mouseover(function () {
        $("div.SearchBtn").find("li").addClass("mouseover-bg")
        $(this).removeClass("mouseover-bg");
        $("div.ks-search-h").show();
        $("[name='HouseSearch']").hide();
        $("[name='SellHouse']").hide();
        $("[name='RentHouse']").hide();
        $("[name='zygw']").hide();
    }).next().mouseover(function () {
        $("div.SearchBtn").find("li").addClass("mouseover-bg")
        $(this).removeClass("mouseover-bg");
        $("div.ks-search-h").hide();
        $("[name='HouseSearch']").show();
        $("[name='SellHouse']").show();
        $("[name='RentHouse']").hide();
        $("[name='zygw']").hide();
    }).next().mouseover(function () {
        $("div.SearchBtn").find("li").addClass("mouseover-bg")
        $(this).removeClass("mouseover-bg");
        $("div.ks-search-h").hide();
        $("[name='HouseSearch']").show();
        $("[name='SellHouse']").hide();
        $("[name='RentHouse']").show();
        $("[name='zygw']").hide();
    }).next().mouseover(function () {
        $("div.SearchBtn").find("li").addClass("mouseover-bg")
        $(this).removeClass("mouseover-bg");
        $("div.ks-search-h").hide();
        $("[name='HouseSearch']").hide();
        $("[name='SellHouse']").hide();
        $("[name='RentHouse']").hide();
        $("[name='zygw']").show();
        $(".TotalHouse").show();
    });

    //    _o.bc({ bd: $(".SearchBtn"), c: "a", dc: "", cc: "Selected", of: function (i, _i) {
    //        if (i != 2) {
    //            $(".SearchBody").find("select[name='fangshi']").css("display", "none");
    //            $(".SearchBody").find("select[name='fangshi']").eq(i).css("display", "");
    //            $(".SearchBody").find("p[name='jiageselect']").css("display", "none");
    //            $(".SearchBody").find("p[name='jiageselect']").eq(i).css("display", "block");
    //            $(".SearchBody").find("p[name='xqselect']").css("display", "none");
    //            $(".SearchBody").find("p[name='xqselect']").eq(i).css("display", "block");
    //            if (i == 0) {
    //                $("#showWangyuan").html("万");
    //                nowfangshi = "卖房";
    //                urll = "detail.aspx";
    //            } else {
    //                $("#showWangyuan").html("元");
    //                nowfangshi = "出租";
    //                urll = "detail.aspx";
    //            }
    //        }
    //    }, cbf: function (i, _i) {
    //        if (i == 2) {
    //            window.open("agents_list.aspx");
    //        }
    //    }, occ: function (i, _i) {
    //        if (i == 2) {
    //            return false;
    //        } else {
    //            return true;
    //        }
    //    }
    //    });
    /*----------------------------------快速找房滑动以及点击事件------------------------------*/

    _f.cookie({ didian: $(this).text() }, { type: "set", time: -1 });
    _f.cookie({ jiage1: 0, jiage2: 0 }, { type: "set", time: -1 });
    _f.cookie({ mianji1: 0, mianji2: 0 }, { type: "set", time: -1 });
    _f.cookie({ huxing1: 0, huxing2: 0 }, { type: "set", time: -1 });
    _f.cookie({ area: -1 }, { type: "set", time: -1 });
    _f.cookie({ star: -1 }, { type: "set", time: -1 });

    var searchDataBase = {
        jiage: -1,
        didian: -1,
        mianji: -1,
        huxing: -1,
        leixing: -1,
        louceng: -1,
        zhuangxiu: -1,
        chaoxiang: -1,
        selectText: -1,
        dateafter: -1,
        szsq: -1,
        laiyuan2: -1,
        laiyuan3: -1,
        jiage1: -1,
        jiage2: -1,
        mianji1: -1,
        mianji2: -1,
        louceng1: -1,
        louceng2: -1,
        huxing1: -1,
        xqmc: -1,
        beizhu: -1,
        todayNow: -1,
        fangling: -1,
        huxing11: -1,
        huxing22: -1
    };

    $(".search-but").find("input").click(function () {
        //searchDataBase = _f.cookie(searchDataBase, { type: "get" });
        var str = _f.query(searchDataBase, { type: "set" });
        window.open(searchUrl + str);
    });

    $("#Budget").slider({
        range: true,
        min: 1,
        max: 10,
        values: [1, 2],
        slide: function (event, ui) {
            SetSlide(".jdtext01", ui, function (minValue, maxValue) {
                searchDataBase.jiage1 = minValue;
                searchDataBase.jiage2 = maxValue;
            });
        }
    });
    $("#Area").slider({
        range: true,
        min: 1,
        max: 8,
        values: [1, 2],
        slide: function (event, ui) {
            SetSlide(".jdtext02", ui, function (minValue, maxValue) {
                searchDataBase.mianji1 = minValue;
                searchDataBase.mianji2 = maxValue;
            });
        }
    });
    $("#Rooms").slider({
        range: true,
        min: 1,
        max: 6,
        values: [1, 2],
        slide: function (event, ui) {
            SetSlide(".jdtext03", ui, function (minValue, maxValue) {
                searchDataBase.huxing11 = minValue;
                searchDataBase.huxing22 = maxValue;
            });
        }
    });

    $(".ks-search-h").find("span").find("a").click(function () {
        $(this).parents("li").find("a").removeClass("ks-off01").end().find("li").removeClass("jdtext-red");
        $(this).addClass("ks-off01");
        if ($(this).text() == "不限") {
            switch ($(this).attr("type")) {
                case "didian":
                searchDataBase.didian = "";
                    break;
                case "jiage":
                searchDataBase.jiage1 = -1;
                searchDataBase.jiage2 = -1;
                    break;
                case "mianji":
                searchDataBase.mianji1 = -1;
                searchDataBase.mianji2 = -1;
                    break;
                case "huxing":
                searchDataBase.huxing11 = -1;
                searchDataBase.huxing22 = -1;
                    break;
            }
        } else {
                searchDataBase.didian = $(this).text();
        }
        return false ;
    });

    $("[name='zygw']").find("a").click(function () {
        $(this).parents("strong").find("a").removeClass("ks-off02");
        $(this).addClass("ks-off02");
        if ($(this).attr("type") == "area") {
            if ($(this).text() == "不限") {
                _f.cookie({ area: -1 }, { type: "set", time: -1 });
            } else {
                _f.cookie({ area: $(this).text() }, { type: "set" });
            }
        } else {
            if ($(this).text() == "不限") {
                _f.cookie({ star: -1 }, { type: "set", time: -1 });
            } else {
                _f.cookie({ star: $(this).attr("upValue") }, { type: "set" });
            }
        }
        return false;
    });

    $("p.s-zygw-textinfo").find("a").click(function () {
        window.open("/AboutMango/job.html");
    });

    $(".SmallBtn").click(function () {
        _f.cookie({ agent: $(this).prev().val() }, { type: "set" });
        window.open(agentsUrl);
    });

    function SetSlide($tag, ui, callback) {
        var $Li = $($tag).find("li");
        var minValue;
        var maxValue;
        $.each($Li, function (i, item) {
            if (i >= ui.values[0] - 1 && i <= ui.values[1] - 1) {
                if (i == ui.values[0] - 1) {
                    minValue = $(item).attr("upValue");
                }
                if (i == ui.values[1] - 1) {
                    maxValue = $(item).attr("upValue");
                }
                $(item).addClass("jdtext-red");
            } else {
                $(item).removeClass("jdtext-red");
            }
        });
        $($Li).parents("li").find(".ks-no").find("a").removeClass("ks-off01");
        callback(minValue, maxValue);
    };

    /*---------------------------------区域选房事件绑定--------------------------------------*/


    $.each($(".sideclassinfo-content").find("li"), function (i, _i) {
        $(_i).hover(function () {
            //$(_i).next().css("display", "block");
            $("#Area" + $(_i).attr("AreaId")).show();
            $(_i).addClass("select01");
            _o.moc([$(_i), $("#Area" + $(_i).attr("AreaId"))], function () {
                $(_i).addClass("select01");
            }, function () {
                $("#Area" + $(_i).attr("AreaId")).hide();
                $(_i).removeClass("select01");
            });
        },
            function () {
                $(_i).removeClass("select01");
            });
    });
    //    _o.bc({ bd: $(".sideclassinfo-content"), c: "li", dc: "", cc: "", of: function (i, _i) {
    //        var self = $(_i).parents();
    //        $("div.sideclassinfo-content").find("li").removeClass("select01");
    //        $(self).addClass("select01");
    //        $("div.sideclass-right").hide();
    //        $("#Area" + $(self).attr("AreaId")).show().hover(
    //           		function () {
    //           		    tempMark = 1;
    //           		    $(self).addClass("select01");
    //           		},
    //            	function () {
    //            	    tempMark = 0;
    //            	    $(self).removeClass("select01");
    //            	    $(this).hide();
    //            	});
    //    }, occ: function (i, _i) {
    //        var self = $(_i).parents();
    //        $(self).removeClass("select01");
    //        setTimeout(function () {
    //            if (tempMark == 0) {
    //                //$("#Area" + $(self).attr("AreaId")).hide()
    //                document.title += "cao,"
    //            }
    //        }, 100);
    //    }
    //    });





    //    $("div.sideclassinfo-content").find("a[name='AreaParent']").mouseover(function () {
    //        var self = $(this).parents();
    //        var tempTime;
    //        $(self).unbind("mouseout");
    //        $("div.sideclassinfo-content").find("li").removeClass("select01");
    //        $("div.sideclass-right").hide();
    //        $("#Area" + $(self).attr("AreaId")).show().hover(
    //       		function () {
    //       		    var childSelf = this;
    //       		    $(self).addClass("select01");
    //       		    $(self).unbind("mouseout").mouseout(function () {
    //       		        $(this).removeClass("select01");
    //       		        $(childSelf).hide();
    //       		    });
    //       		},
    //        	function () {
    //        	    $(self).removeClass("select01");
    //        	    $(this).hide();
    //        	});
    //    });
    //    $("div.sideclass-right").find("a").mouseover(function () {
    //        $(this).parents("div").show();
    //    });
    /*----------------------------------初始化搜索信息列表-----------------------------------*/
    $.each($(".SearchBody").find("select"), function (i, _i) {
        $(_i).val($(_i).find("option").eq(0).attr("value"));
    });
    $.each($(".SearchBody").find(":text"), function (i, _i) {
        $(_i).val("");
    });
    $(".Search_input").val(dText);
    $(".Search_inputT").val(Ttext);
    /*----------------------------------顶部关于芒果显示隐藏-----------------------------------*/
    $(".QuickLink").find("a").eq(2).mouseover(function () {
        $(".AboutMango").css("display", "block");
        _o.moc([$(".AboutMango"), $(".QuickLink").find("a").eq(2)], function () { }, function () {
            $(".AboutMango").css("display", "none");
        });
        return false;
    });

    /*----------------------------------切换区域显示隐藏-----------------------------------*/
    $("#QuickSearchChangeAreaBtn").mouseover(function () {
        $(".QuickSearch").find(".CityBox").css("display", "block");
        _o.moc([$("#QuickSearchChangeAreaBtn"), $(".QuickSearch").find(".CityBox")], function () { }, function () {
            $(".QuickSearch").find(".CityBox").css("display", "none");
        });
    });

    /*----------------------------------切换区域点击事件-----------------------------------*/
    $(".QuickSearch").find(".CityBox").find("a").click(function () {
        $(".QuickSearch").find(".CityBox").css("display", "none");
        $(".QuickSearchBody").find(".shopping").empty();
        selftool.getPList(baseFUrl + "sqlist", { pageSize: 0, currentPage: 1, filter: __.tools.createFilter({ areaid: $(this).attr("href") }) }, function (data) {
            if (data && data.data) {
                $.each(data.data, function (i, _i) {
                    $(".QuickSearchBody").find(".shopping").append("<a href=\"\" upValue=\"" + _i.sqname + "\">" + _i.sqname + "</a>");
                    $(".QuickSearchBody").find(".shopping").append("  ");
                });
                _o.bindLinkOpen($(".QuickSearchBody").find(".shopping").eq(0).find("a"), function (goValue) {
                    _f.cookie({ szsq: goValue }, { type: "set" });
                    return searchUrl;
                });
            }
        });

        return false;
    });


    /*----------------------------------点击查询按钮-----------------------------------*/
    $(".btn_search").click(function () {
        var searchBody = $(".SearchBody");
        var subDate = {};
        $.each(searchBody.find("select,input[type!='button']"), function (i, _i) {
            if ($(_i).css("display") != "none") {
                if ($(_i).val() != "") {
                    if ($(_i).attr("name") == "xqmc") {
                        if ($(_i).val() != dText) {
                            subDate[$(_i).attr("name")] = $(_i).val();
                        }
                    } else {
                        subDate[$(_i).attr("name")] = $(_i).val();
                    }
                }
            }
        });

        var str = _f.query(subDate, { type: "set" });
        window.open(searchUrl + str);
    });
    $(".btn_searchT").click(function () {
        var vl = $(".Search_inputT").val().replace('１', '1').replace('２', '2').replace('３', '3').replace('４', '4').replace('５', '5').replace('６', '6').replace('７', '7').replace('８', '8').replace('９', '9').replace('０', '0');
        if (!isNaN(vl)) {
            window.open(urll + "?id=" + vl);
        }
        else {
            window.alert("请填写正确的房源编号");
        }
    });
    /*----------------------------------搜索框焦点事件-----------------------------------*/
    $(".Search_input").focus(function () {
        if ($(this).val() == dText) {
            $(this).val("");

        }
    });
    $(".Search_input").blur(function () {
        if ($(this).val() == "") {
            $(this).val(dText);
        }
    });
    $(".Search_inputT").focus(function () {
        if ($(this).val() == Ttext) {
            $(this).val("");

        }
    });
    $(".Search_inputT").blur(function () {
        if ($(this).val() == "") {
            $(this).val(Ttext);
        }
    });
    var selectLoad;
    /*----------------------------------动态搜索事件-----------------------------------*/
    $(".Search_inputT").keyup(function (event) {
        var text = $.trim($(this).val());
        if (event.keyCode == 13) {
            var vl = $(".Search_inputT").val().replace('１', '1').replace('２', '2').replace('３', '3').replace('４', '4').replace('５', '5').replace('６', '6').replace('７', '7').replace('８', '8').replace('９', '9').replace('０', '0');
            if (!isNaN(vl)) {
                window.open(urll + "?id=" + vl);
            }
            else {
                window.alert("请填写正确的房源编号");
            }
        }
    });
    $(".Search_input").keyup(function (event) {
        var text = $.trim($(this).val());
        if (event.keyCode == 13) {
            $(".btn_search").click();
            $(".DropDown1").css("display", "none");
        } else {
            $(".DropDown1_text").empty();

            if (selectLoad) {
                selectLoad.abort();
            }
            selectLoad = selftool.getPList(baseHUrl + "plist", { sort: "searchDate", dir: "desc", pageSize: 10, filter: __.tools.createFilter({ fangshi: nowfangshi, StationID: cityData[nowCityBianHao].filter, laiyuan: { value: cityData[nowCityBianHao].laiyuan, filteType: "="} }), ofilter: __.tools.createFilter({ searchText: { value: text, filteType: "like" }, searchPy: { value: text, filteType: "like" }, searchFpy: { value: text, filteType: "like"} }) }, function (data) {
                if (data && data.data) {
                    $(".DropDown1_text").empty();
                    $(".DropDown1").css("display", "");
                    _o.moc([$(".Search_input"), $(".DropDown1")], function () { }, function () {
                        $(".DropDown1").css("display", "none");
                    });
                    $.each(data.data, function (i, _i) {
                        var tempA = $("<p><a href=\"\"><em>" + _i.searchText + "</em>约" + _i.searchCount + "个房源</a></p>");
                        tempA.find("a").click(function () {
                            $(".Search_input").val(_i.searchText);
                            $(".DropDown1").css("display", "none");
                            return false;
                        });
                        $(".DropDown1_text").append(tempA);
                    });
                }
            });

        }
    });

    /*----------------------------------动态加载商圈事件-----------------------------------*/
    $("select[name='didian']").change(function () {
        var val = $(this).val();
        if (val == "") {
            $("select[name='szsq']").find("option[value!='']").remove();
        } else {
            $("select[name='szsq']").find("option[value!='']").remove();
            selftool.getPList(baseFUrl + "sqlist", { pageSize: 0, currentPage: 1, filter: __.tools.createFilter({ areaid: $(this).find("option[value='" + val + "']").attr("name") }) }, function (data) {
                if (data && data.data) {
                    $.each(data.data, function (i, _i) {
                        $("select[name='szsq']").append("<option value=\"" + _i.sqname + "\">" + _i.sqname + "</option>");
                    });
                }
            });
        }
    });

    $.each($(".HouseSingle"), function (i, _i) {
        $.each($(_i).find("img"), function (j, _j) {
            $(_j).hover(function () {
                showtrail($(_j).attr("srt"), $(this).attr("title"), 430, 350);
            }, function () {
                hidetrail();
            });
        });
    });


    $("#selectCityEm").mouseover(function () {
        $(".LogoLeft").find(".CityBox").css("display", "block");
        _o.moc([$("#selectCityEm"), $(".LogoLeft").find(".CityBox")], function () { }, function () {
            $(".LogoLeft").find(".CityBox").css("display", "none");
        });
    });




    $.each($("a[href='wait']"), function (i, _i) {
        $(_i).click(function () {
            return false;
        });
    });

    _o.bindLinkOpen($(".xqselect").eq(0).find("a"), function (goValue) {
        _f.cookie({ xqmc: goValue }, { type: "set" });
        return searchUrl;
    });
    _o.bindLinkOpen($(".xqselect").eq(1).find("a"), function (goValue) {
        _f.cookie({ xqmc: goValue }, { type: "set" });
        return search_rentUrl;
    });
    _o.bindLinkOpen($(".jiageselect").eq(0).find("a"), function (goValue) {
        _f.cookie({ jiage1: goValue.split(",")[0], jiage2: goValue.split(",")[1] }, { type: "set" });
        return searchUrl;
    });
    _o.bindLinkOpen($(".jiageselect").eq(1).find("a"), function (goValue) {
        _f.cookie({ jiage1: goValue.split(",")[0], jiage2: goValue.split(",")[1] }, { type: "set" });
        return search_rentUrl;
    });
    _o.bindLinkOpen($(".HouseInfoBody").find("div[name='jingpin']").find("a"), function (goValue) {
        _f.cookie({ didian: goValue }, { type: "set" });
        return searchUrl;
    });
    _o.bindLinkOpen($(".HouseInfoBody").find("div[name='zhufang']").find("a"), function (goValue) {
        _f.cookie({ didian: goValue }, { type: "set" });
        return search_rentUrl;
    });
    _o.bindLinkOpen($(".QuickSearchBody").find("p").eq(0).find("a"), function (goValue) {
        if (goValue != "今日出售" && goValue != "今日出租") {
            _f.cookie({ beizhu: goValue }, { type: "set" });
            return searchUrl;
        } else {
            if (goValue == "今日出售") {
                _f.cookie({ todayNow: 1 }, { type: "set" });
                return searchUrl;
            } else {
                _f.cookie({ todayNow: 1 }, { type: "set" });
                return search_rentUrl;
            }
        }
    });
    _o.bindLinkOpen($(".kuainav-list01").find("a"), function (goValue) {
        if (goValue != "今日出售" && goValue != "今日出租") {
            _f.cookie({ beizhu: goValue }, { type: "set" });
            return searchUrl;
        } else {
            if (goValue == "今日出售") {
                _f.cookie({ todayNow: 1 }, { type: "set" });
                return searchUrl;
            } else {
                _f.cookie({ todayNow: 1 }, { type: "set" });
                return search_rentUrl;
            }
        }
    });
    $(".AgentBoxBody p").eq(0).find("a").click(function () {
        var val = $(this).html() + "区";
        if (val != "全部") {
            _f.cookie({ area: val }, { type: "set" });
        }
        window.open(agentsUrl);
        return false
    });
    $(".AgentBoxBody p").eq(1).find("a").click(function () {
        var val = $(this).attr("href");
        if (val.replace("http://www.517.cn/jjronline.asp?star=", "").replace("/jjronline.asp?star=", "") == "6") {
            return false;
        }
        if (val != "全部") {
            _f.cookie({ star: val.replace("http://www.517.cn/jjronline.asp?star=", "").replace("/jjronline.asp?star=", "") }, { type: "set" });
        }

        window.open(agentsUrl);
        return false;
    });
    _o.bindLinkOpen($(".QuickSearchBody").find("p").eq(1).find("a"), function (goValue) {
        //_f.cookie({ szsq: goValue }, { type: "set" });
        return searchUrl + "?szsq=" + goValue;
    });
    _o.bindLinkOpen($(".sideclass-right").find("a"), function (goValue) {
        //_f.cookie({ szsq: goValue }, { type: "set" });
        return searchUrl + "?szsq=" + goValue;
    });


    /*-------------------芒果星经济委托卖买房----------*/
    $.each($("p[name='starClickLink']"), function (i, _i) {
        $(_i).find("a").eq(1).click(function () {
            var self = $(this), getAttr = function (type) {
                return self.attr(type);
            };
            _f.cookie({ personname: getAttr("username"), personid: getAttr("userid"), storeid: getAttr("storeid"), storename: getAttr("storename") }, { type: "set" });
            window.open("ToBuy.html");
            return false;
        });
        $(_i).find("a").eq(2).click(function () {
            var self = $(this), getAttr = function (type) {
                return self.attr(type);
            };
            _f.cookie({ personname: getAttr("username"), personid: getAttr("userid"), storeid: getAttr("storeid"), storename: getAttr("storename") }, { type: "set" });
            window.open("ToSell.html");
            return false;
        });
    });

    var isback = _f.cookie({ feedbackclose: "" }, { type: "get" });
    if (!isback.feedbackclose || isback.feedbackclose == "") {
        var feed = $("<div class=\"feedback\"><img src=\"img/FeedBack.gif\"></div>");
        $("body").append(feed);
        feed.click(function () {
            feed.hide();
            var inhtml = "", messageDom = $("<div class=\"MessageBox\"></div>"), ittype = "2";
            inhtml += "<div class=\"ClosedImg\"><a href=\"#\"><img src=\"img/closed2.gif\"></a></div>";
            inhtml += "<div class=\"LinkFont\"><a class=\"first_link click\" href=\"2\">意见反馈</a> | <a href=\"3\">您找到的错误</a> | <a href=\"4\">您的需求</a></div>";
            inhtml += "<div class=\"MessageForm\">";
            inhtml += "<p><textarea name=\"textarea\"></textarea>";
            inhtml += "</p>";
            inhtml += "<p class=\"MessageBtnBox\">";
            inhtml += "<input type=\"button\" value=\"提交\" class=\"MessageBtn\">";
            inhtml += "</p>";
            inhtml += "</div>";
            messageDom.append(inhtml);
            $("body").append(messageDom);
            messageDom.find(".ClosedImg a").click(function () {
                var isback = _f.cookie({ feedbackclose: "close" }, { type: "set" });
                messageDom.remove();
                feed.remove();
                return false;
            });
            messageDom.find(".LinkFont a").click(function () {
                ittype = $(this).attr("href");
                messageDom.find(".LinkFont a").removeClass("click");
                $(this).addClass("click");
                return false;
            });
            messageDom.find(".MessageBtn").click(function () {
                _f.postSuggest({ text: $.trim(messageDom.find("textarea").val()), type: ittype, table: "" }, function () {
                    feed.show();
                    messageDom.remove();
                });
            });

        });
    }

    //    __.tools.tAjaxP({ url: "/Handler/Front/OtherDataOp.ashx?Action=getanycount" }, function (data) {
    //        var tempData;
    //        switch (_f.getSecondName()) {
    //            case "syjm":
    //                tempData = data.result.syjm;
    //                break;
    //            case "fs":
    //                tempData = data.result.fs;
    //                break;
    //            case "as":
    //                tempData = data.result.as;
    //                break;
    //            default:
    //                tempData = data.result.sy;
    //                break;
    //        }
    //        $("li.first").find("span").eq(0).find("a").text(tempData.sf.maxcount);
    //        $("li.first").find("span").eq(1).find("a").text(tempData.sf.daycount);
    //        $("li.second").find("span").eq(0).find("a").text(tempData.zf.maxcount);
    //        $("li.second").find("span").eq(1).find("a").text(tempData.zf.daycount);
    //        $("li.third").find("span").eq(0).find("a").text(tempData.dp.shops);
    //        $("li.third").find("span").eq(1).find("a").text(tempData.dp.agents);
    //    });
    $.each($(".HouseSingle").find("li"), function (i, item) {
        $(item).find("strong").eq(0).text($(item).find("strong").eq(0).text().replace("新区", "").replace("区", ""));
        $(item).find("strong").eq(4).text(parseInt($(item).find("strong").eq(4).text()));
    });

    if (_f.getSecondName() == "sy") {
        __.tools.tAjaxP({ url: "/Handler/Front/IndexOp.ashx?Action=glist" }, function (data) {
            var sellhtml = "";
            if (data.sellData.length != 0) {
                $.each(data.sellData, function (i, item) {
                    sellhtml += "<li>";
                    sellhtml += "<a href=\"detail.aspx?id=" + item.id + ",4\" target=\"_blank\">";
                    sellhtml += "<span><img srt=\"" + item.laiyuan + "\" src=\"" + item.laiyuan2 + "\" onerror=\"this.onerror=null;this.src='/images/none.gif';\"></span>";
                    sellhtml += "<p>[<strong>" + item.didian.replace("新区", "").replace("区", "") + "</strong>]<em> " + item.xqmc + " </em></p>";
                    sellhtml += "<p><strong class=\"green\">" + item.huxing + "</strong>室<strong class=\"green\">" + item.huxing1 + "</strong>厅<strong class=\"green\">" + item.huxing2 + "</strong>卫/<strong class=\"green\">" + item.mianji + "</strong>㎡</p>";
                    sellhtml += "<p>" + item.chaoxiang + " /" + item.zhuangxiu + "</p>";
                    sellhtml += "<p><strong class=\"green\">";
                    if (item.danjia > 10000) {
                        var num = item.danjia / 10000;
                        sellhtml += num.toString().replace(/^(\d+\.\d{2})\d*$/, "$1") + "</strong>万/㎡";
                    } else {
                        sellhtml += item.danjia + "</strong>元/㎡";
                    }
                    sellhtml += "<b> " + Math.ceil(item.jiage) + "万</b> </p>";
                    sellhtml += "</a>";
                    sellhtml += "</li>";
                });
                $("ul.HouseSingle[name='jingpin']").html(sellhtml);
            }

            if (data.sellData.length != 0) {
                var renthtml = "";
                $.each(data.sellData, function (i, item) {
                    renthtml += "<li>";
                    renthtml += "<a href=\"detail.aspx?id=" + item.id + ",4\" target=\"_blank\">";
                    renthtml += "<span><img srt=\"" + item.laiyuan + "\" src=\"" + item.laiyuan2 + "\" onerror=\"this.onerror=null;this.src='/images/none.gif';\"></span>";
                    renthtml += "<p>[<strong>" + item.didian.replace("新区", "").replace("区", "") + "</strong>]<em> " + item.xqmc + " </em></p>";
                    renthtml += "<p><strong class=\"green\">" + item.huxing + "</strong>室<strong class=\"green\">" + item.huxing1 + "</strong>厅<strong class=\"green\">" + item.huxing2 + "</strong>卫/<strong class=\"green\">" + item.mianji + "</strong>㎡</p>";
                    renthtml += "<p>" + item.chaoxiang + " /" + item.zhuangxiu + "</p>";
                    renthtml += "<p><b>" + item.jiage + "</b>元 </p>";
                    renthtml += "</a>";
                    renthtml += "</li>";
                });
            }
        });
    }
});

