﻿var vM = null;               //地图对象
var vMe = null;               //鹰眼对象

var _PluginList = [];
var _DebugControl;              //纠错控件

var _ZoomBar = null;            //缩放工具条
var _TabControl;                //选项卡

var cRotaryPictureControl;      //视窗广告

var _IsBeginSelectMark = false;  //是否开始标记
var _IsBeginScale = false;  //是否开始测距
var _IsBeginShortRoad = false;
var _ShortRoadFlag = false;
var __IsDrawBusLineState = false; //标记当前是公交站点的画线图层还是换乘的画线图层

var _IconLayer;             //小图标图层
var _LabelLayer;            //E店标签图层
var _EyeIconLayer = null;        //鹰眼图标图层
var _BusTransferLineLayer;          //公交换乘线图层
var _PopLayer;
var _ShowMessageBoxLayer;
var _BusStationLayer;
var _ShortRoadLayer;
var ShortRoadCoords = "";
var ShortRoadImage = GlobalConfig.SkinPath + '/Images/PinIco.png';

var _BusLineCoordList = [];        //公交线路坐标
var _BusLineData = null;           //公交站点数据
var _BusLineType = 0;              //线路正向还是反向

var __TradeLabelData = [];         //地图找店请求到显示的数据 ID+数据数组
var __ZoneLabelData = [];

var _EAddressRegTab = null;
var _EAddressManagerTab = null;
var _EAddressStatus = 0; //0：申请，1：管理
var _IsBeginSelectEAddress = false;
var _LoginCallback = null; //登录完成后的回调函数

var _EAddressOperatorType = 0;

var _UserCoordList = null; //用户排队坐标
var __EdushiSuggest = null;

var cNavigationControl;
var _PaneLayer;
var _UseGoogleMap = true; //true:使用google map模式 | false:使用原先的三维/二维模式
function reSizeMap(w, h) {
    var dm = document.getElementById('DetailMap');
    dm.style.width = w + 'px';
    dm.style.height = h + 'px';
    var em = document.getElementById('EdushiMap');
    em.style.width = w + 'px';
    em.style.height = h + 'px';

    if (typeof vEdushiMap != 'undefined') {
        vEdushiMap.MapHeight(h);
        vEdushiMap.MapWidth(w);
    }
}

function initMap() {
    _IconLayer = vM.NewMapLayer('Icon', 269, 0);
    _LabelLayer = vM.NewMapLayer('EStoreLabel', 268, 0);

    _PopLayer = vM.NewMapLayer('Pop', 269, 0);
    _MarkLayer = vM.NewMapLayer('Mark', 265, 0); //标记图层
    _BusTransferLineLayer = vM.NewMapLayer('BusTransferLine', 149); //公交线路
    _ShowMessageBoxLayer = vM.NewMapLayer('message', 300);
    _BusStationLayer = vM.NewMapLayer('BusStation', 261);
    _ShortRoadLayer = vM.NewMapLayer('ShortRoad', 270); //最短路径图层

    _TempLineLayer = vM.NewMapLayer('TempLineLayer', 268, 0);

    _PaneLayer = vM.NewMapLayer('Pane', 267, 0); //拉框搜索图层
    fnAddMarkCss();

    if (_UseGoogleMap) {
        if ($('liWx')) {
            $('liWx').style.display = 'block';
        }
    }

    //加载视窗广告
    //setTimeout("fnLoadRotaryPicture()", 3000);

    //滑竿缩放
    _ZoomBar = new ZoomBarClass();
    _ZoomBar.Init();
    vM.onMapZoomChange = function(z) {
        _ZoomBar.ZoomTo(vM.Zoom());
        if (vMe != null) {
            vMe.FlatZoom(vM.Zoom());
        }
        if (__IsDrawBusLineState) {
            fnShowBusStationIco(_BusLineData, _BusLineType);
        }
        else {
            fnDrawingBusLine(_BusLineCoordList);
        }
        if (ShortRoadCoords != "") {
            vM.Body.DrawPolyLine(_ShortRoadLayer, vM.Body.ChangeCoords(ShortRoadCoords, vM.Body.ZoomPer[vM.Zoom()]), 2, "red", 0.8);
        }
    };
    if (vMe != null) {
        _EyeIconLayer = vMe.NewMapLayer('Icon', 264, 0);

        //地图鹰眼联动
        vMe.onMapMoveEnd = function(x, y, flg) {
            if (_UseGoogleMap)//某些老的地图可能仍在使用老的API(无MapState()方法)，这里兼容下
            {
                if (vM.MapState() != 0) {
                    MoveEndOperation();
                }
            }
            else {
                MoveEndOperation();
            }
            if (flg == 0) { vM.MoveTo(x, y, true); }
        };
    }
    function MoveEndOperation() {
        if (__IsDrawBusLineState) {
            fnShowBusStationIco(_BusLineData, _BusLineType);
        }
        else {
            fnDrawingBusLine(_BusLineCoordList);
        }
        //yuDrawTempLine();
    }
    //地图移动
    vM.onMapMoveEnd = function(x, y, flg) {
        if (flg == 0 && vMe != null) { vMe.MoveTo(x, y, true); }
    };
    //测距结束 
    vM.onScaleEnd = function(dis) {
        fnShowScaleResult(dis);
    };
    //地图双击事件
    vM.onMapDblClick = function(e) {
        //alert(vM.PointerX()+'|'+vM.PointerY());
        //return;
        if (!_IsBeginScale) {
            if (vM.Zoom() > 0) {
                vM.MoveTo(vM.PointerX(), vM.PointerY());
                if (vMe != null) {
                    vMe.MoveTo(vM.PointerX(), vM.PointerY());
                }
                vM.FlatZoom(0);
            }
            else {
                vM.MoveTo(vM.PointerX(), vM.PointerY(), true);
                if (vMe != null) {
                    vMe.MoveTo(vM.PointerX(), vM.PointerY(), true);
                }
            }
        }
        _IsBeginScale = false;
    };
    vM.onMapMouseUp = function(e) {
        if (_IsBeginSelectMark) {
            _Mark.Add(vM.PointerX(), vM.PointerY(), '');
        }
        if (_IsBeginSelectEAddress) {
            _EAddress.Add(vM.PointerX(), vM.PointerY(), '', '');
        }
    };
    vM.onPaneEnd = function(x1, y1, x2, y2, flg) {
        if (flg == 0) {
            fnShowPaneSearch(x1, y1, x2, y2);
        }
    };
    //加载扩展插件
    if (typeof _PluginList != 'undefined') {
        for (var i = 0; i < _PluginList.length; i++) {
            if (typeof _PluginList[i].Init == 'function') {
                _PluginList[i].Init();
            }
        }
    }
    //checkLogin();
    /* GOOGLE统计暂时关闭
    ENetwork.DownloadScript('http://www.google-analytics.com/ga.js',function(){
    if(typeof _gat != 'undefined'){
    pageTracker = _gat._getTracker(GlobalConfig.GoogleID);
    pageTracker._initData();
    pageTracker._trackPageview();
    }
    });
    */
}
function ShortRoadPutFlag(x, y) {
    var o = vM.$C("img");
    o.src = ShortRoadImage;
    //o.style.left =vM.GetWinPos(x) - parseInt(35);
    //o.style.top =vM.GetWinPos(y) - parseInt(34);
    vM.appendEntity(o, _ShortRoadLayer, false, x, y, 35, 34, 2, 34, false);
    o = null;
}

function ShortRoad() {
    var x, y, x1, y1;
    vM.ShowPointerTip('<div style="' + vEdushiMap.Body.CSSTip + '">请双击选择起始点</div>', 10, 10);
    //_IsBeginShortRoad=true;
    var count = "0";
    flag = true;
    vM.onMapDblClick = function() {
        if (flag) {
            if (count == "0") {
                x = vEdushiMap.PointerX();
                y = vEdushiMap.PointerY();
                ShortRoadPutFlag(x, y);
                vM.ShowPointerTip('<div style="' + vEdushiMap.Body.CSSTip + '">请双击选择终点</div>', 10, 10);
                count = "1";
            } else if (count == "1") {
                x1 = vEdushiMap.PointerX();
                y1 = vEdushiMap.PointerY();
                vM.HidePointerTip();
                ShortRoadPutFlag(x1, y1);
                count = "0";
                flag = false;
                fnShowRoadSearch(x, y, x1, y1);
            }
        }
    }
}

function ShowShortRoadFlag(x, y, x1, y1) {
    ShortRoadPutFlag(x, y);
    ShortRoadPutFlag(x1, y1);
}

function drawShortRoad(coorddata, x, y, x1, y1) {
    ShortRoadCoords = coorddata;
    _ShortRoadLayer.innerHTML = "";
    if ((coorddata != '0,0' && coorddata != "undefined") || coorddata == "") {
        if (x != 0) {
            ShowShortRoadFlag(x, y, x1, y1);
        }
        vEdushiMap.Body.DrawPolyLine(_ShortRoadLayer, vEdushiMap.Body.ChangeCoords(ShortRoadCoords, vEdushiMap.Body.ZoomPer[vEdushiMap.Zoom()]), 2, "red", 0.8);
        var a = coorddata.split(',');
        vEdushiMap.MoveTo(a[0], a[1], true);
        $('BG').style.display = "none";

    }
    else {
        alert('没有找到最短路径.');
        $('BG').style.display = "none";
    }
}
ztfnavid = "";
function fnShowNav(mynavid) {
    ztfnavid = mynavid;
    //    if (!cNavigationControl){
    cNavigationControl = new NavigationControl();
    cNavigationControl.onClose = function() {
        if ($('divDialogBg')) {
            $('divDialogBg').style.display = 'none';
            document.body.removeChild($('divDialogBg'));
        }
    };
    cNavigationControl.onNavClick = function(type, id, x, y) {
        if (type == 0) {
            fnShowEntityPop(id, x, y);
        }
        else if (type == 1) {
            fnShowCompanyPop(id, x, y);
        }
        else {
            vM.MoveTo(x, y, true);
            if (vMe != null) {
                vMe.MoveTo(x, y, true);
            }
        }
        if ($('divDialogBg')) $('divDialogBg').style.display = 'none';
    };
    document.body.appendChild(cNavigationControl.Body);
    //    }
    cNavigationControl.Width = 800;
    cNavigationControl.Height = 620;
    cNavigationControl.ResumeLayout();

    var h = fnGetWindowHeight(), w = fnGetWindowWidth();
    cNavigationControl.Body.style.zIndex = 100002;
    cNavigationControl.MoveTo((w - cNavigationControl.Width) / 2, (h - cNavigationControl.Height) / 2);
    var uA = navigator.userAgent;
    if (uA.indexOf('MSIE') != -1 && parseFloat(uA.substring(uA.indexOf('MSIE') + 4, uA.length)) < 7) {
        cNavigationControl.Body.contentWindow.location.reload(); //ie6 hack
    }
    cNavigationControl.Show();

    if (!$('divDialogBg')) {
        var div = $C('div');
        div.id = 'divDialogBg';
        div.style.backgroundColor = 'black';
        div.style.position = 'absolute';
        div.style.filter = 'alpha(opacity=50)';
        div.style.opacity = '.50';
        div.style.zIndex = 100001;
        div.style.left = 0;
        div.style.top = 0;
        div.style.width = w + 'px';
        div.style.height = h + 'px';
        document.body.appendChild(div);
    }
    else {
        $('divDialogBg').style.display = 'block';
    }

}
//拉框搜索
var cPaneSearchControl;
function fnPanel() {
    _PaneLayer.innerHTML = '';
    if (cPaneSearchControl) {
        cPaneSearchControl.Hide();
    }
    vM.StopPane();
    vM.StartPane();
}
function fnShowPaneMark(sx, sy, ex, ey) {
    var x1, y1, x2, y2;
    if (sy < ey) { y1 = sy; y2 = ey; } else { y1 = ey; y2 = sy; }
    if (sx < ex) { x1 = sx; x2 = ex; } else { x1 = ex; x2 = sx; }
    var nd = vM.$C("div");
    nd.id = "SelPanel";
    nd.style.cssText = "border:solid 2px #a2e3ff; float:right;";
    nd.style.top = y1;
    nd.style.left = x1;
    nd.style.width = vM.GetWinPos(x2 - x1);
    nd.style.height = vM.GetWinPos(y2 - y1);
    nd.innerHTML = '<div style="background-color:#a2e3ff;filter:alpha(opacity=50); opacity:.5;  width:100%; height:100%; position: absolute; z-index:-10;"></div>';
    vM.appendEntity(nd, _PaneLayer, true, x1, y1, (x2 - x1), (y2 - y1), 0, 0, false);
}
function fnShowPaneSearch(x1, y1, x2, y2) {
    if (!cPaneSearchControl) {
        cPaneSearchControl = new PaneSearchControl(vM.Body.document);
        cPaneSearchControl.ID = vM.appendEntity(cPaneSearchControl.Body, _PopLayer, false, 0, 0, 300, 135, 0, 0, true);
        if (typeof SearchHotKeyWords != 'undefined') {
            cPaneSearchControl.HotKeywords = SearchHotKeyWords;
        }
        cPaneSearchControl.Height = 135;
        cPaneSearchControl.ResumeLayout();
        cPaneSearchControl.onLoadComplete = function() {
            vM.moveEntity(cPaneSearchControl.ID, vM.CenterX() - 150, vM.CenterY() - 135);
            cPaneSearchControl.ShowPane(x1, y1, x2, y2);
            fnShowPaneMark(x1, y1, x2, y2);
        };
        cPaneSearchControl.onRePane = fnPanel;
        cPaneSearchControl.onPaneClose = function() {
            _PaneLayer.innerHTML = '';
            cPaneSearchControl.Hide();
        };
        cPaneSearchControl.onPaneSearch = function(keyword, x1, y1, x2, y2) {
            if (keyword == '请输入你要查找的关键字') {
                return false;
            }
            if (keyword.length > 1) {
                fnMapSearchByHotAndXY(keyword, x1, y1, x2, y2);
            }
        };
    }
    else {
        vM.moveEntity(cPaneSearchControl.ID, vM.CenterX() - 150, vM.CenterY() - 135);
        cPaneSearchControl.ShowPane(x1, y1, x2, y2);
        fnShowPaneMark(x1, y1, x2, y2);
    }
}
function fnMapSearchByHotAndXY(keyword, x1, y1, x2, y2) {
    tab = new TabControl.Tab(document, 'paneSearch', keyword, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=5&keyword1=' + escape(keyword) + '&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2, true, true, 80);
    fnAddTab(tab);
}
function fnShowScaleResult(dis) {
    //edushi网站核增加了返回总距离接口，这里临时暂时直接调用核内"私有变量"来获得总长度
    dis = vM.Body._dis;
    fnShowMessageBox('测距', '<div class="P">本次测距总长：<strong id="distance">' + dis + '</strong>。</div><div class="P">以上数据仅供参考，请以实际长度为准。</div>');
}
//初始化Pop广告和搜索广告
function fnInitPicAD() {
    //    var sADUrl = GlobalConfig.EDataCenterUrl + 'Ad/ImageAd.aspx?domain='+GlobalConfig.Domain+'&l='+GlobalConfig.Language;
    //    ENetwork.DownloadScript(sADUrl,function(){
    //        if(typeof _StaticAd =='undefined'){
    //        alert(_StaticAd);
    //            return false;
    //        }
    //        else{
    //            return true;
    //        }
    //    });
    //判断是否来源Pop广告
    //fnEaddGoto('');
    var C_ID = fnRequest('cid');
    var E_ID = fnRequest('eid');
    var O_ID = fnRequest('oid');
    if (/.+?\?\d+$/gi.test(window.document.location.href)) {
        O_ID = window.document.location.href.replace(/^.+?\?/gi, '');
    }
    if ((C_ID != '' || O_ID != '' || E_ID != '') && (C_ID * 1 > 0 || E_ID * 1 > 0 || O_ID * 1 > 0)) {
        if (document.referrer != '') {
            window.__IsSourceAD = true; //是否是来源定位
        }
    }
}
//显示纠错 flag:0-实体 1-企业
function fnShowDebugControl(x, y, id, name, flag) {
    if (!_DebugControl) {
        _DebugControl = new DebugControl(vM.Body.document);
        _DebugControl.ID = vM.appendEntity(_DebugControl.Body, _PopLayer, false, x, y, 300, 240, 0, 38, false);
        _DebugControl.Width = 300;
        _DebugControl.Height = 245;
        _DebugControl.ResumeLayout();
        _DebugControl.Debug(id, name, flag, x, y);
    }
    else {
        vM.moveEntity(_DebugControl.ID, x, y);
        _DebugControl.Show();
        _DebugControl.Debug(id, name, flag, x, y);
    }
}
//隐藏纠错控件
function fnHideDebugControl() {
    _DebugControl.Hide();
}
function fnAddMarkCss() {
    var MarkCss = vM.$C('link');
    MarkCss.rel = 'stylesheet';
    MarkCss.type = 'text/css';
    MarkCss.href = GlobalConfig.SkinPath + 'Css/Mark.css';
    vM.Body.document.getElementsByTagName('head')[0].appendChild(MarkCss);
}
//初始化选项卡
function fnInitTabControl() {
    if (!_TabControl) {
        var HeadContainer = $('HeadContainer');
        var BodyContainer = $('BodyContainer');
        var LeftBtn = $('LeftBtn');
        var RightBtn = $('RightBtn');
        _TabControl = new TabControl(HeadContainer, BodyContainer, LeftBtn, RightBtn);
    }
}
function fnOpenTab() {
    //    if (_MapFullScreenState) {
    //        fnFullScreen($('aFullScrenn'));
    //        if (!_MapExpandingState) {
    //            fnExpanding($('imgExpanding'));
    //        }
    //    }
    //    else {
    //        if (!_MapExpandingState) {
    //            fnExpanding($('imgExpanding'));
    //        }
    //}
    _MapFullScreenState = false;
    _MapExpandingState = false;
    AdjustSize();
}
function fnShowFromHereSearch(oname) {
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'PeripheralBus', '从这里出发', GlobalConfig.NewSkinPath + 'Fundation/FromHereStart.html?oname=' + escape(oname) + '&x=' + vM.PointerX() + '&y=' + vM.PointerY(), true, true, 80);
    fnAddTab(tab);
}
function fnShowToHereSearch(oname) {
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'PeripheralBus', '如何到达这里', GlobalConfig.NewSkinPath + 'Fundation/ToHereSearch.html?oname=' + escape(oname) + '&x=' + vM.PointerX() + '&y=' + vM.PointerY(), true, true, 80);
    fnAddTab(tab);
}
function fnShowBusTransfer(x, y, oname) {
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'busTransferSearch', '公交换乘', GlobalConfig.NewSkinPath + 'Fundation/BusTransfer.html?oname=' + escape(oname) + '&x=' + x + '&y=' + y, true, true, 80);
    fnAddTab(tab);
}
function fnShowPeripheralBus(x, y, oname) {
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'PeripheralBus', '周边公交', GlobalConfig.NewSkinPath + 'Fundation/PeripheralBus.html?oname=' + escape(oname) + '&x=' + x + '&y=' + y, true, true, 80);
    fnAddTab(tab);
}
function fnShowPeripheralSearch(x, y, oname) {
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'nearBySearch', '查找周边', GlobalConfig.NewSkinPath + 'Fundation/NearBySearch.html?oname=' + escape(oname) + '&x=' + x + '&y=' + y, true, true, 80);
    fnAddTab(tab);
}
//泡泡周边搜索
function fnNearbySearch(sKeyword, x, y, nArea) {
    var tab = new TabControl.Tab(document, 'FromHereSearch', sKeyword, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=4&keyword1=' + escape(sKeyword) + '&x=' + x + '&y=' + y + '&len=' + nArea, true, true, 80);
    fnAddTab(tab);
}
//搜索结果点击调用的方法，判断是实体还是企业后调用不同的Pop
function fnShowSearchPop(oid, cid, lstid, x, y) {
    if (cid * 1 > 0) {
        if (lstid > 0) {
            fnShowEShopPop(cid, x, y);
        }
        else {
            fnShowCompanyPop(cid, x, y);
        }
    }
    else {
        fnShowEntityPop(oid, x, y);
    }
}
//显示实体POP
function fnShowEntityPop(id, x, y) {
    MoveTo(x * 1 + vM.GetMapPos(170), y * 1, true);
    vM.moveEntity(_EntityPopControl.ID, x * 1, y * 1);
    _EntityPopControl.ShowPop(id);
}
//显示企业Pop
function fnShowCompanyPop(id, x, y) {
    MoveTo(x * 1 + vM.GetMapPos(170), y * 1, true);
    vM.moveEntity(_CompanyPopControl.ID, x * 1, y * 1);
    _CompanyPopControl.ShowPop(id);
}
//显示E店Pop
function fnShowEShopPop(id, x, y) {
    MoveTo(x * 1 + vM.GetMapPos(170), y * 1, true);
    vM.moveEntity(_EShopPopControl.ID, x * 1, y * 1);
    _EShopPopControl.ShowPop(id);
}
//显示主题Pop
function fnShowThemePop(id, x, y) {
    //debugger;
    MoveTo(x * 1 + vM.GetMapPos(170), y * 1, true);
    vM.moveEntity(_ThemePopControl.ID, x * 1, y * 1);
    _ThemePopControl.ShowPop(id);
}
//显示推荐Pop根据主题ID
function ShowCommendPopById(id, x, y) {
    MoveTo(x * 1 + vM.GetMapPos(170), y * 1, true);
    vM.moveEntity(_CommendPopControl.ID, x * 1, y * 1);
    _CommendPopControl.ShowPop(id);
}

//显示推荐Pop根据主题标题和内容
function ShowCommendPopByContent(title, content, x, y) {
    MoveTo(x * 1 + vM.GetMapPos(170), y * 1, true);
    vM.moveEntity(_CommendPopControl.ID, x * 1, y * 1);
    _CommendPopControl.ShowPopData(x, y, title, content);
}
//下载常用位置
function fnLoadCommonGoTo() {
    var url = GlobalConfig.EDataCenterUrl + 'Commmap5.0/QuickLink.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language;
    ENetwork.DownloadScript(url,
        function() {
            if (typeof QuickLinkList == 'undefined') return false;
            var lastType = -1;
            var sHtml;
            sHtml = '<ul>';
            for (var i = 0; i < QuickLinkList.length; i++) {
                if (lastType != -1 && QuickLinkList[i].Type != lastType) {
                    sHtml += '</ul><div class="Hr"></div><ul><li><a href="javascript:fnCommonGoToClick(QuickLinkList[' + i + ']);">' + QuickLinkList[i].Title + '</a></li>';
                }
                else {
                    sHtml += '<li><a href="javascript:fnCommonGoToClick(QuickLinkList[' + i + ']);">' + QuickLinkList[i].Title + '</a></li>';
                }
                lastType = QuickLinkList[i].Type;
            }
            sHtml += '</ul>';
            $('divQuickLinkList').innerHTML = sHtml;
        }
     );
}
function fnCommonGoToClick(QuickLink) {
    if (QuickLink.Flag == 0) {
        vM.MoveTo(QuickLink.x, QuickLink.y);
    }
    else if (QuickLink.Flag == 1) {
        fnShowEntityPop(QuickLink.OwnerID, QuickLink.x, QuickLink.y);
    }
    else if (QuickLink.Flag == 2) {
        fnShowCompanyPop(QuickLink.CompanyID, QuickLink.x, QuickLink.y);
    }
}
//下载热门关键字
function fnLoadHotKey() {
    var url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/ad.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&req=4'; //这里已经同时初始化好了周边搜索关键字
    ENetwork.DownloadScript(url, function() {
        if (typeof _SearchHotkey == 'undefined') return false;
        var sHtml = '';
        var arrHotkey = _SearchHotkey.HotKeyWords;
        for (var i = 0; i < arrHotkey.length; i++) {
            sHtml += '<a href="javascript:fnMapSearchByHotkey(\'' + arrHotkey[i].MKW_Name + '\');">' + arrHotkey[i].MKW_Name + '</a>&nbsp;';
        }
        $('MapHotKeywords').innerHTML = sHtml;
        sHtml = '';
        var arrEShopHotkey = _SearchHotkey.EShopHotKeyWords;
        for (var i = 0; i < arrEShopHotkey.length; i++) {
            sHtml += '<a href="javascript:fnEShopSearch(\'' + arrEShopHotkey[i].MKW_Name + '\');">' + arrEShopHotkey[i].MKW_Name + '</a>&nbsp;';
        }
        $('EShopHotKeyWords').innerHTML = sHtml;
    });
}
//触发选项卡里的Iframe onresize事件
function fnAttachIframeResize() {
    if (typeof _TabControl != 'undefined') {
        for (var i = 0; i < _TabControl.TabList.length; i++) {
            _TabControl.TabList[i].TabBody.style.height = _TabControl.TabList[i].TabBody.parentNode.clientHeight - 8 + 'px';
            _TabControl.TabList[i].resize();
        }
    }
}
//添加小图标至地图与鹰眼中
function fnAppendIcon(title, x, y, text, sImgPath, sImgPath2, sFn, w, h, ew, eh, isAppendEye) {
    if (sImgPath2 && sImgPath2.length == 0) {
        sImgPath2 = sImgPath;
    }
    var iconHTML = '<div id="' + x + '_' + y + '" style ="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + sImgPath + '\',sizingMethod=\'image\');width:' + w + 'px;height:' + h + 'px; background-image:url(' + sImgPath + ')!important;background-image:none;cursor:pointer;" onclick="' + sFn + '" title="' + title + '"><span style="display:block;width:32px;line-height:33px;text-align:center;font-size:12px;font-family:\"宋体\";color:#930;">' + text + '</span></div>';
    var p = vM.$C('div');
    p.innerHTML = iconHTML;
    vM.appendEntity(p, _IconLayer, false, x, y, w, h, ew, eh, false);
    vM.$(x + '_' + y).onmouseover = function() {
        if (document.all) {
            this.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + sImgPath2 + '\',sizingMethod=\'image\')';
        }
        else {
            this.style.backgroundImage = null;
            this.style.backgroundImage = 'url(' + sImgPath2 + ')!important';
        }
    };
    vM.$(x + '_' + y).onmouseout = function() {
        if (document.all) {
            this.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + sImgPath + '\',sizingMethod=\'image\')';
        }
        else {
            this.style.backgroundImage = null;
            this.style.backgroundImage = 'url(' + sImgPath + ')!important';
        }
    };
    if (isAppendEye && vMe != null) {

        var pe = vMe.$C('div');
        pe.innerHTML = iconHTML;
        vMe.appendEntity(pe, _EyeIconLayer, false, x, y, w, h, ew, eh, false);
        vMe.$(x + '_' + y).onmouseover = function() {
            if (document.all) {
                this.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + sImgPath2 + '\',sizingMethod=\'image\')';
            }
            else {
                this.style.backgroundImage = null;
                this.style.backgroundImage = "url(" + sImgPath2 + ")!important";
            }
        };
        vMe.$(x + '_' + y).onmouseout = function() {
            if (document.all) {
                this.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + sImgPath + '\',sizingMethod=\'image\')';
            }
            else {
                this.style.backgroundImage = null;
                this.style.backgroundImage = 'url(' + sImgPath + ')!important';
            }
        }
    }
}
/*************登录部分*********************/
function fnShowLogin(logincallback) {
    if (logincallback) {
        _LoginCallback = logincallback;
    }
    else {
        _LoginCallback = null;
    }
    var h = fnGetWindowHeight();
    var w = fnGetWindowWidth();
    if (!$('divDialogBg')) {
        var div = $C('div');
        div.id = 'divDialogBg';
        div.style.backgroundColor = 'black';
        div.style.position = 'absolute';
        div.style.visibility = 'visible';
        div.style.filter = 'alpha(opacity=50)';
        div.style.opacity = '.50';
        div.style.zIndex = 100001;
        div.style.left = 0;
        div.style.top = 0;
        div.style.width = w + 'px';
        div.style.height = h + 'px';
        document.body.appendChild(div);
    }
    if (!$('divLoginDialog')) {
        var divLogin = $C('div');
        divLogin.id = 'divLoginDialog';
        divLogin.style.left = (w / 2 - 150) + 'px';
        divLogin.style.top = (h / 2 - 60) + 'px';
        divLogin.style.position = 'absolute';
        divLogin.style.zIndex = 100002;
        divLogin.style.width = '300px';
        divLogin.style.height = 'auto';
        var loginHtml = '<div class="LoginNavT"></div><div class="LoginNavD"><h3>用户登录</h3><table border="0" cellpadding="0" cellspacing="0"><tr><th>用户名：</th><td><input class="InFieldSty" onfocus="this.className=\'ThisStyle\';" onblur="this.className=\'InFieldSty\';" style="width:160px;" type="text" id="txtUserName"/></td></tr><tr><th>密码：</th><td><input class="InFieldSty" onfocus="this.className=\'ThisStyle\';" onblur="this.className=\'InFieldSty\';" style="width:160px;" type="password" id="txtPassword"/></td></tr><tr><th>验证码：</th><td><span><input onfocus="this.className=\'ThisStyle\';" onblur="this.className=\'InFieldSty\';" class="InFieldSty" style="width:67px;" type="text" id="txtVerifyCode"/></span><span style="padding-top:1px"><img id="imgVerifyCode" style="cursor:pointer" alt="单击获取新验证码" /></span></td></tr><tr><th>&nbsp;</th><td><span><input id="chkInvalidate" type="checkbox" name="chkInvalidate" /></span><span><label for="chkInvalidate">下次记住密码</label></span></td></tr><tr><th>&nbsp;</th><td><input type="image" src="' + GlobalConfig.SkinPath + '/Images/LoginBtn1.gif" onclick="fnLogin()" />&nbsp;&nbsp;<img src="' + GlobalConfig.SkinPath + 'Images/RegBtn1.gif" alt="注册" style="cursor:pointer;" onclick="window.open(\'' + GlobalConfig.UserCenterUrl + 'Register.aspx\',\'_blank\')" /></td></tr></table><div class="LoginClew" id="divLoginResultMsg"></div></div><div style="position:absolute; top:12px; right:8px; cursor:hand; width:13px; height:13px; overflow:hidden;background:url(/Skins/zh-chs/5.0.0312/Default/Images/CloseBtn.gif) no-repeat left top;" onclick="javascript:$(\'divDialogBg\').style.display=\'none\';$(\'divLoginDialog\').style.display=\'none\';" onmouseover="this.style.backgroundPosition=\'left -13px\'"onmouseout="this.style.backgroundPosition=\'left top\'" title="关闭窗口"></div></div>';
        document.body.appendChild(divLogin);
        //IE6的延时加载
        setTimeout(function() { $('divLoginDialog').innerHTML = loginHtml; }, 1);
    }
    setTimeout(function() {
        $('imgVerifyCode').src = GlobalConfig.WebRootPath + 'VerifyImage.aspx?rnd=' + $Rnd();
        $('divLoginResultMsg').style.display = 'none';
        $('divDialogBg').style.display = 'block';
        $('divLoginDialog').style.display = 'block';
        $('imgVerifyCode').onclick = function() { this.src = GlobalConfig.WebRootPath + 'VerifyImage.aspx?rnd=' + $Rnd(); };
        $('txtUserName').focus();
    }, 10);
}
function fnLogin() {
    var sUserName = $('txtUserName').value.trim();
    var sPassword = $('txtPassword').value.trim();
    var sVerifyCode = $('txtVerifyCode').value.trim();
    var isInvalidate = $('chkInvalidate').checked;
    $('txtUserName').value = '';
    $('txtPassword').value = '';
    $('txtVerifyCode').value = '';
    $('chkInvalidate').checked = false;
    if (sUserName.length < 1 || sPassword.length < 1) {
        $('divLoginResultMsg').style.display = 'block';
        $('divLoginResultMsg').innerHTML = '用户名或者密码不能为空！';
        return;
    }
    var sLoginUrl = GlobalConfig.WebRootPath + 'Login.aspx?verifycode=' + sVerifyCode + '&isinvalidate=' + isInvalidate + '&action=login&rnd=' + $Rnd() + '&username=' + sUserName + '&password=' + sPassword;
    ENetwork.DownloadScript(sLoginUrl, function() {
        if (typeof __LoginResult != 'undefined') {
            if (__LoginResult == 1) {
                fnLoginSuccess(__Member);
                if (_LoginCallback) {
                    _LoginCallback();
                    _LoginCallback = null;
                }
            }
            else if (__LoginResult == 0) {
                $('divLoginResultMsg').style.display = 'block';
                $('divLoginResultMsg').innerHTML = '登录失败，用户名或者密码错误！';
                $('imgVerifyCode').src = GlobalConfig.WebRootPath + 'VerifyImage.aspx?rnd=' + $Rnd();
            }
            else if (__LoginResult == -1) {
                $('divLoginResultMsg').style.display = 'block';
                $('divLoginResultMsg').innerHTML = '登录失败，您输入的验证码不正确！';
                $('imgVerifyCode').src = GlobalConfig.WebRootPath + 'VerifyImage.aspx?rnd=' + $Rnd();
            }
        }
        else {
            $('divLoginResultMsg').style.display = 'block';
            $('divLoginResultMsg').innerHTML = '登录失败！';
            $('imgVerifyCode').src = GlobalConfig.WebRootPath + 'VerifyImage.aspx?rnd=' + $Rnd();
        }
    });
}
function checkLogin() {
    var sLoginUrl = GlobalConfig.WebRootPath + 'Login.aspx?&action=checklogin&rnd=' + $Rnd();
    ENetwork.DownloadScript(sLoginUrl, function() { if (typeof __Member != 'undefined') { fnLoginSuccess(__Member); } })
}
function fnLoginSuccess(memberInfo) {
    //xb090210移除用户中心城市$('liLoginInfo').innerHTML = '欢迎您！<span style="color:#ff6400">'+memberInfo.LM_NickName+'</span><span>[<a href="'+GlobalConfig.UserCenterUrl+'Index.aspx?City='+GlobalConfig.CityCode+'" target="_blank">用户中心</a>]</span>&nbsp;<span>[<a href="javascript:fnLoginOut();">退出</a>]</span>';
    $('liLoginInfo').innerHTML = '欢迎您！<span style="color:#ff6400">' + memberInfo.LM_NickName + '</span><span>[<a href="' + GlobalConfig.UserCenterUrl + 'Index.aspx" target="_blank">用户中心</a>]</span>&nbsp;<span>[<a href="javascript:fnLoginOut();">退出</a>]</span>';
    $('divLoginDialog').style.display = 'none';
    fnShowMessageBox('用户登录', '登录成功！欢迎回来' + memberInfo.LM_NickName);
    if (memberInfo.LM_EAddress.length > 0) {
        $('lnkMyEAddress').href = 'javascript:;';
        $('lnkMyEAddress').setAttribute('onmouseover', 'javascript:fnShowMyEAddress();');
        $('lnkMyEAddress').setAttribute('onmouseout', 'javascript:fnShowMyEAddress();');
        $('lnkMyEAddress').onmouseover = function() { fnShowMyEAddress(); };
        $('lnkMyEAddress').onmouseout = function() { fnShowMyEAddress(); };
        $('lnkMyEAddress').target = '_self';
        $('txtMyEAddress').value = 'http://' + GlobalConfig.Domain + '/' + memberInfo.LM_EAddress;
        $('lnkMyEAddress').title = '我的E地址';
    }
    else {
        $('lnkMyEAddress').setAttribute('onmouseover', '');
        $('lnkMyEAddress').setAttribute('onmouseout', '');
        $('lnkMyEAddress').target = '_blank';
        $('lnkMyEAddress').href = GlobalConfig.UserCenterUrl + 'MyEdushi.aspx?City=' + GlobalConfig.CityCode;
        $('lnkMyEAddress').title = '您还没申请过E地址，点击到用户中心申请吧';
    }
}
function fnLoginOut() {
    var sLoginUrl = GlobalConfig.WebRootPath + 'Login.aspx?action=loginout&rnd=' + $Rnd();
    ENetwork.DownloadScript(sLoginUrl, function() {
        if (typeof __LoginResult != 'undefined') {
            if (__LoginResult == 3) {
                fnLoginOutSuccess();
            }
            else {
                fnShowMessageBox('退出登录', '退出登录失败' + __LoginResult);
            }
        }
        else {
            fnShowMessageBox('退出登录', '退出登录失败');
        }
    });
}
function fnLoginOutSuccess() {
    $('liLoginInfo').innerHTML = '欢迎您！&nbsp;<span>[<a href="' + GlobalConfig.UserCenterUrl + 'Register.aspx" target="_blank">注册</a>]</span>&nbsp;<span>[<a href="javascript:;" onclick="fnShowLogin()">登录</a>]</span>';
    $('lnkMyEAddress').setAttribute('onmouseover', '');
    $('lnkMyEAddress').setAttribute('onmouseout', '');
    $('lnkMyEAddress').target = '_blank';
    $('lnkMyEAddress').href = GlobalConfig.UserCenterUrl + 'MyEdushi.aspx?City=' + GlobalConfig.CityCode;
    $('lnkMyEAddress').title = '我的E地址，登录后显示';
    //fnShowMessageBox('退出登录','您已经成功退出');
}
//公交换乘搜索 type 1:从这里出发，2到这里
function fnBusTransferSearch(type, x, y, keyword) {
    if (keyword != '请输入终点' && type == 1 || keyword != '请输入起点' && type == 2) {
        tab = new TabControl.Tab(document, 'search', keyword, GlobalConfig.NewSkinPath + 'Fundation/BusTransferSearch.html?action=' + type + '&x=' + x + '&y=' + y + '&key=' + escape(keyword), true, true, 80);
        fnAddTab(tab);
    }
}
var searchNavCallBack = null;
//搜索选项切换
function bindSearchNavMenu(curNode, callBack)
{
    searchNavCallBack = callBack;
    var p = document.getElementById("SearchNavMenu");
    if (typeof (curNode) == 'string') {
        curNode = $(curNode);
    }
    var items = p.getElementsByTagName("li");
    if (!curNode) {
        curNode=items[0];
    }
    var curId = '';
    for (var k = 0; k < items.length; k++) {
        var nodeid=items[k].getAttribute("id");
        if (items[k] == curNode)
        {
            curId = nodeid;
        }
        fnShowSearchChange(items[k], curNode);
        bindEvent(nodeid, "click", searchNavClick.bindAsEventListener(items[k]), false);
        var w = fnGetTextLength(items[k].getElementsByTagName("span")[0].innerHTML, 13) + 30;
        items[k].style.width = w + "px";
    }
    setBodyContainerSize();
    if (searchNavCallBack) {
        searchNavCallBack(curId);
    }
}
function searchNavClick() {
    //alert(this.id);
    fnSearchChange2(this);
    if (searchNavCallBack) {
        searchNavCallBack(this.id);
    }
}
function fnSearchChange2(oThis) {
    if (typeof (oThis) == 'string') {
        oThis = $(oThis);
    }
    if (oThis == null) {
        return;
    }
    if (__EdushiSuggest) {
        __EdushiSuggest.Hide();
    }
    var items = oThis.parentNode.childNodes;
    for (var k = 0; k < items.length; k++) {
        var curNode = items[k];
        fnShowSearchChange(curNode, oThis);
    }
    setBodyContainerSize();
}
function fnShowSearchChange(curNode, showNode) {
    var cn = "", dp = "none";
    if (curNode == showNode) {
        cn = "Current";
        dp = "block";
    }
    curNode.className = cn;
    var oid = curNode.id;
    oid = oid.substr(2, oid.length - 2);
    var o = document.getElementById(oid);
    if (o) {
        o.style.display = dp;
    }
}
function fnSearchChange(oThis) {
    if (typeof (oThis) == 'string') {
        oThis = $(oThis);
    }
    __EdushiSuggest.Hide();
    switch (oThis.id) {
        case 'liMapSearch':
            $('MapSearch').style.display = 'block';
            $('BusSearch').style.display = 'none';
            $('EShopSearch').style.display = 'none';
            $('EAddress').style.display = 'none';
            oThis.className = 'Current';
            $('liBusSearch').className = '';
            $('liEShopSearch').className = '';
            $('liEAddress').className = '';
            break;
        case 'liBusSearch':
            $('liEShopSearch').className = '';
            $('liMapSearch').className = '';
            oThis.className = 'Current';
            //$('liEAddress').className = '';
            $('BusSearch').style.display = 'block';
            $('MapSearch').style.display = 'none';
            $('EShopSearch').style.display = 'none';
            $('EAddress').style.display = 'none';
            break;
        case 'liEShopSearch':
            $('EShopSearch').style.display = 'block';
            $('MapSearch').style.display = 'none';
            $('BusSearch').style.display = 'none';
            $('EAddress').style.display = 'none';
            oThis.className = 'Current';
            $('liMapSearch').className = '';
            $('liBusSearch').className = '';
            $('liEAddress').className = '';
            var tab = new TabControl.Tab(document, 'EShopSearch', '找店助手', GlobalConfig.NewSkinPath + 'Fundation/FindEstore.html', true, true, 80);
            //fnAddTab(tab);
            break;
        case 'liEAddress':
            $('liEShopSearch').className = '';
            $('liBusSearch').className = '';
            $('liMapSearch').className = '';
            oThis.className = 'Current';
            $('EAddress').style.display = 'block';
            $('MapSearch').style.display = 'none';
            $('EShopSearch').style.display = 'none';
            $('BusSearch').style.display = 'none';
            fnNewEAddressList();
            break;
    }
    oThis.className = 'Current';
    setBodyContainerSize();
}
//公交搜索切换
function fnBusSearchChange(sValue) {
    __EdushiSuggest.Hide();
    switch (sValue) {
        case '0':
            $('BusTransfer').style.display = 'block';
            $('BusLine').style.display = 'none';
            $('BusStation').style.display = 'none';
            break;
        case '1':
            $('BusLine').style.display = 'block';
            $('BusTransfer').style.display = 'none';
            $('BusStation').style.display = 'none';
            break;
        case '2':
            $('BusStation').style.display = 'block';
            $('BusLine').style.display = 'none';
            $('BusTransfer').style.display = 'none';
            break;
    }
}
//地图搜索|公交搜索|E店搜索Suggest
function fnKeySearchSuggest(fn, input, x, y, w, type, reqtype, evt) {
    //debugger;
    var pos = fnGetElementPos(input);
    x = pos.x;
    y = pos.y + 22;

    if (input.value.trim().length < 1) {
        __EdushiSuggest.Hide();
        input.focus();
        return;
    }
    evt = window.event ? window.event : evt;
    var maptype; //地图|E店搜索类型
    if (reqtype != 0) {
        maptype = reqtype;
    }
    else {
        var iMapSearchType = GetRadioValue('MapSearchType');
        switch (iMapSearchType) {
            case '0':
                maptype = 2;    //模糊搜索
                break;
            case '1':
                maptype = 3;    //名称搜索
                break;
            case '2':
                maptype = 4;    //地址搜索
                break;
        }
    }
    fnKeyInputChanged(input, evt.keyCode, x, y, w, type, maptype);
    if (evt.keyCode == 13 && __EdushiSuggest.SuggestPannel.style.display != 'block') {
        eval(fn);
        __EdushiSuggest.Hide();
    }
}
function fnKeyInputChanged(input, keyCode, x, y, w, type, maptype) {
    if (input.value.length > 0 && input.value != __EdushiSuggest.LastKeyword && keyCode != 38 && keyCode != 40 && keyCode != 13) {
        if (type == 'eshop') {
            var url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/SearchSuggest.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&req=6&address=' + escape(input.value);
            if (maptype == 1) {
                url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/SearchSuggest.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&req=6&address=' + escape($('txtSearchArea').value) + '&kw=' + escape(input.value);
            }
            ENetwork.DownloadScript(url, function() {
                if (typeof _SuggestData != 'undefined') {
                    __EdushiSuggest.Show(_SuggestData, x, y, w);
                }
                else {
                    __EdushiSuggest.Hide();
                }
            });
        }
        else if (type == 'bus') {
            var url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/StationSuggest.aspx?req=1&domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&kw=' + escape(input.value);
            if (maptype == 2) {
                url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/StationSuggest.aspx?req=2&domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&kw=' + escape(input.value);
            }
            else if (maptype == 99) {
                url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/LineSuggest.aspx?req=99&domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&kw=' + escape(input.value);
            }
            ENetwork.DownloadScript(url, function() {
                if (typeof _SuggestData != 'undefined') {
                    __EdushiSuggest.Show(_SuggestData, x, y, w);
                }
                else {
                    __EdushiSuggest.Hide();
                }
            });
        }
        else if (type == 'map') {
            var url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/SearchSuggest.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&req=' + maptype + '&kw=' + escape(input.value);
            if (maptype == 5) {
                url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/SearchSuggest.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&req=' + maptype + '&address=' + escape($('txtSearchPlace').value) + '&kw=' + escape(input.value);
            }
            ENetwork.DownloadScript(url, function() {
                if (typeof _SuggestData != 'undefined') {
                    __EdushiSuggest.Show(_SuggestData, x, y, w);
                }
                else {
                    __EdushiSuggest.Hide();
                }
            });
        }
    }
    __EdushiSuggest.KeycodeChange(keyCode);
    __EdushiSuggest.SelectedIndexChanged = function(item) {
        input.value = item.Value;
        input.focus();
        if (input.createTextRange) {
            var range = input.createTextRange();
            range.collapse(true);
            range.moveStart('character', input.value.length);
            range.select();
        }
        else {
            input.selectionStart = input.value.length;
        }
    }
}
//地图搜索切换
function fnMapSearchChange(sValue) {
    __EdushiSuggest.Hide();
    switch (sValue) {
        case '0':
            $('divSearch').style.display = 'block';
            $('divAroundSearch').style.display = 'none';
            break;
        case '1':
            $('divSearch').style.display = 'block';
            $('divAroundSearch').style.display = 'none';
            break;
        case '2':
            $('divSearch').style.display = 'block';
            $('divAroundSearch').style.display = 'none';
            break;
        case '3':
            $('divSearch').style.display = 'none';
            $('divAroundSearch').style.display = 'block';
            break;
    }
}
/*******************begin添加选项卡的函数集**********************/
function fnOrtherSearch(flag) {
    var iid = flag + "txtSearch";
    var input = $(iid);
    var key = "";
    if (input) {
        key = input.value.trim();
    }
    if (key == "" || key == "请输入查询关键词") {
        input.focus();
        return;
    }
    fnLoadThemeMapListByTypeId(iid.split("_")[1], key, key);
    //var tab=new TabControl.Tab(document,'search',key, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=0&keyword1=' + escape(key), true, true, 80);
    //fnAddTab(tab); 
}
//地图搜索
function fnMapSearchByHotkey(sHotkey) {
    tab = new TabControl.Tab(document, 'search', sHotkey, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=0&keyword1=' + escape(sHotkey), true, true, 80);
    fnAddTab(tab);
}
function fnMapSearch() {
    __EdushiSuggest.Hide();
    var sKeyword1, sKeyword2, iMapSearchType;
    //debugger;
    var tab;
    iMapSearchType = GetRadioValue('MapSearchType');
    switch (iMapSearchType) {
        case '0':   //模糊搜索
        case '1':   //名称搜索    
        case '2':   //地址搜索
            sKeyword1 = $('txtSearchKey').value.trim();
            if (sKeyword1.length < 1) {
                $('txtSearchKey').focus();
                return;
            }
            tab = new TabControl.Tab(document, 'search', sKeyword1, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=' + iMapSearchType + '&keyword1=' + escape(sKeyword1), true, true, 80);
            break;
        case '3':   //周边搜索  
            sKeyword1 = $('txtSearchPlace').value.trim();
            if (sKeyword1.length < 1) {
                $('txtSearchPlace').focus();
                return;
            }
            sKeyword2 = $('txtSearchSomething').value.trim();
            if (sKeyword2.length < 1) {
                $('txtSearchSomething').focus();
                return;
            }
            tab = new TabControl.Tab(document, 'search', sKeyword1 + sKeyword2, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=' + iMapSearchType + '&keyword1=' + escape(sKeyword1) + '&keyword2=' + escape(sKeyword2), true, true, 80);
            break;
    }
    fnAddTab(tab);
}
function fnMapSearch_2(val1,val2) {
//    __EdushiSuggest.Hide();
    var sKeyword1, sKeyword2, iMapSearchType;
    var tab;
    iMapSearchType = val1;
    switch (iMapSearchType) {
        case '0':   //模糊搜索
        case '1':   //名称搜索    
        case '2':   //地址搜索
            sKeyword1 = val2;
            if (sKeyword1.length < 1) {
                $('txtSearchKey').focus();
                return;
            }
            tab = new TabControl.Tab(document, 'search', sKeyword1, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=' + iMapSearchType + '&keyword1=' + sKeyword1, true, true, 80);
            break;
        case '3':   //周边搜索  
            sKeyword1 = $('txtSearchPlace').value.trim();
            if (sKeyword1.length < 1) {
                $('txtSearchPlace').focus();
                return;
            }
            sKeyword2 = $('txtSearchSomething').value.trim();
            if (sKeyword2.length < 1) {
                $('txtSearchSomething').focus();
                return;
            }
            tab = new TabControl.Tab(document, 'search', sKeyword1 + sKeyword2, GlobalConfig.NewSkinPath + 'Fundation/LocalSearch.html?type=' + iMapSearchType + '&keyword1=' + escape(sKeyword1) + '&keyword2=' + escape(sKeyword2), true, true, 80);
            break;
    }
    fnAddTab(tab);
}
//本地地图搜索结果回调
function onSearchDataLoadComplete(data, begin, end) {
    _IconLayer.innerHTML = '';
    if (_EyeIconLayer) {
        _EyeIconLayer.innerHTML = '';
    }
    for (var i = begin; i < end; i++) {
        fnAppendIcon(data[i].OCName, data[i].X, data[i].Y, i + 1, GlobalConfig.SkinPath + 'Images/VesicleBg.png', GlobalConfig.SkinPath + 'Images/AlterVesicle.png', 'if(parent.fnShowSearchPop){parent.fnShowSearchPop(' + data[i].OwnerID + ', ' + data[i].CompanyID + ',' + data[i].LST_ID + ',' + data[i].X + ', ' + data[i].Y + ');}', 41, 33, 13, 27, true);
    };
}
//地图找店回调
function onSearchEStoreLoadComplete(data, begin, end) {
    var lblHtml = '<div style="position:relative; height:24px; width:auto;"><span style="float:left;height:19px; width:6px; overflow:hidden; background-image:url(' + GlobalConfig.SkinPath + 'images/EstoreLabelBg.gif); background-repeat:no-repeat;background-position:left top;"></span><span style="float:left;height:17px; line-height:17px; font-size:12px; font-weight:bold; color:#FFC; background-color:#C30; border-top:1px solid #e3e3e3; border-bottom:1px solid #e3e3e3;cursor:pointer" onclick="parent.fnShowEShopPop({$Id},{$X},{$Y})">{$Title}</span><span style="float:left;height:19px; width:6px; overflow:hidden; background-image:url(' + GlobalConfig.SkinPath + 'images/EstoreLabelBg.gif); background-repeat:no-repeat;background-position:right top;"></span><div style="position:absolute; top:18px; left:15px; width:9px; height:6px; overflow:hidden; background:url(' + GlobalConfig.SkinPath + 'images/EstoreLabelBg.gif) no-repeat -6px -18px;"></div></div>';
    _LabelLayer.innerHTML = '';
    for (var i = begin; i < end; i++) {
        var vlen = data[i].CompanyName.length * 12.1;
        var div = vM.$C('div');
        div.id = 'label_' + data[i].SmallTradeTypeID + '_' + data[i].SmallZoneTypeID + '_' + data[i].CompanyID;
        div.innerHTML = lblHtml.replace('{$Title}', data[i].CompanyName).replace('{$Id}', data[i].CompanyID).replace('{$X}', data[i].X).replace('{$Y}', data[i].Y);
        vM.appendEntity(div, _LabelLayer, false, data[i].X, data[i].Y, vlen + 50, 30, 20, 25, false);
    };
}
//主题数据加载结果回调
function onThemeDataLoadComplete(data) {
    _IconLayer.innerHTML = '';
    if (_EyeIconLayer) {
        _EyeIconLayer.innerHTML = '';
    }
    if (data != null) {
        for (var i = 0; i < data.length; i++) {
            if (data[i].BCC_CompanyICO != '') //判断是否有主题点图片
            {
                var sThemeImage = GlobalConfig.PicUrl + 'cn/' + GlobalConfig.CityCode + '/' + GlobalConfig.Language + '/themeImages/BBLCompany/' + data[i].BCC_CompanyICO;
                if (data[i].BCC_CompanyID * 1 == 0) {
                    fnAppendIcon(data[i].BCC_CompanyName, data[i].X, data[i].Y, i + 1, sThemeImage, '', 'if(parent.ShowCommendPopById){parent.ShowCommendPopById(' + data[i].BCC_ID + ', ' + data[i].X + ', ' + data[i].Y + ');}', 41, 33, 13, 27, false);
                }
                else {
                    fnAppendIcon(data[i].BCC_CompanyName, data[i].X, data[i].Y, i + 1, sThemeImage, '', 'if(parent.fnShowThemePop){(' + data[i].BCC_ID + ', ' + data[i].X + ', ' + data[i].Y + ');}', 41, 33, 13, 27, false);
                }
            }
            else {
                var sThemeImage = GlobalConfig.SkinPath + 'Images/ThMapIco.png';
                var sThemeOverImage = GlobalConfig.SkinPath + 'Images/AlterThMapIco.png';
                if (data[i].BCC_CompanyID * 1 == 0) {
                    fnAppendIcon(data[i].BCC_CompanyName, data[i].X, data[i].Y, i + 1, sThemeImage, sThemeOverImage, 'if(parent.ShowCommendPopById){parent.ShowCommendPopById(' + data[i].BCC_ID + ', ' + data[i].X + ', ' + data[i].Y + ');}', 41, 33, 13, 27, false);
                }
                else {
                    fnAppendIcon(data[i].BCC_CompanyName, data[i].X, data[i].Y, i + 1, sThemeImage, sThemeOverImage, 'if(parent.fnShowThemePop){parent.fnShowThemePop(' + data[i].BCC_ID + ', ' + data[i].X + ', ' + data[i].Y + ');}', 41, 33, 13, 27, false);
                }
            }
        }
    }
}
//公交搜索
function fnBusSearch() {
    __EdushiSuggest.Hide();
    var iBusSearchType = GetRadioValue('BusSearchType');
    switch (iBusSearchType) {
        case '0':   //公交换乘搜索
            var sStartStation = $('txtBusStart').value.trim();
            if (sStartStation.length < 1) {
                $('txtBusStart').focus();
                return;
            }
            var sEndStation = $('txtBusEnd').value.trim();
            if (sEndStation.length < 1) {
                $('txtBusEnd').focus();
                return;
            }
            if (sStartStation == '起点' || sEndStation == '终点') {
                $('txtBusStart').focus();
                return;
            }
            fnAddBusTransferSearchTab(sStartStation, sEndStation);
            break;
        case '1':   //公交线路搜索
            var sBusNo = $('txtBusLine').value.trim();
            if (sBusNo.length < 1) {
                $('txtBusLine').focus();
                return;
            }
            if (sBusNo == '请输入要搜索的线路') {
                $('txtBusLine').focus();
                return;
            }
            fnAddBusLineSearchTab(sBusNo);
            break;
        case '2':   //公交站点搜索
            var sStationName = $('txtBusStation').value.trim();
            if (sStationName.length < 1) {
                $('txtBusStation').focus();
                return;
            }
            if (sStartStation == '请输入站点名') {
                $('txtBusStation').focus();
                return;
            }
            fnAddBusStationSearchTab(sStationName);
            break;
    }
}
function fnBusSearch_2(s_type,s_key1,s_key2) {
    __EdushiSuggest.Hide();
    var iBusSearchType = s_type;
//    switch (iBusSearchType) {
//        case '0':   //公交换乘搜索
//            var sStartStation = s_key1.trim();
//            if (sStartStation.length < 1) {
//                $('txtBusStart').focus();
//                return;
//            }
//            var sEndStation = s_key2.trim();
//            if (sEndStation.length < 1) {
//                $('txtBusEnd').focus();
//                return;
//            }
//            if (sStartStation == '起点' || sEndStation == '终点') {
//                $('txtBusStart').focus();
//                return;
    //            }
    fnAddBusTransferSearchTab(unescape(s_key1), unescape(s_key2));
//            break;
//        
//    }
}
function fnAddBusTransferSearchTab(sStartStation, sEndStation) {
    var tab = new TabControl.Tab(document, 'busTransfer', sStartStation + '→' + sEndStation, GlobalConfig.NewSkinPath + 'Fundation/BusTransferSearch.html?s=' + escape(sStartStation) + '&e=' + escape(sEndStation) + '&action=0', true, true, 80);
    fnAddTab(tab);
}
function fnAddBusLineSearchTab(sBusNo) {
    var tab = new TabControl.Tab(document, 'BusLineSearch', sBusNo, GlobalConfig.NewSkinPath + 'Fundation/BusNoSearch.html?key=' + escape(sBusNo), true, true, 80);
    fnAddTab(tab);
}
function fnAddBusStationSearchTab(sStationName) {
    var tab = new TabControl.Tab(document, 'BusStationSearch', sStationName, GlobalConfig.NewSkinPath + 'Fundation/BusStationSearch.html?key=' + escape(sStationName), true, true, 80);
    fnAddTab(tab);
}
function fnShowRoadSearch(x, y, x1, y1) {
    var tab = new TabControl.Tab(document, 'ShortRoadSearch', '搜索路径', GlobalConfig.NewSkinPath + 'Fundation/ShortRoadSearch.htm?sx=' + x + '&sy=' + y + '&ex=' + x1 + '&ey=' + y1, true, true, 80);
    fnAddTab(tab);
}

function fnAddTab(tab, height) {
    if (!height) {
        tab.TabBody.style.height = '100%';
    }
    else {
        tab.TabBody.style.height = height;
    }
    _TabControl.AddTab(tab);
}
//E店搜索
function fnEShopSearch(keyword) {
    __EdushiSuggest.Hide();
    var sKeyword = '';
    if (keyword) {
        sKeyword = keyword;
    }
    else {
        sKeyword = $('txtSearchEShop').value.trim();
    }
    if (sKeyword.length < 1) {
        $('txtSearchEShop').focus();
        return;
    }
    window.open('http://' + GlobalConfig.NodeUrl + '/yp/KeywordSearchList.aspx?Keyword=' + escape(sKeyword), '_blank', '');
    return;


    /*******作废*********/


    __EdushiSuggest.Hide();
    var sThing = '';
    var sAddress = '';
    if (keyword) {
        sThing = keyword;
    }
    else {
        sThing = $('txtSearchThing').value.trim();
        sAddress = $('txtSearchArea').value.trim();
    }
    if (sAddress.length < 1 && sThing.length < 1) {
        $('txtSearchArea').focus();
        return;
    }
    var tab = new TabControl.Tab(document, 'EStoreSearch', sAddress + ' ' + sThing, GlobalConfig.NewSkinPath + 'Fundation/FindEstoreResult.html?address=' + escape(sAddress) + '&name=' + escape(sThing), true, true, 80);
    fnAddTab(tab);
}
//黄页搜索
function fnYellowPageSearch() {
    window.open('http://' + GlobalConfig.NodeUrl + '/yp/keywordSearchList.aspx?Keyword=32323', 'blank', '');
}
/*******************end添加选项卡**********************/
//初始化分类主题滚动效果
function fnInitThemeScroll() {
    var ulThemeList = $('ulThemeList');
    var iLen = ulThemeList.childNodes.length;
    var iMaxWidth = 0;
    var iClipWidth = fnGetWindowWidth() * 0.6 - 100;
    var iStepWidth = 5;
    var hwScroll;
    for (var i = 0; i < iLen; i++) {
        if (ulThemeList.childNodes[i].tagName) {
            iMaxWidth += ulThemeList.childNodes[i].clientWidth + 10; //10像素是li的margin
        }
    }

    if (iMaxWidth <= iClipWidth)    //自适应浏览器分辨率
    {
        $('RollArLf').style.display = 'none';
        $('RollArRgt').style.display = 'none';
        ulThemeList.parentNode.style.left = '0px';
        return;
    }
    else {
        $('RollArLf').style.display = 'block';
        $('RollArRgt').style.display = 'block';
    }

    $('ImgThemeScrollLeft').onmouseover = function() {
        $('ImgThemeScrollLeft').style.cursor = 'pointer';
        window.clearInterval(hwScroll);
        hwScroll = setInterval(function() {
            var iLeft = ulThemeList.parentNode.style.left.replace('px', '') * 1;
            if (iLeft + iStepWidth > 0) {
                ulThemeList.parentNode.style.left = '0px';
                window.clearInterval(hwScroll);
            }
            else {
                ulThemeList.parentNode.style.left = (iLeft + iStepWidth) + 'px';
            }
        }, 20);
    };
    $('ImgThemeScrollRight').onmouseover = function() {
        $('ImgThemeScrollRight').style.cursor = 'pointer';
        window.clearInterval(hwScroll);
        hwScroll = setInterval(function() {
            var iLeft = ulThemeList.parentNode.style.left.replace('px', '') * 1;
            if ((iLeft * -1 + iClipWidth + iStepWidth) >= iMaxWidth) {
                ulThemeList.parentNode.style.left = (iClipWidth - iMaxWidth) + 'px';
                window.clearInterval(hwScroll);
            }
            else {
                ulThemeList.parentNode.style.left = (iLeft - iStepWidth) + 'px';
            }
        }, 20);
    };
    $('ImgThemeScrollLeft').onmouseout = function() {
        window.clearInterval(hwScroll);
    };
    $('ImgThemeScrollRight').onmouseout = function() {
        window.clearInterval(hwScroll);
    }
}

//region 页面上固定的按钮的功能
//开始标记
function fnSelectMarkPoint() {
    _Mark.Begin();
}
//显示隐藏标签
function fnLabel() {
    if (vM.flgShowLabel) {
        vM.flgShowLabel = false;
        vM.ViewLabels(false);
        vM.Show();
    } else {
        vM.flgShowLabel = true;
        vM.ViewLabels(true);
        vM.Show();
    }
}
//测距
function fnScale() {
    vM.Body.ScaleLine = '#fcff00|2';
    vM.StartScale();
    _IsBeginScale = true;
}


function fnShowCommonGoTo() {
    if ($('divQuickLink').style.display == 'block') {
        $('divQuickLink').style.display = 'none';
    }
    else {
        $('divQuickLink').style.display = 'block';
    }
}
function fnShowMyEAddress() {
    if ($('MyEadNav').style.display == 'block') {
        $('MyEadNav').style.display = 'none';
    }
    else {
        $('MyEadNav').style.display = 'block';
    }
}
//地图打印
function fnPrint() {
    var iMapX = vM.CenterX();
    var iMapY = vM.CenterY();
    var iZoom = vM.Zoom();
    var iWidth = vM.MapWidth();
    var iHeight = vM.MapHeight();
    window.open('http://' + GlobalConfig.Domain + '/Print.aspx?l=' + GlobalConfig.Language + '&x=' + iMapX + '&y=' + iMapY + '&z=' + iZoom + '&w=' + iWidth + '&h=' + iHeight, 'print');
}
//右侧搜索栏收缩展开
function fnExpanding(obj) {
    if (_MapExpandingState) {
        _MapExpandingState = false;
        obj.src = GlobalConfig.SkinPath + 'Images/Expanding.gif';
    }
    else {
        _MapExpandingState = true;
        obj.src = GlobalConfig.SkinPath + 'Images/DrawBack.gif';
    }
    AdjustSize();
}
//鹰眼收缩
function fnEyeExpanding(obj, state) {
    if ($('EagleMapCon').style.display == 'none' && !state) {
        $('EagleMapCon').style.display = 'block';
        obj.src = GlobalConfig.SkinPath + 'Images/DrawBack.gif';
        if ($('EyeArrow').className == 'SmallArrow') {
            $('EagleMapNav').style.width = '196px';
        }
        else {
            $('EagleMapNav').style.width = '376px';
        }
    }
    else {
        $('EagleMapCon').style.display = 'none';
        obj.src = GlobalConfig.SkinPath + 'Images/Expanding.gif';
        $('EagleMapNav').style.width = '10px';
    }
}
//改变鹰眼地图尺寸
function fnEyeResize(obj) {
    var w = 180;
    var h = 140;
    if (obj.className == 'SmallArrow') {
        obj.className = 'BigArrow';
        w = 2 * w;
        h = 2 * h;
        $('EagleMapDH').style.paddingTop = '95px';
        $('EagleMapNav').style.width = '376px';
    }
    else {
        $('EagleMapDH').style.paddingTop = '20px';
        obj.className = 'SmallArrow';
        $('EagleMapNav').style.width = '196px';
    }
    obj.parentNode.style.width = w + 'px';
    obj.parentNode.style.height = h + 'px';
    vMe.MapHeight(h);
    vMe.MapWidth(w);
    vMe.Show();
}
//endregion 页面上固定的按钮的功能
/***************************************/
//缩放条控制类
function ZoomBarClass() {
    this.beginLevel = 1;
    this.beginTopPixel = 112;
    this.zoomStepPixel = 16;
    this.maxLevel = 4;
    this.moveStepPixel = 256;

    this.currentLevel = this.beginLevel;
    this.originalY = 0;
    this.originalTop = 0;
    this.zoomFlag = false;
    this.zoomBar = $('ControlUnit');
    this.Tool = $('EzoomBar');

    //初始化缩放控件
    this.Init = function() {
        bindEvent(this.zoomBar, "mousedown", this.mousedown.bindAsEventListener(this));
        bindEvent(this.zoomBar, "mousemove", this.mousemove.bindAsEventListener(this));
        bindEvent(this.Tool, "mousemove", this.mousemove.bindAsEventListener(this));
        bindEvent(this.Tool, "mouseup", this.mouseup.bindAsEventListener(this));

        var that = this;
        var oDivs = $('MapSwitch').getElementsByTagName('li');
        for (var k = 0; k < oDivs.length; k++) {
            bindEvent(oDivs[k], "click", this.Switch.bindAsEventListener(this));
        }
    };
    this.mousedown = function(evt) {
        evt = window.event ? window.event : evt;
        originalY = evt.clientY;
        this.originalTop = this.zoomBar.offsetTop;
        this.zoomFlag = true;
    };
    this.mousemove = function(evt) {
        evt = window.event ? window.event : evt;
        var ey = evt.clientY;
        if (this.zoomFlag) {
            var iTop = ey - originalY + this.originalTop;
            if (iTop < this.beginTopPixel) iTop = this.beginTopPixel;
            if (iTop > (this.beginTopPixel + this.zoomStepPixel * (this.maxLevel - 1))) iTop = this.beginTopPixel + this.zoomStepPixel * (this.maxLevel - 1);
            this.zoomBar.style.top = iTop + 'px';
        }
    };
    this.mouseup = function(evt) {
        if (this.zoomFlag) {
            var z = Math.round((this.zoomBar.offsetTop - this.beginTopPixel) / this.zoomStepPixel);
            if (z > this.maxLevel - 1) z = this.maxLevel - 1;
            if (z < 0) z = 0;
            this.currentLevel = z;
            this.zoomBar.style.top = (this.beginTopPixel + z * this.zoomStepPixel) + 'px';
            this.zoomFlag = false;
            vM.FlatZoom(this.currentLevel);
        }
    };
    //缩放一定的"步长","步长"可以为负数
    this.ZoomWithStep = function(step) {
        this.currentLevel += step;
        if (this.currentLevel > this.maxLevel - 1) this.currentLevel = this.maxLevel - 1;
        if (this.currentLevel < 0) this.currentLevel = 0;
        this.zoomBar.style.top = (this.beginTopPixel + this.currentLevel * this.zoomStepPixel) + 'px';
        vM.FlatZoom(this.currentLevel);
    };
    //缩放到指定的级别
    this.ZoomTo = function(level) {
        this.currentLevel = level;
        this.zoomBar.style.top = (this.beginTopPixel + this.currentLevel * this.zoomStepPixel) + 'px';
        vM.FlatZoom(this.currentLevel);
    };
    this.Move = function(direction) {
        var iMapCenterX = vM.CenterX();
        var iMapCenterY = vM.CenterY();
        switch (direction) {
            case "up":
                MoveTo(iMapCenterX, iMapCenterY - vM.GetMapPos(this.moveStepPixel), true);
                break;
            case "down":
                MoveTo(iMapCenterX, iMapCenterY + vM.GetMapPos(this.moveStepPixel), true);
                break;
            case "left":
                MoveTo(iMapCenterX - vM.GetMapPos(this.moveStepPixel), iMapCenterY, true);
                break;
            case "right":
                MoveTo(iMapCenterX + vM.GetMapPos(this.moveStepPixel), iMapCenterY, true);
                break;
            case "center":
                MoveTo(vM.Property.CenterX, vM.Property.CenterY);
                break;
        }
    };
    this.Switch = function(evt) {
        evt = window.event ? window.event : evt;
        var srcEle = evt.srcElement ? evt.srcElement : evt.target;
        var o = srcEle.parentNode;
        var oid = o.getAttribute("id");
        if (oid && oid.indexOf('_') > -1)
        {
            switch (oid.split('_')[1]) {
                case 'Scene': this.SwitchScene(oid); break;
                case '3D': this.Switch3D(oid); break;
                case '2D': this.Switch2D(oid); break;
                case 'WX': this.SwitchWX(oid); break;
            }
        }
    };
    this.setCurent = function(obj, scene) {
        if (typeof (obj) == 'string')
            obj = $(obj);

        var oDivs = obj.parentNode.getElementsByTagName('li');
        for (var k = 0; k < oDivs.length; k++) {
            var cur = '';
            if (oDivs[k] == obj) {
                cur = 'Current';
            }
            oDivs[k].className = cur;
        }
    };
    this.SwitchScene = function(obj) {
        this.setCurent(obj, true);
    };
    this.Switch3D = function(obj) {
        if (_UseGoogleMap) {
            if (vM.MapState() != 0 && !vM.MapLoading()) {
                vM.ViewSigns(true, 'park');
                vM.ViewPlots(true, 'ad');
                vM.MapState(0);
                this.setCurent(obj);

                $('CompassNav').innerHTML = '<img src="' + GlobalConfig.SkinPath + 'Images/CompassIco.gif" alt="指针" />';
                $('CopyrightNav').style.display = '';
                fnEyeExpanding($('imgEyeExpanding'), false);

                if ($('lnkSwichCity') != null) {
                    $('lnkSwichCity').style.display = '';
                }
            }
            return false;
        }
        //老模式的二/三维
        vM.Switch23D();
        vM.ViewSigns(true, 'park');
        vM.ViewPlots(true, 'ad');
        vM.MapState(0);
        this.setCurent(obj);

        $('CompassNav').innerHTML = '<img src="' + GlobalConfig.SkinPath + 'Images/CompassIco.gif" alt="指针" />';
        $('CopyrightNav').style.display = '';
        fnEyeExpanding($('imgEyeExpanding'), false);

        if ($('lnkSwichCity') != null) {
            $('lnkSwichCity').style.display = '';
        }
        //$('lnkVisitOldVersion').style.display = 'none';
    };
    this.Switch2D = function(obj) {
        if (_UseGoogleMap) {
            if (vM.MapState() != 1 && !vM.MapLoading()) {
                vM.ViewSigns(false, 'park');
                vM.ViewPlots(false, 'ad');
                vM.MapState(1);
                this.setCurent(obj);
                $('CompassNav').innerHTML = '<img src="' + GlobalConfig.SkinPath + 'Images/CompassIco1.gif" alt="指针" />';
                $('CopyrightNav').style.display = 'none';
                fnEyeExpanding($('imgEyeExpanding'), true);

                if ($('lnkSwichCity') != null) {
                    $('lnkSwichCity').style.display = 'none';
                }
                //$('lnkVisitOldVersion').style.display = 'none';
            }
            return false;
        }

        //老模式
        vM.Switch23D();
        vM.ViewSigns(false, 'park');
        vM.ViewPlots(false, 'ad');
        vM.MapState(1);
        this.setCurent(obj);
        $('CompassNav').innerHTML = '<img src="' + GlobalConfig.SkinPath + 'Images/CompassIco1.gif" alt="指针" />';
        $('CopyrightNav').style.display = 'none';
        fnEyeExpanding($('imgEyeExpanding'), true);

        if ($('lnkSwichCity') != null) {
            $('lnkSwichCity').style.display = 'none';
        }
        // $('lnkVisitOldVersion').style.display = 'none';
    };
    this.SwitchWX = function(obj) {
        if (_UseGoogleMap) {
            if (vM.MapState() != 2 && !vM.MapLoading()) {
                vM.ViewSigns(false, 'park');
                vM.ViewPlots(false, 'ad');

                vM.MapState(2);
                this.setCurent(obj);
                $('CompassNav').innerHTML = '<img src="' + GlobalConfig.SkinPath + 'Images/CompassIco1.gif" alt="指针" />';
                $('CopyrightNav').style.display = 'none';
                fnEyeExpanding($('imgEyeExpanding'), true);

                if ($('lnkSwichCity') != null) {
                    $('lnkSwichCity').style.display = 'none';
                }
                //$('lnkVisitOldVersion').style.display = 'none';
            }
            return false;
        }

    }
}
function MoveTo2(x, y) {
    vM.Zoom(1);
    vM.MoveTo(x, y, true);
    if (vMe != null) {
        vMe.MoveTo(x, y, true);
    }
}
//地图移动和鹰眼联动
function MoveTo(x, y) {
    vM.MoveTo(x, y, true);
    if (vMe != null) {
        vMe.MoveTo(x, y, true);
    }
}
/******************begin:各种URL支持和定位********************/
function fnGetPositionByCID()//企业Pop定位
{
    var cid = fnRequest('cid');
    if (cid != '' && cid * 1 > 0) {
        _CompanyPopControl.ShowPop(cid, true);
    }
}
function fnGetPositionByEID()//E店Pop定位
{
    var eid = fnRequest('eid');
    if (eid != '' && eid * 1 > 0) {
        _EShopPopControl.ShowPop(eid, true);
    }
}
function fnGetPositionByTID()//主题Pop定位
{
    var tid = fnRequest('tid');
    var tname = fnRequest('tname');
    if (tid != '' && tid * 1 > 0 && tname == '') {
        _ThemePopControl.ShowPop(tid, true);
    }
}
function fnGetPositionByOID()  //实体Pop定位
{
    if (fnRequest('cid') != '') {//如果同时带有cid，则不显示实体POPO
        return;
    }

    var oid = fnRequest('oid');
    if (/.+?\?\d+$/gi.test(window.document.location.href)) {
        oid = window.document.location.href.replace(/^.+?\?/gi, '');
    }
    if (oid != '' && oid * 1 > 0) {
        _EntityPopControl.ShowPop(oid, true);
    }
}
function fnGetPositionByGID()//产品Pop定位
{
    var cid = fnRequest('gid');
    if (cid != '' && cid * 1 > 0) {
        _DzcxPopControl.ShowPop(cid, true);
    }
}

function fnGetPositionByHID() //互动pop定位
{
    var hid = fnRequest('hid');
    if (hid != '' && cid * 1 > 0) {
        _HudongPopControl.ShowPop(hid, true);
    }
}
//URL的解析
function fnUrlParse() {
    if (fnRequest('searchshop') == 1) {
        fnSearchChange($('liEShopSearch'));
    }
    if (fnRequest('EAddressRegister') == 1) {
        fnSearchChange($('liEAddress'));
        fnEAddressRegister(fnRequest('EAddressName'));
    }
    if (fnRequest('EAddressManager') == 1) {
        fnSearchChange($('liEAddress'));
        fnEAddressManager();
    }
    var x = fnRequest('x');
    var y = fnRequest('y');
    if (x != '' && y != '') {
        MoveTo(x, y);
    }
    var q = fnRequest('q');       //本搜
    if (q != '') {
        fnMapSearchByHotkey(unescape(q));
    }
    var nq = fnRequest('nq');
    if (nq != '') {
        fnNearbySearch(unescape(nq), x, y, 1000);
    }
    var iBusId = fnRequest('bid');
    if (iBusId != '') {
        fnOnBusClick(iBusId, unescape(fnRequest('bname')), '');
    }
    var tid = fnRequest('tid');
    var tname = fnRequest('tname');
    if (tid != '' && tname != '') {
        fnLoadThemeMapListByTypeId(tid, unescape(tname));
    }
    var b = fnRequest('b');       //公交搜索
    if (b != '') {
        if (/^\w?\d+$/.test(b)) {
            fnAddBusLineSearchTab(unescape(b));
        }
        else {
            fnAddBusStationSearchTab(unescape(b));
        }
    }
    var s = fnRequest('s');       //站名搜索
    if (s != '') {
        fnAddBusStationSearchTab(unescape(s));
    }

    var b1 = fnRequest('b1'); //两个站点间的搜索
    if (b1 != '') {
        var b2 = fnRequest('b2');
        if (b2 != '') {
            fnAddBusTransferSearchTab(unescape(b1), unescape(b2));
        }
    }
    var title = fnRequest('title');
    if (title == "") {
        title = fnRequest('tname');
    }
    var content = fnRequest('content');
    if (x == '') {
        x = fnRequest('tx');
    }
    if (x == '') {
        return;
    }
    if (y == '') {
        y = fnRequest('ty');
    }
    if (y == '') {
        return;
    }
    if (x != '' && y != '' && title != '') {
        _Mark.Show(x, y, unescape(title), unescape(content));
    }
}
/******************end:各种定位********************/
/*****begin:地图上显示如公交**********************/
//显示公交站信息，id:公交站ID
//定位到公交站并显示线路信息
function fnGotoBusStation(id, name, x, y) {
    if (_BusTransferLineLayer.innerHTML == '') {
        var PopHtml = '<span style="cursor:pointer; height:26px; float:left; font-size:12px; color:#000;white-space:nowrap;{$topwidth}"><span style="cursor:pointer; width:24px; height:24px; float:left; background:url(' + GlobalConfig.SkinPath + 'Images/gongjiao.gif) no-repeat; text-align:center; padding-top:2px;">1</span><span style="cursor:pointer; height:19px;line-height:19px; background:#fff; padding-right:4px; float:left;{$width};" onclick="parent.fnShowBusStation(' + id + ',\'' + name + '\',' + x + ',' + y + ')">' + name + '</span></span>';
        _BusStationLayer.innerHTML = '';
        var div = vM.$C('div');
        div.innerHTML = PopHtml;
        var vlen = name.length * 12.1;
        vM.appendEntity(div, _BusStationLayer, false, x, y, vlen + 35, 26, 12, 28, false);
    }
    MoveTo(x, y);
}
function fnShowBusStation(id, name, x, y) {
    if (!_BusStationControl) {
        _BusStationControl = new BusStationControl(vM.Body.document);
        _BusStationControl.ID = vM.appendEntity(_BusStationControl.Body, _PopLayer, false, x, y, 303, 170, 0, 38, false);
        _BusStationControl.Width = 303;
        _BusStationControl.Height = 165;

        _BusStationControl.ResumeLayout();
        _BusStationControl.onLoadComplete = function() {
            _BusStationControl.ShowBusStation(id, name);
        };
        _BusStationControl.onBusClick = function(busid, busname, stationName) {
            fnOnBusClick(busid, busname, stationName);
        };
    }
    else {
        vM.moveEntity(_BusStationControl.ID, x, y);
        _BusStationControl.ShowBusStation(id, name);
    }
}
function fnOnBusClick(busid, busname, stationName) {
    fnOpenTab();
    tab = new TabControl.Tab(document, 'search', busname, GlobalConfig.NewSkinPath + 'Fundation/BusNoSearch.html?stationName=' + escape(stationName) + '&action=1&key=' + busid, true, true, 80);
    fnAddTab(tab);
}
//加载完线路显示公交站
function fnShowBusStationIco(arrBusData, type) {
    _BusLineType = type;
    _BusLineData = arrBusData;
    _BusTransferLineLayer.innerHTML = '';
    _BusStationLayer.innerHTML = '';
    if (_BusLineData != null) {
        var PopHtml = '<span style="cursor:pointer; height:26px; float:left; font-size:12px; color:#000;white-space:nowrap;{$topwidth}"><span style="cursor:pointer; width:24px; height:24px; float:left; background:url(' + GlobalConfig.SkinPath + 'Images/gongjiao.gif) no-repeat; text-align:center; padding-top:2px;">{$No}</span><span style="cursor:pointer; height:19px;line-height:19px; background:#fff; padding-right:4px; float:left;{$width};" onclick="parent.fnShowBusStation({$StationID},\'{$BusStationName}\',{$X},{$Y})">{$BusStationName}</span></span>';
        if (_BusLineType == 1) {
            var l = _BusLineData.BusUp.length;
            for (i = 0; i < l; i++) {
                var oBusUp = _BusLineData.BusUp[i];
                var vlen = oBusUp.StationName.length * 12.1;
                var nd = vM.$C('div');
                nd.id = 'B_pop' + i;

                nd.innerHTML = PopHtml.replace('{$No}', (i + 1)).replace('{$BusStationName}', oBusUp.StationName).replace('{$BusStationName}', oBusUp.StationName).replace('{$topwidth}', 'width:' + (vlen + 40) + 'px').replace('{$width}', 'width:' + (vlen + 10) + 'px').replace('{$StationID}', oBusUp.StationID).replace('{$X}', oBusUp.PositionX).replace('{$Y}', oBusUp.PositionY);

                // nd.innerHTML = PopHtml;
                vM.appendEntity(nd, _BusTransferLineLayer, false, oBusUp.PositionX, oBusUp.PositionY, vlen + 35, 26, 12, 28, false);
            }
            if (_BusLineData.UpCoord.length > 0) {
                vM.DrawPolyLine(_BusTransferLineLayer, vM.ChangeCoords(_BusLineData.UpCoord, vM.Property.ZoomPer[vM.Zoom()]), 4, '#ffff00', 0.7);
            }

        } else {
            var l = _BusLineData.BusDown.length;
            var coords;
            for (i = 0; i < l; i++) {
                var oBusDown = _BusLineData.BusDown[i];
                coords += oBusDown.PositionX + ',' + oBusDown.PositionY + ',';
                var vlen = oBusDown.StationName.length * 12.1;
                var nd = vM.$C('div');
                nd.id = 'B_pop' + i;

                nd.innerHTML = PopHtml.replace('{$No}', (i + 1)).replace('{$BusStationName}', oBusDown.StationName).replace('{$BusStationName}', oBusDown.StationName).replace('{$topwidth}', 'width:' + (vlen + 40) + 'px').replace('{$width}', 'width:' + (vlen + 10) + 'px').replace('{$StationID}', oBusDown.StationID).replace('{$X}', oBusDown.PositionX).replace('{$Y}', oBusDown.PositionY);

                vM.appendEntity(nd, _BusTransferLineLayer, false, oBusDown.PositionX, oBusDown.PositionY, vlen + 35, 26, 12, 28, false);
            }
            if (_BusLineData.DownCoord.length > 0) {
                vM.DrawPolyLine(_BusTransferLineLayer, vM.ChangeCoords(_BusLineData.DownCoord, vM.Property.ZoomPer[vM.Zoom()]), 4, '#ffff00', 0.7);
            }

        }
    }
}
/********************begin:公交搜索回调********************/
function fnDrawingBusLine(busLineCoordList) {
    //debugger;
    //{Coords:coords, Color:color, Alpha:0.7, Size:4, PassStation:node.BestPassStation};
    //debugger;
    _BusLineCoordList = busLineCoordList;
    _BusTransferLineLayer.innerHTML = '';
    _BusStationLayer.innerHTML = '';
    for (var i = 0; i < _BusLineCoordList.length; i++) {
        var coord = _BusLineCoordList[i];
        vM.DrawPolyLine(_BusTransferLineLayer, vM.ChangeCoords(coord.Coords, vM.Property.ZoomPer[vM.Zoom()]), coord.Size, coord.Color, coord.Alpha);

        if (coord.PassStation == null)
            continue;

        var PopHtml = '<span style="cursor:pointer; height:26px; float:left; font-size:12px; color:#000;white-space:nowrap;{$topwidth}"><span style="cursor:pointer; width:24px; height:24px; float:left; background:url(' + GlobalConfig.SkinPath + 'Images/gongjiao.gif) no-repeat; text-align:center; padding-top:2px;">{$No}</span><span style="cursor:pointer; height:19px;line-height:19px; background:#fff; padding-right:4px; float:left;{$width};" onclick="parent.fnShowBusStation({$StationID},\'{$BusStationName}\',{$X},{$Y})">{$BusStationName}</span></span>';
        if (coord.Color == '#00ffff') {
            PopHtml = '<span style="cursor:pointer; height:26px; float:left; font-size:12px; color:#000;white-space:nowrap;{$topwidth}"><span style="cursor:pointer; width:24px; height:24px; float:left; background:url(' + GlobalConfig.SkinPath + 'Images/gongjiao2.gif) no-repeat; text-align:center; padding-top:2px;">{$No}</span><span style="cursor:pointer; height:19px;line-height:19px; background:#fff; padding-right:4px; float:left;{$width};" onclick="parent.fnShowBusStation({$StationID},\'{$BusStationName}\',{$X},{$Y})">{$BusStationName}</span></span>';
        }
        for (var j = 0; j < coord.PassStation.length; j++) {
            var vlen = coord.PassStation[j].StationName.length * 12.1;
            var nd = vM.$C('div');
            nd.innerHTML = PopHtml.replace('{$No}', (j + 1)).replace('{$BusStationName}', coord.PassStation[j].StationName).replace('{$BusStationName}', coord.PassStation[j].StationName).replace('{$topwidth}', 'width:' + (vlen + 40) + 'px').replace('{$width}', 'width:' + (vlen + 10) + 'px').replace('{$StationID}', coord.PassStation[j].StationID).replace('{$X}', coord.PassStation[j].PositionX).replace('{$Y}', coord.PassStation[j].PositionY);
            vM.appendEntity(nd, _BusTransferLineLayer, false, coord.PassStation[j].PositionX, coord.PassStation[j].PositionY, vlen + 35, 26, 12, 28, false);
        }
    }
}
/********************end:公交搜索回调**********************/
function fnEAddressRegister(name) {
    if (_EAddressRegTab) {
        _EAddressRegTab.destroy();
        _EAddressRegTab = null;
    }
    fnOpenTab();
    if (!name) {
        name = '';
    }
    var tab = new TabControl.Tab(document, 'EAddressRegister', '申请E地址', GlobalConfig.NewSkinPath + 'Fundation/EAddressHandle.aspx?eaddress=' + name, true, true, 80);
    if (!_TabControl.ExistTab(tab)) {
        _EAddressRegTab = tab;
        fnAddTab(_EAddressRegTab);
    }
}
function fnEAddressManager() {
    if (_EAddressManagerTab) {
        _EAddressManagerTab.destroy();
        _EAddressManagerTab = null;
    }
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'EAddressManager', '管理E地址', GlobalConfig.NewSkinPath + 'Fundation/EAddressHandle.aspx?operatortype=1', true, true, 80);
    if (!_TabControl.ExistTab(tab)) {
        _EAddressManagerTab = tab;
        fnAddTab(_EAddressManagerTab);
    }
}
function EAddressLoginCallback() {
    if (_EAddressManagerTab) {
        _EAddressManagerTab.destroy();
    }
    if (_EAddressRegTab) {
        _EAddressRegTab.destroy();
    }
    if (_EAddressOperatorType == 0) {
        fnEAddressRegister();
    }
    else {
        fnEAddressManager();
    }
}
function fnNewEAddressList() {
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'NewEAddressList', '最新E地址', GlobalConfig.NewSkinPath + 'Fundation/EAddressList.aspx', true, true, 80);
    fnAddTab(tab);
}
function fnEAddressHelper() {
    fnOpenTab();
    var tab = new TabControl.Tab(document, 'NewEAddressList', 'E地址助手', GlobalConfig.NewSkinPath + 'Fundation/EAddressHelper.html', true, true, 80);
    fnAddTab(tab);
}
function fnOpenEAddressWin(obj) {
    if (!new RegExp('^\s*[.A-Za-z0-9]{4,14}\s*$').test(obj.value)) {
        obj.select();
        obj.focus();
        return;
    }
    window.open('http://edizhi.edushi.com/' + obj.value);
}
//----------------------------------------------------------------------
//地图设置内容

var _IsShowAllMark = false;
//显示设置图标状态
function fnShowli(o, status) {
    o.style.display = status;
}

//地图设置菜单显示
function fnShowMapSetup() {
    $('divMapSetup').style.display = $('divMapSetup').style.display == 'block' ? 'none' : 'block';
}
//标记开始或者关闭
function fnShowAllMark(o) {
    if (_IsShowAllMark) {
        _Mark.Clear();
        fnShowli(o, 'none');
    } else {
        _Mark.ShowAll();
        fnShowli(o, 'block');
    }
}
//显示公交
function fnStation(o) {
    if (vM.Body.SignsVisible['bus']) {
        vM.ViewSigns(false, 'bus');
        fnShowli(o, 'none');
        vM.Show();
    } else {
        vM.ViewSigns(true, 'bus');
        vM.Show();
        fnShowli(o, 'block');
    }
}
function fnRoad(o) {
    if (vM.Body.SignsVisible['road']) {
        vM.ViewSigns(false, 'road');
        vM.Show();
        fnShowli(o, 'none');
    } else {
        vM.ViewSigns(true, 'road');
        vM.Show();
        fnShowli(o, 'block');
    }
}
//停车场关开
function fnPack(o) {
    if (vM.Body.SignsVisible['park']) {
        vM.ViewSigns(false, 'park');
        //alert(fnShowli);
        fnShowli(o, 'none');
        vM.Show();

    } else {
        vM.ViewSigns(true, 'park');
        fnShowli(o, 'block');
        vM.Show();

    }
}
function fnSubWay() {
    if (vM.Body.SignsVisible['subway']) {
        vM.ViewSigns(false, 'subway');
        vM.Show();
    } else {
        vM.ViewSigns(true, 'subway');
        vM.Show();
    }
}

//地图设置代码结束***************************************************************
//E地址代码开始******************************************************************
function fnCreateEAddress() {
    fnGoogleStat('E地址');
    fnSearchChange($('liEAddress'));
    fnEAddressRegister();
}
function fnGoogleStat(sTrackName) {
    try { pageTracker._trackEvent('Map5.2', 'Mater_UI', sTrackName); }
    catch (e) { };
}

//E地址代码结束******************************************************************

//原4.2版E地址功能***************************************************************
var hasEaddr = -1;
function fnEaddGoto(Ecode) {
    if (hasEaddr >= 0) {
        return;
    }
    hasEaddr++;
    var _Url = location.hostname.toLowerCase();
    if (Ecode == '') {
        Ecode = _Url.replace('http://', '');
        Ecode = Ecode.substring(0, Ecode.indexOf('.'));
    }
    if (Ecode != '' && Ecode != 'localhost') {
        var url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/EntityInfo.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&v=1.0&req=3&e=' + Ecode;
        ENetwork.DownloadScript(url, function() {
            if (typeof _EcodeInfo == 'undefined' || typeof _EcodeInfo._Ecode[0] == 'undefined') {
                return;
            }
            //alert(_EcodeInfo._Ecode[0].MED_Flag);
            if (_EcodeInfo._Ecode[0].MED_Flag == 'undefined') {
                return;
            }
            if (_EcodeInfo._Ecode[0].MED_Flag == 2) {

                _EntityPopControl.ShowPop(_EcodeInfo._Ecode[0].GoalID, true);

            } else if (_EcodeInfo._Ecode[0].MED_Flag == 1) {
                _CompanyPopControl.ShowPop(_EcodeInfo._Ecode[0].GoalID, true);
            }
        });
    }
}

//************************************************************************************

function fnLoadRotaryPicture() {
    if (!cRotaryPictureControl) {
        cRotaryPictureControl = new RotaryPictureControl();
        cRotaryPictureControl.Body.style.width = '241px';
        cRotaryPictureControl.Body.style.height = '203px';
        cRotaryPictureControl.Body.style.right = '1px';
        cRotaryPictureControl.Body.style.bottom = '-203px';
        cRotaryPictureControl.Body.style.zIndex = '3000';
        cRotaryPictureControl.Body.style.position = 'absolute';
        document.body.appendChild(cRotaryPictureControl.Body);
        cRotaryPictureControl.onDataLoadComplete = function() {
            cRotaryPictureControl.Show();
            fnShowRotaryPicture();
        };
    }
    else {
        cRotaryPictureControl.Body.style.bottom = '-203px';
        cRotaryPictureControl.Show();
    }
}
function fnShowRotaryPicture() {
    var b = cRotaryPictureControl.Body.style.bottom.replace('px', '');
    b = parseInt(b);
    if (b < 0) {
        b += 10;
        if (b > 0) {
            b = 0;
        }
        cRotaryPictureControl.Body.style.bottom = b + 'px';
        setTimeout("fnShowRotaryPicture()", 50);
    }
}


//初始化赞助商(新闻)选项卡
function fnLoadNewsList() {
    var url = GlobalConfig.EDataCenterUrl + 'CommMap5.0/ad.aspx?domain=' + GlobalConfig.Domain + '&l=' + GlobalConfig.Language + '&req=1';
    ENetwork.DownloadScript(url, function() {
        if (typeof _News == 'undefined') return false;
        //var t = '';
        //alert(_News.ScrollAd.length);   
        //debugger;
        for (i = 0; i < _News.ScrollAd.length; i++) {
            //debugger;
            //t += '<tr><td onclick="fnLoadNewsById(' + _News.ScrollAd[i].MDI_ID + ',\'' + _News.ScrollAd[i].MDI_Title + '\');" style="cursor:pointer">' + _News.ScrollAd[i].MDI_Title + '</td></tr>';
            //判断是否默认激活的
            if (_News.ScrollAd[i].MDI_AutoActive == 1) {
                fnLoadNewsById(_News.ScrollAd[i].MDI_ID, _News.ScrollAd[i].MDI_Title);
            }
        }
        //$('divNews').innerHTML='<table id="newstr" style="border-collapse:collapse;line-height:16px; color:#000;" cellpadding="0">'+t+'</table>';
        //objup = new CBoardExhibition("objup", "divNews", 3, true, "up", 0, 2000);
        //objup.ShowMsg();

        fnUrlParse();   //Url定位
    });
}
function fnLoadNewsById(id, title) {
    if (!title) {
        title = '广告';
    }
    var tab = new TabControl.Tab(document, 'news', title, GlobalConfig.NewSkinPath + 'Fundation/News.html?id=' + id, true, true, 80);
    fnAddTab(tab);
}
