/*************************************************
* 企业泡泡控件 v1.1 xb 2008.10.28
*************************************************/
var BikePopControl = Class.create();
Object.extend(BikePopControl.prototype, ControlBase.prototype);  //继承基类


Object.extend(BikePopControl.prototype,{
    _loadUI : function(){
        this.LoadUI('BikePopControl');//对应BikePopControl.aspx
    },
    _loadComplete : function(){
        this.$('btnClose').onclick = this.ClosePop.bind(this);
        this.$('divLoading').innerHTML = this.Config.Loading;
        this.onLoadComplete();
    },
    //企业ID
    CID : 0,
    IsMove : false,
    CopyMsg : '复制成功，请贴到你的QQ/MSN上发给你的好友！',
    PopAD : [],
    ShowPop : function(id,ismove){
        if(ismove)
        {
            this.IsMove = true;
        }
        else
        {
            this.IsMove = false;
        }
        if(this.CID!=id)
        {
            this.$('divLoading').style.display='';
            this.Show();
        }
        else
        {
            this.$('divLoading').style.display='none';
            this.Show();
            return;
        }
        this.CID = id;
        var url='/MapBus/BikeMaps.ashx?domain='+this.Config.Domain+'&l='+this.Config.Language+'&req=1&id='+id+'&RndNum='+Math.random();
        ENetwork.DownloadScript(url,this.LoadPopData.bind(this));
    },
/*	 配合init.js fnShowBikePopByTitle(sign.ID,sign.Title,vM.PointerX(),vM.PointerY());
	 与function fnShowBikePopByTitle(id,Title,x,y)*/
    ShowPopByTitle : function(id,Title,ismove){
        if(ismove)
        {
            this.IsMove = true;
        }
        else
        {
            this.IsMove = false;
        }
        if(this.CID!=id)
        {
            this.$('divLoading').style.display='';
            this.Show();
        }
        else
        {
            this.$('divLoading').style.display='none';
            this.Show();
            return;
        }
        this.CID = id;
        var url='/MapBus/BikeMaps.ashx?domain='+this.Config.Domain+'&l='+this.Config.Language+'&req=6&title='+escape(Title)+'&id='+id+'&RndNum='+Math.random();
        ENetwork.DownloadScript(url,this.LoadPopData.bind(this));
    },	
    LoadPopData : function(){
        if(typeof _EntityInfo != 'undefined' && _EntityInfo.CompanyInfoDetail[0])
        {
            var o = _EntityInfo.CompanyInfoDetail[0];
            
            //兼容地图初始定位移动
            if(this.IsMove)
            {
                MoveTo(o.X*1 + vM.GetMapPos(170), o.Y*1, true);
                vM.moveEntity(this.ID, o.X*1, o.Y*1);
            }
			this.$('Img_img').src = "../Images/Bike/"+o.ImgName;
			if(o.PointType==1){
				
				this.$('Name_h3').innerHTML = '中国电信';
				this.$('Agent_p').innerHTML = '名称：'+o.OCName;
				this.$('Address_p').innerHTML ='地址：'+o.Address;
				this.$('Tel_p').innerHTML = '联系：'+o.Telephone;
				this.$('RowBz_p').innerHTML = '备注：'+o.Remake;
	
				if(o.EAddress.length>0)
			   {
				this.$('txtUrl').value =  'http://'+o.EAddress+'.3dkunshan.com';
				this.$('btnCopy').onclick = this.Copy.bind(this,this.$('txtUrl').value);
			   }
			   else
				{
				 this.$('txtUrl').value =  'http://'+this.Config.NodeUrl +'/?l='+this.Config.Language+'&cid='+o.CompanyID;
				 this.$('btnCopy').onclick = this.Copy.bind(this,'http://'+this.Config.NodeUrl +'/?l='+this.Config.Language+'&cid='+o.CompanyID);
				}
			}
			if(o.PointType==5){
				this.$('Name_h3').innerHTML = '公共自行车';
				this.$('Agent_p').innerHTML = '网点：'+o.OCName;
				this.$('Address_p').innerHTML ='地址：'+o.Address;
				//this.$('Tel_p').innerHTML = '可借：'+o.BorrowNum+' 可停：'+o.AlsoNum;
				//this.$('Tel_p').innerHTML = '总车位：'+o.BorrowNum+' <a href="http://www.ksbike01.com/map2.asp" target="_blank">可借可还实时数据</a>';
				this.$('Tel_p').innerHTML = '总车位：'+o.BorrowNum;
				this.$('RowBz_p').innerHTML = '备注：'+o.Remake;
	
				if(o.EAddress.length>0)
			   {
				this.$('txtUrl').value =  'http://'+o.EAddress+'.3dkunshan.com';
				this.$('btnCopy').onclick = this.Copy.bind(this,this.$('txtUrl').value);
			   }
			   else
				{
				 this.$('txtUrl').value =  'http://'+this.Config.NodeUrl +'/?l='+this.Config.Language+'&cid='+o.CompanyID;
				 this.$('btnCopy').onclick = this.Copy.bind(this,'http://'+this.Config.NodeUrl +'/?l='+this.Config.Language+'&cid='+o.CompanyID);
				}
			}
			
           this.$('divLoading').style.display='none';    
        }
    },
    ClosePop : function()
    {
        this.Hide();
    },
    Copy  : function(url)
    {
        fnCopyToClipboard(url,this.CopyMsg);
    },
    loadImgErr : function(imgpath){
        if (this.src == imgpath)
        {
            return;
             //默认图片加载失败则不再触发 , ie7光设置 this.onerror=null; 无效
        }
        this.src=imgpath;
        this.onerror=null;
        this.parentNode.href = 'javascript:;';
        this.parentNode.target = '_self';
    },
    onCavil : function(x,y,id,name)
    {
        
    },
    onBusTransfer : function(x,y,ocname)
    {
    },
    onNearBySearch : function(x,y,ocname)
    {
        
    },
    onNearByBus : function(x,y,ocname)
    {
    
    }
});



