﻿
//全局变量定义
var cSearchControl;             //搜索面板控件
var cSearchResultControl;       //搜索结果列表控件
var cEntityPopControl;          //泡泡控件
var cThemePopControl;           //主题泡泡
var cCommendPopControl;         //推荐泡泡
var cDebugControl;              //纠错控件
var cPaneSearchControl;         //拉框搜索
var cFromSearchControl;         //从这里出发搜索控件
var cToSearchControl;           //到这里搜索控件
var cPeripheralBusControl;      //周边公交控件
var cBusStationControl;         //公交站点信息控件
var cPeripheralSearchControl;   //周边搜索控件

var _PopLayer;
var _PaneLayer;
var _IconLayer;
var _BusLayer; 
var _MarkLayer;     
var _EyeIconLayer;
var _EntLayer;  
var _HotelLayer;             

var vM =    null;               //地图对象
var vM2 =    null;               //地图对象
var vMe =   null;               //鹰眼对象
var _isBeginSelectMark = false;  //是否开始选择标记点位置
var _isBeginScale = false;


var MapLoadComplete = false;
var _OldAPIParams = {           //旧api需要的全局变量
    ClickX: null,
    ClickY: null,
    EyeZB:null,
    putPop:null,
    ComExFuncName:null,
    OwnerExFuncName:null,
    CurCompanyID:null,
    CurOwnerID:null,
    CurOwnerName:'',
    MapClickFun:null
};

window.onload = fnLoadRun;

function fnLoadRun(){
//fnSearchLoadInit();
//alert("22222222222222");
 


	if (typeof window.vEdushiMap!='undefined'   && window.vEdushiMap.MapLoadComplete  && window.vEdushiMap  && window.vEdushiMap._Mark && window.vEdushiMap.GlobalConfig){
			fnLoadInit();
			}else{
				setTimeout('fnLoadRun()',50);
			
				}
}

function fnLoadInit(){
    //加载对象

    MapLoadComplete = true;
   vM  =  window.vEdushiMap;
   vM2  =  vM.vEdushiMap;
   vMe = vM.veyeEdushiMap;
   
    window.onresize=function(){
          var h = fnGetWindowHeight(),w = fnGetWindowWidth();
	    $('EdushiMap').style.Width = w + 'px';
        $('EdushiMap').style.Height = h + 'px';
        document.body.style.Height = h + 'px';
        window.setMapWidth(w);
        window.setMapHeight(h);

    };
    window.onresize();
	
    
      _MarkLayer = vM.vEdushiMap.NewMapLayer('Mark', 265, 0);
      _MarkLayer2 = vM.vEdushiMap.NewMapLayer('Mark2', 263, 0);
      _PopLayer = vM.vEdushiMap.NewMapLayer('Pop',269, 0);
	  _EntLayer = vM.vEdushiMap.NewMapLayer('Ent',270, 0);
	  _HotelLayer = vM.vEdushiMap.NewMapLayer('Hotel',271, 0);

	      //初始化背景图
 vM.oApiMap.Body.document.body.style.background='url(/images/waterbg.gif)';
 vM.oEyeApiMap.Body.document.body.style.background='url(/images/waterbg.gif)';
//初始化搜索面版
fnSearchLoadInit();


    
   //搜索面板
     vM.hideTag('Tool');
     vM.Tool.style.top = '58px';
vM.Eye.style.top= '40px';

 //判定搜索直接跳转
 if($('open').value=="1"){
	fnToolsEx3();
	fnNavigationClose();
	 subsearch();
 }

//确定是否直接跳转
 fnGotoXY();

      vM.cbpowerby.style.display = 'none'; 
	      vM.hideTag('proMapTool');  //关闭右下角面版
        vM.hideTag('CopyRight');
        vM.hideTag('imgPanel');
        vM.toolsPanel.style.height = '28px';
        vM.CopyRight.style.height = '33px';
        
  //初始化标签CSS
     fnAddMarkCss(); 
	 fnAddEntCss();  
vM2.onSpotClick = function(spot){
                if (!vM._isBeginSelectMark){
                    vM._OldAPIParams.CurOwnerID = spot.ID;
                    vM._OldAPIParams.CurOwnerName = spot.OwnerName;
						  subsearchEnt(spot);
                }
            };    
     
      vM._Mark._MarkerView = '<div style="width:200px;"><div style="height:45px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/ding.png\',sizingMethod=\'image\');"><!--[if !IE]><!--><img src="/images/ding.png" /><!--<![endif]--></div><div class="dialog">'
                                +'<div class="title"><div><img src="/images/newmap10.gif" alt="标记" style="margin-top:3px;" /></div><div style="overflow:hidden; width:140px; height:20px;">{$MarkerTitle}</div><a class="HideMarkerInfo" style="cursor:pointer" onclick="parent._Mark.fnMarkEx(\'{$id}\',this);" ></a></div>'
                                +'<div id="MarkC{$id}" class="content"><div class="textLine" style="padding-left:5px; text-indent:2em; padding-right:5px;white-space:normal; word-break:break-all; overflow:hidden;">{$MarkerContent}'
                                +'</div><div style="border-bottom:solid 1px #666; margin:5px 1px 10px 1px;"></div><input id="MarkAdd{$id}" value="{$Add}" style="width:195px; display:none;"  /><div class="textLine" style="background-color:#ffffff; height:25px;"><div class="DelMarker" onclick="parent._Mark.Del(\'{$id}\',\'{$Clear}\');">删除标记</div><div class="CopyMarker" onclick="parent._Mark.fnCopyCode(MarkAdd{$id},\'复制成功，请贴到你的QQ/MSN上发给你的好友！\')">复制给好友</div></div></div></div></div>';  
 
	vM._Mark.Del=function(i,clearContent){
	    if(i=='EMark')
    {
        vM._Mark.RemoveMarkPop('PopMark_'+i);
        return;
    }
    else
    {
        vM._Mark.RemoveMarkPop('PopMark_'+i);
	    var c = new CookieHelper();
	    var d = new Date();
	    var Mark = c.getCookie('Mark')==null?'':c.getCookie('Mark');
	    Mark = Mark.replace(clearContent,'');
	    d.setHours(d.getHours()+5);
	    c.setCookie('Mark',Mark,d);
	    c=null;
	    vM._Mark.Load();
	}
}

vM._Mark.Load = function(){
    var c = new CookieHelper();
    var aMark = c.getCookie('Mark')==null?'':c.getCookie('Mark').split('|');
	var r='';
	$('MarkLi').innerHTML='<li onclick="if (confirm(\'你确定清除所有标记吗\')){vM._Mark.Clear()}">　清除所有标记 </li>';
	for(i=0;i<aMark.length-1;i++){
        var aryTemp = aMark[i].split('^');
        r+='<li onmouseover="OverBackground(this)" onmouseout="OutBackground(this)" onclick="vM._Mark.Show('+i+','+aryTemp[0]+','+aryTemp[1]+',\''+aryTemp[3]+'\',\''+aryTemp[2]+'\');" >'+aryTemp[3]+'</li>';
	}
	$('MarkLi').innerHTML=r+$('MarkLi').innerHTML;
}
 vM._Mark.Load();

vM._Mark.Clear=function(){
    var c = new CookieHelper();
    var aMark = c.getCookie('Mark')==null?'':c.getCookie('Mark').split('|');
    if(aMark=="")return false;
	for(i=0;i<aMark.length;i++){
		if(vM.vEdushiMap.$('PopMark_'+i)) vM._Mark.RemoveMarkPop('PopMark_'+i);
	}
	var d = new Date();
	d.setHours(d.getHours()+5);
	c.setCookie('Mark','',d);
	$('MarkLi').innerHTML=' <li onclick="if (confirm(\'你确定清除所有标记吗\')){_Mark.Clear()}">清除所有标记</li>';
}
   
     
     
   
             //测距
   /*
        $('imgScale').style.display = 'none';
        $('toolsPanel').style.height = '28px';
        $('CopyRight').style.height = '33px';
    */    
    
      //兼容旧核
    vM.onMapMouseDown = function(e){
        if(e.button == 1)
        {
            _OldAPIParams.ClickX = vEdushiMap.PointerX();
            _OldAPIParams.ClickY = vEdushiMap.PointerY(); 
        }
        if (typeof _OldAPIParams.MapClickFun == 'function')
        {
            _OldAPIParams.MapClickFun(e, vEdushiMap.PointerX(), vEdushiMap.PointerY());
        }
    }
    
    vM.onMapMouseUp = function(e){
        if (_isBeginSelectMark){
            _Mark.Mark(vM.PointerX(),vM.PointerY(),'');
        }
    };
    vM.onMapDblClick = function(e){
  
        if (!_isBeginScale){
            if (vM.Zoom() >0){
                vM.MoveTo(vM.PointerX(),vM.PointerY());
                vMe.MoveTo(vM.PointerX(),vM.PointerY());
                vM.FlatZoom(0);
            }
            else{
                vM.MoveTo(vM.PointerX(),vM.PointerY(),true);
                vMe.MoveTo(vM.PointerX(),vM.PointerY(),true);
            }
        }
        _isBeginScale = false; 
    };
    vMe.onMapMoveEnd = function(x,y,flg){
        if(flg==0){vM.vEdushiMap.MoveTo(x,y,true);}
    };
    vM.onMapMoveEnd = function(x,y,flg){
        if(flg==0){vMe.vEdushiMap.MoveTo(x,y,true);}
    };
    


}

function fnEntInfo(x,y,obj)
{

    vM.vEdushiMap.MoveTo(x*1, y*1, true);

RemovePop("AddEntPop");
    if($('AddEntPop')){
        $('AddEntPop').style.display = "block";
        $('AddEntPop').style.top    = y;
        $('AddEntPop').style.left   = x;
        }else{
        var info = vM.vEdushiMap.$C('div');
        info.id='AddEntPop';
		var imageinfo ="/images/bloading.gif";
		if (obj.IMAGE!=null && obj.IMAGE.length>20)
		{
			imageinfo="/dzdt/thxzl/"+obj.IMAGE;
		}
        

        info.innerHTML="<div class=\"Popo\" id=\"Entr_POP\" style=\"position: relative;\">  "   
            	+"	<div class=\"PLeft\" style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/newmap38.png',sizingMethod='image');\"></div> "
            	+"     	<div class=\"PRight\">      	<div class=\"PHead\">  	<div id=\"Entr_Title\" class=\"Title\">"+obj.DOCTITLE+"</div>	<div class=\"Close\"> "
            	+"   	<a id=\"Entr_close\" title=\"关闭\" onclick=\"top.RemovePop('AddEntPop')\" style=\"margin-left: -16px;\" class=\"m_h_c\"></a>                    </div> "
            	+"	</div> 	<div class=\"PContent\">  	<div class=\"AdImg\"> "  
            	+"                  		<div id=\"Entr_Tell\" class=\"AIOver\" style=\"width: 276px; height: 149px\">                                <table border=\"0\" width=\"288\" id=\"table1\" height=\"274\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-size: 12px\">	<tr>		<td width=\"118\" rowspan=\"3\">"
            	+"		<img border=\"0\" src=\""+imageinfo+"\" width=\"118\" height=\"99\" style=\"height:99px; border:1px solid #A4A4A4; font-size:12px;\"></td>		<td width=\"147\" id=\"cgroup\">&nbsp;商&nbsp; 圈："+obj.CGROUP+"</td>	</tr>	<tr>		<td width=\"147\" id=\"linkman\">&nbsp;联系人："+obj.LINKMEN+"</td>	</tr>	<tr>		<td width=\"147\" id=\"linktel\">&nbsp;联系电话："+obj.LINKTEL+"</td>	</tr>	<tr>		<td width=\"288\" height=\"12\" colspan=\"2\"></td>	</tr>	<tr>	"
            	+"	<td width=\"288\" height=\"31\" colspan=\"2\" valign=\"top\" id=\"jtqk\">		交通情况："+obj.JTQK+"</td>	</tr>	<tr>		<td width=\"288\" height=\"18\" colspan=\"2\" id=\"jtqk\" bgcolor=\"#EEEEEE\">		大厦简介： </td></tr>	<tr>		<td width=\"288\" height=\"114\" colspan=\"2\" valign=\"top\" >		<table width=\"288\" height=\"75\" style=\"height:130px; border:1px solid #A4A4A4; font-size:12px;\" cellspacing=\"0\" cellpadding=\"0\" >			<tr>				<td id=\"doccontent\"><div class=Scroll>"+obj.DOCCONTENT+"</div></td>			</tr>		</table>		</td>	</tr></table></div>     	</div>	    </div>     "
            	+"           <div  style=\"height:9px; font-size:1px; background:url(/images/newmap36.gif) no-repeat\">                </div>            </div>      </div> ";
        
        vM.vEdushiMap.appendEntity(info, _PopLayer, false, x,y,233,110,0,135, false);
        info=null;
        delete info;
    }
    }


function fnHotelInfo(x,y,obj)
{

    vM.vEdushiMap.MoveTo(x*1, y*1, true);
RemovePop("AddHotelPop");
    if($('AddHotelPop')){
        $('AddHotelPop').style.display = "block";
        $('AddHotelPop').style.top    = y;
        $('AddHotelPop').style.left   = x;
        }else{
       
		  var infoHotel = vM.vEdushiMap.$C('div');
        infoHotel.id='AddHotelPop';
		infoHotel.innerHTML="<div >"
+"<div  style=\"POSITION: relative;margin:-150px 0px 0px 15px;display:block\">"
+"<table border=\"0\" width=\"345\"  height=\"245\" cellspacing=\"0\" cellpadding=\"0\">"
+"	<tr>		<td width=\"42\" rowspan=\"3\">		<img border=\"0\" src=\"/images/newmap38.png\" width=\"42\" height=\"36\"></td>		<td width=\"303\" height=\"21\" background=\"/images/newmap34.gif\">"
+"		<p align=\"center\"><b><span style=\"font-size: 15px\">星级酒店</span></b><span class=hotelClose><a title=\"关闭\" onclick=\"top.RemovePop('AddHotelPop')\"  class=\"hotelm_h_c\"></a></span></td>	</tr>	<tr>		<td width=\"303\" background=\"/images/newmap35.gif\" align=\"center\" valign=\"top\">		<table border=\"0\" width=\"93%\" id=\"table2\" height=\"193\" cellspacing=\"0\" cellpadding=\"0\">			<tr>				<td height=\"30\" class=line>				<b><font size=\"2\">酒店名称：</font></b>"+obj.DOCTITLE+"</td>			</tr>			<tr>				<td height=\"30\" class=line>				<b><font size=\"2\">星&nbsp;&nbsp;&nbsp; 级：</font></b>"+obj.LINKMEN+"</td>			</tr>			<tr>				<td height=\"30\" class=line>				<b><font size=\"2\">电&nbsp;&nbsp;&nbsp; 话：</font></b>"+obj.LINKTEL+"</td>			</tr>			<tr>				<td height=\"30\" class=line>				<b><font size=\"2\">传&nbsp;&nbsp;&nbsp; 真：</font></b>"+obj.ZSFS+"</td>			</tr>"
+"<tr>				<td height=\"30\" class=line>				<b><font size=\"2\">地&nbsp;&nbsp;&nbsp; 址：</font></b><p>"+obj.ADDRESS+"　</td>			</tr>		</table>		</td>	</tr>	<tr>		<td width=\"303\" height=\"9\" background=\"/images/newmap36.gif\"></td>	</tr></table>"
+"</div></div>";
       vM.vEdushiMap.appendEntity(infoHotel, _HotelLayer, false, x,y,233,110,10,-10, false);
        infoHotel=null;
        delete infoHotel;
    }
    }


      



function RemovePop(id)
{
    if(vM.vEdushiMap.$(id))
    {
        vM.vEdushiMap.$(id).parentNode.removeChild(vM.vEdushiMap.$(id));
    }
}



function fnScrollBG(hp)
{
    var h = $('BG').style.height.replace('px', '') * 1;
    h -= hp;
    if (h > 0)
    {
        $('BG').style.height = h + 'px';
        setTimeout(function(){fnScrollBG(hp);}, 30);
    }
    else
    {
        $('BG').style.display = 'none';
    }
}
//添加 样式表
function fnAddMarkCss()
{
    var MarkCss=vM.vEdushiMap.$C('link');
    MarkCss.rel='stylesheet';
    MarkCss.type = 'text/css';
    MarkCss.href='/images/Mark.css';
    vM.vEdushiMap.Body.document.getElementsByTagName('head')[0].appendChild(MarkCss);
}

function fnAddEntCss()
{
    var EntCss=vM.vEdushiMap.$C('link');
    EntCss.rel='stylesheet';
    EntCss.type = 'text/css';
     EntCss.href='/images/EntityPopControl.css';
    vM.vEdushiMap.Body.document.getElementsByTagName('head')[0].appendChild(EntCss);
}

function fnNewInitPop()
{
//绑定实体点击事件
	  vM2.onSpotClick = function(spot){
                if (!vM._isBeginSelectMark){
                    vM._OldAPIParams.CurOwnerID = spot.ID;
                    vM._OldAPIParams.CurOwnerName = spot.OwnerName;
						//	  alert("Title||"+spot['Title']);
						
                }
            };
			

}


//泡泡控件
function fnInitPop(){
   if (!vM.cEntityPopControl){
        cEntityPopControl = new EntityPopControl({Parent:vM});
        cEntityPopControl.ID = vM.appendEntity(cEntityPopControl.Body, _PopLayer, false, 0, 0, 345,340,0,135, false);
        cEntityPopControl._loadUI();
        cEntityPopControl.onLoadComplete  = function()
        {
            //@小火 各种定位 开关
            if(ProductSetting.Position && window._IsPosition == '1')
            {
                fnEaddGoto('');
                fnOCGoto();
                fnMarkGoto();
            }
            
            //绑定实体点击事件
            vM.onSpotClick = function(spot){
                if (!_isBeginSelectMark){
                    _OldAPIParams.CurOwnerID = spot.ID;
                    _OldAPIParams.CurOwnerName = spot.OwnerName;
                    fnShowEntityPop(spot.ID, spot.CenterX, spot.CenterY); 
                }
            };
            vM.onSpotLabelClick = function(spot){
                if (!_isBeginSelectMark){
                    _OldAPIParams.CurOwnerID = spot.ID;
                    _OldAPIParams.CurOwnerName = spot.OwnerName;
                    fnShowEntityPop(spot.ID, spot.CenterX, spot.CenterY);  
                }
            };
            vM.onSignClick = function(sign){
                switch (sign.SortKey){
                    case 'bus':
                        fnShowBusStation(sign.ID);
                        break;
                    case 'vir':
                        window.open(GlobalConfig._WebRootPath + 'Vir/Vir.aspx?Image=' + escape(sign.Url), '_blank', 'width=520,height=400');
                        break;
                }
            };
            vM.onContextMenuClick = function(key,wx,wy,mx,my,spot){
                switch (key){
                    case 'spot':
                        if(spot){
                            fnShowEntityPop(spot.ID, spot.CenterX, spot.CenterY);
                        }
                        break;
                    case 'center':
                        vM.MoveTo(mx,my,true);
                        break;
                    case 'zoomout':
                        vM.FlatZoom(vM.Zoom()+1);
                        break;
                    case 'zoomin':
                        vM.FlatZoom(vM.Zoom()-1);
                        break;
                    case 'start':
                        fnShowFromHereSearch();
                        break;
                    case 'end':
                        fnShowToHereSearch();
                        break;    
                    case 'cirbus':
                        fnShowPeripheralBus();
                        break;  
                    case 'cirsearch':
                        fnShowPeripheralSearch();
                        break;  
                    case 'errors':
                        if (spot){
                            fnShowDebugControl(vM.PointerX(),vM.PointerY(), spot.ID, spot.Title, 0);
                        }
                        else{
                            fnShowDebugControl(vM.PointerX(),vM.PointerY(), 0, '', 0);
                        }    
                        break;    
                    case 'sign':
                        if (spot){
                            _Mark.Mark(vM.PointerX(),vM.PointerY(),spot.Title);
                        }
                        else{
                            _Mark.Mark(vM.PointerX(),vM.PointerY(),'');
                        }
                        break; 
                    case 'about':
                        alert('阿拉丁信息科技有限公司\r\nhttp://www.edushi.com ');
                        break;
                }
            };
        }
        cEntityPopControl.MoveTo(0, 0); 
        //Pop控件对外提供的事件的重写
        cEntityPopControl.onBusIDSearch  = function(nID,sName)
        {
            cSearchResultControl.BusIDSearch(nID,sName);
        };
        cEntityPopControl.onBusSEXYSearch = function(action,x,y,sKeyword)
        {
            cSearchResultControl.BusSEXYSearch(action,x,y,sKeyword);
        };
        if(ProductSetting.PeripheralSearch)
        {
            cEntityPopControl.onLocalNearBySearch = function(sKeyword,x,y,len)
            {                   
                cSearchResultControl.LocalNearBySearch(sKeyword,x,y,len);
            };
        }
        cEntityPopControl.onHistorySaved = function(type, spot)
        {
            fnSaveHistory(type, spot);
        };
        cEntityPopControl.onSign = function(x, y,sName)
        {
            cEntityPopControl.Hide();
             _Mark.Mark(x, y,sName);
        };
        cEntityPopControl.onCavil = function(type,nID,sName,x, y)
        {
            cEntityPopControl.Hide();
            if (type != 1){
                type = 0;
            }
            fnShowDebugControl(x*1, y*1, nID, sName, type);
        };
    }
    //主题泡泡初始化
    if (!cThemePopControl){
        cThemePopControl = new ThemePopControl({Parent:vM});
        cThemePopControl.ID = vM.appendEntity(cThemePopControl.Body, _PopLayer, false, 0, 0, 345,300,0,135, false);
        cThemePopControl._loadUI();
        cThemePopControl.MoveTo(0, 0); 
        //Pop控件对外提供的事件的重写
        cThemePopControl.onBusIDSearch  = function(nID,sName)
        {
            cSearchResultControl.BusIDSearch(nID,sName);
        };
        cThemePopControl.onBusSEXYSearch = function(action,x,y,sKeyword)
        {
            cSearchResultControl.BusSEXYSearch(action,x,y,sKeyword);
        };
        cThemePopControl.onLocalNearBySearch = function(sKeyword,x,y,len)
        {                   
            cSearchResultControl.LocalNearBySearch(sKeyword,x,y,len);
        };
        cThemePopControl.onHistorySaved = function(type, spot)
        {
            fnSaveHistory(type, spot);
        };
        cThemePopControl.onSign = function(x, y,sName)
        {
            cThemePopControl.Hide();
             _Mark.Mark(x, y,sName);
        };
        cThemePopControl.onCavil = function(type,nID,sName,x, y)
        {
            cThemePopControl.Hide();
            if (type != 1){
                type = 0;
            }
            fnShowDebugControl(x*1, y*1, nID, sName, type);
        };
    }
    //推荐泡泡初始化
    if (!cCommendPopControl){
        cCommendPopControl = new CommendPopControl({Parent:vM});
        cCommendPopControl.ID = vM.appendEntity(cCommendPopControl.Body, _PopLayer, false, 0, 0, 398,300,0,135, false);
        cCommendPopControl._loadUI();
        cCommendPopControl.MoveTo(0, 0);
    }
}
//显示实体泡泡
function fnShowEntityPop(id,x,y){
    //即使关闭泡泡也会定位
    vM.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    vMe.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    
    if(!ProductSetting.EntityPop || window._IsShowEPop == '0')
    {
	    return;
    }
    if (typeof _OldAPIParams.OwnerExFuncName == 'function')
    {
        _OldAPIParams.OwnerExFuncName();
    }

    cEntityPopControl.CID = '';
    if(cEntityPopControl.OID!=id){
        cEntityPopControl.Hide();
        setTimeout(function(){
           vM.moveEntity(cEntityPopControl.ID, x*1, y*1);
            cEntityPopControl.ShowEntityPop(id);   
        }, 100);  
    }
    else{
        
        vM.moveEntity(cEntityPopControl.ID, x*1, y*1);
        cEntityPopControl.Show();
    }
}
//显示企业泡泡
function fnShowCompanyPop(id,x,y){
    //即使关闭泡泡也会定位
    vM.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    vMe.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    
    if(!ProductSetting.CompanyPop || window._IsShowCPop == '0')
    {
	    return;
    }
    _OldAPIParams.CurCompanyID = id;
    if (typeof _OldAPIParams.ComExFuncName == 'function')
    {
        _OldAPIParams.ComExFuncName();
    }
    
    cEntityPopControl.OID = '';
    if(cEntityPopControl.CID!=id){
        cEntityPopControl.Hide(); 
        setTimeout(function(){
           vM.moveEntity(cEntityPopControl.ID, x*1, y*1);
            cEntityPopControl.ShowComanyPop(id);   
        }, 100); 
    }
    else{
        vM.moveEntity(cEntityPopControl.ID, x*1, y*1);
        cEntityPopControl.Show();
    }
}
//显示主题泡泡
function fnShowThemePop(id,x,y){
    if(!ProductSetting.ThemePop)
    {
	    return;
    }
    vM.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    vMe.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    if(cThemePopControl.TID!=id){
        cThemePopControl.Hide(); 
        setTimeout(function(){
           vM.moveEntity(cThemePopControl.ID, x*1, y*1);
            cThemePopControl.ShowThemePop(id);   
        }, 100); 
    }
    else{
        vM.moveEntity(cThemePopControl.ID, x*1, y*1);
        cThemePopControl.Show();
    }
}
//显示推荐泡泡
function fnShowCommendPop(sTitle, sContent, x, y)
{
    if(!ProductSetting.CommendPop && window._IsShowCdPop == '0')
    {
	    return;
    }
    vM.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    vMe.MoveTo(x*1 + vM.GetMapPos(170), y*1, true);
    cCommendPopControl.Hide(); 
    setTimeout(function(){
       vM.moveEntity(cCommendPopControl.ID, x*1, y*1);
        cCommendPopControl.ShowCommendPop(sTitle, sContent);   
    }, 100);
}

//搜索面板控件呈现
function fnShowSearchControl(){
    if(!ProductSetting.SearchPanel || window._IsShowSp == '0')
    {
	    return;
    }
    
    if (!cSearchControl){
        cSearchControl = new SearchControl();
        $('Tool').appendChild(cSearchControl.Body);
        cSearchControl._loadUI();
        cSearchControl.Width = 303;
        cSearchControl.Height = 103;
        cSearchControl.ResumeLayout();
        
        cSearchControl.onLocalSearch = function(sKeyword){
            cSearchResultControl.LocalSearch(sKeyword);
        };
        cSearchControl.onBusSearch = function(iType, param1, param2){
            cSearchResultControl.BusSearch(iType, param1, param2);
        };
        //@小火 黄页搜索
        if(ProductSetting.YellowPage && window._IsShowYp == '1')
        {
            cSearchControl.onYellowPageSearch = function(sKeyword){
                window.open('http://' + GlobalConfig._AppDomain + '/yp/KeywordSearchList.aspx?Keyword=' + escape(sKeyword), '_blank', '');
            };
        }
        else
        {
            cSearchControl.onLoadComplete = function()
            {
                cSearchControl.$('YPSearchMenu').style.display = 'none';
            }
        }
    }
    cSearchControl.Show();
}

//搜索列表控件初始化
function fnInitSearchResult(){
    if (!cSearchResultControl){
        cSearchResultControl = new SearchResultControl();
        $('DragWindow').appendChild(cSearchResultControl.Body);
        cSearchResultControl._loadUI();
        cSearchResultControl.Body.style.zIndex = 999;
        cSearchResultControl.Width = 303;
        cSearchResultControl.Height = 418;
        cSearchResultControl.ResumeLayout();
        cSearchResultControl.MoveTo(0, 0);
        cSearchResultControl.onLoadComplete = function(){
            //当搜索列表控件载入完成时载入下面的触发控件
            fnShowSearchControl(); //搜索面板
            fnLoadPro();    //主题面板
            fnDragControl($('DragWindow'), 20, 30);     
            fnDragControl($('Tool'), 20, 30);
            fnUrlGoto();    //与搜索列表面板相关的定位
        };
        //搜索结果页卡对外提供的实体点击
        cSearchResultControl.onEntityClick = function(oid,cid,x,y)
        {
            if(cid==0)
            {
                fnShowEntityPop(oid,x,y);
            }
            else
            {
                fnShowCompanyPop(cid,x,y);
            }
        };
        //主题地图点击
        cSearchResultControl.onThemeClick = function(tid,x,y)
        {
            fnShowThemePop(tid, x, y);
        };
        //推荐泡泡
        cSearchResultControl.onVouchClick = function(title, content, x, y)
        {
            fnShowCommendPop(title, content, x, y);
        };
        //搜索图标
        cSearchResultControl.onLocalDataLoad = function(arrLocalData, nBegin, nEnd){
            _IconLayer.innerHTML = '';
            _EyeIconLayer.innerHTML = '';
            for (var i=nBegin; i<nEnd; i++)
            {
                if (arrLocalData.CompanyID[i] > 0)
                {
                    fnAppendIcon(arrLocalData.x[i], arrLocalData.y[i], i+1, GlobalConfig._ImgPath + '12-22.gif', GlobalConfig._ImgPath + 'iconflash.gif', 'parent.fnShowCompanyPop('+arrLocalData.CompanyID[i]+', ' + arrLocalData.x[i] + ', ' + arrLocalData.y[i] + ');',27,37,13,27);
                }
                else
                {
                    fnAppendIcon(arrLocalData.x[i], arrLocalData.y[i], i+1, GlobalConfig._ImgPath + '12-22.gif', GlobalConfig._ImgPath + 'iconflash.gif', 'parent.fnShowEntityPop('+arrLocalData.OwnerID[i]+', ' + arrLocalData.x[i] + ', ' + arrLocalData.y[i] + ');',27,37,13,27);
                }
            }
        };
        //主题图标
        cSearchResultControl.onClassDataLoad = function(arrClassData,nBegin,nEnd){
            _IconLayer.innerHTML = '';
            _EyeIconLayer.innerHTML = '';
            var sImgUrl = GlobalConfig._PicUrl + GlobalConfig._Country+'/'+GlobalConfig._CityCode+'/'+GlobalConfig._L+'/themeImages/';
            for (var i=nBegin; i<nEnd; i++)
            {
                if (arrClassData.ComIco[i].length > 0)
                {
                    var sThemeImage = sImgUrl + 'BBLCompany/' + arrClassData.ComIco[i]; 
                    var sThemeImage2 = sThemeImage;
                }
                else
                {
                    var sThemeImage = sImgUrl + arrClassData.CommIco[i];
                    var sThemeImage2 = sImgUrl + arrClassData.FocusIco[i];
                }
                fnAppendIcon(arrClassData.x[i], arrClassData.y[i], '', sThemeImage, sThemeImage2, 'parent.fnShowThemePop('+arrClassData.ID[i]+', ' + arrClassData.x[i] + ', ' + arrClassData.y[i] + ');',26,26,13,13);
            }
        };
        //公交图标 type:1-正向 0-反向
        //@小火 公交数据Load
        cSearchResultControl.onBusDataLoad = function(arrBusData, type){
            _BusLayer.innerHTML='';
            if(arrBusData!=null)
            {
                var coords = [];
                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._ImgPath + '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};">{$BusStationName}</span></span>';
                if(type==1){
                    var l=arrBusData.Bus_BN_UP_BS_StationName_Js.length;
                    for(i=0;i<l;i++){
                        var vlen = arrBusData.Bus_BN_UP_BS_StationName_Js[i].length*12.1;
                        var nd = vM.$C('div');
                        nd.id='B_pop'+i;
                        nd.innerHTML=PopHtml.replace('{$No}',(i+1)).replace('{$BusStationName}',arrBusData.Bus_BN_UP_BS_StationName_Js[i]).replace('{$topwidth}','width:'+(vlen+40)+'px').replace('{$width}','width:'+(vlen+10)+'px');
                        vM.appendEntity(nd, _BusLayer, false, arrBusData.Bus_Bs_UpX_Js[i],arrBusData.Bus_Bs_UpY_Js[i],vlen+35,26,12,28, false);
                        coords.push(vM.GetWinPos(arrBusData.Bus_Bs_UpX_Js[i]));
                        coords.push(vM.GetWinPos(arrBusData.Bus_Bs_UpY_Js[i]));
                    }
                }else{
                    var l=arrBusData.Bus_BN_Down_BS_StationName_Js.length;           
                    for(i=0;i<l;i++){
                        var vlen = arrBusData.Bus_BN_Down_BS_StationName_Js[i].length*12.1;
                        var nd = vM.$C('div');
                        nd.id='B_pop'+i;
                        nd.innerHTML=PopHtml.replace('{$No}',(i+1)).replace('{$BusStationName}',arrBusData.Bus_BN_Down_BS_StationName_Js[i]).replace('{$topwidth}','width:'+(vlen+40)+'px').replace('{$width}','width:'+(vlen+10)+'px');
                        vM.appendEntity(nd, _BusLayer, false, arrBusData.Bus_Bs_DownX_Js[i],arrBusData.Bus_Bs_DownY_Js[i],vlen+35,26,12,28, false);
                        coords.push(vM.GetWinPos(arrBusData.Bus_Bs_DownX_Js[i]));
                        coords.push(vM.GetWinPos(arrBusData.Bus_Bs_DownY_Js[i]));
                    }           
                }
//                if (vM.Zoom() == 3){
//                    vM.DrawPolyLine(_BusLayer, coords.join(','), 1, '#ff0000', 80);
//                }
            }
        };
        //公交站定位
        cSearchResultControl.onGoToXY = function(x, y){
            if (x && y){
                vM.MoveTo(x, y, true);
                vMe.MoveTo(x, y, true);
            }
        };
    }
    else
    {
        cSearchResultControl.Show();
    }
}
//添加小图标至地图与鹰眼中
function fnAppendIcon(x, y, text, sImgPath, sImgPath2, sFn, w, h, ew, eh, sEyeImg){
    if (sImgPath2.length == 0)
    {
        sImgPath2 = sImgPath;
    }
    var p = vM.$C('div');
    p.innerHTML = '<div onmouseover="this.style.backgroundImage=\'url(' + sImgPath2 + ')\';" onmouseout="this.style.backgroundImage=\'url(' + sImgPath + ')\';" style="background-image:url(' + sImgPath + '); background-repeat:no-repeat;width:' + w + 'px; height:' + h + 'px; text-align:center; padding-top:5px; cursor:pointer;" onclick="' + sFn + '"><a >'+ text +'</a></div>';
    vM.appendEntity(p, _IconLayer, false, x, y, w,h,ew,eh, false);
    var pe = vMe.$C('div');
    if (sEyeImg && sEyeImg.length > 0){
        //alert(3);
        pe.innerHTML = '<div style="background-image:url(' + sEyeImg + '); background-repeat:no-repeat;width:' + w + 'px; height:' + h + 'px; text-align:center; padding-top:5px; cursor:pointer;" onclick="' + sFn + '"><a >'+ text +'</a></div>';
    }
    else{
        pe.innerHTML = p.innerHTML;
    }
    vMe.appendEntity(pe, _EyeIconLayer, false, x, y, w,h,ew,eh, false);
}

//主题面板
var _ClassTypeNum=1;
function fnLoadPro(){
    var url= GlobalConfig._DataCenterUrl + 'CommMap/themeInfo.aspx?node='+GlobalConfig._Node+'&viewxml=&req=1&v=1.0';
    ENetwork.DownloadScript(url,function(){
        if(typeof ThemeMapsList=='undefined'||ThemeMapsList==null)return false;
        $('proMap').style.display='block';
        var r='',t='';
        for(i=0;i<ThemeMapsList.ID.length;i++){
            t+='<img title="'+ThemeMapsList.TypeName[i]+'" onclick="fnLoadProById('+ThemeMapsList.ID[i]+',\''+ThemeMapsList.TypeName[i]+'\');" onmouseover="fnOnMouseOver(this,\''+ThemeMapsList.FocusIco[i]+'\');" onmouseout="fnOnMouseOut(this,\''+ThemeMapsList.CommIco[i]+'\');" src="' + GlobalConfig._PicUrl + GlobalConfig._Country+'/'+GlobalConfig._CityCode+'/'+GlobalConfig._L+'/themeImages/'+ThemeMapsList.CommIco[i]+'"/>';
            if((i!=0)&&((i+1)%6==0)){
                r+='<div class="lei" style="width:35px;">'+t+'</div>';
                t='';_ClassTypeNum++;                
           } 
        }
        if(t!='')r+='<div class="lei" style="width:35px;">'+t+'</div>';        
        $('proMapC').innerHTML=r;
        $('proMap').style.width=43+'px';
        if(ThemeMapsList.ID.length>6)
        {
            $('proMap_out').style.display='block';
        }
    });
}
function fnProMapOut(){
    if($('proMap').style.width=='43px'){
        $('proMap').style.width=35*_ClassTypeNum+8+'px';
        $('proMapC').style.width=35*_ClassTypeNum+'px';
        $('proMap_out').style.right= 35*_ClassTypeNum+7+'px';
        $('proMap_out').className='pouta';
    }else{
       $('proMap').style.width=43+'px';
       $('proMapC').style.width=35+'px';
        $('proMap_out').style.right= 42+'px';
        $('proMap_out').className='pout';
    }    
}
function fnOnMouseOut(o,i){
    o.src=GlobalConfig._PicUrl + GlobalConfig._Country+'/'+GlobalConfig._CityCode+'/'+GlobalConfig._L+'/themeImages/'+i;
}
function fnOnMouseOver(o,i){
    o.src=GlobalConfig._PicUrl + GlobalConfig._Country+'/'+GlobalConfig._CityCode+'/'+GlobalConfig._L+'/themeImages/'+i;
}
function fnLoadProById(Tid,Tname){
    cSearchResultControl.ClassSearch(Tid, Tname);
}

//全屏
function fnFullSrc(){
    if($('srcExit').style.display=='none'){
        $('srcExit').style.display='block'
        $('EdushiMenu').style.display = 'none';
        $('Top').style.display = 'none';
        $('EdushiMap').style.top='0px'; 
        $('Tool').style.top='20px';
    }else{
        $('srcExit').style.display='none';
        $('Top').style.display = 'block';
        $('EdushiMenu').style.display = 'block';
        $('EdushiMap').style.top='32px';
        $('Tool').style.top=''; 
    }
    var h = fnGetWindowHeight(),w = fnGetWindowWidth();
   	$('EdushiMap').style.Width = w;
    $('EdushiMap').style.Height= h;
   	//	 vM.setMapWidth(w);
     //   vM.setMapHeight(h);
    vM2.MapHeight(h);
    vM2.MapWidth(w);
}

//引导图
function fnNavigation(){
    if($('Navigation').style.display=='none'){
        $('Navigation').style.display='block'
        $('NavigationShow').style.display='block'

        
        }
     var h = fnGetWindowHeight(),w = fnGetWindowWidth();
   	$('Navigation').style.width = w;
    $('Navigation').style.height= h;
    $('NavigationShow').style.width = w;
    $('NavigationShow').style.height= h;
}

function fnNavigationClose(){
        $('Navigation').style.display='none';
        $('NavigationShow').style.display='none';

}

//@小火 框选功能
function fnPanel(){

vM.fnPanel();
   }
//拉框结束回调
function fnShowPaneSearch(x1,y1,x2,y2){

    if (!cPaneSearchControl){
        cPaneSearchControl = new PaneSearchControl({Parent:vM});
        cPaneSearchControl.ID = vM.appendEntity(cPaneSearchControl.Body, _PopLayer, false, 0, 0, 300, 135, 0, 0, true);
        cPaneSearchControl._loadUI();
        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){
            cSearchResultControl.LocalXYSearch(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 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 fnScale(){

  vM.vEdushiMap.Body.ScaleLine='#fcff00|2'; 
    vM.vEdushiMap.StartScale();
    vM._isBeginScale = true;
 }

//显示纠错 flag:0-实体 1-企业
function fnShowDebugControl(x, y, id, name, flag){
    if (!cDebugControl){
        cDebugControl = new DebugControl({Parent:vM});
        cDebugControl.ID = vM.appendEntity(cDebugControl.Body, _PopLayer, false, x, y, 300, 285, 0, 38, false);
        cDebugControl.Width = 300;
        cDebugControl.Height = 285;
        cDebugControl.ResumeLayout();
        cDebugControl.Debug(id, name, flag);
    }
    else{
        vM.moveEntity(cDebugControl.ID, x, y);
        cDebugControl.Show();
        cDebugControl.Debug(id, name, flag);
    }
}
//隐藏纠错控件
function fnHideDebugControl(){
    cDebugControl.Hide();
}

//显示从这里出发
function fnShowFromHereSearch(){
    if (!cFromSearchControl){
        cFromSearchControl = new FromSearchControl({Parent:vM});
        cFromSearchControl.ID = vM.appendEntity(cFromSearchControl.Body, _PopLayer, false, vM.PointerX(), vM.PointerY(), 233, 135, 0, 38, false);
        cFromSearchControl._loadUI();
        cFromSearchControl.Width = 233;
        cFromSearchControl.Height = 135;
        cFromSearchControl.ResumeLayout();
        cFromSearchControl.onLoadComplete = function(){
            cFromSearchControl.ShowFromHereSearch(vM.PointerX(), vM.PointerY());
        };
        cFromSearchControl.onShowFromHereSearch = function(keyword, x, y){
            cSearchResultControl.BusSEXYSearch(1, x, y, keyword);
        };
    }
    else{
        vM.moveEntity(cFromSearchControl.ID, vM.PointerX(), vM.PointerY());
        cFromSearchControl.ShowFromHereSearch(vM.PointerX(), vM.PointerY());
    }
}
//显示到这里
function fnShowToHereSearch(){
    if (!cToSearchControl){
        cToSearchControl = new ToSearchControl({Parent:vM});
        cToSearchControl.ID = vM.appendEntity(cToSearchControl.Body, _PopLayer, false, vM.PointerX(), vM.PointerY(), 233, 135, 0, 38, false);
        cToSearchControl._loadUI();
        cToSearchControl.Width = 233;
        cToSearchControl.Height = 135;
        cToSearchControl.ResumeLayout();
        cToSearchControl.onLoadComplete = function(){
            cToSearchControl.ShowToHereSearch(vM.PointerX(), vM.PointerY());
        };
        cToSearchControl.onShowToHereSearch = function(keyword, x, y){
            cSearchResultControl.BusSEXYSearch(2, x, y, keyword);
        };
    }
    else{
        vM.moveEntity(cToSearchControl.ID, vM.PointerX(), vM.PointerY());
        cToSearchControl.ShowToHereSearch(vM.PointerX(), vM.PointerY());
    }
}
//周边公交搜索
function fnShowPeripheralBus(){
    if (!cPeripheralBusControl){
        cPeripheralBusControl = new PeripheralBusControl({Parent:vM});
        cPeripheralBusControl.ID = vM.appendEntity(cPeripheralBusControl.Body, _PopLayer, false, vM.PointerX(), vM.PointerY(), 303, 310, 0, 38, false);
        cPeripheralBusControl._loadUI();
        cPeripheralBusControl.Width = 303;
        cPeripheralBusControl.Height = 310;
        
        cPeripheralBusControl.ResumeLayout();
        cPeripheralBusControl.onLoadComplete = function(){
            cPeripheralBusControl.ShowPeripheralBus(vM.PointerX(), vM.PointerY());
        };
        cPeripheralBusControl.onBusClick = function(busid, busname){
            cSearchResultControl.BusIDSearch(busid, busname);
        };
    }
    else{
        vM.moveEntity(cPeripheralBusControl.ID, vM.PointerX(), vM.PointerY());
        cPeripheralBusControl.ShowPeripheralBus(vM.PointerX(), vM.PointerY());
    }
}
//显示公交站信息，id:公交站ID
function fnShowBusStation(id, x, y){
    if (!cBusStationControl){
        if (!x || !y)
        {
            x = vM.PointerX();
            y = vM.PointerY();
        }
        cBusStationControl = new BusStationControl({Parent:vM});
        cBusStationControl.ID = vM.appendEntity(cBusStationControl.Body, _PopLayer, false, x, y, 303, 260, 0, 38, false);
        cBusStationControl._loadUI();
        cBusStationControl.Width = 303;
        cBusStationControl.Height = 260;
        
        cBusStationControl.ResumeLayout();
        cBusStationControl.onLoadComplete = function(){
            cBusStationControl.ShowBusStation(id);
        };
        cBusStationControl.onBusClick = function(busid, busname){
            cSearchResultControl.BusIDSearch(busid, busname);
        };
    }
    else{
        vM.moveEntity(cBusStationControl.ID, vM.PointerX(), vM.PointerY());
        cBusStationControl.ShowBusStation(id);
    }
}
//查找周边
function fnShowPeripheralSearch(){
    if(!ProductSetting.PeripheralSearch)
    {
        return;
    }
    if (!cPeripheralSearchControl){
        cPeripheralSearchControl = new PeripheralSearchControl({Parent:vM});
        cPeripheralSearchControl.ID = vM.appendEntity(cPeripheralSearchControl.Body, _PopLayer, false, vM.PointerX(), vM.PointerY(), 303, 185, 0, 38, false);
        cPeripheralSearchControl._loadUI();
        cPeripheralSearchControl.Width = 303;
        cPeripheralSearchControl.Height = 185;
        cPeripheralSearchControl.ResumeLayout();
        cPeripheralSearchControl.onLoadComplete = function(){
            cPeripheralSearchControl.ShowPeripheralSearch(vM.PointerX(), vM.PointerY());
        };
        cPeripheralSearchControl.onPeripheralSearch = function(keyword, x, y, area){
            cSearchResultControl.LocalNearBySearch(keyword, x, y, area);
        };
    }
    else{
        vM.moveEntity(cPeripheralSearchControl.ID, vM.PointerX(), vM.PointerY());
        cPeripheralSearchControl.ShowPeripheralSearch(vM.PointerX(), vM.PointerY());
    }
}
//载入新闻
function fnLoadNews(){
    var url=GlobalConfig._DataCenterUrl + 'CommMap/ad.aspx?node='+GlobalConfig._Node+'&l='+GlobalConfig._L+'&v=1.0&req=1';
    ENetwork.DownloadScript(url,function(){
        if(typeof ScrollText=='undefined')return false;
        var t='';
        var d=new ScrollText();
        for(i=0;i<d.ID.length;i++){
            t+='<tr><td onclick="fnLoadNewsById('+d.ID[i]+',\''+d.Title[i]+'\');">'+d.Title[i]+'</td></tr>';
            //判断是否默认激活的
            if (d.AutoActive[i] == 1)
            {
                fnLoadNewsById(d.ID[i], d.Title[i]);
            }
        }
        $('newsC').innerHTML='<table id="newstr" style="border-collapse:collapse;line-height:20px" cellpadding="0">'+t+'</table>';
        objup = new CBoardExhibition("objup", "newsC", 3, true, "up", 0, 2000);
        objup.ShowMsg();
        
        fnUrlGoto();    //与搜索列表面板相关的定位
    });
    
}
function fnLoadNewsById(Tid,sTitle){
    cSearchResultControl.NewsSearch(Tid,sTitle);  
}
//保存浏览历史记录
//type: 1:实体泡泡 2:企业泡泡
var _HistoryArray = [];
function fnSaveHistory(type, spot){

}


//需要搜索列表面板支持的定位
function fnUrlGoto(){
    if(!ProductSetting.Position)
    {
        return;
    }
    var x = window._X;
    if (x != '')
    {
        var y = window._Y;
        if (y != '')
        {
            vM.MoveTo(x, y, true);
        }
    }
    var d = window._DirectSign;         //显示公司导向标
    if (d != '')
    {
        var dw = d.length * 15 + 40;
        var dDiv = vM.$C('div');
        dDiv.innerHTML = '<div style="width:auto;background-color:#FB5207;padding:1px 1px 4px 1px; width:' + dw + 'px; ">' +
		'<div style="background-color:#fff; padding:5px 10px 3px 10px; font-weight:bold; font-size:14px;">' +
		'<span style="background-color:#FB5207; width:12px; height:5px; float:left; font-size:1px; line-height:1px;"></span>' + d +
		'</div>' +
		'<div style="position:absolute; left:20px; background-image:url(' + GlobalConfig._SkinUrl + 'images/shubiao_09.gif); width:15px; height:10px; font-size:1px;"></div>' +
	    '</div>';
        vM.appendEntity(dDiv, _PopLayer, false, x, y, dw, 50, 30, 15, false);
    }
}

//需要Pop支持的定位
function fnEaddGoto(Ecode){    
    if(!ProductSetting.Position)
    {
        return;
    }
    if(Ecode=='')
    {
        Ecode = window._EddressPosition;
        if(Ecode == '')
            return;
    }
    //Ecode='E13134';
    if(Ecode!=''&&Ecode!='localhost'){
        var url= GlobalConfig._DataCenterUrl + 'CommMap/CompanyInfo.aspx?node='+GlobalConfig._Node+'&l='+GlobalConfig._L+'&v=1.0&req=3&e='+Ecode;
        ENetwork.DownloadScript(url,function(){
        if (typeof ocType == 'undefined')
        {
            return;
        }
        if(ocType==1){
                fnShowCompanyPop(c.ComID, c.ComX, c.ComY);
        }else if(ocType==2){
            if(typeof o!='undefined'&&o!=null){
                fnShowEntityPop(o.ID, o.CenterX, o.CenterY);  
            }
        }
        });
     }    
}
function fnOCGoto(){
    if(!ProductSetting.Position)
    {
        return;
    }
    var url;
    //企业定位
    var C_ID = window._CompanyID;
    if (C_ID != '' && C_ID*1 > 0)
    {
        url= GlobalConfig._DataCenterUrl + 'CommMap/CompanyInfo.aspx?node='+GlobalConfig._Node+'&l='+GlobalConfig._L+'&v=1.0&req=1&id='+C_ID;
        ENetwork.DownloadScript(url,function(){
            if(typeof c!='undefined'&& c!=null)
            {
                fnShowCompanyPop(c.ComID, c.ComX ,c.ComY);
            }
        });
        return;
    }
    
    //实体定位
    var O_ID = window._OwnerID;
    if (/.+?\?\d+$/gi.test(window.document.location.href))
    {
        O_ID = window.document.location.href.replace(/^.+?\?/gi, '');
    }
    if (O_ID != '' && O_ID*1 > 0)
    {
        url= GlobalConfig._DataCenterUrl + 'CommMap/CompanyInfo.aspx?node='+GlobalConfig._Node+'&l='+GlobalConfig._L+'&v=1.0&req=2&id='+O_ID;
        ENetwork.DownloadScript(url,function(){
            if(typeof o!='undefined'&& o!=null)
            {
                fnShowEntityPop(o.ID, o.CenterX ,o.CenterY);
            }
        });
    }
    
}

//X Y定位
function fnGotoXY(){
  
    var x = fnRequest('x');
    if(x=="")
    {
        return;
    }
    var y = fnRequest('y');
    if(y=="")
    {
        return;
    }

 
 //vM._Mark.Show('EMark',x,y,"某大楼","商务圈");
go2xy(x,y,true);
}

//标记定位
function fnMarkGoto(){
    if(!ProductSetting.Position)
    {
        return;
    }
    var title = fnRequest('title');
    if(title=="")
    {
        return;
    }
    var content = fnRequest('content');
    var x = fnRequest('x');
    if(x=="")
    {
        return;
    }
    var y = fnRequest('y');
    if(y=="")
    {
        return;
    }
    _Mark.Show('EMark',x,y,title,content);
}

//显示标记
function ShowUL(o,name)
{	
    $(name).style.display= "block";
	$(o).style.backgroundColor="#fff";
	$(o).className='active';
	$(o).style.color="#000";
	
}
function HideUL(o,name)
{
    $(name).style.display= "none"; 
    $(o).style.backgroundColor="";   
	$(o).className='unactive';
	$(o).style.color="#fff";
}
function ShowLIUL(obj)
{
	obj.childNodes[1].style.display= "block";
}
function HideLIUL(obj)
{
	obj.style.display= "none";
}
function OverBackground(obj)
{
	obj.style.background="#eae9e7";
}
function OutBackground(obj)
{
	obj.style.background="#ffffff";
}
function fnLabel(){
vM.fnLabel();
}
//@小火 公交站
function fnStation(){
   vM.fnStation();
   }

//@小火 路牌
function fnRoad(){
  vM.fnRoad();
}
//@小火 停车场
function fnPack(){
    vM.fnPack();
}

//新功能搜索面析
function fnSearch(){
	if($("Tool").style.display=="none"){
	$("Tool").style.display="block";
	$("Tool2").style.display="block";
			}else{
$("Tool").style.display="none";
$("Tool2").style.display="none";
$("Tool3").style.display="none";
$("Tool4").style.display="none";

	}
}


//@小火 创建标签
function fnSelectMarkPoint(){

  vM.GlobalConfig._ImgPath="/images";
 

   vM.fnUnMark();
    //fnUnPanel();
    //fnUnScale();
    vM._isBeginSelectMark = true;
   var tip = '<div style="height:15px; line-height:15px; border:1px solid #1A70C7; background:#fff; padding:0 4px 0 4px;filter:alpha(opacity=90); opacity:.9; float:left; color:#000; font-size:12px; white-space:nowrap;">单击左键选择标记位置</div>';
 
     
  vM.vEdushiMap.ShowPointerTip(tip); 
  
  vM._Mark._MarkerAdd='<div id="MenuMarkerPop" style="width:300px; position:absolute; z-index:200;"><div style="height:45px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/ding.png\',sizingMethod=\'image\');"><!--[if !IE]><!--><img src="/images/ding.png" /><!--<![endif]--></div>'
                                +'<div class="dialog" style="height:195px;"><div class="title"><div	id=showtest><img src="/images/newmap10.gif" alt="标记" style="margin-top:3px;" /></div><div style="margin-left:2px;">标记</div><a style="cursor:pointer" onclick="parent._Mark.RemoveMarkPop(\'AddMarkerPop\');"></a></div>'
                                +'<div class="content"><div class="all"><div class="textLine"><div style="float:left;">标题： </div><input id="txtMarkerTitle" value="{$MarkerTitle}" style="width:220px; color:#333; border:solid 1px #666; margin-left:2px;" type="text" /><span class="redText">&nbsp;*</span>'
                                +'</div><div id="divMarkerError" class="redText" style="background:url(/images/Warning.gif) no-repeat; padding-left:20px; margin-left:38px; display:none;"></div>'
                                +'<div class="textLine"><div style="float:left;">内容：</div><textarea id="txtMarkerContent" style="width:220px; height:70px; border:solid 1px #666;"></textarea>'
                                +'</div><div class="textLine"><div class="btnConfirm" style="margin-left:100px; " onclick="parent._Mark.Save({$x},{$y})"></div></div></div></div></div></div>';
 
 
 
 vM._Mark.Save=function(x,y){

    if (vM.vEdushiMap.$('txtMarkerTitle').value.length < 1){
        vM.vEdushiMap.$('divMarkerError').innerHTML = '必须填写标题';
        vM.vEdushiMap.$('divMarkerError').style.display = 'block';
        return;
    }
    if (vM.vEdushiMap.$('txtMarkerTitle').value.length > 20){
        vM.vEdushiMap.$('divMarkerError').innerHTML = '标题不能超过20个字符';
        vM.vEdushiMap.$('divMarkerError').style.display = 'block';
        return;
    }
//    if ($('txtMarkerContent').value.length < 1){
//        $('divMarkerError').innerHTML = '必须填写内容';
//        $('divMarkerError').style.display = 'block';
//        return;
//    }
    if (vM.vEdushiMap.$('txtMarkerContent').value.length > 100){
        vM.vEdushiMap.$('divMarkerError').innerHTML = '内容不能超过100个字符';
        vM.vEdushiMap.$('divMarkerError').style.display = 'block';
        return;
    }
    
     vM.vEdushiMap.$('divMarkerError').style.display = 'none';
    var c = new CookieHelper();
	var d = new Date();
	var MarkCookie = c.getCookie('Mark')==null?'':c.getCookie('Mark'); 
	Mark = parseInt(x)+'^'+parseInt(y)+'^'+vM.vEdushiMap.$('txtMarkerContent').value+'^'+vM.vEdushiMap.$('txtMarkerTitle').value+'|';
	d.setMonth(d.getMonth()+12)
	c.setCookie('Mark',MarkCookie+Mark,d);
	var i=0;

	var add='http://'+vM.GlobalConfig._Node+'/?x='+x+'&y='+y+'&title='+escape(vM.vEdushiMap.$('txtMarkerTitle').value)+'&content='+escape(vM.vEdushiMap.$('txtMarkerContent').value);
	i=c.getCookie('Mark').split('|').length-2;
	var nd = vM.vEdushiMap.$C('div');
    nd.id='PopMark_'+i;
    nd.innerHTML=this._MarkerView.replace('{$MarkerTitle}',vM.vEdushiMap.$('txtMarkerTitle').value).replace('{$MarkerContent}',vM.vEdushiMap.$('txtMarkerContent').value).replaceAll('{$id}',i).replace('{$Add}',add).replace('{$Clear}',Mark);
   
   vM.vEdushiMap.appendEntity(nd, _MarkLayer, false, x,y,233,110,0,40, false);
    nd=null;
   $('MarkLi').innerHTML='<li onmouseover="OverBackground(this)" onmouseout="OutBackground(this)" onclick="_Mark.Show('+i+','+x+','+y+',\''+vM.vEdushiMap.$('txtMarkerTitle').value+'\',\''+vM.vEdushiMap.$('txtMarkerContent').value+'\');" >'+vM.vEdushiMap.$('txtMarkerTitle').value+'</li>'+$('MarkLi').innerHTML;
   vM._Mark.RemoveMarkPop('AddMarkerPop');
  
  
}

 
 
}


//@小火 地铁站
function fnSubWay(){
    vM.fnSubWay();
}
function fnShowli(o){
    if(o.className=='action'){
        o.className='unaction';
    }else{
        o.className='action';
    }
}
function fnMarkLi(o){
    if(o.id=="MarkHiddinall"){
        $('MarkShowall').className='unaction';
    }else{
        $('MarkHiddinall').className='unaction';
    }
    if(o.className!='action')o.className='action';
}
//显示工具面板, id:工具控件外围容器ID
function fnDisplayTool(id){
    if ($(id).style.display == 'none')
    {
        $(id).style.display = 'block';
    }
    else
    {
        $(id).style.display = 'none';
    }
}


function fnDisplayToolForVM(id){
     var newvM= eval("vM."+id);     
    if (newvM.style.display == 'none')
    {
        newvM.style.display = 'block';
    }
    else
    {
        newvM.style.display = 'none';
    }
}



//拖动控件 o:控件父容器DIV对象, w, h:供拖动的手柄宽高
function fnDragControl(o,w,h)  
{  
    if (typeof o == "string") o = document.getElementById(o);  
    o.orig_x = parseInt(o.style.left) - document.body.scrollLeft;  
    o.orig_y = parseInt(o.style.top) - document.body.scrollTop;  
    o.orig_index = o.style.zIndex;  
          
    o.onmousedown = function(a)  
    {  
        this.style.cursor = "move";  
        this.style.zIndex = 10000;  
        var d=document;  
        if(!a)a=window.event;  
        var x = a.clientX+d.body.scrollLeft-o.offsetLeft;  
        var y = a.clientY+d.body.scrollTop-o.offsetTop;  
        //author: www.longbill.cn  
        d.ondragstart = "return false;"  
        d.onselectstart = "return false;"  
        d.onselect = "document.selection.empty();"  
        if (a.target)
        {
            fnSetDragFlag(a.target, 1, w, h)
        }
        if(o.setCapture)  
            o.setCapture();  
        else if(window.captureEvents)  
            window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  

        d.onmousemove = function(a)  
        {  
            if(!a)a=window.event;  
            o.style.left = a.clientX+document.body.scrollLeft-x + 'px';  
            o.style.top = a.clientY+document.body.scrollTop-y + 'px';  
            o.orig_x = parseInt(o.style.left) - document.body.scrollLeft;  
            o.orig_y = parseInt(o.style.top) - document.body.scrollTop;  
        }  

        d.onmouseup = function()  
        {  
            
            if(o.releaseCapture)  
                o.releaseCapture();  
            else if(window.captureEvents)  
                window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
            d.onmousemove = null;  
            d.onmouseup = null;  
            d.ondragstart = null;  
            d.onselectstart = null;  
            d.onselect = null;  
            o.style.cursor = "normal";  
            o.style.zIndex = o.orig_index;  
            if (a.target)
            {
                fnSetDragFlag(a.target, 0, w, h)
            }
        }  
    }  
}

function fnSetDragFlag(t, flag, w, h)
{
    if (flag == 1)
    {
        t.style.width = fnGetWindowWidth()*2 + 'px';
        t.style.height = fnGetWindowHeight()*2 + 'px';
        t.style.left = fnGetWindowWidth()*-1 + 'px';;
        t.style.top = fnGetWindowHeight()*-1 + 'px';
    }
    else
    {
        t.style.width = w + 'px';
        t.style.height = h + 'px';
        t.style.left = 0;
        t.style.top = 0;
    }
}

function hideTag(id)
{
    $(id).style.display = 'none';
}
function showTag(id)
{
    $(id).style.display = 'block';
}


//--------兼容老API函数集合---------------
function getCenterX()
{
    return vM.CenterX();
}
function getCenterY()
{
    return vM.CenterY();
}
function getOriginalCenterX()
{
    return vM.Property.CenterX;
}
function getOriginalCenterY()
{
    return vM.Property.CenterY;
}
function goCenter()
{
    vM.MoveTo(getOriginalCenterX(), getOriginalCenterY(), true);
}
function go2xy(x,y,flag)
{
//alert("ddd"+x+"||"+y);

	vM.go2xy(x,y);
	//alert(vM.ProductSetting.EagleEye);
	/*
	if (vM.ProductSetting.EagleEye)
	{
	    vMe.go2xy(x, y, flag);
	}
	

for (ggg in vM.ProductSetting)
{
	alert(ggg+"||"+vM.ProductSetting[ggg]);
}
*/

}
function getCurx()
{
    return _OldAPIParams.ClickX;
}
function getCury()
{
    return _OldAPIParams.ClickY;
}
function d23()
{
    _OldAPIParams.EyeZB.C23D();
}
function getCurZoom()
{
    return vM.Zoom();
}
function zoomTo(z)
{
    vM.FlatZoom(z);
    _OldAPIParams.EyeZB.ZoomBarSignPos(z);
}
function zoomIn()
{
    var z=vM.Zoom();
    if(z>0){
        z = z-1;
        vM.FlatZoom(z);
        _OldAPIParams.EyeZB.ZoomBarSignPos(z);
    }
}
function zoomOut()
{
    var z=vM.Zoom();
    if(z<3){
        z = z+1;
        vM.FlatZoom(z);
        _OldAPIParams.EyeZB.ZoomBarSignPos(z);
    }   
}
function setComExFunc(fnStr)
{
   _OldAPIParams.ComExFuncName = fnStr;
}
function setMapClickFun(fnStr)      //设置地图鼠标点击事件
{
    _OldAPIParams.MapClickFun = fnStr;
}
function getCurCompanyID()
{
    return _OldAPIParams.CurCompanyID;
}
function getCurOwnerID()
{
    return _OldAPIParams.CurOwnerID;
}
function getCurOwnerName()
{
    return _OldAPIParams.CurOwnerName;
}
function setOwnerExFunc(fnStr)
{ 
    _OldAPIParams.OwnerExFuncName = fnStr;
}
function setMapWidth(iWidth)
{
	    $('EdushiMap').style.width = iWidth + 'px';
        vM2.MapWidth(iWidth);
        vM.frameElement.style.width = iWidth + 'px';
}
function setMapHeight(iHeight)
{
        $('EdushiMap').style.height = iHeight + 'px';
        vM2.MapHeight(iHeight);
        vM.frameElement.style.height = iHeight + 'px';
}
function putPop(x,y,px,py,htmlStr,id,zIndex,autoresize,canDrag)
{
    var w=0,h=0;
    var oDiv = vEdushiMap.$C('div');
    oDiv.id = id;
    oDiv.innerHTML = htmlStr;
    w = oDiv.offsetWidth;
    h = oDiv.offsetHeight;
	vM.appendEntity(oDiv, _OldAPIParams.putPop, autoresize, x, y, w, h, px, py, canDrag);
}
function removePop(id)
{
    if(vM.$(id))
    {
        vM.$(id).parentNode.removeChild(vM.$(id));
    }
}

