﻿/// <reference path="jquery-1.2.6-vsdoc-cn.js" />
/// <reference path="StringBuilder.js" />
/// <reference path="jquery.pager.js" />
/// <reference path="MapConfig.js" />
/// <reference path="LiveMap.js" />

if (window.my)
    var my = window.my;
else
    var my = window.my = {};

//class: 搜索历史记录管理器
//params:panel the search history div container
//params:maxHistory 允许最大的历史记录数，默认为10;
my.searchHistoryManager = function(panel, maxHistory) {
    this._panel = panel;
    this._panel.hide();
    this._maxHistory = maxHistory | 8;
    this._tempID = 0;
    this._historys = [];
    var bar = document.createElement("div");
    bar.className = "bar";
    bar.innerHTML = "搜索历史记录:";
    var ul = $(document.createElement("ul"));
    ul.hide();
    bar = $(bar);
    bar.click(function() {
        bar.toggleClass('barOpen');
        ul.slideToggle('fast');
    });
    panel.append(bar);
    panel.append(ul);
    this._ul = ul;
    document.__onDoSearchHistory = function() {
    };
};
//method: 添加历史记录
//params: history a json object.
//        keyword:搜索关键字
//        searchType:搜索类型之shortName
my.searchHistoryManager.prototype.add = function(history) {
    if (this._panel) {
        var flagAdd = true;
        if (this._historys.length > 0) {
            var lastHistory = this._historys[this._historys.length - 1];
            flagAdd = lastHistory.keyword != history.keyword || lastHistory.searchType != history.searchType;
        }
        if (flagAdd) {
            history.tempID = this._tempID++;
            this._historys[this._historys.length] = history;
            var li = document.createElement("li");
            li.id = '_h_li_' + history.tempID;
            li.innerHTML = history.keyword;
            li.title = history.description + ' at ' + (new Date().format("yyyy-MM-dd hh:mm:ss"));
            li = $(li);
            this._ul.prepend(li);
            li.mouseover(function(e) {
                $(this).addClass("active");
            });
            li.mouseout(function(e) {
                $(this).removeClass("active");
            });
            li.click(function(e) {
                document.__onDoSearchHistory(history.searchType, history.keyword);
            });
            //移除超出指定最大值历史记录
            if (this._historys.length > this._maxHistory) {
                var removedHistory = this._historys[0];
                this._historys.splice(0, 1);
                var id = '#_h_li_' + removedHistory.tempID;
                $(id).remove();
            }
            this._panel.show();
        }
    }
};

//class: 搜索组件管理器
//params:searchControl 搜索输入控制容器
//params:components 自定义搜索组件集合
my.searchManager = function(searchControl, workSpace, components) {

    this.pageTitle = document.title;
    this.workSpace = workSpace;

    //初始化搜索控制UI组件
    var sb = new StringBuilder();
    sb.append('<div>');
    sb.append('<div style="float: left; margin-top: 13px; margin-right: 5px;">');
    sb.append('<a href="javascript:void(0)" title="选择搜索选项" id="btn_ShowPopupMenu">');
    sb.append('<span class="currentSearchOption" id="lblCurrentSearchName"></span>');
    sb.append('<img src="images/arr.gif" />');
    sb.append('</a>');
    sb.append('<ul id="optionsMenu" style="display: none; margin-left:-80px;">');
    sb.append('</ul>');
    sb.append('</div>');
    sb.append('<div style="float: left; margin-top: 10px;">');
    sb.append('<input id="txtKeyword" type="text" maxlength="80" title="按Enter键提交搜索" onblur="this._isActive=false;" onFocus="this._isActive=true;" onmouseover="this.focus(); if(!this._isActive){this.select();}" class="input_Search" />');
    sb.append('<div style="line-height: 10px; clear: left;">');
    sb.append('<span id="lblCurrentSearchDescription" style="font-size: 11px; color: gray;"></span>');
    sb.append('</div>');
    sb.append('</div>');
    sb.append('<div style="float: left; margin-top: 11px; margin-left: 3px;">');
    sb.append('<input type="button" class="btn_SearchMap" id="btn_SearchMap" />');
    sb.append('</div>');
    sb.append('</div>');
    $(searchControl).append(sb.toString());

    this.txtKeyWord = $('#txtKeyword');
    this.cmdShowOptionsMenu = $('#btn_ShowPopupMenu');
    this.menuOptions = $('#optionsMenu');
    this.cmdSearch = $('#btn_SearchMap');
    this.lblCurrentSearchName = $('#lblCurrentSearchName');
    this.lblCurrentSearchDescription = $('#lblCurrentSearchDescription');
    this.lastAdTitle = "";

    //搜索历史记录管理器
    this.history = new my.searchHistoryManager(this.workSpace.historyPanel);
    var addHistory = false;
    //开始搜索
    var onSearchClick = (function(e, start, keyword) {
        this.currentKeyWord = keyword ? $.trim(keyword) : $.trim(this.txtKeyWord.val());
        this.txtKeyWord.val(this.currentKeyWord);
        if (this.currentSearch) {
            //重新设置浏览器url.hash
            document.liveMap.urlHash['st'] = this.currentSearch.shortName; //当前的搜索类型
            document.liveMap.urlHash['q'] = this.currentKeyWord; //搜索关键字
            document.liveMap.urlHash['start'] = start ? start : 0; //分页索引
            document.liveMap.resetUrlHash();
        }
        this.workSpace.resultBody.html('');
        this.workSpace.resultSummary.html('');
        this.workSpace.resultPager.html('');
        this.workSpace.resultExPanel.html('');

        if (this.currentKeyWord.length > 0) {
            document.title = this.currentKeyWord + '-' + this.pageTitle;
            this.workSpace.resultSummary.html('<span style="font-size:14px;margin-left:24px;"><strong>正在搜索...</span></strong>');
            start = start ? start : 0;
            if (this.lastAdTitle != this.currentKeyWord) {
                this.lastAdTitle = this.currentKeyWord;
                $('#adPanel').html(String.format('<iframe src="Ad.aspx?{0}" height="80" scrolling="no" frameborder="0"></iframe>', this.currentKeyWord));
            }
            if (this.currentSearch && this.currentSearch.beginSearch) {
                this.currentSearch.clearResult();
                this.currentSearch.beginSearch(this.currentKeyWord, start);
                if (addHistory) {
                    this.history.add({ keyword: this.currentKeyWord, searchType: this.currentSearch.shortName, description: this.currentSearch.name });
                }
            }
        }
    }).createDelegate(this);
    document.__onDoSearchHistory = (function(searchType, keyword) {
        $.each(this.searchComponents, (function(i, n) {
            if (n.shortName == searchType) {
                this.currentSearch = null;
                this.txtKeyWord.val(keyword);
                this.menuOptions.selectChanged(i, true, false, true);
            }
        }).createDelegate(this));
    }).createDelegate(this);

    //初始化组件下拉菜单选择
    this.searchComponents = null;
    this.currentSearch = null;
    this._menuBuilder = new StringBuilder();
    if (components) {
        this.searchComponents = components;
        this.currentSearch = this.searchComponents[0];
        this.lblCurrentSearchName.text(this.currentSearch.name);
        this.lblCurrentSearchDescription.text(this.currentSearch.description);

        $.each(this.searchComponents, (function(i, n) {
            this._menuBuilder.append('<li id="' + n.shortName + '">');
            this._menuBuilder.append(n.name);
            this._menuBuilder.append('<div>');
            this._menuBuilder.append(n.description);
            this._menuBuilder.append('</div>');
            this._menuBuilder.append('</li>');
        }).createDelegate(this));
    }
    this.menuOptions.append(this._menuBuilder.toString());
    this._menuBuilder = null;

    this.menuOptions = this.menuOptions.popupMenu();
    this.menuOptions.selectChanged = (function(i, enforce, clearSearchString, fireHandler) {
        if (clearSearchString) {
            this.txtKeyWord.val('');
        }
        if (this.currentSearch != this.searchComponents[i]) {
            if (this.currentSearch != null) {
                this.currentSearch.clearResult();
                if (this.currentSearch.unActive) {
                    this.currentSearch.unActive();
                }
            }
            this.currentSearch = this.searchComponents[i];

            //重新设置浏览器url.hash
            document.liveMap.urlHash['st'] = this.currentSearch.shortName; //当前的搜索类型
            if ($.trim(this.txtKeyWord.val()).length == 0 && document.liveMap.urlHash.q) {
                this.txtKeyWord.val(decodeURIComponent(document.liveMap.urlHash.q).replace(/\+/g, " "));
            }
            document.liveMap.resetUrlHash();

            if (this.currentSearch.active) {
                this.currentSearch.active();
            }
            this.lblCurrentSearchName.text(this.currentSearch.name);
            this.lblCurrentSearchDescription.text(this.currentSearch.description);
            if ($.trim(this.txtKeyWord.val()).length > 0 && fireHandler) {
                onSearchClick();
            }
        } else {
            if (enforce) {
                if ($.trim(this.txtKeyWord.val()).length > 0) {
                    onSearchClick();
                }
            }
        }
    }).createDelegate(this);

    this.cmdShowOptionsMenu.click((function(e) {
        e.stopPropagation();
        return false;
    }).createDelegate(this));
    this.cmdShowOptionsMenu.hover((function(e) {
        this.menuOptions.slideDown(300);
        e.stopPropagation();
    }).createDelegate(this));

    //订阅'搜索按钮'事件
    this.cmdSearch.click(function() {
        addHistory = true;
        onSearchClick();
        addHistory = false;
    });
    //支持回车搜索
    this.txtKeyWord.keydown((function(e) {
        if (e.keyCode == 13) {
            addHistory = true;
            onSearchClick();
            addHistory = false;
        }
    }).createDelegate(this));

    //重设分页信息
    //params:pageIndex, 当前分页索引，从0开始
    //params:pageSize, 每页分页数
    //params:recordCount, 总记录数
    this.resetPager = (function(start, take, recordCount) {
        if (recordCount > 0) {
            this.workSpace.resultPager.bindpager({ pagenumber: (start / take) + 1,
                DataCount: recordCount,
                PageSize: take,
                PageLength: 4,
                buttonClickCallback: (function(pageclickednumber) {
                    onSearchClick(null, (pageclickednumber - 1) * take, this.currentKeyWord);
                }).createDelegate(this)
            });
        }
        else {
            this.workSpace.resultPager.empty();
        }
    }).createDelegate(this);

    //通用搜索结果关键字高亮
    var eachFnOfhighlight = (function(i, n) {
        if (n && n.length > 0)
            this.workSpace.resultBody.highlight(n, this._currentFilter);
    }).createDelegate(this);
    //params:keywords 要高亮的关键字数组
    this.highlight = (function(keywords, filter) {
        this._currentFilter = filter;
        $.each(keywords, eachFnOfhighlight);
    }).createDelegate(this);

    //初始化组件
    if (this.searchComponents) {
        $.each(this.searchComponents, (function(i, n) {
            if (n.init)
                n.init(this);
        }).createDelegate(this));
    }

    //重新设置搜索建议
    document.__onSuggestionClick = (function(strQuery) {
        this.txtKeyWord.val(strQuery);
        onSearchClick();
    }).createDelegate(this);
    this.resetSearchSuggestion = function(strQuery, description) {
        if (strQuery && strQuery.length > 0) {
            this.workSpace.resultSummary2.html('<span style="color:red;font-style: italic;">你的意思是不是:</span> <a href="javascript:void(0)" onclick="__onSuggestionClick(\'' + strQuery + '\');return false;">' + strQuery + '</a> <span style="color:#888;">' + description + '</span>');
        } else
            this.workSpace.resultSummary2.html("");
    };

    document.liveMap.invoke((function() {
        //处理URL传值搜索
        var hash = document.liveMap.urlHash;
        if (hash.q) {
            this.txtKeyWord.val(decodeURIComponent(hash.q).replace(/\+/g, " "));
        }
        if (hash.st) {
            $.each(this.searchComponents, (function(i, n) {
                if (n.shortName == hash.st) {
                    this.currentSearch = null;
                    addHistory = true;
                    this.menuOptions.selectChanged(i, true, false, true);
                    addHistory = false;
                    return;
                }
            }).createDelegate(this));
        }
    }).createDelegate(this));
};

//class:自定义搜索之地图搜索（企业和建筑道路搜索）组件
//Constructor:初始化组件
my.mapSearchComponent = function() {
    //定义本搜索组件的相关描述
    this.shortName = 'MapSearch';
    this.name = '地图搜索';
    this.description = ' 检索地图上的商户、地名和地址。';
    this.take = 10; //每页显示的分页数
    this.adviceString = '<div style="font-size:12px;color:#444;line-height:18px;padding-left:30px;"><p style="color:red;">建议:</p><p style="color:#333;">请确保所有街道、商户、类别和地点名称无错别字。</p><p style="color:#333;">试试去掉街道和街号后面过于冗长的部分。</p><p style="color:#333;">想让所有人了解并找到您的商户吗?</p><p><a target="_blank" style="text-decoration: underline;color:#0000CC;" href="http://local.' + my.domain + '/add/lookup.aspx">将它添加到0577emap地图中吧(<span style="color:red;">免费</span>)!</a></p></div>';
    document.__SearchComponent = this;
};

//method: 当使用searchManager.addComponent方法时会回调此方法。
my.mapSearchComponent.prototype.init = function(sm) {
    this.searchManager = sm;
};

//method: 开始搜索, 当点击按索按钮或分页时会调用此方法
//params:keyword 搜索关键字
//params:start
my.mapSearchComponent.prototype.beginSearch = function(keyword, start) {
    $.getJSON(String.format('http://index.{0}/mapsearch.ashx?q={1}&start={2}&take={3}&jsoncallback=?',
    my.domain,
    encodeURIComponent(keyword),
    start,
    this.take),
    (function(data) {
        this.searchManager.resetSearchSuggestion(data.ParsedQuery.SuggestionQueryString, data.ParsedQuery.SuggestionQueryDescription);
        //显示数据
        this.showSearchData(data);
        //设置分页
        this.searchManager.resetPager(start, this.take, data.RecordCount);
        //关键字着色
        this.searchManager.highlight(data.ParsedQuery.KeyWords, '.lh1');
    }).createDelegate(this));
};
//显示数据
my.mapSearchComponent.prototype.showSearchData = function(data) {
    var results = data.Results;
    this._DataSource = {};
    this.searchManager.workSpace.resultSummary.html(data.ParsedQuery.Title);
    if (results && results.length > 0) {
        var sb = new StringBuilder();

        for (i = 0, l = results.length; i < l; i++) {
            var data = results[i];
            var render = my.mapSearchComponent.dataRenders[data.Type];
            if (render)
                render(data, sb, i);
            this._DataSource[data.ID] = data;
        }
        sb.appendFormat('<div style="font-size:11px;margin-left:22px;color:#888;">帮助我们改善搜索体验，<a href="{0}" style="color:red;" target="_blank">从这里开始吧...</a></div>', "http://dict." + my.domain + "/add.aspx");
        this.searchManager.workSpace.resultBody.html(sb.toString());
    } else {
        this.searchManager.workSpace.resultBody.html(this.adviceString);
    }
};
//清除本组件的搜索结果
my.mapSearchComponent.prototype.clearResult = function() {
    if (this._DataSource) {
        jQuery.each(this._DataSource, function(i, n) {
            document.liveMap.Map.RemoveMarker(i);
        });
        this._DataSource = {};
    }
    this.searchManager.resetPager(0, 0, 0);
    this.searchManager.workSpace.resultSummary2.html('');
};
//地图数据类型枚举
my.mapSearchComponent.dataTypes = {
    "Building": "1",
    "Store": "2",
    "Region": "3",
    "Category": "4",
    "Topic": "5"
};
//不同地图数据渲染器键值集合
my.mapSearchComponent.dataRenders = {};

//建筑数据渲染器
(function() {
    document._dispalyBuildingDetail = function(id) {
        var data = document.__SearchComponent._DataSource[id];
        document.liveMap.Map.DispalyBuildingDetail(data.ID,
        data.Name,
        data.Address,
        data.Center,
        0,
        -34,
        "http://maps." + my.domain + "/Place.aspx?t=building&id=" + data.ID);
    };
    //param: data, 数据
    //param: sb, StringBuilder object
    //param: index, index
    my.mapSearchComponent.dataRenders[my.mapSearchComponent.dataTypes.Building] = function(data, sb, index) {
        sb.append('<div style="margin: 6px 0 6px 0">');
        //marker icon
        sb.appendFormat('<div style="float:left;margin-right:4px;"><img src="images/markers/iconr{0}.gif" /></div>', (index + 1).toString());
        sb.append('<div style="margin-left:26px;">');
        //名称
        sb.appendFormat('<a href="javascript:void(0)" onclick="document._dispalyBuildingDetail(\'{0}\');return false;" class="list_title lh1" style="margin-top:4px;">{1}</a> <span class="list_summary_small"> [建筑]</span>', data.ID, data.Name);
        //地址
        sb.appendFormat('<div class="list_summary lh1" style="margin-top:4px;">{0}</div>', data.Address.length > 0 ? data.Address : '&nbsp');
        //功能按钮
        sb.append('<div style="margin-top:4px;">');
        sb.append('</div></div></div>');
        //地图上打印标记
        document.liveMap.Map.CreateDefaultMarker(data.Center, index + 1, data.ID, '_dispalyBuildingDetail');
    };
})();
//本地商户数据渲染器
(function() {
    document._dispalyStoreDetail = function(id) {
        var data = document.__SearchComponent._DataSource[id];
        document.liveMap.Map.DispalyStoreDetail(data.ID,
        data.Name,
        data.Address,
        data.ZipCode,
        data.Mail,
        data.Tel,
        data.LatLng,
        0,
        -34,
        "http://local." + my.domain + "/add/Choice.aspx?" + data.ID,
        "http://local." + my.domain + "/Details.aspx?" + data.ID);
    };
    //param: data, 数据
    //param: sb, StringBuilder object
    //param: index, index
    my.mapSearchComponent.dataRenders[my.mapSearchComponent.dataTypes.Store] = function(data, sb, index) {
        sb.append('<div style="margin: 6px 0 6px 0">');
        //marker icon
        sb.appendFormat('<div style="float:left;margin-right:4px;"><img src="images/markers/iconr{0}.gif" /></div>', (index + 1).toString());
        sb.append('<div style="margin-left:26px;">');
        //名称
        sb.appendFormat('<a href="javascript:void(0)" onclick="document._dispalyStoreDetail(\'{0}\');return false;" class="list_title lh1" style="margin-top:4px;">{1}</a>', data.ID, data.Name);
        //more
        sb.appendFormat('<span> - <a target="_blank" style="color:#7777CC;text-decoration: underline;font-size:11px;" href="http://local.{0}/details.aspx?{1}">更多 »</a></span>', my.domain, data.ID);
        //地址
        sb.appendFormat('<div class="list_title_small lh1" style="margin-top:4px;">{0}</div>', data.Address.length > 0 ? data.Address : '&nbsp');
        //邮编
        if (data.ZipCode.length > 0) {
            sb.appendFormat('<div class="list_summary">{0} </div>', data.ZipCode);
        }
        //电话
        if (data.Tel.length > 0) {
            sb.appendFormat('<div class="list_summary">{0} </div>', data.Tel);
        }
        //邮件
        if (data.Tel.length > 0) {
            sb.appendFormat('<div class="list_summary">{0} </div>', data.Mail);
        }
        //功能按钮
        sb.append('<div style="margin-top:4px;">');
        //声明该商户的所有权
        sb.appendFormat('<span class="list_summary_small">您是业主吗?</span> <a style="text-decoration: underline;font-size:11px;" class="list_command" target="_blank" href="http://local.{1}/add/Choice.aspx?{0}">声明所有权 »</a>', data.ID, my.domain);
        sb.append('</div></div></div>');
        //地图上打印标记
        document.liveMap.Map.CreateDefaultMarker(data.LatLng, index + 1, data.ID, '_dispalyStoreDetail');
    };
})();

//行政区划数据渲染器
(function() {
    document._dispalyRegionDetail = function(id) {
        var data = document.__SearchComponent._DataSource[id];
        document.liveMap.Map.PanTo(data.Center);
    };
    //param: data, 数据
    //param: sb, StringBuilder object
    //param: index, index
    my.mapSearchComponent.dataRenders[my.mapSearchComponent.dataTypes.Region] = function(data, sb, index) {
        sb.append('<div style="margin: 6px 0 6px 0">');
        //marker icon
        sb.appendFormat('<div style="float:left;margin-right:4px;"><img src="images/markers/iconr{0}.gif" /></div>', (index + 1).toString());
        sb.append('<div style="margin-left:26px;">');
        //名称
        sb.appendFormat('<a href="javascript:void(0)" onclick="document._dispalyRegionDetail(\'{0}\');return false;" class="list_title lh1" style="margin-top:4px;">{1}</a>', data.ID, data.Name);
        //more
        sb.appendFormat('<span> - <a target="_blank" style="color:#7777CC;text-decoration: underline;font-size:11px;" href="http://maps.{0}/Place.aspx?id={1}&t=region">更多 »</a></span>', my.domain, data.ID);
        //地址
        sb.appendFormat('<div class="list_summary lh1" style="margin-top:4px;">{0}</div>', data.Address.length > 0 ? data.Address : '&nbsp');
        //邮编
        if (data.ZipCode.length > 0) {
            sb.appendFormat('<span class="list_summary">{0} </span>', data.ZipCode);
        }
        //功能按钮
        sb.append('<div style="margin-top:4px;">');
        //在此处搜索
        sb.appendFormat('<span class="list_summary_small">在此处搜索</span> <input id="txtChild{1}" onkeydown="if (event.keyCode==13){document.__onSuggestionClick(document.getElementById(\'txtChild{1}\').value + \' {0}\')}" style="width:65px;border:0px;border-bottom:1px solid #888;color:#444;padding-left:2px;font-size:11px;"/> <a class="list_command" style="font-size:11px;text-decoration: underline;" href="javascript:void(0)" onclick="document.__onSuggestionClick(document.getElementById(\'txtChild{1}\').value + \' {0}\');return false;">确定</a>', data.Name, data.ID);
        sb.append('</div></div></div>');
        //地图上打印标记
        document.liveMap.Map.CreateDefaultMarker(data.Center, index + 1, data.ID, '_dispalyRegionDetail');
    };
})();

//商户类别数据渲染器
(function() {
    //param: data, 数据
    //param: sb, StringBuilder object
    //param: index, index
    my.mapSearchComponent.dataRenders[my.mapSearchComponent.dataTypes.Category] = function(data, sb, index) {
        sb.append('<div style="margin: 6px 0 6px 0">');
        //marker icon
        sb.appendFormat('<div style="float:left;margin-right:4px;"><img src="images/markers/iconr{0}.gif" /></div>', (index + 1).toString());
        sb.append('<div style="margin-left:26px;">');
        //名称
        sb.appendFormat('<span class="list_title lh1" style="margin-top:4px;">{0}</span><span class="list_summary_small"> [商户类别]</span>', data.Name);
        //功能按钮
        sb.append('<div style="margin-top:4px;">');
        sb.appendFormat('<span class="list_summary_small">搜索此分类</span><a class="list_command" style="font-size:11px;text-decoration: underline;" href="javascript:void(0)" onclick="document.__onSuggestionClick(\'category:{0}\');return false;"> category:{0}</a>', data.Name);
        sb.append('</div></div></div>');
    };
})();

//建筑录入数据查询
my.buildOfEditSearchComponent = function() {
    this.shortName = 'buildOfEdit';
    this.name = '建筑查询';
    this.description = '城市建设之建筑数据查询。';
    this.pageSize = 10;
    $.include(String.format("http://build.{0}/guest/GetBuildSearchScript.ashx", my.domain),
    'GetBuildSearchScript.js',
    'script',
    null);
    document.__buildingOfEditSearchComponent = this;
};

//method: 当使用searchManager.addComponent方法时会回调此方法。
my.buildOfEditSearchComponent.prototype.init = function(sm) {
    this.searchManager = sm;
    document.__buildOfEditSearchComponent = this;
};
//停止本组件
my.buildOfEditSearchComponent.disable = function() {
    document.__buildOfEditSearchComponent.searchManager.menuOptions.hideItem(document.__buildOfEditSearchComponent.shortName);
};

//method: 开始搜索, 当点击按索按钮或分页时会调用此方法
//params:keyword 搜索关键字
//params:pageIndex 分页索引页（从0开始）
my.buildOfEditSearchComponent.prototype.beginSearch = function(keyword, pageIndex) {
};
//清除本组件的搜索结果
my.buildOfEditSearchComponent.prototype.clearResult = function() {
};
my.buildOfEditSearchComponent.prototype.active = function() {
    $('#adPanel').hide();
    document.liveMap.Map.ShowBuildingEditCommand();
};
my.buildOfEditSearchComponent.prototype.unActive = function() {
    $('#adPanel').show();
    document.liveMap.Map.HideBuildingEditCommand();
};

//行政区划录入数据查询
my.regionalismOfEditSearchComponent = function() {
    this.shortName = 'regionalismOfEdit';
    this.name = '行政区划查询';
    this.description = '城市建设之行政区划数据查询。';
    this.pageSize = 10;
    $.include(String.format("http://build.{0}/guest/GetRegionSearchScript.ashx", my.domain),
    'GeRegionSearchScript.js',
    'script',
    null);
};

//method: 当使用searchManager.addComponent方法时会回调此方法。
my.regionalismOfEditSearchComponent.prototype.init = function(sm) {
    this.searchManager = sm;
    document.__regionalismOfEditSearchComponent = this;
};
//停止本组件
my.regionalismOfEditSearchComponent.disable = function() {
    document.__regionalismOfEditSearchComponent.searchManager.menuOptions.hideItem(document.__regionalismOfEditSearchComponent.shortName);
};

//method: 开始搜索, 当点击按索按钮或分页时会调用此方法
//params:keyword 搜索关键字
//params:pageIndex 分页索引页（从0开始）
my.regionalismOfEditSearchComponent.prototype.beginSearch = function(keyword, pageIndex) {
};
//清除本组件的搜索结果
my.regionalismOfEditSearchComponent.prototype.clearResult = function() {
};
my.regionalismOfEditSearchComponent.prototype.active = function() {
    document.liveMap.Map.ShowAreaEditCommand();
    $('#adPanel').hide();
};
my.regionalismOfEditSearchComponent.prototype.unActive = function() {
    document.liveMap.Map.HideAreaEditCommand();
    $('#adPanel').show();
};