﻿/// <reference path="libs/mootools-1.2.3-core-yc.js" />

// 应用程序
function CitycomeApp() {
    var self = this;

    var userAgent = navigator.userAgent.toLowerCase();
    this.browser = {
        version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [0, '0'])[1],
        safari: /webkit/.test(userAgent),
        opera: /opera/.test(userAgent),
        msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
        mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
    };
    this.isIE6 = this.browser.msie && this.browser.version == '6.0';

    var getEle = function(oid) {
        return document.getElementById(oid);
    };


    // 初始化侧栏
    var openFrameItv = null;
    var openFrameUrl = '';
    var oFrame = document.getElementById('dSidePanel');
    this.showPanel = function(url) {
        $clear(openFrameItv);
        //if(url== openFrameUrl) return;
        openFrameUrl = url;
        openFrameItv = setTimeout(function() {
            try {
                if (openFrameUrl == '#' || openFrameUrl == 'javascript:void(0)') {
                    return false;
                }
                oFrame.src = 'jump.htm?' + escape(openFrameUrl);
            } catch (e) { }
        }, 30);

    };
    this.setActiveTab = function(tabid) {
        $$('#dSysTabs a').each(function(mi, i) {
            if (mi.hasClass('current')) mi.removeClass('current');
        });

        var o = $(tabid);
        if (o) {
            o.addClass('current');
        }
    };
    $$('#dSysTabs a').each(function(item, i) {
        if (item.target != '_blank')
            item.addEvent('click', function(event) {
                self.showPanel(this.href);
                gApp.togSidePanel(true);
                $$('#dSysTabs a').each(function(mi) {
                    if (mi.hasClass('current')) mi.removeClass('current');
                });
                $(event.target).addClass('current');
                event.stop();
                return false;
            });
    });



    var idSysBanner = 'dSysBanner';
    var idSysTools = 'dSysTools';

    var idSysMap = 'dSysMap';
    var idSysSide = 'dSysSide';

    var idSysSplit = 'dSysSplit';
    var idSysSplitTogButton = 'dSysSplitTogButton';
    var idSysSplitFullScreen = 'dSysSplitFullScreen';


    var isFullScreen = false;    // [ 屏幕一共有三种模式：正常、全屏、侧栏隐 ]
    var isShowSide = true;       // [ 是否显示侧栏 ]
    var sideFrameWidth = getEle(idSysSide).offsetWidth;        // 记录侧栏的宽度

    var ptxSide = $(idSysSide).getCoordinates();
    $(idSysSide).setStyles({
        'position': 'absolute',
        'left': ptxSide.left,
        'top': ptxSide.top
    });

    var resizeItv = null;
    var delayResize = function() {
        clearTimeout(resizeItv);
        setTimeout(self.doResize, 50);
    };

//    // 搜索面板
//    this.searchPanel = new SearchPanel();

    this.doResize = function() {
        var ps = window.getSize();

        // 限制窗口最小宽度
        if (ps.x < 600) ps.x = 600;
        if (ps.y < 400) ps.y = 400;

        var oBanner = document.getElementById(idSysBanner);
        var oMap = document.getElementById(idSysMap);
        var oSplit = document.getElementById(idSysSplit);
        var oSide = document.getElementById(idSysSide);
//        var oSysToolbar = document.getElementById(idSysTools);

        // 计算
        var bannerHeight = 0;
        var splitWidth = 0;
        var splitHeight = 0;
        var sideWidth = 0;
        var sideHeight = 0;
        var toolbarHeight = 0;  //2009.12.30

        // 全屏与非全屏模式下Banner的高度
        if (isFullScreen) {
            bannerHeight = 0;
            if (oBanner.style.display != 'none') oBanner.style.display = 'none';
            getEle(idSysSplitFullScreen).className = 'togFullscreenClose';
        } else {
            if (oBanner.style.display != '') oBanner.style.display = '';
            bannerHeight = oBanner.offsetHeight;
            getEle(idSysSplitFullScreen).className = 'togFullscreenOpen';
        }

        // 得到顶部高度
        var topHeight = bannerHeight + toolbarHeight;

        // 工具栏下的阴影
        var oShadow = getEle('dSysToolsShadow');
        if (oShadow) {
            oShadow.style.top = topHeight + 'px';
        }

        // 限制最小宽度
        //oSysToolbar.style.width = ps.x + 'px';
        oBanner.style.width = ps.x + 'px';

        // 计算侧栏宽度
        if (isShowSide) {
            if (oSide.style.display != '') oSide.style.display = '';
            sideWidth = sideFrameWidth;
            sideHeight = ps.y - topHeight;

            oSide.style.width = sideWidth + 'px';
            oSide.style.height = sideHeight + 'px';
            oSide.style.top = topHeight + 'px';
            oSide.style.left = (ps.x - sideWidth) + 'px';

            getEle(idSysSplitTogButton).className = 'togSidebarOpen';
            //oSideNavTabs.style.display = '';
        } else {
            if (oSide.style.display != 'none') oSide.style.display = 'none';
            sideWidth = 0;
            sideHeight = 0;

            getEle(idSysSplitTogButton).className = 'togSidebarClose';
            //oSideNavTabs.style.display = 'none';
        }

        splitHeight = ps.y - topHeight;
        splitWidth = oSplit.offsetWidth;

        oSplit.style.height = splitHeight + 'px';
        oSplit.style.top = topHeight + 'px';
        oSplit.style.left = (ps.x - sideWidth - splitWidth) + 'px';


        var oSBButton = getEle(idSysSplitTogButton);
        var mSBHeight = oSBButton.offsetHeight;
        oSBButton.style.top = (splitHeight - mSBHeight) / 2 + 'px';
        oSBButton.style.left = (splitWidth - oSBButton.offsetWidth) + 'px';

        var oFSButton = getEle(idSysSplitFullScreen);
        var mFBHeight = oFSButton.offsetHeight;
        oFSButton.style.top = (splitHeight - mSBHeight) / 2 + mSBHeight + 'px';
        oFSButton.style.left = (splitWidth - oFSButton.offsetWidth) + 'px';


        oMap.style.top = (topHeight) + 'px';
        oMap.style.left = (0) + 'px';
        oMap.style.width = (ps.x - sideWidth - splitWidth) + 'px';
        oMap.style.height = (ps.y - topHeight) + 'px';


        oSBButton = null;
        oFSButton = null;
        oShadow = null;

        oBanner = null;
        oMap = null;
        oSplit = null;
        oSide = null;
        //oSysToolbar = null;

        if (gMap) gMap.doResize();
    };

    // 全屏切换
    //@status: 指定是否全屏，不设置则在全屏与非全屏之间进行切换
    this.togFullScreen = function(status) {
        if (status) {
            isFullScreen = status;
        } else {
            isFullScreen = !isFullScreen;
        }
        if (isFullScreen) isShowSide = false; else isShowSide = true;
        self.doResize();
    };

    // 侧栏切换
    //@status: 指定是否显示侧栏，不设置值则在显示与不显示侧栏之间切换
    //@fwidth: 指定侧栏的宽度，不设置则使用最后一次使用的宽度
    this.togSidePanel = function(status, fwidth) {
        if (status) {
            //if (status == isShowSide) return;
            isShowSide = status;
        } else {
            isShowSide = !isShowSide;
        }
        if (fwidth && typeof (fwidth) == 'number') {
            sideFrameWidth = fwidth;
        }
        self.doResize();
    };

    this.doDestroy = function() {

    };

    this.doInit = function() {
        // 设置窗口分隔按钮的事件
        $(idSysSplitTogButton).addEvent('click', function() {
            isShowSide = !isShowSide;
            self.doResize();
        }).setProperty('hideFocus', 'true');

        $(idSysSplitFullScreen).addEvent('click', function() {
            self.togFullScreen();
        }).setProperty('hideFocus', 'true');

        // 工具栏阴影
        var oShadow = document.getElementById('dSysToolsShadow');
        if (oShadow) {
            if (self.isIE6) {
                oShadow.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="citycomeSkin/default/map/shadow.png")';
            } else {
                oShadow.src = 'citycomeSkin/default/map/shadow.png';
            }
        }

        var l_urls = [
            'http://nnmap2009.citycome.com/mb2.aspx?v={V}&t={T}&x={X}&y={Y}&z={Z}&f={F}',
            'http://map-nn.poto.cc/mb2.aspx?v={V}&t={T}&x={X}&y={Y}&z={Z}&f={F}'
        ];

        citycome.SkinPath = "citycomeSkin/Dinner/";

        // gConfig.startup.x = 229436;
        // gConfig.startup.y = 124458;

        gMap = new CityMap('dSysMap', gConfig);



        var glayer_m = gMap.BuildMapLayer(true, l_urls, 1, 2, false, 'jpeg', true, false);

        var glayer_r = gMap.BuildMapLayer(false, l_urls, 1, 3, true, 'png', true, true);

        gMap.BuildHotspotLayer('hotspot', true, '_map_hs.ashx', function(arg, _id, _name) {
            var pt = gMap.screen2map(gMap.scrmousePt);
            ObjWin.show(pt.x, pt.y, _id, _name);
        });

        var glayer_l = gMap.BuildLabelsLayer('citycome-labels', false, '_map_label.ashx', 'moilabel', function(arg, _id, _name) {
            var pt = gMap.screen2map(gMap.scrmousePt);
            ObjWin.show(pt.x, pt.y, _id, _name);
        });


        var zb = gMap.BuildZoombar();
        zb.handler.style.backgroundColor = '#921919';
        zb.handler.style.borderColor = '#921919';

        var birdview = gMap.BuildBirdView('city-birdview', 220, 145, true, l_urls, 32);
        birdview.handler.style.borderColor = '#921919';
        birdview.handler.style.backgroundColor = '#921919';
        birdview.setRoleLayerManager(glayer_r);
        birdview.setLabelManager(glayer_l);

    };

   // var update_user_status_itv = setInterval(updateUserStatus, 3000);


    // 添加窗体事件
    window.addEvent('resize', delayResize);
    window.addEvent('domready', delayResize);
    window.addEvent('unload', this.doDestroy);

    // 调整界面位置
    this.doResize();

    // 执行初始化
    this.doInit();

    // 调整界面位置
    this.doResize();

    if (_START == "MO") {
        window.setTimeout(function() {
            ObjWin.show(mox, moy, moid, moname);
        }, 500);
    }
};

var gMap = null;
var gApp = new CitycomeApp();

function AjaxService() {
    var XHRQueue = [];
    var XHRQueueAbort = function(_method) {
        for (var i = 0; i < XHRQueue.length; i++) {
            if (XHRQueue[i]._method == _method) {
                XHRQueue[i]._obj.cancel();
                break;
            }
        }
    };
    var XHRQueueAdd = function(_m, _o) {
        var isExit = false;
        for (var i = 0; i < XHRQueue.length; i++) {
            if (XHRQueue[i]._method == _m) {
                XHRQueue[i]._obj = _o;
                isExit = true;
                break;
            }
        }
        if (!isExit) XHRQueue.push({ _method: _m, _obj: _o });
    };
    this.getData = function(_method, _url, _param, _CallBack) {
    XHRQueueAbort(_method);
        Req = new Request({ url: (_url + "?__t="+$time()+'&' + _param), method: 'post', onComplete: function() { _CallBack(this.response.text); } }).send();
        //Req = new Request({ url: (_url + "?" + _param), method: 'get', onComplete: function() { _CallBack(this.response.text); } }).send();

        XHRQueueAdd(_method, Req);
    };
}
var AjaxSvc = new AjaxService();

function BusPlanSvc() {
    var self = this;
    var pos = { s: null, e: null };
    this.setPoint = function(type) {
        try {
            gMap.getmappos_start(type, "取点", false, self.succ, null);
        }
        catch (e) { }
    };
    this.succ = function(type, mapx, mapy) {
        var urlp = 't=' + new Date().getSeconds();
        if (type == 1) {
            pos.s = { x: mapx, y: mapy };
        }
        else {
            pos.e = { x: mapx, y: mapy };
        }
        if (pos.s != null) urlp += '&spos=' + pos.s.x + ',' + pos.s.y;
        if (pos.e != null) urlp += '&epos=' + pos.e.x + ',' + pos.e.y;
        gApp.showPanel('map/BusSearchResult.aspx?' + urlp);
        if (pos.s != null && pos.e != null) {
            pos.s = null;
            pos.e = null;
        }
    };
}
var BusSvc = new BusPlanSvc();

function BusStationInfoWin() {
    this.stations = [];
    var self = this;
    var _bsID = 0;
    var isInit = false;
    var winw = 311;
    var winh = 150;
    var win = null;
    var posx = 0;
    var posy = 0;
    var content = '';
    var header = '<div class="bWHeader"><div><span>{0}</span><a href="javascript:BusWin.close();" title="关闭" class="close"></a></div></div><div class="bWBody" style=\"height: 112px;\">&nbsp;</div>';
    this.init = function() {
        if (win == null) win = gMap.BuildWindow('busStationInfoWin', winw, winh, null, null);
    };
    this.showline = function(lineid) {
        gApp.showPanel('map/BusSearchResult.aspx?lineid=' + lineid + '&nofly=1');
    };
    this.showbyid = function(_id) {
        for (var i = 0; i < self.stations.length; i++) {
            if (self.stations[i].id == _id) {
                self.show(self.stations[i].x, self.stations[i].y, self.stations[i].id, self.stations[i].name);
                break;
            }
        }
    };
    this.show = function(x, y, id, _title) {
        if (!isInit) self.init();

        if (x < 1 || y < 1) return;

        var loadinfo = false;
        if (_bsID != id) loadinfo = true;

        if (loadinfo) {
            posx = x;
            posy = y;
            header = header.replace("{0}", _title);
            win.show(x, y, header, winw, winh);
            _bsID = id;
            self.getInfo(id, _title);
        }
        else {
            win.show(x, y, content, winw, winh);
        }
    };
    this.getInfo = function(id, name) {
        AjaxSvc.getData('gblbshtml', "map/bussvc.ashx", "method=gblbshtml&param=" + id + "&name=" + escape(name), self.cb);
    };
    this.cb = function(res) {
        if (res != null && res != "") {
            content = res;
            win.show(posx, posy, res, winw, winh);
        }
    };
    this.close = function() {
        win.close();
    };
}
var BusWin = new BusStationInfoWin();

function MapObjInfoWin() {
    var self = this;
    var _ObjID = 0;
    var isInit = false;
    var winw = 311;
    var winh = 356;
    var tabobj = ['oWTab1', 'oWTab2', 'oWTab3'];
    var tabpnl = ['oWPnl1', 'oWPnl2', 'oWPnl3'];
    var win = null;
    var posx = 0;
    var posy = 0;
    var content = '';
    var header = '<div class="oWHeader"><div><span>{0}</span><a href="javascript:ObjWin.close();" title="关闭" class="close"></a></div></div><div class="oWBody" style=\"height: 232px;\"></div>';
    this.init = function() {
        if (win == null) win = gMap.BuildWindow('mapObjInfoWin', winw, winh, null, null);
    };
    this.show = function(x, y, id, _title) {
        if (!isInit) self.init();

        if (x < 1 || y < 1) return;

        var loadinfo = false;
        if (_ObjID != id) loadinfo = true;

        if (loadinfo) {
            posx = x;
            posy = y;
            header = header.replace("{0}", _title);
            win.show(x, y, header, winw, winh);
            _ObjID = id;
            self.getBaseInfo(id);
        }
        else {
            win.show(x, y, content, winw, winh);
        }
    };
    this.tab = function(idx) {
        for (var i = 0; i < tabobj.length; i++) {
            $(tabobj[i]).className = (idx == i) ? "on" : "off";
            $(tabpnl[i]).style.display = (idx == i) ? "" : "none";
        }

    };
    this.ApplyShop = function(id) {
        window.open("http://life.citycome.com/shopping/shop/member.php?ac=itemapply&shopid=m" + id);
    }
    this.AddShop = function() {
        window.open("http://life.citycome.com/shopping/shop/post.php?action=newshop");
    }
    this.ReportBug = function(id) {
        alert("感谢您为我们补充信息，系统将跳转到商铺页面完成纠错步骤。\n*如果商铺信息有误，请点击‘商家展示’一栏中的‘补充商铺信息’按钮\n*如果是地图有误，请点击地图右下方的‘报错’。");
        window.open("http://life.citycome.com/shopping/shop/m" + id);
    }
    this.getBaseInfo = function(id) {
        AjaxSvc.getData('getobjinfo', "map/mapsvc.ashx", "method=getobjinfo&param=" + id, self.cb);
    };
    this.cb = function(res) {
        if (res != null && res != "") {
            content = res;
            win.show(posx, posy, res, winw, winh);
            sa.setStatus(true);
            self.tab(2);
        }
    };
    this.close = function() {
        win.close();
    };
    this.getPOS = function() {
        return { x: posx, y: posy };
    };
};
var ObjWin = new MapObjInfoWin();


// 背投广告
(function() {
    var displayTime = 10;
    var g = function(_id) {
        return document.getElementById(_id);
    };
    if (!g('dMaskAD')) return;

    // 关闭广告层
    window.doCloseMaskAD = function() {
        clearInterval(adcounterItv); adcounterItv = null;
        $('dMaskWating').style.display = 'none';
        $('dMaskClose').style.display = 'none';
        $('dMaskList').style.display = 'none';
        doCloseAD();
    };

    var closeADItv = null;

    $('dMaskBG_T').style.top = '0px';
    $('dMaskBG_B').style.top = '270px';

    var openHeight = 0;

    var ajustElements = function() {
        var ps = window.getSize();
        var boH = ps.y - 94;
        $('dMaskAD').setStyles({
            'width': ps.x,
            'height': boH
        });
        var boHdiv2 = Math.round(boH / 2);

        if (null == closeADItv) {
            $('dMaskBG_T').setStyle('height', boHdiv2 - openHeight);

            $('dMaskBG_B').setStyles({
                'top': boHdiv2 + openHeight,
                'height': boHdiv2 - openHeight
            });
        }

        $('dMaskT').setStyles({
            'top': boHdiv2 - 170 - openHeight,
            'left': Math.round((ps.x - 600) / 2)
        });
        $('dMaskB').setStyles({
            'top': boHdiv2 + openHeight,
            'left': Math.round((ps.x - 600) / 2)
        });

        $('dMaskWating').setStyles({
            'top': boHdiv2 - 170 - openHeight - 22,
            'left': Math.round((ps.x - 600) / 2)
        });
        $('dMaskClose').setStyles({
            'top': boHdiv2 - 170 - openHeight - 22,
            'left': Math.round(ps.x / 2 + 300 - 50)
        });
        $('dMaskList').setStyles({
            'top': boHdiv2 + openHeight + 170 + 3,
            'left': Math.round((ps.x - 600) / 2)
        });
    };
    ajustElements();

    $('dMaskAD').setStyle('visibility', 'visible');

    window.addEvent('resize', ajustElements);

    // 关闭广告
    var doCloseAD = function() {
        closeADItv = setInterval(function() {

            var mTop = parseInt($('dMaskBG_T').style.top, 10);
            var mBom = parseInt($('dMaskBG_B').style.top, 10);

            var nTop = mTop - 15;
            var nBom = mBom + 15;

            $('dMaskBG_T').setStyle('top', nTop);
            $('dMaskBG_B').setStyle('top', nBom);

            $('dMaskT').setStyle('top', nTop + parseInt($('dMaskBG_T').offsetHeight, 10) - $('dMaskT').offsetHeight);
            $('dMaskB').setStyle('top', nBom);

            if (mTop < -$('dMaskBG_T').getCoordinates().height) {
                clearInterval(closeADItv); closeADItv = null;
                g('dMaskAD').style.display = 'none';
                window.removeEvent('resize', ajustElements);
            }
        }, 30);
    };


    // 关闭倒计时
    var adcounterItv = setInterval(function() {
        displayTime--;
        g('dMaskWaitTime').innerHTML = displayTime;
        if (displayTime <= 0) {
            clearInterval(adcounterItv); adcounterItv = null;
            doCloseMaskAD();
        }
    }, 1000);
})();

/*基本信息框 周边*/
function SearchAround() {
    var self = this;

    this.idx = -1;
    this._id = '';
    this.pops = [];
    this.icons = ['gc.gif', 'zs.gif', 'cy.gif', 'yl.gif', 'gw.gif', 'mr.gif', 'yh.gif', 'yd.gif', 'yd.gif', 'jyz.gif'];
    this.icons2 = ['gc2.gif', 'zs2.gif', 'cy2.gif', 'yl2.gif', 'gw2.gif', 'mr2.gif', 'yh2.gif', 'yd2.gif', 'yd2.gif', 'jyz2.gif'];
    this.morePnl = $('d_moreAroundPnl');
    this.morePnlClose = $('a_moreAourndClose');
    this.morePnlClose.addEvent('click', function() {
        self.morePnl.style.top = '-2000px';
    });
    this.morePnlLinks = $$('#d_moreAround A');
    for (var i = 0; i < this.morePnlLinks.length; i++) {
        this.morePnlLinks[i].addEvent("click", function() {
            self.more(this);
            //$('d_ClearMark').style.display = '';
        });
    }

    this.showmore = function() {
        var wincoor = window.getCoordinates();
        var pnlcoor = self.morePnl.getCoordinates();
        self.morePnl.style.left = (wincoor.width - pnlcoor.width) / 2 + 'px';
        self.morePnl.style.top = (wincoor.height - pnlcoor.height) / 2 + 'px';
    };
    this.more = function(obj) {
        var id = obj.id.replace('a_c', '');
        var ca = gMap.getMapViewport();
        var area = ca.l + ',' + ca.t + ',' + ca.r + ',' + ca.b;
        gApp.showPanel('/map/SearchResult.aspx?area=' + area + '&class=' + id);
    };
    this.show = function(id, idx) {
        self._id = id;
        self.idx = idx;
        self.setStatus(false);
        if (id == 'bs') {
            self.loadObjByCatID(id, self.getRange());
        }
        else {
            var ca = self.getRange();
            var area = ca.l + ',' + ca.t + ',' + ca.r + ',' + ca.b;
            gApp.showPanel('/map/SearchResult.aspx?area=' + area + '&class=' + id);
        }
        if (id == '-1') {
            $('d_ClearMark').style.display = 'none';
            self.morePnl.style.top = '-2000px';
        }
    };
    this.changeRange = function() {
        if (self._id == 'bs') {
            self.loadObjByCatID(self._id, self.getRange());
        }
        else {
            var ca = self.getRange();
            var area = ca.l + ',' + ca.t + ',' + ca.r + ',' + ca.b;
            gApp.showPanel('/map/SearchResult.aspx?area=' + area + '&class=' + self._id);
        }
        //self.loadObjByCatID(self._id, self.getRange());
    };
    this.getRange = function() {
        var range = 0;
        var rads = $('d_aroundRange').getElementsByTagName("INPUT");
        for (var i = 0; i < rads.length; i++) {
            if (rads[i].checked) {
                range = (rads[i].value * 2);
                break;
            }
        }
        var pos = ObjWin.getPOS();
        return { l: (pos.x - range), t: (pos.y - range), r: (pos.x + range), b: (pos.y + range) };
    };
    this.loadObjByCatID = function(id, ca) {

        function mvcb(res) {
            try {
                eval("var list = " + res);
                self.pops = list;
                gMap.layerMarks.clear();
                for (var i = 0; i < self.pops.length; i++) {
                    var o = self.pops[i];
                    gMap.layerMarks.add(o.id, 'citycomeSkin/default/map/caticons/' + self.icons[self.idx], o.x, o.y, 25, 29, 13, 29, o.name, function(_id) { self.showinfo(_id); });
                }
            }
            catch (e) { }
        }

        var param = escape(self._id) + '&l=' + ca.l + '&t=' + ca.t + '&r=' + ca.r + '&b=' + ca.b;
        AjaxSvc.getData('getcatsbyaround', "map/mapsvc114.ashx", "method=getcatsbyaround&param=" + param, mvcb);

    };
    this.showinfo = function(_id) {
        var pop = null;
        for (var i = 0; i < self.pops.length; i++) {
            if (self.pops[i].id == _id) {
                pop = self.pops[i];
                break;
            }
        }
        if (pop != null) {
            if (self._id != 'bs') {
                ObjWin.show(pop.x, pop.y, pop.id, pop.name);
            }
            else {
                BusWin.show(pop.x, pop.y, pop.id, pop.name);
            }
        }
    };
    this.setStatus = function(resetFlag) {
        if (resetFlag) {
            self.idx = -1;
            self._id = '-1';
            $('rad_500').checked = true;
        }
        var aa = $('d_aroundLinks').getElementsByTagName("A");
        for (var i = 0; i < aa.length; i++) {
            if (aa[i].id == 'aa_' + self.idx.toString()) {
                aa[i].className = 'on';
                aa[i].style.backgroundImage = 'url(citycomeSkin/default/map/caticons/' + self.icons[i] + ')';
            }
            else {
                aa[i].className = 'off';
                aa[i].style.backgroundImage = 'url(citycomeSkin/default/map/caticons/' + self.icons2[i] + ')';
            }
        }
    };
};
var sa = null;
window.addEvent('domready', function() {
    sa = new SearchAround();
});

//(function() {
//    var self = this;
//    this.cid = '';
//    this.idx = -1;
//    this.pops = [];
//    this.icons = ['gc.gif', 'zs.gif', 'cy.gif', 'yl.gif', 'gw.gif', 'mr.gif', 'yh.gif', 'yd.gif', 'yd.gif', 'jyz.gif'];

//    this.ToolBtn = $('aTMapAround');
//    this.Pnl = $("ul_aroundList");
//    this.links = self.Pnl.getElementsByTagName('A');
//    this.links[0].onclick = function() { self.show('bs', 0); };
//    this.links[1].onclick = function() { self.show('119', 1); };
//    this.links[2].onclick = function() { self.show('118', 2); };
//    this.links[3].onclick = function() { self.show('121', 3); };
//    this.links[4].onclick = function() { self.show('45', 4); };
//    this.links[5].onclick = function() { self.show('38', 5); };
//    this.links[6].onclick = function() { self.show('124', 6); };
//    this.links[7].onclick = function() { self.show('107', 7); };
//    this.links[8].onclick = function() { self.show('47', 8); };
//    this.links[9].onclick = function() { self.show('514', 9); };
//    this.links[10].onclick = function() { self.show('-1', -1); };
//    this.ClearBtn = $('d_ClearMark');

//    this.ClearBtn.addEvent('click', function() {
//        self.show('-1', -1);
//    });

//    this.ToolBtn.addEvent('mouseover', function() {
//        self.pnlshow(true);
//    });
//    this.ToolBtn.addEvent('mouseout', function() {
//        self.pnlshow(false);
//    });
//    this.Pnl.addEvent('mouseover', function() {
//        self.pnlshow(true);
//    });
//    this.Pnl.addEvent('mouseout', function() {
//        self.pnlshow(false);
//    });

//    this.pnlshow = function(flag) {
//        if (flag) {
//            var coor = self.ToolBtn.getCoordinates();
//            self.Pnl.style.left = coor.left + 'px';
//            self.Pnl.style.top = coor.top + 12 + 'px';
//            self.Pnl.style.display = '';
//        }
//        else {
//            self.Pnl.style.display = 'none';
//        }
//    };

//    this.show = function(cid, idx) {
//        self.idx = idx;
//        self.cid = cid;
//        if (cid == 'bs') {
//            if (gMap.getZoom() > 3) {
//                var ca = gMap.getMapViewport();
//                var param = escape(cid) + '&l=' + ca.l + '&t=' + ca.t + '&r=' + ca.r + '&b=' + ca.b;
//                AjaxSvc.getData('getcatsbyaround', "map/mapsvc114.ashx", "method=getcatsbyaround&param=" + param, self.callback);
//            }
//            else {
//                self.changeZoom();
//            }
//        }
//        else {
//            var ca = gMap.getMapViewport();
//            var area = ca.l + ',' + ca.t + ',' + ca.r + ',' + ca.b;
//            gApp.showPanel('/map/SearchResult.aspx?area=' + area + '&class=' + cid);
//        }
//        if (cid == '-1') {
//            this.ClearBtn.style.display = 'none';
//            sa.morePnl.style.top = '-2000px';
//        }
//        else {
//            this.ClearBtn.style.display = '';
//        }
//    };
//    this.callback = function(res) {
//        try {
//            eval("var list = " + res);
//            self.pops = list;
//            gMap.layerMarks.clear();
//            for (var i = 0; i < self.pops.length; i++) {
//                var o = self.pops[i];
//                gMap.layerMarks.add(o.id, 'citycomeSkin/default/map/caticons/' + self.icons[self.idx], o.x, o.y, 25, 29, 13, 29, o.name, function(_id) { self.showinfo(_id); });
//            }
//        }
//        catch (e) { }
//    };
//    this.showinfo = function(_id) {
//        var pop = null;
//        for (var i = 0; i < self.pops.length; i++) {
//            if (self.pops[i].id == _id) {
//                pop = self.pops[i];
//                break;
//            }
//        }
//        if (pop != null) {
//            if (self.idx != 0) {
//                ObjWin.show(pop.x, pop.y, pop.id, pop.name);
//            }
//            else {
//                BusWin.show(pop.x, pop.y, pop.id, pop.name);
//            }
//        }
//    };
//    this._timeID = null;
//    this.changeZoom = function() {
//        self._timeOutID = $clear(self._timeID);
//        self._timeID = null;
//        gMap.zoomTo(4);
//        self._timeOutID = window.setTimeout(function() { self.show(self.cid, self.idx); }, 1000);
//    };
//})();